Liquidator can receive an inflated bonus against PLPs on PanopticPool._liquidate
The settleBurn function returns a tokenPaid value that excludes commission fees burned afterwards, so the netPaid used in liquidation is understated. A liquidator can therefore receive a larger liquidation bonus than the liquidatee actually paid.
hecker_trieu_tien Follow with Albert
Originally disclosed on Code4rena
Submitted by hecker_trieu_tien, also found by Albert
CollateralTracker.sol L1595
Summary
CollateralTracker.settleBurn computes tokenPaid without commission/interest, which will cause a higher reported netPaid for PLPs as a liquidator will use the understated netPaid to receive a larger liquidation bonus than the liquidatee actually paid.
Root Cause
In contracts/CollateralTracker.sol, settleBurn returns tokenPaid derived from _updateBalancesAndSettle before commission shares are burned, so the amount returned to the pool does not include the commission paid by the liquidatee.
_updateBalancesAndSettlecomputestokenToPayfrom AMM delta, net borrows, and realized premium, then returns it astokenPaid.settleBurnthen burns commission shares based onrealizedPremium, but the return value is not adjusted to reflect that additional cost.PanopticPool._liquidateuses the unadjustednetPaidto compute the liquidation bonus.
Finding description
Step 1: settleBurn returns a tokenPaid value that does not include commission burned after the fact.
// contracts/CollateralTracker.sol
function settleBurn(...) external onlyPanopticPool returns (int128) {
(, int128 tokenPaid, uint256 _totalAssets, uint256 _totalSupply) = _updateBalancesAndSettle(
optionOwner,
false,
longAmount,
shortAmount,
ammDeltaAmount,
realizedPremium
);
if (realizedPremium != 0) {
uint128 commissionFee = ...;
uint256 sharesToBurn = Math.mulDivRoundingUp(commissionFee, _totalSupply, _totalAssets);
_burn(optionOwner, sharesToBurn);
}
return tokenPaid;
}
tokenPaid is computed before commission is burned, so it under-reports total value paid by the liquidatee in this burn.
Step 2: _burnAllOptionsFrom aggregates tokenPaid into netPaid without commission.
// contracts/PanopticPool.sol
(paidAmounts, premiasByLeg[i], ) = _burnOptions(...);
netPaid = netPaid.add(paidAmounts);
paidAmounts is built from settleBurn return values, so the omission propagates to netPaid.
Step 3: _liquidate uses netPaid to compute the liquidation bonus.
// contracts/PanopticPool.sol
(netPaid, premiasByLeg) = _burnAllOptionsFrom(...);
(bonusAmounts, collateralRemaining) = riskEngine().getLiquidationBonus(
tokenData0,
tokenData1,
Math.getSqrtRatioAtTick(twapTick),
netPaid,
shortPremium
);
The bonus is calculated using a value that excludes commission paid, which inflates the liquidatee’s remaining collateral and therefore the bonus.
Impact
Liquidation bonuses can be slightly overstated relative to the liquidatee’s true collateral change, creating a small protocol loss when commissions are non-zero.
Recommended mitigation steps
Include the commission fee (in asset terms) in the tokenPaid returned from settleBurn, or return the commission separately and incorporate it into netPaid before calling getLiquidationBonus.
Sample mitigation (adjust return value to include commission):
// contracts/CollateralTracker.sol
function settleBurn(...) external onlyPanopticPool returns (int128) {
(, int128 tokenPaid, uint256 _totalAssets, uint256 _totalSupply) = _updateBalancesAndSettle(
optionOwner,
false,
longAmount,
shortAmount,
ammDeltaAmount,
realizedPremium
);
if (realizedPremium != 0) {
uint128 commissionFee = ...;
uint256 sharesToBurn = Math.mulDivRoundingUp(commissionFee, _totalSupply, _totalAssets);
_burn(optionOwner, sharesToBurn);
tokenPaid += int128(uint128(commissionFee));
}
return tokenPaid;
}
Proof of Concept
test/foundry/core/PanopticPool.t.sol
View detailed Proof of Concept
Include commissions in
tokenPaid.
Status: Mitigation confirmed. Full details in reports from Valves, edoscoba, and Nyx.
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 settleBurn function computes and returns tokenPaid before burning commission shares, so the returned amount does not include the commission fee.
Impact
Liquidation bonuses can be slightly overstated relative to the liquidatee’s true collateral change, creating a small protocol loss when commissions are non-zero.
What the attacker needed
A liquidation event with non-zero commission
The fix
The mitigation was to include commissions in tokenPaid, and the project confirmed the fix.
How it was found
- settleBurn computes tokenPaid without including commission.
- settleBurn burns commission shares after computing tokenPaid.
- _burnAllOptionsFrom aggregates tokenPaid into netPaid without commission.
- _liquidate uses netPaid to compute the liquidation bonus.
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 position is liquidated, the protocol calculates a bonus for the person doing the liquidation based on how much the liquidatee paid. Here, one function forgot to include a fee in the amount it reported, so the bonus was calculated on a smaller payment than was actually made. This means the liquidator could get slightly more than they should.
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.