The DSCEngine protocol is designed to accept both WETH (18 decimals) and WBTC (8 decimals) as collateral assets to mint the pegged DSC stablecoin.
However, both _get_usd_value and _get_token_amount_from_usd hardcode PRECISION = 10**18 and assume all collateral tokens have 18 decimals. Because WBTC has only 8 decimals, _get_usd_value undervalues WBTC collateral by a factor of 10^10 (treating 1 WBTC as $0.00000001 instead of its true USD value). Inversely, _get_token_amount_from_usd overestimates required WBTC tokens by 10^10, causing liquidation math to revert or demand astronomical token amounts.
Likelihood:
This bug manifests immediately whenever a user deposits WBTC, attempts to mint DSC against WBTC collateral, or when liquidators attempt to liquidate WBTC collateral.
Impact:
High. Complete breakdown of protocol accounting for WBTC. Users depositing WBTC receive virtually zero borrowing power, and any liquidation involving WBTC either reverts due to arithmetic overflow or drains liquidity.
Calculating USD value for 1 WBTC (10^8 units) at a BTC price of $60,000 yields 60,000 * 10^8 instead of the expected 18-decimal value 60,000 * 10^18, understating collateral by 10 orders of magnitude.
Dynamically fetch token decimals from the ERC20 contract or store the token decimals in a mapping, adjusting amount or precision accordingly before scaling to 18 decimals.
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.