# API

## 1. Get Route

* Path：/zap/{chain}/in/route
* Method: POST
* Path Parameters:

| Parameter | isRequired | Type   | Example | Description |
| --------- | ---------- | ------ | ------- | ----------- |
| chain     | true       | string | 8453    | chainId     |

* Request body:&#x20;

| Parameter         | isRequired | Type   | Example     | Description                                                                                                                                                                                                                                                                                                                  |
| ----------------- | ---------- | ------ | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| dex               | true       | string | UNISWAP\_V2 | pool type, supports UNISWAP\_V2,UNISWAP\_V3                                                                                                                                                                                                                                                                                  |
| pool              | true       | string | 0xc18f50... | address of the pool to zap into                                                                                                                                                                                                                                                                                              |
| positionTickUpper | false      | number | -276350     | max tick of the position, required if zap into a uniswapV3 pool.                                                                                                                                                                                                                                                             |
| positionTickLower | false      | number | -276450     | min tick of the position, required if zap into a uniswapV3 pool.                                                                                                                                                                                                                                                             |
| tokens            | true       | array  |             | the tokens to use as zap source                                                                                                                                                                                                                                                                                              |
| tokens\[n].token  | true       | string | 0x833589... | token address                                                                                                                                                                                                                                                                                                                |
| tokens\[n].amount | true       | string | 1000000     | token amount                                                                                                                                                                                                                                                                                                                 |
| slippage          | true       | string | 100         | maximum slippage tolerance in basis points (0.01%), used for aggregator (exceeding which the transaction will revert) and pool swap during zap (for additional zapping and for refund). From 0 to 5,000 inclusively. Example: 1 for 0.01%.                                                                                   |
| referrer          | false      | string | 0x.....     | referrer address                                                                                                                                                                                                                                                                                                             |
| referrerFee       | false      | number | 100         | Specify the percentage of in-token you wish to receive from the transaction, within the range of 0% to 50%, with 1% represented as 100, in the range of 0.01 to 50. e.g. 1.2% fee set as 120 . Ignored if referrer is empty. By default, OpenOcean shares 30% of the fee. Please contact us if you wish to modify this rate. |

* &#x20;example：

```javascript
{
    "dex": "UNISWAP_V3",
    "pool": "0xc18f50d6a832f12f6dcaaeee8d0c87a65b96787e",
    "positionTickUpper": -276305,
    "positionTickLower": -276405,
    "tokens": [
        {
            "token": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
            "amount": 100000000
        }
    ],
    "slippage": 100,
    "referrer": "0xD01ef7C0A5d8c432fc2d1a85c66cF2327362E5C6"
}
```

* Response：

```javascript
{
    "code": 200,
    "data": {
        "chainId": 8453,
        "poolDetail": {
            "poolId": "0xC18F50d6A832f12F6DcAaeEe8D0c87A65B96787E",
            "dex": "UNISWAP_V3",
            "token0": {
                "symbol": "DAI",
                "name": "Dai",
                "address": "0x50c5725949a6f0c72e6c4a641f24049a917db0cb",
                "decimals": 18,
                "price": 0.999871
            },
            "token1": {
                "symbol": "USDC",
                "name": "USDC",
                "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
                "decimals": 6,
                "price": 0.99988
            }
        },
        "zapDetails": {
            "initialAmountUsd": 99.938006,
            "actions": [
                {
                    "type": "ACTION_TYPE_PROTOCOL_FEE",
                    "data": {
                        "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
                        "amount": "50000",
                        "amountUsd": 0.049994000000000004,
                        "zapFeeRate": 0.0005
                    }
                },
                {
                    "type": "ACTION_TYPE_AGGREGATOR_SWAP",
                    "data": {
                        "tokenIn": {
                            "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
                            "amount": "36601537",
                            "amountUsd": 36.59714481556
                        },
                        "tokenOut": {
                            "address": "0x50c5725949a6f0c72e6c4a641f24049a917db0cb",
                            "amount": "36662253061107726432",
                            "amountUsd": 36.65752363046284
                        },
                        "swapImpact": 0.0016498230997837053
                    }
                },
                {
                    "type": "ACTION_TYPE_ADD_LIQUIDITY",
                    "data": {
                        "token0": {
                            "address": "0x50c5725949a6f0c72e6c4a641f24049a917db0cb",
                            "amount": "36662253061107726432",
                            "amountUsd": 36.65752363046284
                        },
                        "token1": {
                            "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
                            "amount": "63348463",
                            "amountUsd": 63.34086118444
                        },
                        "liquidity": "20034656042451628"
                    }
                }
            ],
            "addedLiquidityUsd": 99.99838481490283,
            "zapImpact": 0.0006041626936486331
        },
        "route": "MzYwNjAzODY5MmMzZDMyNzQyOGExNjgwODgyNzdm..........w==",
        "routerAddress": "0xbD2c0b5d820AFa4C2cF9A82da310E6248d2f2323"
    }
}
```

