# ERC20TokenEmitter::buyToken function mints more tokens to users than it should do

ERC20TokenEmitter.buyToken quotes creator and buyer token amounts separately against the same VRGDA supply, minting more governance tokens than a single combined quote would.

- Payout: Contest reward
- Severity: medium
- Program: Collective
- Credited: osmanozdemir1
- Disclosed: 2024-02-08
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2023-12-revolutionprotocol-findings/issues/194
- Library page: https://bugbountylibrary.com/r/c4%3A2023-12-revolutionprotocol%3AM-10
- Tags: domain:web3 impact:integrity kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic vuln:precision-loss

**Target:** ERC20TokenEmitter.buyToken VRGDA token sale contract
**Root cause:** totalTokensForCreators and totalTokensForBuyers are each computed via getTokenQuoteForEther against the same un-updated emittedTokenWad, so the convex VRGDA curve is applied twice to split payments instead of once to the total.
**Steps:**
1. Call `getTokenQuoteForEther(100e18)` and `getTokenQuoteForEther(500e18)` on the emitter.
2. Call `getTokenQuoteForEther(600e18)`.
3. Observe `quote(100)+quote(500) > quote(600)` (586.75e18 vs 581.80e18), proving split quoting over-mints.
4. In buyToken, creator share and buyer share are quoted separately against the same emittedTokenWad before it is incremented.
**How found:** Reading buyToken, noticed two independent getTokenQuoteForEther calls both reading the same emittedTokenWad state variable before it is updated, and hypothesized the convex VRGDA curve makes split quotes exceed a single combined quote; confirmed with a Foundry test comparing quotes.
**Exploitation:** Any buyToken call with nonzero creatorRateBps/entropyRateBps mints excess governance tokens to buyers and creators, diluting supply and breaking VRGDA schedule; no attacker capital needed beyond a normal purchase.
**Insight:** When a bonding-curve/VRGDA quote is applied to multiple payment slices within one transaction, check whether the supply state variable is updated between quotes; convex curves make split quoting systematically over-mint.
