# BalancedVault.sol: Early depositor can manipulate exchange rate and steal funds

First depositor mints 1 wei of shares then donates assets, inflating share price so later depositors round down to 0 shares and lose funds.

- Payout: Contest reward
- Severity: medium
- Program: Perennial
- Credited: Phantasmagoria
- Disclosed: 2023-05-05
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-05-perennial-judging/issues/46
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-05-perennial%3AM-6
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:share-inflation

**Target:** BalancedVault.sol ERC4626-style vault share accounting
**Root cause:** Share minting rounds down against totalAssets/totalSupply; a tiny first deposit plus direct asset donation inflates the exchange rate so subsequent deposits mint zero shares.
**Steps:**
1. Attacker deposits 1 wei (`smallestDeposit`) to mint 1 wei of shares as first depositor.
2. Attacker transfers/donates 1 DSU directly to the vault address, raising totalAssets without minting shares.
3. Victim deposits 1 DSU; `updateOracle()` + `vault.sync()` then deposit.
4. Victim's shares round down to 0 while vault holds ~2e18 assets against 1 wei supply owned by attacker.
**How found:** Code review of share conversion rounding in BalancedVault; recognized classic ERC4626 first-depositor inflation attack, adapted to the epoch/oracle sync model.
**Exploitation:** Attacker must be the sole/first depositor of a fresh epoch; deposits 1 wei, donates assets to inflate share price, then later depositors' deposits round to zero shares, donating their funds to the attacker's single share.
**Insight:** In epoch-based vaults, the inflation window is per-epoch not just deployment: attacker only needs to be the first depositor of an epoch, so seeding at deploy time does not fully mitigate; check rounding in share math at each sync boundary.
