# Virtual swap impacts can be bypassed by swapping through markets where only one of the collateral tokens has virtual inventory

GMX swap price-impact calc skips virtual inventory when one collateral token lacks it, letting traders split orders across markets to dodge impact fees.

- Payout: Contest reward
- Severity: medium
- Program: Gmx
- Credited: IllIllI
- Disclosed: 2023-04-20
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-04-gmx-judging/issues/257
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-04-gmx%3AM-10
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:business-logic vuln:fee-bypass

**Target:** SwapPricingUtils.getPriceImpactUsd in gmx-synthetics
**Root cause:** getPriceImpactUsd returns early when either token lacks a virtual inventory, skipping virtual impact entirely instead of substituting the non-virtual token's inventory.
**Steps:**
1. Identify a market where only one collateral token has virtual inventory set.
2. Note SwapPricingUtils.getPriceImpactUsd returns priceImpactUsd unchanged when `!hasVirtualInventoryTokenA || !hasVirtualInventoryTokenB`.
3. Split a large swap into smaller orders routed through such markets with favorable non-virtual imbalance.
4. Observe reduced/zero virtual price impact fees versus direct swap.
**How found:** Code reading of SwapPricingUtils.getPriceImpactUsd revealed the early-return guard skipping virtual impacts when either token lacks virtual inventory.
**Exploitation:** Trader splits a large order into smaller swaps routed through markets lacking virtual inventory for one token, avoiding the large negative virtual price impact that a direct large swap would incur.
**Insight:** When a pricing/impact function has a guard that skips computation if either of two symmetric inputs is missing, check whether routing through a market missing one input lets users evade the fee entirely.
