Zap API

1. Get Route

  • Path: /zap/{chain}/in/route
  • Method: POST

Path Parameters:

ParameterisRequiredTypeExampleDescription
chaintruestring8453chainId

Request body:

ParameterisRequiredTypeExampleDescription
dextruestringUNISWAP_V2pool type, supports UNISWAP_V2, UNISWAP_V3
pooltruestring0xc18f50...address of the pool to zap into
positionTickUpperfalsenumber-276350max tick of the position, required if zap into a uniswapV3 pool.
positionTickLowerfalsenumber-276450min tick of the position, required if zap into a uniswapV3 pool.
tokenstruearraythe tokens to use as zap source
tokens[n].tokentruestring0x833589...token address
tokens[n].amounttruestring1000000token amount
slippagetruestring100maximum 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%.
referrerfalsestring0x.....referrer address
referrerFeefalsenumber100Specify 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.

Example:

Terminal
JS
1
{
2
"dex": "UNISWAP_V3",
3
"pool": "0xc18f50d6a832f12f6dcaaeee8d0c87a65b96787e",
4
"positionTickUpper": -276305,
5
"positionTickLower": -276405,
6
"tokens": [
7
{
8
"token": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
9
"amount": 100000000
10
}
11
],
12
"slippage": 100,
13
"referrer": "0xD01ef7C0A5d8c432fc2d1a85c66cF2327362E5C6"
14
}

Response:

Terminal
JS
1
{
2
"code": 200,
3
"data": {
4
"chainId": 8453,
5
"poolDetail": {
6
"poolId": "0xC18F50d6A832f12F6DcAaeEe8D0c87A65B96787E",
7
"dex": "UNISWAP_V3",
8
"token0": {
9
"symbol": "DAI",
10
"name": "Dai",
11
"address": "0x50c5725949a6f0c72e6c4a641f24049a917db0cb",
12
"decimals": 18,
13
"price": 0.999871
14
},
15
"token1": {
16
"symbol": "USDC",
17
"name": "USDC",
18
"address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
19
"decimals": 6,
20
"price": 0.99988
21
}
22
},
23
"zapDetails": {
24
"initialAmountUsd": 99.938006,
25
"actions": [
26
{
27
"type": "ACTION_TYPE_PROTOCOL_FEE",
28
"data": {
29
"address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
30
"amount": "50000",
31
"amountUsd": 0.049994000000000004,
32
"zapFeeRate": 0.0005
33
}
34
},
35
{
36
"type": "ACTION_TYPE_AGGREGATOR_SWAP",
37
"data": {
38
"tokenIn": {
39
"address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
40
"amount": "36601537",
41
"amountUsd": 36.59714481556
42
},
43
"tokenOut": {
44
"address": "0x50c5725949a6f0c72e6c4a641f24049a917db0cb",
45
"amount": "36662253061107726432",
46
"amountUsd": 36.65752363046284
47
},
48
"swapImpact": 0.0016498230997837053
49
}
50
},
51
{
52
"type": "ACTION_TYPE_ADD_LIQUIDITY",
53
"data": {
54
"token0": {
55
"address": "0x50c5725949a6f0c72e6c4a641f24049a917db0cb",
56
"amount": "36662253061107726432",
57
"amountUsd": 36.65752363046284
58
},
59
"token1": {
60
"address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
61
"amount": "63348463",
62
"amountUsd": 63.34086118444
63
},
64
"liquidity": "20034656042451628"
65
}
66
}
67
],
68
"addedLiquidityUsd": 99.99838481490283,
69
"zapImpact": 0.0006041626936486331
70
},
71
"route": "MzYwNjAzODY5MmMzZDMyNzQyOGExNjgwODgyNzdm..........w==",
72
"routerAddress": "0xbD2c0b5d820AFa4C2cF9A82da310E6248d2f2323"
73
}
74
}

2. Build Route

  • Path: /zap/{chain}/in/route/build
  • Method: POST

Path Parameters:

ParameterisRequiredTypeExampleDescription
chaintruestring8453chainId

Request body:

ParameterisRequiredTypeExampleDescription
routetruestringMzYwNjAz.....get from /in/route
deadlinefalsenumber1749718309Expiration time in seconds
accounttruestring0x5fb7a....the wallet that receiving the new position.
permitsfalsearraythe tokens to use permit2
permits[n].tokentruestring0x833589...token address
permits[n].permittruestring0x30f28...permit2 data

Example:

Terminal
JS
1
{
2
"route": "MzYwNjAzODY5MmMzZDMyNz......5NjJlNDUwM2UzNg==",
3
"deadline": 1749718309,
4
"account": "0x5fb7a1B487BDdFF4d6Dc83dc14054b2Be967eEa1",
5
"permits": [
6
{
7
"token": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
8
"permit": "0x30f28b7a00...........00000000000000000000000"
9
}
10
]
11
}

Response:

Terminal
{}
1
{
2
"code": 200,
3
"data": {
4
"zapDetails": {
5
"initialAmountUsd": 99.938006,
6
"actions": [
7
{
8
"type": "ACTION_TYPE_PROTOCOL_FEE",
9
"data": {
10
"address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
11
"amount": "50000",
12
"amountUsd": 0.049994000000000004,
13
"zapFeeRate": 0.0005
14
}
15
},
16
{
17
"type": "ACTION_TYPE_AGGREGATOR_SWAP",
18
"data": {
19
"tokenIn": {
20
"address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
21
"amount": "36605350",
22
"amountUsd": 36.600957358
23
},
24
"tokenOut": {
25
"address": "0x50c5725949a6f0c72e6c4a641f24049a917db0cb",
26
"amount": "36666086677057471419",
27
"amountUsd": 36.66135675187613
28
},
29
"swapImpact": 0.0016502134981155952
30
}
31
},
32
{
33
"type": "ACTION_TYPE_ADD_LIQUIDITY",
34
"data": {
35
"token0": {
36
"address": "0x50c5725949a6f0c72e6c4a641f24049a917db0cb",
37
"amount": "36666086677057471419",
38
"amountUsd": 36.66135675187613
39
},
40
"token1": {
41
"address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
42
"amount": "63344650",
43
"amountUsd": 63.337048642
44
},
45
"liquidity": "20034658756254530"
46
}
47
}
48
],
49
"addedLiquidityUsd": 99.99840539387613,
50
"zapImpact": 0.0006043686110379761
51
},
52
"to": "0xbD2c0b5d820AFa4C2cF9A82da310E6248d2f2323",
53
"value": "0",
54
"data": "0x22f894c800000000000.........000000000000000000"
55
}
56
}