@@ -5,6 +5,7 @@ import { IERC20Upgradeable } from "openzeppelin-contracts-upgradeable/contracts/
5
5
import "openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol " ;
6
6
7
7
import { IonicLiquidator, ILiquidator } from "../../IonicLiquidator.sol " ;
8
+ import { IonicUniV3Liquidator } from "../../IonicUniV3Liquidator.sol " ;
8
9
import { ICurvePool } from "../../external/curve/ICurvePool.sol " ;
9
10
import { CurveSwapLiquidatorFunder } from "../../liquidators/CurveSwapLiquidatorFunder.sol " ;
10
11
import { UniswapV3LiquidatorFunder } from "../../liquidators/UniswapV3LiquidatorFunder.sol " ;
@@ -23,13 +24,12 @@ import { BasePriceOracle } from "../../oracles/BasePriceOracle.sol";
23
24
24
25
import { BaseTest } from "../config/BaseTest.t.sol " ;
25
26
import { UpgradesBaseTest } from "../UpgradesBaseTest.sol " ;
27
+ import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol " ;
28
+ import { ProxyAdmin } from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol " ;
29
+ import { PoolLens } from "../../PoolLens.sol " ;
26
30
27
31
contract MockRedemptionStrategy is IRedemptionStrategy {
28
- function redeem (
29
- IERC20Upgradeable ,
30
- uint256 ,
31
- bytes memory
32
- ) external returns (IERC20Upgradeable , uint256 ) {
32
+ function redeem (IERC20Upgradeable , uint256 , bytes memory ) external returns (IERC20Upgradeable , uint256 ) {
33
33
return (IERC20Upgradeable (address (0 )), 1 );
34
34
}
35
35
@@ -151,12 +151,56 @@ contract IonicLiquidatorTest is UpgradesBaseTest {
151
151
152
152
vars.redemptionStrategies[0 ] = IFundsConversionStrategy (0x5cA3fd2c285C4138185Ef1BdA7573D415020F3C8 );
153
153
vars.strategyData[
154
- 0
155
- ] = hex "0000000000000000000000004200000000000000000000000000000000000006000000000000000000000000ac48fcf1049668b285f3dc72483df5ae2162f7e8 " ;
154
+ 0
155
+ ] = hex "0000000000000000000000004200000000000000000000000000000000000006000000000000000000000000ac48fcf1049668b285f3dc72483df5ae2162f7e8 " ;
156
156
157
157
liquidator.safeLiquidateToTokensWithFlashLoan (vars);
158
158
}
159
159
160
+ function testLiquidateAfterUpgradeLiquidator () public debuggingOnly forkAtBlock (MODE_MAINNET, 9382006 ) {
161
+ // upgrade IonicLiquidator
162
+ TransparentUpgradeableProxy proxyV3 = TransparentUpgradeableProxy (payable (ap.getAddress ("IonicUniV3Liquidator " )));
163
+ IonicUniV3Liquidator implV3 = new IonicUniV3Liquidator ();
164
+ IonicUniV3Liquidator liquidatorV3 = IonicUniV3Liquidator (payable (ap.getAddress ("IonicUniV3Liquidator " )));
165
+ PoolLens lens = PoolLens (0x70BB19a56BfAEc65aE861E6275A90163AbDF36a6 );
166
+
167
+ ProxyAdmin proxyAdmin = ProxyAdmin (ap.getAddress ("DefaultProxyAdmin " ));
168
+
169
+ vm.startPrank (proxyAdmin.owner ());
170
+ proxyAdmin.upgrade (proxyV3, address (implV3));
171
+ vm.stopPrank ();
172
+
173
+ vm.startPrank (0x1155b614971f16758C92c4890eD338C9e3ede6b7 );
174
+ liquidatorV3.setPoolLens (lens);
175
+ liquidatorV3.setHealthFactorThreshold (1e18 );
176
+ vm.stopPrank ();
177
+
178
+ IonicComptroller pool = IonicComptroller (0xFB3323E24743Caf4ADD0fDCCFB268565c0685556 );
179
+ (, , uint256 liquidity , uint256 shortfall ) = pool.getAccountLiquidity (0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d );
180
+ emit log_named_uint ("liquidity " , liquidity);
181
+ emit log_named_uint ("shortfall " , shortfall);
182
+
183
+ uint256 healthFactor = lens.getHealthFactor (0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d , pool);
184
+ emit log_named_uint ("hf before " , healthFactor);
185
+
186
+ ILiquidator.LiquidateToTokensWithFlashSwapVars memory vars = ILiquidator.LiquidateToTokensWithFlashSwapVars ({
187
+ borrower: 0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d ,
188
+ repayAmount: 1134537086250983 ,
189
+ cErc20: ICErc20 (0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2 ),
190
+ cTokenCollateral: ICErc20 (0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2 ),
191
+ flashSwapContract: 0x468cC91dF6F669CaE6cdCE766995Bd7874052FBc ,
192
+ minProfitAmount: 0 ,
193
+ redemptionStrategies: new IRedemptionStrategy [](0 ),
194
+ strategyData: new bytes [](0 ),
195
+ debtFundingStrategies: new IFundsConversionStrategy [](0 ),
196
+ debtFundingStrategiesData: new bytes [](0 )
197
+ });
198
+ liquidatorV3.safeLiquidateToTokensWithFlashLoan (vars);
199
+
200
+ uint256 healthFactorAfter = lens.getHealthFactor (0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d , pool);
201
+ emit log_named_uint ("hf after " , healthFactorAfter);
202
+ }
203
+
160
204
// TODO test with marginal shortfall for liquidation penalty errors
161
205
function _testLiquidatorLiquidate (address contractForFlashSwap ) internal {
162
206
IonicComptroller pool = IonicComptroller (poolAddress);
0 commit comments