Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c4-013 Liquidate does not have deadline protection #132

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/libraries/actions/Liquidate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 6 additions & 8 deletions src/libraries/actions/LiquidateWithReplacement.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ library LiquidateWithReplacement {
state.validateLiquidate(
LiquidateParams({
debtPositionId: params.debtPositionId,
minimumCollateralProfit: params.minimumCollateralProfit
minimumCollateralProfit: params.minimumCollateralProfit,
deadline: params.deadline
})
);

Expand All @@ -73,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({
Expand Down Expand Up @@ -105,7 +101,8 @@ library LiquidateWithReplacement {
state,
LiquidateParams({
debtPositionId: params.debtPositionId,
minimumCollateralProfit: params.minimumCollateralProfit
minimumCollateralProfit: params.minimumCollateralProfit,
deadline: params.deadline
}),
liquidatorProfitCollateralToken
);
Expand All @@ -131,7 +128,8 @@ library LiquidateWithReplacement {
liquidatorProfitCollateralToken = state.executeLiquidate(
LiquidateParams({
debtPositionId: params.debtPositionId,
minimumCollateralProfit: params.minimumCollateralProfit
minimumCollateralProfit: params.minimumCollateralProfit,
deadline: params.deadline
})
);

Expand Down
Loading