The burn function executes but contains two key issues:
Incorrect amount scaling when burning tokens
Return values don't match parameter order
RToken::burn
burns tokens based on the liquidityIndex
to account for accrued interest. As interest accrues (liquidityIndex
> 1), fewer rTokens should be burned to receive the same underlying amount, reflecting their increased value.
The implementation has three issues:
Incorrect scaling:
Using rayMul
instead of rayDiv
inflates the burn amount.
Example:
Initial: 50 underlying = 50 rTokens (index = 1.0)
After interest: 50 underlying should = 45.45 rTokens (index = 1.1)
Current code burns 55 rTokens (50 * 1.1)
The current implementation:
Uses rayMul instead of rayDiv, scaling up instead of down
Burns raw amount instead of scaled amount
Returns wrong scaled value
Burns unscaled amount:
Returns amount
in first parameter when it should be amountScaled
The order is wrong, we're returning the unscaled amount for the first parameter which is supposed to be the scaled tokens burned per natspec.
Incorrect burn amounts lead to value loss for users when interest has accrued
Inaccurate return values break protocols integrating with burn function
Foundry
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.