Skip to content

Commit f450aec

Browse files
committed
fix money market errors
1 parent 1a6ccd4 commit f450aec

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

hydradx/model/amm/trade_strategies.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,11 +1099,18 @@ def strategy(state: GlobalState, agent_id: str) -> GlobalState:
10991099
def liquidate_cdps(pool_id: str = None, iters: int = 16) -> TradeStrategy:
11001100
def strategy(state: GlobalState, agent_id: str) -> GlobalState:
11011101
agent = state.agents[agent_id]
1102-
pools: set[Exchange] = {state.pools[pool_id]} if pool_id else set(state.pools.values())
1103-
for pool in list(pools):
1102+
liquidation_pools: set[Exchange] = {state.pools[pool_id]} if pool_id else set(state.pools.values())
1103+
for pool in list(liquidation_pools):
11041104
if hasattr(pool, 'exchanges'):
1105-
pools |= set(pool.exchanges.values())
1106-
mms = [pool for pool in pools if isinstance(pool, MoneyMarket)]
1105+
liquidation_pools |= set(pool.exchanges.values())
1106+
mms = []
1107+
for pool in state.pools.values():
1108+
if isinstance(pool, MoneyMarket):
1109+
mms.append(pool)
1110+
elif hasattr(pool, 'exchanges'):
1111+
for sub_pool in pool.exchanges.values():
1112+
if isinstance(sub_pool, MoneyMarket):
1113+
mms.append(sub_pool)
11071114
for mm in mms:
11081115
for cdp in mm.cdps:
11091116
potential_liquidations = True
@@ -1124,7 +1131,7 @@ def strategy(state: GlobalState, agent_id: str) -> GlobalState:
11241131
# not liquidatable
11251132
continue
11261133

1127-
for pool in pools:
1134+
for pool in liquidation_pools:
11281135
if collateral_tkn not in pool.asset_list or debt_tkn not in pool.asset_list:
11291136
continue
11301137
if debt_tkn not in cdp.debt or collateral_tkn not in cdp.collateral \

hydradx/tests/test_money_market.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ def test_full_liquidation_not_profitable():
960960

961961

962962
def test_get_money_market():
963-
from hydradx.model.processing import get_current_money_market
963+
from hydradx.model.indexer_utils import get_current_money_market
964964
mm = get_current_money_market()
965965
if not isinstance(mm, MoneyMarket):
966966
raise ValueError("MoneyMarket should be returned")

0 commit comments

Comments
 (0)