Swap

Here are 3 cases of swapping in Pangea's pool via router :

1. ERC20 --> ERC20

  • Before the swap request, you need to make an approve request to the router for the input token.

poolRouter.exactInputSingle({
          tokenIn: tokenInAddress, // input token address
          amountIn: BigNumber.from(amountIn), // amount of input token to swap
          amountOutMinimum: BigNumber.from(amountOutMinimum), // slippage
          pool: PoolAddress, // pool address
          to: recipient,     // recipient address
          unwrap: false      // always "false" for erc20 tokens
        });

2. ERC20 --> KLAY

  • Before the swap request, you need to make an approve request to the router for the input token.

poolRouter.exactInputSingle({
          tokenIn: tokenInAddress, // input token address
          amountIn: BigNumber.from(amountIn), // amount of input token to swap
          amountOutMinimum: BigNumber.from(amountOutMinimum), // slippage
          pool: PoolAddress, // pool address
          to: recipient,     // recipient address
          unwrap: true      // always "false" for erc20 tokens
        });

3. KLAY --> ERC20

Last updated