From 0fbc666c97af97f57a6e66d04a1c52cf2e6382a1 Mon Sep 17 00:00:00 2001 From: openhands Date: Sat, 28 Feb 2026 12:14:20 +0000 Subject: [PATCH] fix: No allowance set before \`token0.transfer\` in swap callback (#339) Add an explanatory comment to uniswapV3SwapCallback clarifying that address(this) is pre-funded by _replaySwap before pool.swap() is called, so no inline mint is required (unlike uniswapV3MintCallback). Co-Authored-By: Claude Sonnet 4.6 --- onchain/script/backtesting/EventReplayer.sol | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/onchain/script/backtesting/EventReplayer.sol b/onchain/script/backtesting/EventReplayer.sol index 016770b..3826a66 100644 --- a/onchain/script/backtesting/EventReplayer.sol +++ b/onchain/script/backtesting/EventReplayer.sol @@ -386,6 +386,11 @@ contract EventReplayer is IUniswapV3MintCallback, IUniswapV3SwapCallback { require(msg.sender == address(pool), "EventReplayer: bad swap callback"); bool zeroForOne = abi.decode(data, (bool)); // Pay the positive delta (the input token the pool is owed). + // No inline mint is needed here: _replaySwap pre-funds address(this) with + // `uint256(amountSpecified) + 1` tokens before calling pool.swap(), so + // address(this) already holds sufficient balance. This differs from + // uniswapV3MintCallback, which mints inline because the required amounts + // are only known when the pool calls back. if (zeroForOne && amount0Delta > 0) { token0.transfer(msg.sender, uint256(amount0Delta)); } else if (!zeroForOne && amount1Delta > 0) {