Potential for Inaccurate Melting Due to Balance Discrepancies #234
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
🤖_27_group
AI based duplicate group recommendation
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-07-reserve/blob/3f133997e186465f4904553b0f8e86ecb7bbacbf/contracts/p1/Furnace.sol#L65
Vulnerability details
Vulnerability Details
The core problem lies in the fact that the function uses
lastPayoutBal
to calculate the melt amount, but then updateslastPayoutBal
based on the current balance. This can lead to inconsistencies if the actual balance has changed between melt operations.Code Snippet
The problem
amount
is calculated based onlastPayoutBal
.lastPayoutBal
is then updated using the current balance (rToken.balanceOf(address(this))
).lastPayoutBal
won't accurately reflect the starting balance for the next period.Scenario
lastPayoutBal
: 1000 tokensmelt()
is called:amount
is calculated based on 1000 tokenslastPayoutBal
is updated to(1500 - amount)
, which doesn't accurately represent the starting balance for the next periodImpact
Potential fix
To address this, the function should either:
A possible implementation of the first approach:
This change ensures that melting is always based on the current balance, accounting for any changes since the last melt operation.
Assessed type
Context
The text was updated successfully, but these errors were encountered: