Fast Khaki Raccoon
Medium
Liquidators will sometimes get unprofitable liquidations due to the way protocol fee is taken, this will lower liquidations and push the system into reaching bad debt more easily.
Fees are taken from liquidator's collateral, which would decrease it's earning and may even make liquidations unprofitable in some cases.
The code snippet bellow shows how we: https://github.com/sherlock-audit/2025-01-peapods-finance/blob/main/fraxlend/src/contracts/FraxlendPairCore.sol#L1132-L1157
// get liquidator's liquidating assets
uint256 _liquidationAmountInCollateralUnits =
((_totalBorrow.toAmount(_sharesToLiquidate, false) * _exchangeRate) / EXCHANGE_PRECISION);
// calculate the fee he would get for executing the task
uint256 _optimisticCollateralForLiquidator =
(_liquidationAmountInCollateralUnits * (LIQ_PRECISION + cleanLiquidationFee)) / LIQ_PRECISION;
// get leftover and make sure we aren't getting more collateral than the user has
_leftoverCollateral = (_userCollateralBalance.toInt256() - _optimisticCollateralForLiquidator.toInt256());
_collateralForLiquidator = _leftoverCollateral <= 0
? _userCollateralBalance
: (_liquidationAmountInCollateralUnits * (LIQ_PRECISION + dirtyLiquidationFee)) / LIQ_PRECISION;
// calculate the protocol fee from liquidator's final amount
if (protocolLiquidationFee > 0) {
_feesAmount = (protocolLiquidationFee * _collateralForLiquidator) / LIQ_PRECISION;
_collateralForLiquidator = _collateralForLiquidator - _feesAmount;
}
However since we are taking the fee from the liquidator's final amount that protocol fee is applied on a bigger value (coll + liquidator fee), thus having more impact and being proportionally bigger.
Taking the fee from the liquidator's final amount
if (protocolLiquidationFee > 0) {
_feesAmount = (protocolLiquidationFee * _collateralForLiquidator) / LIQ_PRECISION;
_collateralForLiquidator = _collateralForLiquidator - _feesAmount;
}
No response
No response
- Protocol and liquidator fees are 10% each
- Liquidator liquidates 10k worth of assets
- We math out his
_collateralForLiquidator
to be worth 11k - Fees would be 11k * 10% -> 1.1k
- Final
_collateralForLiquidator
would be 9.9k making the liquidation bad for the liquidator
Liquidators will sometimes get unprofitable liquidations due to the way protocol fee is taken, this will lower liquidations and push the system into reaching bad debt more easily.
No response
Take the fee from the amount before the increase.