# ERC4626 inflate issue mitigation is not sufficient

Gate/absorber use balance_of for share pricing; attacker donates assets to inflate total_assets, causing later depositors to receive near-zero yang and lose funds on withdrawal.

- Payout: Contest reward
- Severity: medium
- Program: Opus
- Credited: jasonxiale
- Disclosed: 2024-03-08
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-01-opus-findings/issues/179
- Library page: https://bugbountylibrary.com/r/c4%3A2024-01-opus%3AM-03
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:solidity technique:source-review vuln:business-logic vuln:oracle-manipulation vuln:share-inflation

**Target:** Cairo ERC4626-style gate/absorber share conversion
**Root cause:** convert_to_yang_helper divides by get_total_assets_helper which reads asset.balance_of(gate), so direct token donations inflate the denominator; the 1000-wei initial_yang_amt mitigation does not prevent donation-based inflation.
**Steps:**
1. Admin calls sentinel.add_yang, transferring 1000 wei DAI, setting yang_total=1000.
2. Attacker transfers `100000*1e18 - 1000` DAI directly to gate contract.
3. Alice calls abbot.open_trove depositing `199*1e18` DAI; convert_to_yang_helper computes `199e18*1000/(100000e18)` = 1 wei yang.
4. Alice closes trove; convert_to_assets computes `1*(100000e18+199e18)/1001` ≈ 100e18 DAI, losing ~99 DAI to gate.
**How found:** Code reading of convert_to_yang_helper/convert_to_assets noting get_total_assets_helper uses asset.balance_of rather than tracked deposits, defeating the initial_yang_amt first-depositor mitigation.
**Exploitation:** Attacker donates large asset amount to gate to skew balance_of-based share price, then victim deposits and receives negligible shares; on withdrawal victim recovers only a fraction, remainder stranded in gate. Attacker does not directly profit but griefs users.
**Insight:** When a protocol 'mitigates' ERC4626 inflation via a fixed initial deposit, check whether share price still derives from live balance_of; any direct-transfer donation path reopens the attack as griefing even if attacker can't profit.
