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

Missing Fee Deduction in Withdrawal Swap Flow

Summary

The runSwap() function triggers _handleReturn() with refundFee = true, assuming an execution fee was paid.

  • However, there is no mechanism in _runSwap() or its related functions to actually deduct an execution fee for the withdrawal flow.

  • This results in an inconsistent fee mechanism, where users may receive a refund for an execution fee they never paid.

Vulnerability Details

  1. Keeper Calls run() to withdraw
    if FLOW.WITHDRAW, runSwap() is executed to handle the withdrawal swap.

  2. Inside _runSwap()
    The function processes the swap then calls _handleReturn();

_handleReturn(outputAmount + swapProgressData.swapped, false, true);
ISSUE: ExecutionFee is not paid

ISSUE:

  • refundFee = true is hardcoded, but there was never an execution fee deduction anywhere in the flow.

Inside _handleReturn()

  • Since refundFee = true, the contract attempts to refund an execution fee:

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

Key issue:
depositInfo[depositId].executionFee was never set or deducted, yet the contract tries to refund it.
This could lead to

  • Logical inconsistencies in accounting

  • Potential gas waste and unnecessary external calls
    }

Tools Used

Manual Review

Recommendations

Option 1

  • Charge Execution fee before Swap Execution

    Option 2

  • Prevent Refund when no fee was paid

Updates

Lead Judging Commences

n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!