# Interested calculated is ampliefied by multiple of 1000 in `_debt_interest_since_last_update`

Vault.vy interest accrual divides by PERCENTAGE_BASE (1e4) instead of PERCENTAGE_BASE_HIGH, inflating debt interest ~1000x and bricking leverage/liquidation.

- Payout: Contest reward
- Severity: high
- Program: Unstoppable
- Credited: BugBusters
- Disclosed: 2023-06-21
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-06-unstoppable-judging/issues/191
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-06-unstoppable%3AH-8
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:solidity technique:source-review vuln:accounting-error vuln:precision-loss

**Target:** Vault.vy margin-dex debt interest calculation
**Root cause:** Interest-per-second carries precision 23 (utilization uses PERCENTAGE_BASE_HIGH precision 5 times PRECISION 1e18), but _debt_interest_since_last_update divides only by PERCENTAGE_BASE (1e4) and PRECISION (1e18), precision 20, leaving a 1000x amplification.
**Steps:**
1. Read _debt_interest_since_last_update: `(dt * interest_per_second * total_debt) / PERCENTAGE_BASE / PRECISION`.
2. Note _current_interest_per_second derives from utilization computed with PERCENTAGE_BASE_HIGH (1e5 precision), yielding per-second value with precision 23 (test: 9512937595129375 for 3% APR).
3. Observe divisor precision is only 1e4 * 1e18 = 1e22, three orders short of 1e23.
4. Compute accrued interest and confirm it is ~1000x the intended value.
5. Fix: divide by PERCENTAGE_BASE_HIGH instead of PERCENTAGE_BASE.
**How found:** Code-reading of the interest formula against the test's expected per-second interest value; noticed the precision mismatch between numerator (1e23) and denominator (1e22).
**Insight:** When a rate is derived using a high-precision base (PERCENTAGE_BASE_HIGH) but consumed in a formula dividing by the low-precision base, the leftover factor equals the ratio of the two bases (here 1000x). Cross-check every divisor against the precision of the value it normalizes.
