The Stability Pool's exchange rate calculation between RToken
and DEToken
deposits contains a fundamental flaw in decimal handling. When users deposit RTokens
, the contract incorrectly scales the amount when minting DETokens
, leading to a mismatch between expected and actual DEToken
amounts.
The core issue lies in its decimal handling. It applies an 18-decimal scaling on top of the token decimal adjustment, effectively double-counting the base decimal places. This creates the systematic overvaluation of DETokens relative to deposited RTokens.
The exchange rate calculation in StabilityPool.sol
uses: StabilityPool.sol#L192-L193
This creates a mismatch when decimal places differ between RToken and DEToken.
The exchange rate miscalculation means users depositing into the Stability Pool receive an incorrect amount of DETokens. This creates an arbitrage opportunity where users could extract excess value by depositing and withdrawing at advantageous rates, directly impacting the protocol's stability mechanism.
Consider this attack Flow
A user deposits 1 RToken (1e18 units) into the Stability Pool. Due to the decimal scaling error, instead of receiving 1 DEToken, they receive 1.1 DETokens (1.1e18 units). This 10% inflation of DETokens dilutes other depositors' share of the pool.
The calculateDeCRVUSDAmount
function applies an incorrect scaling factor when converting between token decimals.
When Alice deposits 1 RToken into the Stability Pool, she expects to receive 1 DEToken in return. The protocol's exchange rate is meant to maintain this 1:1 peg. However, due to the subtle decimal scaling error, she actually receives 1.1 DETokens. This 10% inflation creates an arbitrage opportunity that undermines the entire stability mechanism.
The exchange rate calculation starts in StabilityPool.sol
where the deposit()
function accepts RTokens. The crucial miscalculation happens in calculateDeCRVUSDAmount()
This seemingly innocent decimal adjustment creates a compounding error. Each deposit increases the DEToken
supply more than it should, diluting the claims on the underlying RToken
reserves.
Real-World Impact
Think of this like a bank accidentally giving out $110 in withdrawal receipts for every $100 deposited. Over time, the bank would have more claims against its reserves than actual deposits. In the protocol's case, this means the Stability Pool meant to be the backbone of the system's price stability becomes increasingly undercollateralized.
We caught this by comparing:
Expected DETokens: 1000000000000000000 (1e18)
Actual minted: 1100000000000000000 (1.1e18)
This 10% difference compounds with each deposit, potentially leading to a complete destabilization of the protocol's core mechanism.
The decimal precision mismatch between RToken
and DEToken
leads to incorrect DEToken
minting amounts. Users could receive more or fewer DETokens than intended based on their RToken deposits.
The correct implementation should normalize the token decimals without the additional 18-decimal scaling
Both tokens have 18 decimals. Info
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.