# Delayed Compound and Beta interest accrual reduces gamer rewards and affects funds distribution to vaults

Derby vaults read Compound/Beta balances via stale exchangeRateStored/totalLoan without accruing interest, so gamer rewards and cross-vault distributions are computed on understated underlying balances.

- Payout: Contest reward
- Severity: medium
- Program: Derby
- Credited: Jeiwan
- Disclosed: 2022-10-17
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-01-derby-judging/issues/317
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-01-derby%3AM-11
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:oracle-manipulation vuln:reward-distribution

**Target:** Yield-optimiser vault rebalancing / Compound & Beta providers
**Root cause:** balanceUnderlying uses Compound exchangeRateStored (cached, no accrual) and Beta totalLoan without calling accrue, so interest since last accrual is excluded from reported underlying balances.
**Steps:**
1. During rebalance, MainVault.setTotalUnderlying calls Vault.balanceUnderlying for each provider.
2. CompoundProvider.balanceUnderlying multiplies cToken balance by exchangeRate(), which calls ICToken.exchangeRateStored() — cached rate, no accrual.
3. BetaProvider.balanceUnderlying/calcShares read IBeta.totalLoan without calling IBeta.accrue, so accrued interest is missing.
4. savedTotalUnderlying is set from these understated values; storePriceAndRewards/calcUnderlyingIncBalance compute gamer rewards on them.
5. Interest only accrues later in Vault.rebalance on deposit/withdraw, after rewards are already fixed.
6. Fix: use exchangeRateCurrent and call IBeta.accrue before reading totalLoan.
**How found:** Code reading of provider balance functions against Compound/Beta source: noticed exchangeRateStored explicitly does not accrue interest and totalLoan only grows on accrue, while Derby reads them before any deposit/withdraw triggers accrual.
**Insight:** When integrating lending markets, check whether balance/valuation reads use cached (Stored) vs accruing (Current) exchange rates; any reward or share calculation reading the cached value before a state-changing call systematically understates balances.
