The repayment function incorrectly scales the user’s debt when determining the actualRepayAmount
, but this does not impact core logic, only the emitted event. The issue arises from unscaling an already scaled debt amount before capping the repayment value.
In the _repay
function, the user's debt is retrieved and then unscaled using rayDiv(reserve.usageIndex)
, leading to an incorrect actualRepayAmount
:
Problem: balanceOf
already returns the correctly scaled debt. The unscaling step is unnecessary.
https://github.com/Cyfrin/2025-02-raac/blob/89ccb062e2b175374d40d824263a4c0b601bcb7f/contracts/core/tokens/DebtToken.sol#L223
Effect: The actualRepayAmount
value is lower than intended, but since it is only used in the event emission, there is no security risk but causes inconsistencies in event emission.
Parameter | Value |
---|---|
userDebt |
80 RAY |
usageIndex |
1.2 RAY |
amount |
90 |
Incorrect Calculation:
The event emitted that user repay 80 debt instead of 90
https://github.com/Cyfrin/2025-02-raac/blob/89ccb062e2b175374d40d824263a4c0b601bcb7f/contracts/core/pools/LendingPool/LendingPool.sol#L430
Incorrect Event Logging: The Repay
event may display a lower repayment value than what actually occurred.
Potential UI Confusion: If front-end applications rely on actualRepayAmount
, they may show incorrect repayment details.
Manual Code Review
balanceOf
return the correct scaled debt, protocol should use it.
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.