Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit 9153436

Browse files
renamed modifier
1 parent 0c02c77 commit 9153436

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

contracts/IonicLiquidator.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ contract IonicLiquidator is OwnableUpgradeable, ILiquidator, IUniswapV2Callee, I
8484
*/
8585
uint256 public healthFactorThreshold;
8686

87-
modifier onlyPERPermissioned(address borrower, ICErc20 cToken) {
87+
modifier onlyLowHF(address borrower, ICErc20 cToken) {
8888
uint256 currentHealthFactor = lens.getHealthFactor(borrower, cToken.comptroller());
8989
require(currentHealthFactor < healthFactorThreshold, "HF not low enough, reserving for PYTH");
9090
_;
@@ -168,7 +168,7 @@ contract IonicLiquidator is OwnableUpgradeable, ILiquidator, IUniswapV2Callee, I
168168
ICErc20 cErc20,
169169
ICErc20 cTokenCollateral,
170170
uint256 minOutputAmount
171-
) external onlyPERPermissioned(borrower, cTokenCollateral) returns (uint256) {
171+
) external onlyLowHF(borrower, cTokenCollateral) returns (uint256) {
172172
return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);
173173
}
174174

@@ -203,7 +203,7 @@ contract IonicLiquidator is OwnableUpgradeable, ILiquidator, IUniswapV2Callee, I
203203
*/
204204
function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)
205205
external
206-
onlyPERPermissioned(vars.borrower, vars.cTokenCollateral)
206+
onlyLowHF(vars.borrower, vars.cTokenCollateral)
207207
returns (uint256)
208208
{
209209
// Input validation

contracts/IonicUniV3Liquidator.sol

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,9 @@ contract IonicUniV3Liquidator is OwnableUpgradeable, ILiquidator, IUniswapV3Flas
6666
*/
6767
uint256 public healthFactorThreshold;
6868

69-
modifier onlyPERPermissioned(address borrower, ICErc20 cToken) {
69+
modifier onlyLowHF(address borrower, ICErc20 cToken) {
7070
uint256 currentHealthFactor = lens.getHealthFactor(borrower, cToken.comptroller());
71-
if (currentHealthFactor > healthFactorThreshold) {
72-
require(expressRelay.isPermissioned(address(this), abi.encode(borrower)), "invalid liquidation");
73-
}
71+
require(currentHealthFactor < healthFactorThreshold, "HF not low enough, reserving for PYTH");
7472
_;
7573
}
7674

@@ -88,13 +86,13 @@ contract IonicUniV3Liquidator is OwnableUpgradeable, ILiquidator, IUniswapV3Flas
8886
* @param cTokenCollateral The cToken collateral to be liquidated.
8987
* @param minOutputAmount The minimum amount of collateral to seize (or the minimum exchange output if applicable) required for execution. Reverts if this condition is not met.
9088
*/
91-
function safeLiquidate(
89+
function _safeLiquidate(
9290
address borrower,
9391
uint256 repayAmount,
9492
ICErc20 cErc20,
9593
ICErc20 cTokenCollateral,
9694
uint256 minOutputAmount
97-
) external onlyPERPermissioned(borrower, cTokenCollateral) returns (uint256) {
95+
) internal returns (uint256) {
9896
// Transfer tokens in, approve to cErc20, and liquidate borrow
9997
require(repayAmount > 0, "Repay amount (transaction value) must be greater than 0.");
10098
IERC20Upgradeable underlying = IERC20Upgradeable(cErc20.underlying());
@@ -111,6 +109,27 @@ contract IonicUniV3Liquidator is OwnableUpgradeable, ILiquidator, IUniswapV3Flas
111109
return transferSeizedFunds(address(cTokenCollateral.underlying()), minOutputAmount);
112110
}
113111

112+
function safeLiquidate(
113+
address borrower,
114+
uint256 repayAmount,
115+
ICErc20 cErc20,
116+
ICErc20 cTokenCollateral,
117+
uint256 minOutputAmount
118+
) external onlyLowHF(borrower, cTokenCollateral) returns (uint256) {
119+
return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);
120+
}
121+
122+
function safeLiquidatePyth(
123+
address borrower,
124+
uint256 repayAmount,
125+
ICErc20 cErc20,
126+
ICErc20 cTokenCollateral,
127+
uint256 minOutputAmount
128+
) external returns (uint256) {
129+
require(expressRelay.isPermissioned(address(this), abi.encode(borrower)), "invalid liquidation");
130+
return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);
131+
}
132+
114133
/**
115134
* @dev Transfers seized funds to the sender.
116135
* @param erc20Contract The address of the token to transfer.
@@ -127,7 +146,7 @@ contract IonicUniV3Liquidator is OwnableUpgradeable, ILiquidator, IUniswapV3Flas
127146

128147
function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)
129148
external
130-
onlyPERPermissioned(vars.borrower, vars.cTokenCollateral)
149+
onlyLowHF(vars.borrower, vars.cTokenCollateral)
131150
returns (uint256)
132151
{
133152
// Input validation

0 commit comments

Comments
 (0)