Merge pull request 'fix: No allowance set before token0.transfer in swap callback (#339)' (#370) from fix/issue-339 into master

This commit is contained in:
johba 2026-02-28 13:46:19 +01:00
commit c6f25c98ab

View file

@ -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) {