Skip to content

Commit

Permalink
Fix a small bug in route exec planning probing conditions.
Browse files Browse the repository at this point in the history
  • Loading branch information
dowlandaiello committed Oct 14, 2024
1 parent 6e44e5e commit 7cce893
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
12 changes: 11 additions & 1 deletion local-interchaintest/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,17 @@ pub fn test_osmo_arb(arbfile: Option<Value>) -> Result<(), Box<dyn Error + Send
println!("AUCTION BOT PROFIT: {auction_profit}");
println!("OSMOSIS BOT PROFIT: {osmo_profit}");

util::assert_err("osmo_profit == 9482512", osmo_profit, 9482512)?;
util::assert_err(
"200000 + PROFIT_MARGIN > profit > 200000 - PROFIT_MARGIN",
200000 + ERROR_MARGIN_PROFIT > osmo_profit && osmo_profit > 200000 - ERROR_MARGIN_PROFIT,
true,
)?;
util::assert_err(
"200000 + PROFIT_MARGIN > auction_profit > 200000 - PROFIT_MARGIN",
200000 + ERROR_MARGIN_PROFIT > auction_profit
&& auction_profit > 200000 - ERROR_MARGIN_PROFIT,
true,
)?;

Ok(())
}
19 changes: 9 additions & 10 deletions src/strategies/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,13 +695,12 @@ async def next_legs(
nonlocal eval_profit

if len(path) >= 2:
matching_denoms = [
info.denom
for info in await ctx.query_denom_info(
path[-2].backend.chain_id,
path[-2].out_asset(),
)
]
denom_infos = await ctx.query_denom_info(
path[-2].backend.chain_id,
path[-2].out_asset(),
)

matching_denoms = [info.denom for info in denom_infos]

if not (
path[-1].in_asset() == path[-2].out_asset()
Expand Down Expand Up @@ -1209,7 +1208,7 @@ async def quantities_for_route_profit(
", ".join(
(
f"[{', '.join((str(qty) for qty in plans[plan_idx]))}]"
for plan_idx in plans_by_profit[:5]
for plan_idx in plans_by_profit[:-5]
)
),
],
Expand All @@ -1218,11 +1217,11 @@ async def quantities_for_route_profit(
profit = 0 if len(quantities) == 0 else quantities[-1] - quantities[0]

# Insert in sorted position
if len(quantities) >= len(route):
if len(quantities) > len(route):
insort(plans_by_profit, mid, key=lambda idx: plans[idx][-1] - plans[idx][0])

# Continue checking plans, since this quantity was not profitable
if len(quantities) < len(route) or profit <= 0:
if len(quantities) <= len(route) or profit <= 0:
right = mid
mid = right // 2

Expand Down

0 comments on commit 7cce893

Please sign in to comment.