Skip to content

Commit

Permalink
Update neutron osmosis tests to make pools.
Browse files Browse the repository at this point in the history
  • Loading branch information
dowlandaiello committed Jul 1, 2024
1 parent 0867b54 commit 46e4303
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions examples/neutron_osmosis.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use localic_utils::{ConfigChainBuilder, TestContextBuilder};
use localic_utils::{error::Error as LocalIcUtilsError, ConfigChainBuilder, TestContextBuilder};
use std::error::Error;

/// Demonstrates using localic-utils for neutron + osmosis.
Expand All @@ -20,18 +20,55 @@ fn main() -> Result<(), Box<dyn Error>> {
.with_chain_name("neutron")
.with_subdenom("bruhtoken")
.send()?;
ctx.build_tx_create_tokenfactory_token()
.with_chain_name("osmosis")
.with_subdenom("amoguscoin")
let bruhtoken = ctx.get_tokenfactory_denom(
"neutron1kuf2kxwuv2p8k3gnpja7mzf05zvep0cyuy7mxg",
"bruhtoken",
);
ctx.build_tx_mint_tokenfactory_token()
.with_chain_name("neutron")
.with_amount(10000000000000000000)
.with_denom(&bruhtoken)
.send()?;

let ibc_bruhtoken = ctx.get_ibc_denom(&bruhtoken, "neutron", "osmosis").ok_or(
LocalIcUtilsError::MissingContextVariable(format!("ibc_denom::{}", &bruhtoken)),
)?;
let ibc_neutron = ctx.get_ibc_denom("untrn", "neutron", "osmosis").ok_or(
LocalIcUtilsError::MissingContextVariable(format!("ibc_denom::{}", "untrn")),
)?;

// Transfer from osmosis to neutron and neutron to osmosis
ctx.build_tx_transfer()
.with_chain_name("neutron")
.with_recipient("osmo1kuf2kxwuv2p8k3gnpja7mzf05zvep0cysqyf2a")
.with_denom("untrn")
.with_amount(1000000)
.send()?;
ctx.build_tx_transfer()
.with_chain_name("neutron")
.with_recipient("osmo1kuf2kxwuv2p8k3gnpja7mzf05zvep0cysqyf2a")
.with_denom(&bruhtoken)
.with_amount(1000000)
.send()?;

// Create an osmosis pool
ctx.build_tx_create_osmo_pool()
.with_weight(&ibc_neutron, 1)
.with_weight(&ibc_bruhtoken, 1)
.with_initial_deposit(&ibc_neutron, 1)
.with_initial_deposit(&ibc_bruhtoken, 1)
.send()?;

// Get its id
let pool_id = ctx.get_osmo_pool(&ibc_neutron, &ibc_bruhtoken)?;

// Fund the pool
ctx.build_tx_fund_osmo_pool()
.with_pool_id(pool_id)
.with_max_amount_in(&ibc_neutron, 10000)
.with_max_amount_in(&ibc_bruhtoken, 10000)
.with_share_amount_out(1000000000000)
.send()?;

Ok(())
}

0 comments on commit 46e4303

Please sign in to comment.