Skip to content

Commit

Permalink
fix test_stableswap_router_arbitrage
Browse files Browse the repository at this point in the history
  • Loading branch information
jepidoptera committed Sep 12, 2024
1 parent c6f0087 commit a692cf1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion hydradx/tests/test_arbitrage_agent_refactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from hydradx.model.amm.arbitrage_agent_general import calculate_profit, calculate_arb_amount, \
process_next_swap, execute_arb, get_arb_swaps, combine_swaps
from hydradx.model.amm.centralized_market import OrderBook, CentralizedMarket
from hydradx.model.amm.omnipool_amm import OmnipoolState
from hydradx.model.amm.omnipool_amm import OmnipoolState, lrna_price
from hydradx.model.amm.stableswap_amm import StableSwapPoolState
from hydradx.model.processing import get_omnipool_data_from_file, get_orderbooks_from_file, get_stableswap_data
from hydradx.model.processing import get_omnipool_data, get_centralized_market, get_unique_name, get_omnipool, save_omnipool, load_omnipool
Expand Down Expand Up @@ -882,6 +882,17 @@ def test_stableswap_router_arbitrage():
initial_agent = agent.copy()
execute_arb(exchanges, agent, swaps)
profit = calculate_profit(initial_agent, agent, equivalency_map)
for asset in profit:
if asset not in exchanges['binance'].asset_list and (
asset not in equivalency_map or equivalency_map[asset] not in exchanges['binance'].asset_list):
if 'USD' not in profit:
profit['USD'] = 0
if asset in omnipool.asset_list:
# estimate value from omnipool price
profit['USD'] += (
profit[asset] * lrna_price(omnipool, asset)
/ omnipool.lrna['4-Pool'] * sum(fourpool.liquidity.values())
)
profit_total = exchanges['binance'].value_assets(profit, equivalency_map)
print(profit_total)
if profit_total <= 0:
Expand Down

0 comments on commit a692cf1

Please sign in to comment.