# borrow amount recorded in AssetInfo and BorrowRecord unmatched due to the precision loss

Precision loss in Dodo's accrueInterest makes AssetInfo.totalBorrows smaller than summed BorrowRecord.amount, causing underflow that blocks repay and finishLiquidation.

- 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/248
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-06-dodo%3AM-15
- Tags: domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:accounting-error vuln:dos vuln:precision-loss

**Target:** D3Vault lending/borrowing accounting (accrueInterest, repay, finishLiquidation)
**Root cause:** borrowIndex grows above 1e18 while totalBorrows is stored in token decimals (e.g. 8 for WBTC); repeated accrueInterest truncation makes totalBorrows drift below the sum of BorrowRecord.amount.
**Steps:**
1. Deploy D3Vault with WBTC (8 decimals) as borrow token.
2. Maker deposits collateral and borrows 10e8 WBTC.
3. Call `d3Vault.accrueInterest(wbtcAddr)` repeatedly over simulated time (loop ~2 years of 12h steps).
4. Observe assetInfo[wbtc].totalBorrows < sum of BorrowRecord.amount.
5. Maker calls `d3MM.repayAll(wbtcAddr)`; `info.totalBorrows = info.totalBorrows - realDebt` underflows and reverts.
6. Alternatively trigger `startLiquidation`/`finishLiquidation`; finishLiquidation reverts for same reason.
**How found:** Protocol team noticed borrowIndex scaling (1e18 base) versus token-decimal totalBorrows, hypothesized rounding drift over many accruals, and confirmed with a Foundry loop test showing repayAll reverting after accrueInterest.
**Exploitation:** Not an attacker-profit exploit; the mismatch arises naturally from interest accrual on low-decimal tokens. The last borrower's repay and the pool's finishLiquidation revert, locking debt settlement and liquidation completion (DoS on pool wind-down).
**Insight:** When an index-based interest model multiplies a token-decimal balance by a 1e18-scaled index, check for asymmetric truncation: the stored aggregate can drift below the sum of per-user records, so any subtraction of summed debt from the aggregate underflows. Test with low-decimal tokens (WBTC/USDC) over many accrual cycles.
