This repository has been archived by the owner on Dec 10, 2023. It is now read-only.
IllIllI - Virtual swap impacts can be bypassed by swapping through markets where only one of the collateral tokens has virtual inventory #257
Labels
Medium
A valid Medium severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
IllIllI
medium
Virtual swap impacts can be bypassed by swapping through markets where only one of the collateral tokens has virtual inventory
Summary
Virtual swap impacts can be bypassed by swapping through markets where only one of the collateral tokens has virtual inventory
Vulnerability Detail
The code that calculates price impacts related to swapping, skips the application of virtual impacts if one of the tokens doesn't have a virtual token set
Impact
If the virtual swap amount for a particular token is very large, and a large swap through that market would cause the balance to drop a lot, causing the trade to have a large negative impact, a user can split their large order into multiple smaller orders, and route them through other markets where there is no virtual token for one of the pools, and avoid the fees (assuming those pools have non-virtual imbalances that favor such a trade).
Code Snippet
Virtual impacts are completely skipped if one of the tokens doesn't have a virtual version:
https://github.com/sherlock-audit/2023-04-gmx/blob/main/gmx-synthetics/contracts/pricing/SwapPricingUtils.sol#L113-L121
Tool used
Manual Review
Recommendation
Use the non-virtual token's inventory as the standin for the missing virtual inventory token
The text was updated successfully, but these errors were encountered: