# GMX High описание
## HIGH 2. Irrelevant oracle return selection for stablecoins in case of their depeg.
Here is a detailed case scenario to demonstrate how it can affect the Vault.
- https://github.com/gmx-io/gmx-contracts/blob/96e516bc8d0979c51c7fdffee50622415d5c411d/contracts/core/VaultPriceFeed.sol#L148-L248
Let's dive into these lines - they are similar in gePriceV1 and getPriceV2.
```
if (strictStableTokens[_token]) {
uint256 delta = price > ONE_USD ? price.sub(ONE_USD) : ONE_USD.sub(price);
if (delta <= maxStrictPriceDeviation) {
return ONE_USD;
}
// if _maximise and price is e.g. 1.02, return 1.02
if (_maximise && price > ONE_USD) {
return price;
}
// if !_maximise and price is e.g. 0.98, return 0.98
if (!_maximise && price < ONE_USD) {
return price;
}
return ONE_USD;
}
```
Consider that a strict stablecoin depegs to 0.75 USD / stable (the number that leads to `delta` above `maxStrictPriceDeviation`).
Depending on the `_maximise` we have two scenarios:
1) Vault.getMinPrice() works ok
`_maximise = false`
it will return ~0.75
2) Vault.getMaxPrice() works not ok
`_maximise = true`
In these case neither of these two conditions will pass:
```
// if _maximise and price is e.g. 1.02, return 1.02
if (_maximise && price > ONE_USD) {
return price;
}
// if !_maximise and price is e.g. 0.98, return 0.98
if (!_maximise && price < ONE_USD) {
return price;
}
```
So, this line will be executed and return ONE_USD:
```
return ONE_USD;
```
- https://github.com/gmx-io/gmx-contracts/blob/96e516bc8d0979c51c7fdffee50622415d5c411d/contracts/core/VaultPriceFeed.sol#L238
As the result we have that:
- Vault.getMinPrice() returns 0.75
- Vault.getMaxPrice() returns 1.00
So:
- Vault.buyUSDG() will mint 75 USDG for 100 stables provided (75 USD value in, 75 USD value out).
https://github.com/gmx-io/gmx-contracts/blob/96e516bc8d0979c51c7fdffee50622415d5c411d/contracts/core/Vault.sol#L452-L482
- Vault.sellUSDG() will burn 75 USDG with 75 stables out (75 USD value in, 56.25 value out)
https://github.com/gmx-io/gmx-contracts/blob/96e516bc8d0979c51c7fdffee50622415d5c411d/contracts/core/Vault.sol#L484-L518
https://github.com/gmx-io/gmx-contracts/blob/96e516bc8d0979c51c7fdffee50622415d5c411d/contracts/core/Vault.sol#L769-L773
The same problem is relevant for `swap()` when our stable is `_tokenOut`.
So, user do not have motivation to have our stable as `_tokenOut` for `Vault.sellUSDG()` and `Vault.swap()`.
Thus, these token probably will never leave the Vault.
Moreover, the `GLPManager.addLiquidity()` will brake as well.
https://github.com/gmx-io/gmx-contracts/blob/96e516bc8d0979c51c7fdffee50622415d5c411d/contracts/core/GlpManager.sol#L209-L230
It iterates through Vault tokens and calculates AUM as the sum of poolAmount * getMaxPrice() for all whitelisted tokens. This is used to minimize the amount of GLP minted.
https://github.com/gmx-io/gmx-contracts/blob/96e516bc8d0979c51c7fdffee50622415d5c411d/contracts/core/GlpManager.sol#L220
```
GLP minted = [USDG received from Vault.buyUSDG() in any token] * GLPSupply / AUM_maximized
```
So, as the Vault AUM is highly inflated - **any token provision will give less GLP than expected**
Depegged stables spoil the whole motivation to provide liquidity and mint GLP.