Inside withdraw() Gamma collects execution fee from the user:
But this fee is never used if curPositionKey != bytes32(0)
is false
i.e. there's no open position. The control moves to the else
clause where _withdraw()
is called which internally calls _handleReturn(0, true, false)
. the presence of false
as the third param ensures no refund is issued.
Similar behaviour is observed in deposit()
. Even if all the fee provided by user is not spent on GMX and the unspent amount is refunded to Gamma, it never makes it way back to the user.
Do not ask the user to pay execution fee if curPositionKey == bytes32(0)
Incorporate a mechanism to refund unspent GMX fees back to the user at the time of deposit()
No fee needed in _payExecutionFee when position is closed. Make a PoC if you disagree.
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.