> For the complete documentation index, see [llms.txt](https://pangeaswap.gitbook.io/pangeaswap/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pangeaswap.gitbook.io/pangeaswap/en/developers/interacting-with-the-protocol/swap.md).

# Swap

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

### 1. ERC20 --> ERC20&#x20;

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

```typescript
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.

```typescript
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

```typescript
poolRouter.exactInputSingle({
          // if input token is KLAY, set token address to 0 address
          tokenIn: "0x0000000000000000000000000000000000000000", 
          amountIn: BigNumber.from(amountIn),
          amountOutMinimum: BigNumber.from(amountOutMinimum),
          pool: PoolAddress,
          to: recipient,
          unwrap: false
        }, {
           // amount of KLAY to sent should be input like below
           value: BigNumber.from(amountIn)
        });
```