## 2. Build Route

* Path：/zap/{chain}/in/route/build
* Method: POST
* Path Parameters:

| Parameter | isRequired | Type   | Example | Description |
| --------- | ---------- | ------ | ------- | ----------- |
| chain     | true       | string | 8453    | chainId     |

* Request body:&#x20;

| Parameter          | isRequired | Type   | Example       | Description                                 |
| ------------------ | ---------- | ------ | ------------- | ------------------------------------------- |
| route              | true       | string | MzYwNjAz..... | get from /in/route                          |
| deadline           | false      | number | 1749718309    | Expiration time in seconds                  |
| account            | true       | string | 0x5fb7a....   | the wallet that receiving the new position. |
| permits            | false      | array  |               | the tokens to use permit2                   |
| permits\[n].token  | true       | string | 0x833589...   | token address                               |
| permits\[n].permit | true       | string | 0x30f28...    | permit2 data                                |

* &#x20;example：

```javascript
{
    "route": "MzYwNjAzODY5MmMzZDMyNz......5NjJlNDUwM2UzNg==",
    "deadline": 1749718309,
    "account": "0x5fb7a1B487BDdFF4d6Dc83dc14054b2Be967eEa1",
    "permits": [
        {
            "token": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
            "permit": "0x30f28b7a00...........00000000000000000000000"
        }
    ]
}
```

* Response：

```json
{
    "code": 200,
    "data": {
        "zapDetails": {
            "initialAmountUsd": 99.938006,
            "actions": [
                {
                    "type": "ACTION_TYPE_PROTOCOL_FEE",
                    "data": {
                        "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
                        "amount": "50000",
                        "amountUsd": 0.049994000000000004,
                        "zapFeeRate": 0.0005
                    }
                },
                {
                    "type": "ACTION_TYPE_AGGREGATOR_SWAP",
                    "data": {
                        "tokenIn": {
                            "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
                            "amount": "36605350",
                            "amountUsd": 36.600957358
                        },
                        "tokenOut": {
                            "address": "0x50c5725949a6f0c72e6c4a641f24049a917db0cb",
                            "amount": "36666086677057471419",
                            "amountUsd": 36.66135675187613
                        },
                        "swapImpact": 0.0016502134981155952
                    }
                },
                {
                    "type": "ACTION_TYPE_ADD_LIQUIDITY",
                    "data": {
                        "token0": {
                            "address": "0x50c5725949a6f0c72e6c4a641f24049a917db0cb",
                            "amount": "36666086677057471419",
                            "amountUsd": 36.66135675187613
                        },
                        "token1": {
                            "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
                            "amount": "63344650",
                            "amountUsd": 63.337048642
                        },
                        "liquidity": "20034658756254530"
                    }
                }
            ],
            "addedLiquidityUsd": 99.99840539387613,
            "zapImpact": 0.0006043686110379761
        },
        "to": "0xbD2c0b5d820AFa4C2cF9A82da310E6248d2f2323",
        "value": "0",
        "data": "0x22f894c800000000000.........000000000000000000"
    }
}
```
