The _get_usd_value function assumes all collateral tokens have 18 decimals. WBTC has 8 decimals, causing the protocol to undervalue WBTC collateral by a factor of 10^10.
The vulnerable calculation in _get_usd_value (line 314-316):
This formula works correctly only when amount is in 18-decimal format:
WETH (18 decimals): 1 WETH = 10^18 units. (2000e8 * 1e10 * 1e18) / 1e18 = 2000e18 = $2,000 in 18-decimal format. Correct.
WBTC (8 decimals): 1 WBTC = 10^8 units. (60000e8 * 1e10 * 1e8) / 1e18 = 60000e8 = 6e12 = $0.000006 in 18-decimal format. Off by 10^10.
The same issue propagates to _get_token_amount_from_usd (line 360-364), which calculates inverse token amounts during liquidation:
For a $1 DSC debt covered against WBTC, this returns 1e18 * 1e18 / (60000e8 * 1e10) = 1e18 / 60000 = ~1.67e13 WBTC units, which is ~167,000 WBTC instead of ~0.0000167 WBTC.
Likelihood: High -- WBTC is explicitly listed as a supported collateral token. Any user depositing WBTC will be affected immediately.
Impact: High -- Users depositing WBTC as collateral effectively have worthless collateral in the system. They cannot mint any meaningful amount of DSC. The protocol's core functionality is broken for one of its two supported tokens.
Real-World Precedent: Uranium Finance ($57M, 2021) suffered from a similar arithmetic miscalculation. Token decimal mismatches are a well-documented vulnerability class (CWE-682).
How the attack works:
User deposits 1 WBTC (worth $60,000) as collateral
Protocol calculates collateral value as $0.000006 instead of$60,000
Health factor: (0.000006 * 50/100 * 1e18) / dsc_minted -- virtually zero borrowing power
User can mint at most ~0.000003 DSC (worth $0.000003) for$60,000 of collateral
WBTC collateral is essentially unusable
Expected outcome: Users depositing WBTC cannot mint any meaningful amount of DSC. The protocol's 200% overcollateralization requirement becomes ~200,000,000,000% for WBTC.
Read the token's decimals dynamically and normalize all amounts to 18 decimals:
Apply the same normalization in _get_token_amount_from_usd to convert the result back to the token's native decimal format.
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.