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 <noreply@anthropic.com>
This commit is contained in:
parent
936d6cd60a
commit
0fbc666c97
1 changed files with 5 additions and 0 deletions
|
|
@ -386,6 +386,11 @@ contract EventReplayer is IUniswapV3MintCallback, IUniswapV3SwapCallback {
|
||||||
require(msg.sender == address(pool), "EventReplayer: bad swap callback");
|
require(msg.sender == address(pool), "EventReplayer: bad swap callback");
|
||||||
bool zeroForOne = abi.decode(data, (bool));
|
bool zeroForOne = abi.decode(data, (bool));
|
||||||
// Pay the positive delta (the input token the pool is owed).
|
// 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) {
|
if (zeroForOne && amount0Delta > 0) {
|
||||||
token0.transfer(msg.sender, uint256(amount0Delta));
|
token0.transfer(msg.sender, uint256(amount0Delta));
|
||||||
} else if (!zeroForOne && amount1Delta > 0) {
|
} else if (!zeroForOne && amount1Delta > 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue