Skip to content
Request an audit

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

TitlePrice cannot be represented when a high-value base asset is quoted in a high-decimal asset
Reward$3318, Unique
ContestDango Dex - 15 Sep 2025 on Sherlock
Author0xShoonya
ContextMath 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, 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 2128 − 11024, 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:

Internal Price = Nominal Price · Base Unit of Base TokenBase 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 · 1014. 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
Codebase

Message on Telegram All 62 posts