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:
commit
c6f25c98ab
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");
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue