From 675bb69a00b6df36486cca7502c93d5ae668eea1 Mon Sep 17 00:00:00 2001 From: Antonio Guilherme Ferreira Viggiano Date: Wed, 3 Jul 2024 12:30:42 -0300 Subject: [PATCH 1/2] c4-013 Liquidate does not have deadline protection --- src/libraries/actions/Liquidate.sol | 7 +++++++ src/libraries/actions/LiquidateWithReplacement.sol | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/libraries/actions/Liquidate.sol b/src/libraries/actions/Liquidate.sol index 59b8de16..6dd77cca 100644 --- a/src/libraries/actions/Liquidate.sol +++ b/src/libraries/actions/Liquidate.sol @@ -20,6 +20,8 @@ struct LiquidateParams { uint256 debtPositionId; // The minimum profit in collateral tokens expected by the liquidator uint256 minimumCollateralProfit; + // The deadline for the transaction + uint256 deadline; } /// @title Liquidate @@ -51,6 +53,11 @@ library Liquidate { // validate minimumCollateralProfit // N/A + + // validate deadline + if (params.deadline < block.timestamp) { + revert Errors.PAST_DEADLINE(params.deadline); + } } /// @notice Validates the minimum profit in collateral tokens expected by the liquidator diff --git a/src/libraries/actions/LiquidateWithReplacement.sol b/src/libraries/actions/LiquidateWithReplacement.sol index a3f17b81..8eda2cef 100644 --- a/src/libraries/actions/LiquidateWithReplacement.sol +++ b/src/libraries/actions/LiquidateWithReplacement.sol @@ -55,7 +55,8 @@ library LiquidateWithReplacement { state.validateLiquidate( LiquidateParams({ debtPositionId: params.debtPositionId, - minimumCollateralProfit: params.minimumCollateralProfit + minimumCollateralProfit: params.minimumCollateralProfit, + deadline: params.deadline }) ); @@ -105,7 +106,8 @@ library LiquidateWithReplacement { state, LiquidateParams({ debtPositionId: params.debtPositionId, - minimumCollateralProfit: params.minimumCollateralProfit + minimumCollateralProfit: params.minimumCollateralProfit, + deadline: params.deadline }), liquidatorProfitCollateralToken ); @@ -131,7 +133,8 @@ library LiquidateWithReplacement { liquidatorProfitCollateralToken = state.executeLiquidate( LiquidateParams({ debtPositionId: params.debtPositionId, - minimumCollateralProfit: params.minimumCollateralProfit + minimumCollateralProfit: params.minimumCollateralProfit, + deadline: params.deadline }) ); From 96bfc9c5958c82c609025216f16cc0b8fe170701 Mon Sep 17 00:00:00 2001 From: Antonio Guilherme Ferreira Viggiano Date: Wed, 10 Jul 2024 11:51:21 -0300 Subject: [PATCH 2/2] Remove duplicate check --- src/libraries/actions/LiquidateWithReplacement.sol | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/libraries/actions/LiquidateWithReplacement.sol b/src/libraries/actions/LiquidateWithReplacement.sol index 8eda2cef..a0de8c35 100644 --- a/src/libraries/actions/LiquidateWithReplacement.sol +++ b/src/libraries/actions/LiquidateWithReplacement.sol @@ -74,11 +74,6 @@ library LiquidateWithReplacement { revert Errors.INVALID_BORROW_OFFER(params.borrower); } - // validate deadline - if (params.deadline < block.timestamp) { - revert Errors.PAST_DEADLINE(params.deadline); - } - // validate minAPR uint256 apr = borrowOffer.getAPRByTenor( VariablePoolBorrowRateParams({