Obedient Lava Monkey
Medium
The calculation of liquidationProtocolFee
in _calculateAvailableCollateralToLiquidate
incorrectly deducts the fee from the collateralAmount
before returning, which may lead to a mismatch in the total collateral liquidated versus what is credited to the liquidator and the protocol.
In LiquidationLogic.sol
(within _calculateAvailableCollateralToLiquidate), the liquidationProtocolFee
is subtracted from the collateralAmount
without ensuring proper separation of the liquidator's and protocol's shares. This can result in:
- Liquidators receiving less collateral than expected.
- The protocol's fee being double-counted or inaccurately applied.
- A liquidation occurs where the
liquidationProtocolFeePercentage
is non-zero. - The calculated
liquidationProtocolFee
is deducted from the totalcollateralAmount
.
None (assumes trusted dependencies).
- A liquidator calls the liquidation function.
- The
_calculateAvailableCollateralToLiquidate
function deducts theliquidationProtocolFee
fromcollateralAmount
. - The returned
collateralAmount
excludes the protocol's fee, causing:- A mismatch in expected collateral transfer to the liquidator.
- Potential double deduction of the protocol fee if the function consuming this logic also accounts for the fee separately.
The protocol may lose fees, or liquidators may receive less collateral than expected, reducing their incentive to participate in liquidation. This could destabilize the protocol's liquidation process and treasury balance.
Separate the collateralAmount
and liquidationProtocolFee
in the return values and ensure they are handled independently downstream.