The PerpetualVault contract lacks a deleveraging mechanism to handle increasing position leverage caused by GMX's negative funding fees being charged against collateral. As collateral decreases while position size remains constant, the effective leverage increases over time, potentially leading to liquidations if not monitored and adjusted.
The contract allows users to open and maintain a leveraged position on GMX with a specified leverage value set during initialization. However, GMX charges negative funding fees by reducing the collateral amount over time, which creates two key issues:
The effective leverage increases as collateral decreases:
The contract lacks safety mechanisms:
There's currently no way to
Partially reduce position size
Adjust leverage without closing
Gradually deleverage positions
Note that the run
and runNextAction
responsible for creating GMX orders can only:
Open a new position when closed
Close an existing position completely
Switch position direction (close then reopen)
Decrease position size and collateral together
Other Causes
Also, note that the the GMX max leverage constantly decreases as open interest increases, effectively increasing our risks exposure. But unfortunately we have no mechanism to adjust our derisk our Position.
User opens a 10x leveraged long position with $100 collateral
GMX charges -$20 in funding fees over time, reducing collateral to $80
Position size remains at $1000
Effective leverage increases to 12.5x
This continues until potential liquidation
No automatic mechanism exists to reduce position size or add only collateral
High risk of user positions being liquidated due to uncontrolled leverage increase leading to loss of user funds.
Manual Review
Implement automatic deleveraging mechanism:
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
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.