Because Gamma create and manage GMX positions, it also uses GMX price functions to estimate assets values on GMX. GMX returns a min and max value when requesting a price.
The issue is that Gamma uses prices.indexTokenPrice.min to estimate the total position amount of the vault, rather than using prices.indexTokenPrice.max, which will underestimate the total value of the vault.
And when user gets minted new shares, the amount of minted shares is proportional to what they deposited compared to the total vault position, meaning users can get minted too much shares compared to what they should have received.
This difference is at all the other users expense, which is the opposite of what should happen in a vault.
When users deposits assets into a leveraged vault, the minted amount of shares is defined L774 as _shares = amount * totalShares / totalAmountBefore.
The user gets minted an amount proportional to the value he has deposited (amount) compared to the already deposited amount (totalAmountBefore).
totalAmountBefore is defined L771, which is equal to totalAmountBefore = _totalAmount(prices) - amount.
But as we can see L826, _totalAmount is estimated using the GMX price bounds (min/max), and in the current design, its prices.indexTokenPrice.min that is used to compute total, which will result in a lower total than if prices.indexTokenPrice.max was used:
Going back to the _mint function, this under-estimated value of _totalAmount clearly shows that the users will have an amount of _shares minted that might be over-estimated compared to the real price, while it should be under-estimated, otherwise the vault (and all the other users) would be at loss compared to the current depositor.
This is similar to what vault does when they round down what goes out of the vault, and round up what goes in.
Depositor gets minted too much shares at the expense of the vault and its users.
Likelihood: high, as this happens on every deposits
Impact: medium, as this impact all users funds, but it is indirect
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.