Closed sherlock-admin2 closed 6 months ago
1 comment(s) were left on this issue during the judging contest.
takarez commented:
invalid
Invalid and by design as noted in contest details:
When long max skew (skewFractionMax) is reached, flatcoin holders cannot withdraw, and no new leverage positions can be opened. This is to prevent the flatcoin holders being increasingly short. This is temporary because the funding rate will bring the skew back to 0 and create more room for flatcoin holders to withdraw and leverage traders to open positions.
KingNFT
medium
Users can not increase or decrease margin while
screw >= 120
Summary
In current implementation, the max allowed screw is
120%
, increasing new position size would be rejected above this threshold. But actually, pure increasing or decreasing collateral would be reverted too. As this two operations are not related to net position changes, so they should be allowed.Vulnerability Detail
The issue arise on L163 of
LeverageModule.sol
, the= 0
case which represent increasing or decreasing collateral would be rejected while current screw is bigger than120%
(L166 & L305).Impact
1) break part of core functionality 2) users might be liquidated out as they can't increase margin in time.
Code Snippet
https://github.com/sherlock-audit/2023-12-flatmoney/blob/bba4f077a64f43fbd565f8983388d0e985cb85db/flatcoin-v1/src/LeverageModule.sol#L163
Tool used
Manual Review
Recommendation
see PoC