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-002 Wrong crLiquidation cap in overdue liquidation #119

Merged
merged 1 commit into from
Jul 15, 2024
Merged
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
6 changes: 3 additions & 3 deletions src/libraries/actions/Liquidate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ library Liquidate {
);
liquidatorProfitCollateralToken = debtInCollateralToken + liquidatorReward;

// split the remaining collateral between the protocol and the borrower, capped by the crLiquidation
// the protocol earns a portion of the collateral remainder
uint256 collateralRemainder = assignedCollateral - liquidatorProfitCollateralToken;

// cap the collateral remainder to the liquidation collateral ratio
// cap the collateral remainder to FV * (1 - crLiquidation)
// otherwise, the split for non-underwater overdue loans could be too much
uint256 collateralRemainderCap =
Math.mulDivDown(debtInCollateralToken, state.riskConfig.crLiquidation, PERCENT);
Math.mulDivDown(debtInCollateralToken, state.riskConfig.crLiquidation - PERCENT, PERCENT);

collateralRemainder = Math.min(collateralRemainder, collateralRemainderCap);

Expand Down
Loading