Learn
UniswapV3

Uniswap V3

Swap

  • Label: Swap_UniswapV3
  • Description: Swap a token to get another in exchange in Uniswap V3.
  • Actions in execution process:
    1. Swap SELL_TOKEN to get BUY_TOKEN in exchange.

Note: If SELL_TOKEN or BUY_TOKEN is a native token, it gets wrapped before executing the following functions.

SELL_TOKEN · approve

Approve SwapRouter to spend SELL_TOKEN tokens on behalf of the avatar.

  • Contract: SELL_TOKEN

  • Function: approve(address,uint256)

    ParameterConstraint
    spenderSwapRouter
    amountequal to the SELL_TOKEN amount to swap

TargetPool · Exchange

Swap amountIn of  SELL_TOKEN tokens for as much as possible of BUY_TOKEN tokens.

  • Contract: SwapRouter
  • Function: ExactInputSingle(address,address,uint24,address,uint256,uint256,uint160)
ParameterConstraint
payableAmount-
params.tokenInequal to SELL_TOKEN address
params.tokenOutequal to BUY_TOKEN address
params.feeequal to “100” (in hundredths of basis points. e.g. the fee for a pool at the 0.3% tier is 3000; the fee for a pool at the 0.01% tier is 100)
params.recipientequal to AVATAR
params.amountInequal to SELL_TOKEN amount
params.amountOutMinimumequal to minimum amount of BUY_TOKEN to receive
params.sqrtPriceLimitX96equal to “0”