Users first deposit/mint USDC and get an equal amount of OUSG then can be wrapped into rOUSGto earn rebase interests.
However when the user wants to redeem the OUSG for USDC due to the difference in magnitude between amountE36 and decimalsMultiplier rounding issue occurs which leads to loss of funds for the user.
the amountE36represents the product of the ousgAmountBurned and price, which is relatively small compared to the large value of decimalsMultiplier.
In this example, after scaling down, the result is rounded down to 0 due to the significant difference in magnitudes between amountE36 and decimalsMultiplier.
Lines of code
https://github.com/code-423n4/2024-03-ondo-finance/blob/main/contracts%2Fousg%2FousgInstantManager.sol#L388-L400 https://github.com/code-423n4/2024-03-ondo-finance/blob/main/contracts%2Fousg%2FousgInstantManager.sol#L699-L705
Vulnerability details
Users first deposit/mint
USDC
and get an equal amount ofOUSG
then can be wrapped intorOUSG
to earn rebase interests. However when the user wants to redeem theOUSG
forUSDC
due to the difference in magnitude betweenamountE36
anddecimalsMultiplier
rounding issue occurs which leads to loss of funds for the user.the
amountE36
represents the product of theousgAmountBurned
andprice
, which is relatively small compared to the large value ofdecimalsMultiplier
.Impact
Financial loss for the user
Proof of Concept
Users redeem by calling
redeem
https://github.com/code-423n4/2024-03-ondo-finance/blob/main/contracts%2Fousg%2FousgInstantManager.sol#L335-L351
Then the
_getRedemptionAmount
calculates the amount ofUSDC
the user recieves. https://github.com/code-423n4/2024-03-ondo-finance/blob/main/contracts%2Fousg%2FousgInstantManager.sol#L699-L705Suppose
ousgAmountBurned
is 1,000,000OUSG
tokens and price is $0.001USDC
perOUSG
token.Calculate the amount in E36 (E36 denotes 10^36):
scale down
amountE36
bydecimalsMultiplier
, which is 1 trillion:decimalsMultiplier ` is calculated as follows
In this example, after scaling down, the result is rounded down to 0 due to the significant difference in magnitudes between
amountE36
anddecimalsMultiplier
.Which indicates smaller values will be rounded down to zero leading to loss of precision in the calculation
Tools Used
Manual Review
Recommended Mitigation Steps
consider using fixed-point arithmetic or external library for precise calculations.
Assessed type
Math