# Calculation B0 meets devision 0 error when a token has small decimal and high price with a small kBid

In Dodo PMMRangeOrder, small-decimal high-price tokens with small kBid make temp2 zero, causing division-by-zero and reverting swaps.

- Payout: Contest reward
- Severity: medium
- Program: Dodo
- Credited: Protocol Team
- Disclosed: 2023-06-14
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-06-dodo-judging/issues/241
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-06-dodo%3AM-11
- Tags: domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:dos vuln:precision-loss

**Target:** DODOV3MM PMMRangeOrder.sol _calB0WithPriceLimit
**Root cause:** temp2 = DecimalMath.mul(i, k) rounds to zero when kBid is tiny (e.g. 1e14) and price is high, so DecimalMath.div(temp1, temp2) divides by zero.
**Steps:**
1. Configure a pool with a small-decimal high-price token (e.g. WBTC at ~30445) and kBid = 1e14.
2. Call d3Proxy.sellTokens swapping token1 to token2.
3. Query path reaches _calB0WithPriceLimit where temp2 = mul(i,k) = 0.
4. DecimalMath.div(temp1, temp2) reverts, aborting the swap.
**How found:** Manual review of the _calB0WithPriceLimit formula; noticed temp2 = mul(i,k) can round to zero for small kBid with high price, then wrote a Foundry PoC confirming the revert.
**Insight:** When auditing fixed-point math, check intermediate products of two small factors for rounding to zero before a division; low-decimal high-price assets (WBTC) with tiny k parameters are prime triggers.
