# After a User withdraws The interest Rate is not updated accordingly leading to the next user using an inflated index during next deposit before the rate is normalized again

Treasury share transfer during withdrawal skips interest-rate update, so the next depositor mints shares against a stale inflated index and receives slightly fewer shares.

- Payout: Audit contest
- Severity: medium
- Program: New Scope
- Found by: A2-security
- Disclosed: 2024-06-27
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-06-new-scope-judging/issues/387
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-06-new-scope%3AM-5
- Tags: area:web3 domain:web3 impact:integrity kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:regression technique:source-review vuln:accounting-error vuln:business-logic

**Target:** Zerolend lending pool executeMintToTreasury / interest rate accounting
**Root cause:** executeMintToTreasury transfers accrued treasury shares as underlying to the treasury without calling updateInterestRates, so pool liquidity drops while the stored rate/index still reflects pre-transfer liquidity.
**Steps:**
1. Deploy pool, supply tokenA (60 ether) as owner, warp 100s, borrow 20 ether.
2. Warp 50s, execute flashLoanSimple of 40 ether tokenA to accrue premium to protocol/treasury.
3. Warp 200s, owner calls withdrawSimple(tokenA, owner, 10 ether, index) which triggers executeMintToTreasury transferring accrued shares to treasury.
4. Warp 50s, bob calls supplySimple(tokenA, bob, 60 ether, index).
5. Observe bob's supplyShares = 59999989872672182169; with updateInterestRates before transfer it would be 59999989869411349179.
**How found:** Compared Zerolend's executeMintToTreasury against Aave v3 patterns where every liquidity-changing transfer updates rates; noticed the missing updateInterestRates call before safeTransfer to treasury.
**Exploitation:** No direct theft; a subsequent depositor receives marginally fewer shares because the index used is computed from stale (higher) liquidity. Requires treasury accrual via flashloan premium and a withdrawal to trigger the transfer.
**Insight:** When auditing lending forks, diff every path that moves underlying out of the pool (treasury mint, reserve factor, fee sweeps) against the canonical updateInterestRates-before-transfer pattern; treasury accrual paths are commonly missed.

## Proof of concept (copied exactly from the original report)

**Flashloan setup helper supplying tokenC**

```
function \_generateFlashloanCondition() internal {
    // Mint and approve tokenA and tokenC for bob
    \_mintAndApprove(bob, tokenA, 60 ether, address(pool));
    \_mintAndApprove(bob, tokenC, 2500 ether, address(pool));

    // Start prank as bob to simulate transactions from bob's account
    vm.startPrank(bob);

    // Supply tokenC to the pool for bob
    pool.supplySimple(address(tokenC), bob, 1000 ether, 0);

    // Stop prank as bob
    vm.stopPrank();
}
```

