Skip to content

Commit

Permalink
feat: remove check that manager is registered
Browse files Browse the repository at this point in the history
  • Loading branch information
lekhovitsky committed Jul 17, 2024
1 parent 07142aa commit 2875a62
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
12 changes: 5 additions & 7 deletions contracts/bots/PartialLiquidationBotV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IPartialLiquidationBotV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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`
Expand Down
7 changes: 1 addition & 6 deletions contracts/test/integration/PartialLiquidationBotV3.int.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2875a62

Please sign in to comment.