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

Commit e563751

Browse files
committed
fix: lint
1 parent 6190e13 commit e563751

File tree

6 files changed

+109
-38
lines changed

6 files changed

+109
-38
lines changed

contracts/ILiquidator.sol

+5-7
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,14 @@ interface ILiquidator {
3838
uint256 minOutputAmount
3939
) external returns (uint256);
4040

41-
function safeLiquidateToTokensWithFlashLoan(
42-
LiquidateToTokensWithFlashSwapVars calldata vars
43-
) external returns (uint256);
41+
function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)
42+
external
43+
returns (uint256);
4444

4545
function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external;
4646

47-
function _whitelistRedemptionStrategies(
48-
IRedemptionStrategy[] calldata strategies,
49-
bool[] calldata whitelisted
50-
) external;
47+
function _whitelistRedemptionStrategies(IRedemptionStrategy[] calldata strategies, bool[] calldata whitelisted)
48+
external;
5149

5250
function setExpressRelay(address _expressRelay) external;
5351

contracts/IonicLiquidator.sol

+42-13
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ contract IonicLiquidator is OwnableUpgradeable, ILiquidator, IUniswapV2Callee, I
9292
_;
9393
}
9494

95-
function initialize(address _wtoken, address _uniswapV2router, uint8 _flashSwapFee) external initializer {
95+
function initialize(
96+
address _wtoken,
97+
address _uniswapV2router,
98+
uint8 _flashSwapFee
99+
) external initializer {
96100
__Ownable_init();
97101
require(_uniswapV2router != address(0), "_uniswapV2router not defined.");
98102
W_NATIVE_ADDRESS = _wtoken;
@@ -105,7 +109,11 @@ contract IonicLiquidator is OwnableUpgradeable, ILiquidator, IUniswapV2Callee, I
105109
/**
106110
* @dev Internal function to approve unlimited tokens of `erc20Contract` to `to`.
107111
*/
108-
function safeApprove(IERC20Upgradeable token, address to, uint256 minAmount) private {
112+
function safeApprove(
113+
IERC20Upgradeable token,
114+
address to,
115+
uint256 minAmount
116+
) private {
109117
uint256 allowance = token.allowance(address(this), to);
110118

111119
if (allowance < minAmount) {
@@ -117,7 +125,11 @@ contract IonicLiquidator is OwnableUpgradeable, ILiquidator, IUniswapV2Callee, I
117125
/**
118126
* @dev Internal function to approve
119127
*/
120-
function justApprove(IERC20Upgradeable token, address to, uint256 amount) private {
128+
function justApprove(
129+
IERC20Upgradeable token,
130+
address to,
131+
uint256 amount
132+
) private {
121133
token.approve(to, amount);
122134
}
123135

@@ -170,9 +182,11 @@ contract IonicLiquidator is OwnableUpgradeable, ILiquidator, IUniswapV2Callee, I
170182
* @notice Safely liquidate an unhealthy loan, confirming that at least `minProfitAmount` in NATIVE profit is seized.
171183
* @param vars @see LiquidateToTokensWithFlashSwapVars.
172184
*/
173-
function safeLiquidateToTokensWithFlashLoan(
174-
LiquidateToTokensWithFlashSwapVars calldata vars
175-
) external onlyPERPermissioned(vars.borrower, vars.cTokenCollateral) returns (uint256) {
185+
function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)
186+
external
187+
onlyPERPermissioned(vars.borrower, vars.cTokenCollateral)
188+
returns (uint256)
189+
{
176190
// Input validation
177191
require(vars.repayAmount > 0, "Repay amount must be greater than 0.");
178192

@@ -240,7 +254,12 @@ contract IonicLiquidator is OwnableUpgradeable, ILiquidator, IUniswapV2Callee, I
240254
/**
241255
* @dev Callback function for Uniswap flashloans.
242256
*/
243-
function uniswapV2Call(address, uint256, uint256, bytes calldata data) public override {
257+
function uniswapV2Call(
258+
address,
259+
uint256,
260+
uint256,
261+
bytes calldata data
262+
) public override {
244263
// Liquidate unhealthy borrow, exchange seized collateral, return flashloaned funds, and exchange profit
245264
// Decode params
246265
LiquidateToTokensWithFlashSwapVars memory vars = abi.decode(data[4:], (LiquidateToTokensWithFlashSwapVars));
@@ -253,11 +272,21 @@ contract IonicLiquidator is OwnableUpgradeable, ILiquidator, IUniswapV2Callee, I
253272
/**
254273
* @dev Callback function for PCS flashloans.
255274
*/
256-
function pancakeCall(address sender, uint256 amount0, uint256 amount1, bytes calldata data) external {
275+
function pancakeCall(
276+
address sender,
277+
uint256 amount0,
278+
uint256 amount1,
279+
bytes calldata data
280+
) external {
257281
uniswapV2Call(sender, amount0, amount1, data);
258282
}
259283

260-
function moraswapCall(address sender, uint256 amount0, uint256 amount1, bytes calldata data) external {
284+
function moraswapCall(
285+
address sender,
286+
uint256 amount0,
287+
uint256 amount1,
288+
bytes calldata data
289+
) external {
261290
uniswapV2Call(sender, amount0, amount1, data);
262291
}
263292

@@ -428,10 +457,10 @@ contract IonicLiquidator is OwnableUpgradeable, ILiquidator, IUniswapV2Callee, I
428457
* Each whitelisted redemption strategy has to be checked to not be able to
429458
* call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`
430459
*/
431-
function _whitelistRedemptionStrategies(
432-
IRedemptionStrategy[] calldata strategies,
433-
bool[] calldata whitelisted
434-
) external onlyOwner {
460+
function _whitelistRedemptionStrategies(IRedemptionStrategy[] calldata strategies, bool[] calldata whitelisted)
461+
external
462+
onlyOwner
463+
{
435464
require(
436465
strategies.length > 0 && strategies.length == whitelisted.length,
437466
"list of strategies empty or whitelist does not match its length"

contracts/IonicUniV3Liquidator.sol

+24-10
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ contract IonicUniV3Liquidator is OwnableUpgradeable, ILiquidator, IUniswapV3Flas
125125
return seizedOutputAmount;
126126
}
127127

128-
function safeLiquidateToTokensWithFlashLoan(
129-
LiquidateToTokensWithFlashSwapVars calldata vars
130-
) external onlyPERPermissioned(vars.borrower, vars.cTokenCollateral) returns (uint256) {
128+
function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)
129+
external
130+
onlyPERPermissioned(vars.borrower, vars.cTokenCollateral)
131+
returns (uint256)
132+
{
131133
// Input validation
132134
require(vars.repayAmount > 0, "Repay amount must be greater than 0.");
133135

@@ -196,15 +198,27 @@ contract IonicUniV3Liquidator is OwnableUpgradeable, ILiquidator, IUniswapV3Flas
196198
* @dev Callback function for Uniswap flashloans.
197199
*/
198200

199-
function supV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {
201+
function supV3FlashCallback(
202+
uint256 fee0,
203+
uint256 fee1,
204+
bytes calldata data
205+
) external {
200206
uniswapV3FlashCallback(fee0, fee1, data);
201207
}
202208

203-
function algebraFlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {
209+
function algebraFlashCallback(
210+
uint256 fee0,
211+
uint256 fee1,
212+
bytes calldata data
213+
) external {
204214
uniswapV3FlashCallback(fee0, fee1, data);
205215
}
206216

207-
function uniswapV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) public {
217+
function uniswapV3FlashCallback(
218+
uint256 fee0,
219+
uint256 fee1,
220+
bytes calldata data
221+
) public {
208222
// Liquidate unhealthy borrow, exchange seized collateral, return flashloaned funds, and exchange profit
209223
// Decode params
210224
LiquidateToTokensWithFlashSwapVars memory vars = abi.decode(data[4:], (LiquidateToTokensWithFlashSwapVars));
@@ -363,10 +377,10 @@ contract IonicUniV3Liquidator is OwnableUpgradeable, ILiquidator, IUniswapV3Flas
363377
* Each whitelisted redemption strategy has to be checked to not be able to
364378
* call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`
365379
*/
366-
function _whitelistRedemptionStrategies(
367-
IRedemptionStrategy[] calldata strategies,
368-
bool[] calldata whitelisted
369-
) external onlyOwner {
380+
function _whitelistRedemptionStrategies(IRedemptionStrategy[] calldata strategies, bool[] calldata whitelisted)
381+
external
382+
onlyOwner
383+
{
370384
require(
371385
strategies.length > 0 && strategies.length == whitelisted.length,
372386
"list of strategies empty or whitelist does not match its length"

contracts/compound/Comptroller.sol

+18-5
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,13 @@ contract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorR
575575
require(borrowBalance >= repayAmount, "!borrow>repay");
576576
} else {
577577
/* The borrower must have shortfall in order to be liquidateable */
578-
(Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(borrower, ICErc20(address(0)), 0, 0, 0);
578+
(Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(
579+
borrower,
580+
ICErc20(address(0)),
581+
0,
582+
0,
583+
0
584+
);
579585
if (err != Error.NO_ERROR) {
580586
return uint256(err);
581587
}
@@ -755,7 +761,7 @@ contract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorR
755761
uint256 redeemTokens,
756762
uint256 borrowAmount,
757763
uint256 repayAmount
758-
)
764+
)
759765
public
760766
view
761767
returns (
@@ -770,7 +776,13 @@ contract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorR
770776
uint256 collateralValue,
771777
uint256 liquidity,
772778
uint256 shortfall
773-
) = getHypotheticalAccountLiquidityInternal(account, ICErc20(cTokenModify), redeemTokens, borrowAmount, repayAmount);
779+
) = getHypotheticalAccountLiquidityInternal(
780+
account,
781+
ICErc20(cTokenModify),
782+
redeemTokens,
783+
borrowAmount,
784+
repayAmount
785+
);
774786
return (uint256(err), collateralValue, liquidity, shortfall);
775787
}
776788

@@ -791,7 +803,7 @@ contract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorR
791803
uint256 redeemTokens,
792804
uint256 borrowAmount,
793805
uint256 repayAmount
794-
)
806+
)
795807
internal
796808
view
797809
returns (
@@ -847,7 +859,8 @@ contract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorR
847859

848860
// accumulate the collateral value to sumCollateral
849861
uint256 assetCollateralValue = mul_ScalarTruncate(vars.tokensToDenom, vars.cTokenBalance);
850-
if (assetCollateralValue > vars.assetAsCollateralValueCap) assetCollateralValue = vars.assetAsCollateralValueCap;
862+
if (assetCollateralValue > vars.assetAsCollateralValueCap)
863+
assetCollateralValue = vars.assetAsCollateralValueCap;
851864
vars.sumCollateral += assetCollateralValue;
852865
}
853866

contracts/test/liquidators/IonicLiquidatorTest.sol

+7-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ import { ProxyAdmin } from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin
2929
import { PoolLens } from "../../PoolLens.sol";
3030

3131
contract MockRedemptionStrategy is IRedemptionStrategy {
32-
function redeem(IERC20Upgradeable, uint256, bytes memory) external returns (IERC20Upgradeable, uint256) {
32+
function redeem(
33+
IERC20Upgradeable,
34+
uint256,
35+
bytes memory
36+
) external returns (IERC20Upgradeable, uint256) {
3337
return (IERC20Upgradeable(address(0)), 1);
3438
}
3539

@@ -151,8 +155,8 @@ contract IonicLiquidatorTest is UpgradesBaseTest {
151155

152156
vars.redemptionStrategies[0] = IFundsConversionStrategy(0x5cA3fd2c285C4138185Ef1BdA7573D415020F3C8);
153157
vars.strategyData[
154-
0
155-
] = hex"0000000000000000000000004200000000000000000000000000000000000006000000000000000000000000ac48fcf1049668b285f3dc72483df5ae2162f7e8";
158+
0
159+
] = hex"0000000000000000000000004200000000000000000000000000000000000006000000000000000000000000ac48fcf1049668b285f3dc72483df5ae2162f7e8";
156160

157161
liquidator.safeLiquidateToTokensWithFlashLoan(vars);
158162
}

package-lock.json

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)