# Price cannot be represented when a high-value base asset is quoted in a high-decimal asset

Bug Deep Dive #13 · 9 December 2025

Bug Deep Dives · [The Contest Academy](https://0xsimao.com/the-contest-academy) · 0xSimao

---

| Title | Price cannot be represented when a high-value base asset is quoted in a high-decimal asset |
| Reward | $3318, Unique |
| Contest | Dango Dex - 15 Sep 2025 on Sherlock |
| Author | 0xShoonya |
| Context | Math Overflow |

A design flaw in the DEX's price representation logic can render certain trading pairs non-functional. The internal price calculation for pairs where a high-value base asset is quoted in a high-decimal asset (e.g., WBTC/DAI) can exceed the maximum value of the Udec128_24 type used for storage. This causes transactions to fail, a denial of service for that market.\
**README:**

The internal price is stored as a [Price](https://github.com/sherlock-audit/2025-09-dango-dex/blob/main/left-curve/dango/types/src/dex/price.rs#L35), which is a type alias for **Udec128_24**. This is a 128-bit unsigned number with 24 fixed decimal places. Its maximum representable value is $\frac{2^{128} - 1}{10^{24}}$, roughly \$3.4 \cdot 10^{14}$.

The DEX converts human-readable prices into an internal format by scaling them based on the decimal counts of the two tokens involved:

$$\text{Internal Price} = \text{Nominal Price} \cdot \frac{\text{Base Unit of Base Token}}{\text{Base Unit of Quote Token}}$$

The issue is that for certain valid pairs under the README's definition, this scaling formula produces a result that overflows the Udec128_24 limit. A concrete example is the WBTC/DAI pair.

- Pair: WBTC (base) vs. DAI (quote)
- Nominal Price: 1 BTC = \$110,000 DAI
- Decimals:
- WBTC (base_decimals): 8
- DAI (quote_decimals): 18

The resulting internal price of \$1.1 \cdot 10^{15}$ is well above the maximum representable value of about \$3.4 \cdot 10^{14}$. The price cannot be stored, so the operation overflows.

This contradicts the README's promise to support every token with 0 to 18 decimals, since a common and realistic pair is fundamentally incompatible.

**Alpha:** check that every variable and maths operation works for all the tokens listed in the README. Unusual decimal counts, high or low, should raise questions.

**Conclusion**

This finding would earn you **\$3318**, and again it comes from a checklist item: every token the README allows must actually work with the codebase.

[**Full Report**](https://audits.sherlock.xyz/contests/1066/report)\
**Codebase**

---

Newer: [XYK reflect_curve is incorrect and decreases K over time leading to loss of funds for LP providers](https://0xsimao.com/the-contest-academy/bug-deep-dive-14) · Older: [User can pause all auctions by overflow in mid-price average](https://0xsimao.com/the-contest-academy/bug-deep-dive-12)
