Skip to content

Commit a05ae47

Browse files
committed
adjusted test_matching_trades_execute_more to check agent holdings
1 parent 6b8e885 commit a05ae47

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

hydradx/tests/test_solver.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -473,22 +473,23 @@ def test_single_trade_partially_settles():
473473

474474

475475
def test_matching_trades_execute_more():
476-
# agents = [Agent(holdings={'DOT': 10000, 'LRNA': 7500}), Agent(holdings={'USDT': 9010})]
477-
agents = [Agent(enforce_holdings=False), Agent(enforce_holdings=False)]
476+
dot_sale, usdt_buy = mpf(1_000_000), mpf(4_000_000)
477+
usdt_sale, dot_buy = mpf(6_000_000 / 2), mpf(1_000_000 / 2)
478+
lrna_sale, usdt_lrna_buy = mpf(7_500_000), mpf(7_500_000 * 0.9)
479+
agents = [
480+
Agent(holdings={'DOT': dot_sale}), Agent(holdings={'USDT': usdt_sale}), Agent(holdings={'LRNA': lrna_sale})
481+
]
478482

479483
intent1 = { # selling DOT for $4.00, too big to fully execute against AMMs
480-
'sell_quantity': mpf(1000000), 'buy_quantity': mpf(4000000), 'tkn_sell': 'DOT', 'tkn_buy': 'USDT', 'agent': agents[0], 'partial': True
484+
'sell_quantity': dot_sale, 'buy_quantity': usdt_buy, 'tkn_sell': 'DOT', 'tkn_buy': 'USDT', 'agent': agents[0], 'partial': True
481485
}
482-
483486
intent2 = { # buying DOT for $6.00
484-
'sell_quantity': mpf(6000000 / 2), 'buy_quantity': mpf(1000000 / 2), 'tkn_sell': 'USDT', 'tkn_buy': 'DOT', 'agent': agents[1], 'partial': True
487+
'sell_quantity': usdt_sale, 'buy_quantity': dot_buy, 'tkn_sell': 'USDT', 'tkn_buy': 'DOT', 'agent': agents[1], 'partial': True
485488
}
486-
487489
intent1_lrna = { # selling LRNA for $0.90
488-
'sell_quantity': mpf(7500000), 'buy_quantity': mpf(7500000 * 0.9), 'tkn_sell': 'LRNA', 'tkn_buy': 'USDT', 'agent': agents[0], 'partial': True
490+
'sell_quantity': lrna_sale, 'buy_quantity': usdt_lrna_buy, 'tkn_sell': 'LRNA', 'tkn_buy': 'USDT', 'agent': agents[2], 'partial': True
489491
}
490492

491-
# initial_state, amm_list = get_markets_minimal()
492493
initial_state, amm_list = get_markets_even()
493494

494495
# do the DOT sale alone

0 commit comments

Comments
 (0)