@@ -1099,11 +1099,18 @@ def strategy(state: GlobalState, agent_id: str) -> GlobalState:
10991099def 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 \
0 commit comments