DeFiFoundry
50,000 USDC
View results
Submission Details
Severity: medium
Invalid

usedFee is overestimated and actual refund received from GMX is not used by Gamma to calculate refund in `_handleReturn()`

Description

_handleReturn() estimates the usedFee by using the max possible gas limit:

if (refundFee) {
@--> uint256 usedFee = callbackGasLimit * tx.gasprice;
if (depositInfo[depositId].executionFee > usedFee) {
try IGmxProxy(gmxProxy).refundExecutionFee(depositInfo[counter].owner, depositInfo[counter].executionFee - usedFee) {} catch {}
}
}

This is not necessarily the fee amount which GMX refunds back to Gamma via the refundExecutionFee() callback. Gamma can readily calculate the actual amount refunded by GMX and use that to refund the user but instead it refunds only the amount in excess of max possible callbackGasLimit via depositInfo[counter].executionFee - usedFee.
This will almost always lead to no refunds for the user while Gamma itself benefits from the refunds.

Impact

User fee refunds not based on actual usage and in majority of txs, users will be given back nothing while Gamma itself keeps on receiving refunds from GMX.

Recommendation

Introduce accounting for the refund received from GMX and use that to base the user's refund calculation on inside _handleReturn().

Updates

Lead Judging Commences

n0kto Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.