@@ -7,6 +7,9 @@ import {IBaseManager} from "v2-core/src/interfaces/IBaseManager.sol";
7
7
import {ISubAccounts} from "v2-core/src/interfaces/ISubAccounts.sol " ;
8
8
import {IAsset} from "v2-core/src/interfaces/IAsset.sol " ;
9
9
import {DutchAuction} from "v2-core/src/liquidation/DutchAuction.sol " ;
10
+ import {IPMRM_2} from "v2-core/src/interfaces/IPMRM_2.sol " ;
11
+ import {PMRM_2} from "v2-core/src/risk-managers/PMRM_2.sol " ;
12
+ import {ISpotFeed} from "v2-core/src/interfaces/ISpotFeed.sol " ;
10
13
11
14
/**
12
15
* @title LyraAuctionUtils
@@ -42,11 +45,18 @@ contract LyraAuctionUtils {
42
45
return (manager, mm, mtm, 0 );
43
46
}
44
47
45
- // Otherwise we assume it is a PMRM, so we need to work out the worst scenario by getting the portfolio and
46
- // calculating margin in the lib
47
- IPMRM.Portfolio memory portfolio = PMRM (manager).arrangePortfolio (subId);
48
- (mm, mtm, worstScenario) =
49
- PMRM (manager).lib ().getMarginAndMarkToMarket (portfolio, false , PMRM (manager).getScenarios ());
48
+ try PMRM_2 (manager).collateralSpotFeeds (address (0 )) returns (ISpotFeed) {
49
+ IPMRM_2.Portfolio memory p2 = PMRM_2 (manager).arrangePortfolio (subId);
50
+ (mm, mtm, worstScenario) =
51
+ PMRM_2 (manager).lib ().getMarginAndMarkToMarket (p2, false , PMRM_2 (manager).getScenarios ());
52
+ return (manager, mm, mtm, worstScenario);
53
+ } catch {
54
+ // Fall back to PMRM
55
+ IPMRM.Portfolio memory p = PMRM (manager).arrangePortfolio (subId);
56
+ (mm, mtm, worstScenario) = PMRM (manager).lib ().getMarginAndMarkToMarket (p, false , PMRM (manager).getScenarios ());
57
+ }
58
+
59
+ return (manager, mm, mtm, worstScenario);
50
60
}
51
61
52
62
function startInsolventAuction (uint accountId , uint worstScenario ) external {
0 commit comments