`ViewLogic::maxLiquidatable()` doesn't take the bonus into account, making the agent liquidatable again
The maxLiquidatable() view function computes the maximum debt a liquidator can repay without accounting for the liquidation bonus, so the resulting health is lower than the intended target. This lets an agent be liquidated more than once in a row, causing larger losses than expected.
0x73696d616f Follow with 0xzey, Albert_Mei and 6 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-07-cap-judging/issues/638
Found by
0x73696d616f, 0xzey, Albert_Mei, Drynooo, KrisRenZo, anirruth_, maxim371, montecristo, ustas
Summary
ViewLogic::maxLiquidatable() computes the maximum debt to liquidate such that the resulting target health is exactly the desired:
maxLiquidatableAmount = (($.targetHealth * totalDebt) - (totalDelegation * liquidationThreshold)) * decPow
/ (($.targetHealth - liquidationThreshold) * assetPrice);
However, this is inaccurate due to the bonus, which affects the final health as it slashes more than the debt is repays.
Thus, it will trigger more than 1 liquidations in certain conditions and lead to heavy losses for the agent.
Root Cause
In ViewLogic.sol:91, it doesn't include the bonus.
Internal Pre-conditions
None
External Pre-conditions
None
Attack Path
- Agent is liquidated twice in a row due to the
ViewLogic::maxLiquidatable()calculation not taking into account the bonus.
Impact
Agent suffers more losses than supposed.
PoC
No response
Mitigation
Include the bonus in the debt to repay so the health factor equals the target.
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
Likely the maximum liquidatable amount formula omits the liquidation bonus, so the health after liquidation falls below the target.
Impact
The agent could suffer more losses than intended because it can be liquidated repeatedly.
What the attacker needed
Agent has a liquidatable position; liquidator repays the max amount
The fix
The bonus should be included in the debt-to-repay calculation so the resulting health equals the target.
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.
When a borrower's collateral falls below a threshold, a liquidator can repay part of their debt and receive a bonus in collateral. A helper function is meant to calculate the largest repayment that leaves the borrower at a chosen safety level, but it forgets the bonus, so the borrower ends up less safe than intended and can be liquidated again straight away.
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.