Liquidation Fee is incorrectly computed
The liquidation fee was calculated as a percentage of the repaid debt rather than the liquidator's profit, causing liquidators to lose money on full liquidations. This disincentivised liquidations, risking protocol insolvency from bad debt.
Source: https://github.com/sherlock-audit/2025-08-usg-tangent-judging/issues/651
Found by
0xFlare, 0xodus, 0xsh, 0xxAristos, AMOW, Nyxx, ParthMandale, Pro_King, Sa1ntRobi, Tigerfrake, VictorUbi, auditorshambu, deadmanwalking, gh0xt, silver_eth, sl1
Summary
The liquidation fee is incorrectly calculated as a percentage of the repaid debt (USGToRepay) rather than the liquidation bonus or profit (collateral value minus repaid debt), leading to scenarios where liquidators incur losses instead of profits, disincentivizing liquidations.
Finding Description
In the _liquidate function,
https://github.com/sherlock-audit/2025-08-usg-tangent/blob/main/tangent-contracts/src/USG/Market/abstract/MarketCore.sol#L441
function _liquidate(LiquidateInput memory liquidateInput, ZapStruct calldata liquidateCall) internal returns (uint256, uint256, uint256, uint256) {
uint256 collatAmountToLiquidate = liquidateInput.collatToLiquidate;
_verifyCollatInputNotZero(liquidateInput.collatToLiquidate);
uint256 debtSharesToRemove;
uint256 USGToRepay;
// Liquidate all
if (collatAmountToLiquidate >= liquidateInput._collateralBalance) {
collatAmountToLiquidate = liquidateInput._collateralBalance;
USGToRepay = liquidateInput.userDebt;
debtSharesToRemove = liquidateInput._userDebtShares;
}
// Liquidate partial
else {
USGToRepay = (collatAmountToLiquidate * liquidateInput.userDebt) / liquidateInput._collateralBalance;
debtSharesToRemove = _convertToShares(USGToRepay, liquidateInput.newDebtIndex);
// Ensure that the remaining debt is bigger than a minimum in order to leave profitable liquidation
_verifyMinimumDebt(liquidateInput.userDebt - USGToRepay);
}
uint256 newUserDebtShares = liquidateInput._userDebtShares - debtSharesToRemove;
// Modify the collateral balance, the user debt and the total debt
_updateCollatAndDebts(
liquidateInput.account,
liquidateInput._collateralBalance - collatAmountToLiquidate,
liquidateInput._totalCollateral - collatAmountToLiquidate,
newUserDebtShares,
liquidateInput._totalDebtShares - debtSharesToRemove
);
uint256 fee = _mulDiv(USGToRepay, liquidationFee, DENOMINATOR); //<<@audit
_postLiquidate(collatAmountToLiquidate, USGToRepay + fee, liquidateInput.minUSGOut, liquidateCall);
if (fee != 0) {
_mintUSG(usg, controlTower.feeTreasury(), fee);
}
return (collatAmountToLiquidate, USGToRepay, fee, newUserDebtShares);
}
the liquidation fee is computed as:
fee = _mulDiv(USGToRepay, liquidationFee, DENOMINATOR);
where USGToRepay is the portion of the user's debt being repaid (proportional to the collateral liquidated). This fee is then added to the repayment amount in _postLiquidate (requiring the liquidator to effectively pay USGToRepay + fee while receiving collateral of potentially lower value) and minted to the treasury via _mintUSG. In a full liquidation scenario with a price drop, this results in the liquidator overpaying relative to the collateral's value.
For example:
Scenario Parameters:
Initial collateral: $5,000Initial debt: $4,500Liquidation threshold: 95%Liquidation fee: 14%Collateral drops to: $4,700Health factor: 0.992 < 1 (liquidatable)
Current (Incorrect) Calculation:
Liquidator receives: $4,700 in collateralLiquidator pays: $4,500 (debt) + $630 (14% of $4,500) = $5,130Net loss to liquidator: $5,130 - $4,700 = $430
Correct Calculation:
Liquidation reward: $4,700 - $4,500 = $200Fee should be: 14% × $200 = $28Liquidator pays: $4,500 (debt) + $28 (fee) = $4,528Net profit to liquidator: $172
Impact
- Liquidation Mechanism Failure: No rational liquidator will participate when guaranteed to lose money, effectively disabling the liquidation system.
- Protocol Insolvency Risk: Without functioning liquidations, undercollateralized positions accumulate bad debt, threatening protocol solvency.
- Cascading Liquidation Failures: During market stress, when liquidations are most needed, the broken incentive structure prevents liquidators from acting.
Mitigation
// Current (incorrect):
- uint256 fee = _mulDiv(USGToRepay, liquidationFee, DENOMINATOR);
// Should be (correct):
+ uint256 liquidationReward = collatAmountToLiquidate * _collateralPrice() / 1e18 - USGToRepay;
+ uint256 fee = _mulDiv(liquidationReward, liquidationFee, DENOMINATOR);
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/Tangent-labs/tangent-contracts/pull/117
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The fee was computed from the debt repaid instead of the liquidation reward (collateral value minus debt).
Impact
Liquidators would lose money and stop liquidating, which could lead to bad debt and protocol insolvency during market stress.
What the attacker needed
None
The fix
The fee should be calculated on the liquidation reward (collateral value minus repaid debt) instead of the repaid debt, and the protocol team fixed this issue.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In a lending protocol, when a borrower's collateral falls below a threshold, a liquidator repays their debt and receives the collateral at a discount. The liquidator should earn a profit for taking this risk. Here, the fee charged to the liquidator was based on the debt amount, not the profit, so the liquidator often paid more than the collateral was worth and lost money.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.