Skip to content

Conversation

@jinoosss
Copy link
Member

Descriptions

The Swap function was invoking the safeSwapCallback before transferring the swapped token to the recipient.
This sequence violated the flash swap mechanism invariant, which requires the callback to be executed after the swap output is delivered.

Changes

1. Transfer swapped token before callback (zeroForOne == true):

  • Moved safeTransfer for token1 to execute before safeSwapCallback
  • Recipient now receives the output token before the callback is invoked

2. Transfer swapped token before callback (zeroForOne == false):

  • Moved safeTransfer for token0 to execute before safeSwapCallback
  • Recipient now receives the output token before the callback is invoked

Impact

This fix ensures proper flash swap behavior, allowing users to utilize the swapped tokens during the callback execution for arbitrage opportunities or other strategies before repaying the input tokens.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 1, 2025

@jinoosss jinoosss merged commit 7d238e7 into main Dec 1, 2025
163 of 166 checks passed
@jinoosss jinoosss deleted the fix-pool-change-sequence-of-callback-and-token-transfer branch December 1, 2025 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants