post burn state fee calculation model can be gamed by burning small amounts
The burn fee is calculated from the post-burn ratio and applied to the whole amount, so splitting a large burn into several smaller burns moves the ratio through the fee slope in steps and pays less total fee. An attacker could therefore avoid part of the burn fee by breaking one burn into many calls.
kangaroo Follow with lanrebayode77 and moray5554
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-07-cap-judging/issues/449
Found by
kangaroo, lanrebayode77, moray5554
Summary
Protocol suppose to incentives users for burning CAP for popular assets by 0 fee and penalised if asset we want to burn for is "rare" with fee up to 100%. There are 2 main functions we need to pay attention to understand the issue MinterLogic.sol
function _amountOutBeforeFee(address _oracle, IMinter.AmountOutParams memory params)
internal
view
returns (uint256 amount, uint256 newRatio)
{
(uint256 assetPrice,) = IOracle(_oracle).getPrice(params.asset);
(uint256 capPrice,) = IOracle(_oracle).getPrice(address(this));
uint256 assetDecimalsPow = 10 ** IERC20Metadata(params.asset).decimals();
uint256 capDecimalsPow = 10 ** IERC20Metadata(address(this)).decimals();
uint256 capSupply = IERC20(address(this)).totalSupply();
uint256 capValue = capSupply * capPrice / capDecimalsPow;
uint256 allocationValue = IVault(address(this)).totalSupplies(params.asset) * assetPrice / assetDecimalsPow;
uint256 assetValue;
if (params.mint) {
assetValue = params.amount * assetPrice / assetDecimalsPow;
if (capSupply == 0) {
newRatio = 0;
amount = assetValue * capDecimalsPow / assetPrice;
} else {
newRatio = (allocationValue + assetValue) * RAY_PRECISION / (capValue + assetValue);
amount = assetValue * capDecimalsPow / capPrice;
}
} else {
assetValue = params.amount * capPrice / capDecimalsPow;
if (params.amount == capSupply) {
newRatio = RAY_PRECISION;
amount = assetValue * assetDecimalsPow / assetPrice;
} else {
if (allocationValue < assetValue || capValue <= assetValue) {
newRatio = 0;
} else {
newRatio = (allocationValue - assetValue) * RAY_PRECISION / (capValue - assetValue);
}
amount = assetValue * assetDecimalsPow / assetPrice;
}
}
}
function _applyFeeSlopes(IMinter.FeeData memory fees, IMinter.FeeSlopeParams memory params)
internal
pure
returns (uint256 amount, uint256 fee)
{
uint256 rate;
if (params.mint) {
rate = fees.minMintFee;
if (params.ratio > fees.optimalRatio) {
if (params.ratio > fees.mintKinkRatio) {
uint256 excessRatio = params.ratio - fees.mintKinkRatio;
rate += fees.slope0 + (fees.slope1 * excessRatio / (RAY_PRECISION - fees.mintKinkRatio));
} else {
rate += fees.slope0 * (params.ratio - fees.optimalRatio) / (fees.mintKinkRatio - fees.optimalRatio);
}
}
} else {
if (params.ratio < fees.optimalRatio) {
if (params.ratio < fees.burnKinkRatio) {
uint256 excessRatio = fees.burnKinkRatio - params.ratio;
rate = fees.slope0 + (fees.slope1 * excessRatio / fees.burnKinkRatio);
} else {
rate = fees.slope0 * (fees.optimalRatio - params.ratio) / (fees.optimalRatio - fees.burnKinkRatio);
}
}
}
if (rate > RAY_PRECISION) rate = RAY_PRECISION;
fee = params.amount * rate / RAY_PRECISION;
amount = params.amount - fee;
}
_amountOutBeforeFee calculates amount and the ratio (share of the asset in the pool) and _applyFeeSlopes applies slope depends on the ratio we got. The problem here, the ratio we calculating essentially is a post burn state ratio.Means, the fee will be applied to the whole amount like as whole amount was burned at specific point in the slope. In reality, say, 30% of total amount can be burned above optimal ratio, another 20 bellow it, and another 50 bellow burn kink ratio - resulting lower fee than if we burn it one tx.
Let's illustrate it with an example:
fees = IMinter.FeeData({
...
optimalRatio: 0.5e27, // 50%
mintKinkRatio: 0.8e27, // 80%
burnKinkRatio: 0.2e27, // 20%
slope0: 0.2e27, // 20% fee slope before kink
slope1: 0.8e27 // 80% fee slope after kink
});
I willing to burn 1000e18 tokens and the ratio (we got from _amountOutBeforeFee()) will be 0.05e27(5% allocation)
If i do it one burn:
excessRatio = burnKinkRatio - ratio = 0.15e27
rate = slope0 + (slope1 * excessRatio / burnKinkRatio) = 0.8e27 (80%) -> fee 800e18, receive 200e18
If i split it into 2 500e18 calls : 1st) rate = 0.2 + (0.8 * 0.08 / 0.2) = 0.2 + 0.32 = 0.52 (52%) fee = 500 * 0.52 = 260 receive = 240 2nd) rate = 0.2 + (0.8 * 0.15 / 0.2) = 0.2 + 0.6 = 0.8 (80%) fee = 500 * 0.8 = 400 receive = 100
In our example splitting let us moving ratio 0.2 to 0.12 and pays fee on this ratio first, and then 0.12 to 0.05 (the final ratio in our one tx burn()) In reality, attacker will burn everything before optimal ratio and then start splitting as more as close we go to "fee cliffs".
Root Cause
_amountOutBeforeFee(), _applyFeeSlopes() in MinterLogic.sol
Internal Pre-conditions
None, but at the fee cliff state or low volume basket it will drastically reduce the fee
External Pre-conditions
none
Attack Path
attacker split burn() into multiple calls in order to save on fees
Impact
User avoids fees while burn()
PoC
No response
Mitigation
No response
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 fee rate is derived from the post-burn ratio and applied uniformly to the entire burn amount, instead of integrating the fee across the ratio range the burn actually crosses.
Impact
A user could reduce the burn fee they pay by splitting a burn into multiple calls, with the saving largest near the fee cliffs or in low-volume baskets.
What the attacker needed
Ability to call burn() repeatedly; no special role needed
How it was found
- Choose a burn amount that would push the pool ratio well below the burn kink ratio.
- Perform the burn in a single call and note the high fee rate applied to the whole amount.
- Instead split the same total into several smaller burn calls.
- Each smaller call is charged at a lower rate because the post-burn ratio moves less per call.
- Total fee paid across the split burns is lower than the single burn.
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.
The protocol charges a fee when you burn tokens, and the fee grows as the pool's balance ratio gets worse. The code works out the fee using the ratio after the whole burn, then applies that one rate to everything. If you burn in several smaller pieces, each piece is charged at a gentler rate, so you pay less overall.
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.