Potential Inaccurate Reserve Calculations Due To Hardcoded decimals #36
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
duplicate-13
🤖_08_group
AI based duplicate group recommendation
sufficient quality report
This report is of sufficient quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2024-07-basin/blob/main/src/functions/Stable2.sol#L224
Vulnerability details
Vulnerability Details
The calcReserveAtRatioSwap function calls
calcReserve(scaledReserves, i, lpTokenSupply, abi.encode(18, 18))
to calculate thescaledReserves[i]
value. However, thecalcReserve
function expects thedecimals
parameter to be the actual decimal values of the tokens in the well, not hardcoded 18.Code
Impact
If the reserve calculation is inaccurate, it can result in incorrect pricing and resource allocation within the well. This could lead to users experiencing losses when performing swaps or providing liquidity, as the contract may not be able to accurately track the true value of the assets.
Poc
Mitigation
The correct way to calculate
scaledReserves[i]
would be to use thedecodeWellData
function to get the actual decimal values of the tokens, and then use those values when callingcalcReserve
.The corrected code would look like this:
Assessed type
Decimal
The text was updated successfully, but these errors were encountered: