The PerpetualVault contract fails to validate if there will be sufficient collateral when creating increase position orders on GMX. This oversight leads to orders that are destined to fail GMX's internal collateral validation, resulting in wasted gas and execution fees for users and keepers.
The PerpetualVault contract's _createIncreasePosition()
function creates increase orders without checking if the position will have sufficient collateral according to GMX's requirements. However, GMX's increasePosition()
function performs strict collateral sufficiency validation and reverts if the check fails.
Several dynamic factors affect position collateral requirements:
Position leverage fluctuates with market price changes
GMX's maximum leverage is dynamic, increasing with market open interest
Trading fees and price impact can increase required collateral
Funding fees accumulate over time
Here's how GMX validates collateral sufficiency:
The PerpetualVault should perform similar validation before submitting orders to avoid guaranteed failures:
User deposits into vault when market conditions make GMX's required collateral higher than normal
Vault creates increase position order without validating collateral sufficiency
Keeper executes order and pays gas
GMX's increasePosition()
reverts due to insufficient collateral
Transaction fails, gas and execution fees are wasted
Failed orders due to insufficient collateral validation result in wasted gas fees for users and keepers, along with consumed execution fees for unsuccessful transactions. This issue is particularly impactful during high volatility periods when market conditions frequently change collateral requirements, leading to a higher rate of failed transactions and unnecessary gas consumption.
Manual Review
Add collateral sufficiency validation before creating increase position orders:
This ensures orders are only created when they have a reasonable chance of success based on current market conditions.
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.
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.
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.