diff --git a/contracts/bots/PartialLiquidationBotV3.sol b/contracts/bots/PartialLiquidationBotV3.sol index e8411d1..d632b1d 100644 --- a/contracts/bots/PartialLiquidationBotV3.sol +++ b/contracts/bots/PartialLiquidationBotV3.sol @@ -26,8 +26,8 @@ import {IPriceOracleV3, PriceUpdate} from "@gearbox-protocol/core-v3/contracts/i import {IBot} from "@gearbox-protocol/core-v3/contracts/interfaces/base/IBot.sol"; import {IVersion} from "@gearbox-protocol/core-v3/contracts/interfaces/base/IVersion.sol"; import {PERCENTAGE_FACTOR} from "@gearbox-protocol/core-v3/contracts/libraries/Constants.sol"; -import {ContractsRegisterTrait} from "@gearbox-protocol/core-v3/contracts/traits/ContractsRegisterTrait.sol"; import {ReentrancyGuardTrait} from "@gearbox-protocol/core-v3/contracts/traits/ReentrancyGuardTrait.sol"; +import {SanityCheckTrait} from "@gearbox-protocol/core-v3/contracts/traits/SanityCheckTrait.sol"; import {IPartialLiquidationBotV3} from "../interfaces/IPartialLiquidationBotV3.sol"; @@ -48,7 +48,7 @@ import {IPartialLiquidationBotV3} from "../interfaces/IPartialLiquidationBotV3.s /// - this implementation can't handle fee-on-transfer underlyings. /// The bot can also be used for deleverage to prevent liquidations by triggering earlier, limiting /// operation size and/or charging less in premium and fees. -contract PartialLiquidationBotV3 is IPartialLiquidationBotV3, ContractsRegisterTrait, ReentrancyGuardTrait { +contract PartialLiquidationBotV3 is IPartialLiquidationBotV3, ReentrancyGuardTrait, SanityCheckTrait { using SafeERC20 for IERC20; /// @dev Internal liquidation variables @@ -86,20 +86,19 @@ contract PartialLiquidationBotV3 is IPartialLiquidationBotV3, ContractsRegisterT uint16 public immutable override feeScaleFactor; /// @notice Constructor - /// @param contractsRegister_ Contracts register address /// @param treasury_ Treasury address /// @param minHealthFactor_ Minimum health factor to trigger the liquidation /// @param maxHealthFactor_ Maximum health factor to allow after the liquidation /// @param premiumScaleFactor_ Factor to scale credit manager's liquidation premium by /// @param feeScaleFactor_ Factor to scale credit manager's liquidation fee by + /// @dev Reverts if `treasury_` is zero address constructor( - address contractsRegister_, address treasury_, uint16 minHealthFactor_, uint16 maxHealthFactor_, uint16 premiumScaleFactor_, uint16 feeScaleFactor_ - ) ContractsRegisterTrait(contractsRegister_) { + ) nonZeroAddress(treasury_) { treasury = treasury_; if (maxHealthFactor_ < PERCENTAGE_FACTOR || maxHealthFactor_ < minHealthFactor_) { revert IncorrectParameterException(); @@ -172,9 +171,8 @@ contract PartialLiquidationBotV3 is IPartialLiquidationBotV3, ContractsRegisterT vars.feeLiquidation = feeLiquidation * feeScaleFactor / PERCENTAGE_FACTOR; } - /// @dev Ensures that `creditAccount` is liquidatable, its credit manager is registered and `token` is not underlying + /// @dev Ensures that `creditAccount` is liquidatable and `token` is not underlying function _validateLiquidation(LiquidationVars memory vars, address creditAccount, address token) internal view { - _ensureRegisteredCreditManager(vars.creditManager); if (token == vars.underlying) revert UnderlyingNotLiquidatableException(); if (!_isLiquidatable(_calcDebtAndCollateral(vars.creditManager, creditAccount), minHealthFactor)) { revert CreditAccountNotLiquidatableException(); diff --git a/contracts/interfaces/IPartialLiquidationBotV3.sol b/contracts/interfaces/IPartialLiquidationBotV3.sol index 42a174b..455aba2 100644 --- a/contracts/interfaces/IPartialLiquidationBotV3.sol +++ b/contracts/interfaces/IPartialLiquidationBotV3.sol @@ -77,7 +77,6 @@ interface IPartialLiquidationBotV3 is IBot { /// @param priceUpdates On-demand price feed updates to apply before calculations /// @return seizedAmount Amount of `token` seized /// @dev Requires underlying token approval from caller to this contract - /// @dev Reverts if `creditAccount`'s credit manager is not registered /// @dev Reverts if `token` is underlying /// @dev Reverts if `creditAccount`'s health factor is not less than `minHealthFactor` before liquidation /// @dev Reverts if amount of `token` to be seized is less than `minSeizedAmount` @@ -100,7 +99,6 @@ interface IPartialLiquidationBotV3 is IBot { /// @param priceUpdates On-demand price feed updates to apply before calculations /// @return repaidAmount Amount of underlying repaid /// @dev Requires underlying token approval from caller to this contract - /// @dev Reverts if `creditAccount`'s credit manager is not registered /// @dev Reverts if `token` is underlying /// @dev Reverts if `creditAccount`'s health factor is not less than `minHealthFactor` before liquidation /// @dev Reverts if amount of underlying to be repaid is greater than `maxRepaidAmount` diff --git a/contracts/test/integration/PartialLiquidationBotV3.int.t.sol b/contracts/test/integration/PartialLiquidationBotV3.int.t.sol index 0be113e..60b06cd 100644 --- a/contracts/test/integration/PartialLiquidationBotV3.int.t.sol +++ b/contracts/test/integration/PartialLiquidationBotV3.int.t.sol @@ -87,12 +87,7 @@ contract PartialLiquidationBotV3IntegrationTest is IntegrationTestHelper { treasury = makeAddr("TREASURY"); bot = new PartialLiquidationBotV3( - address(cr), - treasury, - params.minHealthFactor, - params.maxHealthFactor, - params.premiumScaleFactor, - params.feeScaleFactor + treasury, params.minHealthFactor, params.maxHealthFactor, params.premiumScaleFactor, params.feeScaleFactor ); dai = tokenTestSuite.addressOf(Tokens.DAI);