Steep Rose Rattlesnake
Medium
Vault.sol when market closed, minPosition is calculated incorrectly, which may cause allocated assets to remain unreleased
The Vault.sol
calculation of minPosition
doesn't take into account market closed, which can lead to values that are too large and funds never get released.
We will calculate marketContext.minPosition
to avoid MarketOverCloseError/MarketInsufficientLiquidityError
error when decreasing Position
Use formula: minPosition = user.maker - min( (global.maker - | global.long - global.short | ) , user.closable )
The current code doesn't take into account market closed, which may result in global.maker - | global.long - global.short |
being very small, resulting in minPosition
being too large.
note: when market closed , don't check MarketInsufficientLiquidityError
It should use : minPosition = user.maker - user.closable
when the market closed.
marketContext.minPosition = marketContext.currentAccountPosition.maker
.unsafeSub(marketContext.currentPosition.maker
.unsafeSub(marketContext.currentPosition.skew().abs()).min(marketContext.closable));
- market.marketParameter.closed = true
No response
No response
marketContext.minPosition
is too large will cause that can't reduce position=0
, even if weight=0
, collateral can't be released, closed markets are not profitable, this part funds fails to generate revenue
No response
when market closed:marketContext.minPosition = marketContext.currentAccountPosition.maker .unsafeSub(marketContext.closable);