Skip to content

Commit

Permalink
add test with real omnipool data
Browse files Browse the repository at this point in the history
  • Loading branch information
enthusiastmartin committed Oct 16, 2024
1 parent c77fdf9 commit 5c33d40
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions hydradx/tests/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,44 @@ def test_with_lrna_intent():
assert validate_and_execute_solution(initial_state, intents, intent_deltas)

pprint(intent_deltas)


def test_solver_with_real_omnipool():
agents = [
Agent(holdings={'HDX': 100}),
Agent(holdings={'CRUST': 5}),
]

intents = [
{'sell_quantity': mpf(100), 'buy_quantity': mpf(1.149711278057), 'tkn_sell': 'HDX', 'tkn_buy': 'CRU', 'agent': agents[0]},
{'sell_quantity': mpf(1.149711278057), 'buy_quantity': mpf(100), 'tkn_sell': 'CRU', 'tkn_buy': 'HDX', 'agent': agents[1]},
]

liquidity = {'4-Pool': mpf(1392263.9295618401), 'HDX': mpf(140474254.46393022), 'KILT': mpf(1941765.8700688032),
'WETH': mpf(897.820372708098), '2-Pool': mpf(80.37640742108785), 'GLMR': mpf(7389788.325282889),
'BNC': mpf(5294190.655262755), 'RING': mpf(30608622.54045291), 'vASTR': mpf(1709768.9093601815),
'vDOT': mpf(851755.7840315843), 'CFG': mpf(3497639.0397717496), 'CRU': mpf(337868.26827475097),
'2-Pool': mpf(14626788.977583803), 'DOT': mpf(2369965.4990946855), 'PHA': mpf(6002455.470581388),
'ZTG': mpf(9707643.829161936), 'INTR': mpf(52756928.48950746), 'ASTR': mpf(31837859.71273387), }
lrna = {'4-Pool': mpf(50483.454258911326), 'HDX': mpf(24725.8021660851), 'KILT': mpf(10802.301353604526),
'WETH': mpf(82979.9927924809), '2-Pool': mpf(197326.54331209575), 'GLMR': mpf(44400.11377262768),
'BNC': mpf(35968.10763198863), 'RING': mpf(1996.48438233777), 'vASTR': mpf(4292.819030020081),
'vDOT': mpf(182410.99000727307), 'CFG': mpf(41595.57689216696), 'CRU': mpf(4744.442135139952),
'2-Pool': mpf(523282.70722423657), 'DOT': mpf(363516.4838824808), 'PHA': mpf(24099.247547699764),
'ZTG': mpf(4208.90365804613), 'INTR': mpf(19516.483401186168), 'ASTR': mpf(68571.5237579274), }

initial_state = OmnipoolState(
tokens={
tkn: {'liquidity': liquidity[tkn], 'LRNA': lrna[tkn]} for tkn in lrna
},
asset_fee=mpf(0.0025),
lrna_fee=mpf(0.0005)
)
initial_state.last_fee = {tkn: mpf(0.0025) for tkn in lrna}
initial_state.last_lrna_fee = {tkn: mpf(0.0005) for tkn in lrna}

intent_deltas = find_solution2(initial_state, intents)

assert validate_and_execute_solution(initial_state, intents, intent_deltas)

pprint(intent_deltas)

0 comments on commit 5c33d40

Please sign in to comment.