# Exercising a large amount of options gives significantly higher discounts than supposed to.

OptionTokenV4 prices options using average amountOut over TWAP points, so exercising larger amounts yields disproportionately larger discounts, letting users buy underlying far below intended price.

- Payout: Audit contest
- Severity: high
- Program: Velocimeter
- Found by: bughuntoor
- Disclosed: 2024-06-27
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2024-06-velocimeter-judging/issues/238
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-06-velocimeter%3AH-7
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:business-logic vuln:oracle-manipulation

**Target:** OptionTokenV4.getTimeWeightedAveragePrice / option exercise pricing
**Root cause:** getTimeWeightedAveragePrice averages IPair.prices() amountOut values for the full exercise amount instead of using the actual TWAP price, so price impact of the swap is baked into the average and larger amounts get better average rates.
**Steps:**
1. Observe OptionTokenV4.getTimeWeightedAveragePrice calls IPair(pair).prices(underlyingToken, _amount, twapPoints) and averages the returned amountOut values.
2. Note that amountOut for a large _amount includes the AMM price impact, so the average output per unit rises with size.
3. With 1e18 reserves each side, exercising 0.1e18 costs ~0.09e18 payment token (avg price 0.9).
4. Exercising 100e18 costs ~0.99e18 payment token (avg price 0.01).
5. Split exercises into multiple large transactions to capture the inflated discount repeatedly.
**How found:** Code review of the paymentAmount calculation; noticed the 'TWAP' was actually an average of amountOut values from IPair.prices, which are size-dependent, and reasoned that larger exercises would skew the average favorably.
**Exploitation:** Attacker exercises options in multiple large transactions rather than one, exploiting the size-dependent average amountOut to pay far less payment token per underlying than the intended TWAP price, extracting value from the protocol.
**Escalation:** Splitting exercises across multiple transactions to repeatedly capture the inflated discount.
**Insight:** When a protocol labels a function 'TWAP' but it averages AMM quote outputs (amountOut) rather than spot/TWAP prices, the quote embeds price impact — check whether the averaging input scales with user-controlled size, since that turns size into a discount lever.

