Function: uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, byte[] _data)
This is the callback implementation for UniswapV3 pools.
Inputs
amount0Delta
Constraints: Either one of
amount0Delta
oramount1Delta
should be greater than zero.Impact: The amount of
token0
received.
amount1Delta
Constraints: Either one of
amount0Delta
oramount1Delta
should be greater than zero.Impact: The amount of
token1
received.
_data
Constraints: Should correctly decode to
tokenIn
,tokenOut
, andfee
.Impact: The encoded pool address, fee, and
tokenOut
address.
Branches and code coverage (including function calls)
Intended branches
The function requires either
amount0Delta
oramount1Delta
to be greater than zero.
Negative behaviour
The function reverts if neither
amount0Delta
noramount1Delta
are greater than zero.The function reverts if the caller is the incorrect pool.
Function call analysis
decodePool(_data)
What is controllable?
_data
.If return value controllable, how is it used and how can it go wrong? The return value is used to extract
tokenIn
,tokenOut
, andfee
; if manipulated, it could lead to incorrect token transfers.What happens if it reverts, reenters, or does other unusual control flow? If this reverts, the entire call fails --- no reentrancy issues.
getPool(tokenIn, tokenOut, fee)
What is controllable?
tokenIn
,tokenOut
, andfee
.If return value controllable, how is it used and how can it go wrong? The return value is used as the caller of the function; if manipulated, an incorrect pool could be considered as the caller.
What happens if it reverts, reenters, or does other unusual control flow? If this reverts, the entire call fails --- no reentrancy issues.
SafeTransferLib.safeTransfer(ERC20(tokenIn), msg.sender, amount0Delta > 0 ? uint256(amount0Delta) : uint256(amount1Delta))
What is controllable?
tokenIn
,msg.sender
,amount0Delta
, andamount1Delta
.If return value controllable, how is it used and how can it go wrong? N/A.
What happens if it reverts, reenters, or does other unusual control flow? If this reverts, the entire call fails --- no reentrancy issues.