Skip to content

Commit

Permalink
Use normalized denoms in pool funding for osmo integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dowlandaiello committed Jul 18, 2024
1 parent fff600e commit 510b896
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
31 changes: 27 additions & 4 deletions local-interchaintest/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,36 @@ impl Test {
.try_for_each(|((denom_a, denom_b), pools)| {
pools.iter().try_for_each(|pool_spec| match pool_spec {
Pool::Astroport(spec) => {
let funds_a = spec.balance_asset_a;
let funds_b = spec.balance_asset_b;

// Create the osmo pool and join it
let (norm_denom_a, denom_map_ent_1) =
denom_a.normalize(funds_a, ctx).unwrap();
let (norm_denom_b, denom_map_ent_2) =
denom_b.normalize(funds_b, ctx).unwrap();

if let Some((map_ent_a_1, map_ent_a_2)) = denom_map_ent_1 {
// (denom, neutron) -> denom'
// (denom', osmo) -> denom
denom_map.insert((denom_a.to_string(), "neutron".into()), map_ent_a_1);
denom_map.insert((norm_denom_a.clone(), "osmosis".into()), map_ent_a_2);
}

if let Some((map_ent_b_1, map_ent_b_2)) = denom_map_ent_2 {
// (denom, neutron) -> denom'
// (denom', osmo) -> denom
denom_map.insert((denom_b.to_string(), "neutron".into()), map_ent_b_1);
denom_map.insert((norm_denom_b.clone(), "osmosis".into()), map_ent_b_2);
}

ctx.build_tx_create_pool()
.with_denom_a(denom_a.to_string())
.with_denom_b(&denom_b.to_string())
.with_denom_a(&norm_denom_a)
.with_denom_b(&norm_denom_b)
.send()?;
ctx.build_tx_fund_pool()
.with_denom_a(&denom_a.to_string())
.with_denom_b(&denom_b.to_string())
.with_denom_a(&norm_denom_a)
.with_denom_b(&norm_denom_b)
.with_amount_denom_a(spec.balance_asset_a)
.with_amount_denom_b(spec.balance_asset_b)
.with_liq_token_receiver(OWNER_ADDR)
Expand Down
2 changes: 2 additions & 0 deletions src/strategies/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ async def recover_funds(
[ctx.cli_args["base_denom"], curr_leg.in_asset(), curr_leg.backend.chain_id],
)

# TODO: Check this
route = route[: route.index(curr_leg) - 1]
backtracked = list(
reversed([Leg(leg.out_asset, leg.in_asset, leg.backend) for leg in route])
Expand All @@ -337,6 +338,7 @@ async def recover_funds(
if not balance_resp:
raise ValueError(f"Couldn't get balance for asset {curr_leg.in_asset()}.")

# TODO: Trade as much of tokens as possible
resp = await quantities_for_route_profit(balance_resp, backtracked, r, ctx)

if not resp:
Expand Down

0 comments on commit 510b896

Please sign in to comment.