# Klayswap V3

### Supported Chains

Available on Kaia **Mainnet.**

### Available Endpoints:

*Click on the endpoint to jump to the section with full details*

* [<mark style="color:blue;">/getprice</mark>](#getprice) <mark style="color:blue;">`GET`</mark> - Returns the swap quotation for a given token pair on Klayswap V3.
* [<mark style="color:blue;">/getuserliquidity</mark>](#getuserliquidity) <mark style="color:blue;">`GET`</mark> - Returns the balance of a particular token pair of accounts.&#x20;
* [<mark style="color:blue;">/getpoolliquidity</mark>](#getpoolliquidity) <mark style="color:blue;">`GET`</mark> - Returns the total liquidity for a specified pool.
* [<mark style="color:blue;">/gettokenliquidity</mark>](#gettokenliquidity) <mark style="color:blue;">`GET`</mark> - Returns the individual token liquidity within the specified liquidity pool.
* [/<mark style="color:blue;">swap</mark>](#swap) <mark style="color:green;">`POST`</mark> - Initiate a swap transaction on a specified DEX.&#x20;
* [/<mark style="color:blue;">addliquidity</mark>](#addliquidity) <mark style="color:green;">`POST`</mark> - Add liquidity to a specified pool in a specified DEX.&#x20;
* [<mark style="color:blue;">/removeliquidity</mark>](#removeliquidity) <mark style="color:green;">`POST`</mark> - Remove liquidity from a specified pool in a specified DEX.&#x20;

### DEX IDs

Many endpoints have a parameter where you can provide a DEX ID.&#x20;

Below is a list of DEX IDs related to Klayswap V3. For a complete list and more information, please see the [DEX ID](https://docs.expand.network/ids/dex-ids) page.

| DEX Name    | Chain        | DEX ID |
| ----------- | ------------ | ------ |
| Klayswap V3 | Kaia Mainnet | 3800   |

## Endpoint Details

### /getprice

Returns the swap quotation for a given token pair on Klayswap V3

<mark style="color:blue;">`GET`</mark> `https://api.expand.network/dex/getprice`

#### Query Parameters

| Name                                       | Type   | Description                                                             |
| ------------------------------------------ | ------ | ----------------------------------------------------------------------- |
| rpc                                        | String | Remote procedural call URL.                                             |
| dexId<mark style="color:red;">\*</mark>    | String | See the [DEX ID](#dex-ids) page for a list of all DEX IDs.              |
| path<mark style="color:red;">\*</mark>     | String | Comma separated values of token addresses whose price is to be fetched. |
| amountIn<mark style="color:red;">\*</mark> | String | Amount of token.                                                        |
| poolFees                                   | String | Different pool based on the fees. By default, it is selected as 3000.   |

{% tabs %}
{% tab title="Sample Request" %}

```url
https://api.expand.network/dex/getprice?path=0x19aac5f612f524b754ca7e7c41cbfa2e981a4432%2C0xe815a060b9279eba642f8c889fab7afc0d0aca63&amountIn=100000000000&vsCurrencies=inr&dexId=3800
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "amountIn": "100000000000",
        "path": [
            "0x19aac5f612f524b754ca7e7c41cbfa2e981a4432",
            "0xe815a060b9279eba642f8c889fab7afc0d0aca63"
        ],
        "amountsOut": [
            "100000000000",
            "26756168926310"
        ],
        "prices": {
            "usd": [
                {
                    "0x19aac5f612f524b754ca7e7c41cbfa2e981a4432": "0.15094559073474745"
                },
                {
                    "0xe815a060b9279eba642f8c889fab7afc0d0aca63": "0.000552569860306771"
                }
            ],
            "inr": [
                {
                    "0x19aac5f612f524b754ca7e7c41cbfa2e981a4432": "13.394202277525034"
                },
                {
                    "0xe815a060b9279eba642f8c889fab7afc0d0aca63": "0.04903245232527941"
                }
            ]
        }
    }
}
```

{% endtab %}
{% endtabs %}

[<mark style="color:blue;">back to top</mark>](#endpoints-available)

### /getindividualposition

Returns the liquidity position for a specified user address across all the pools for a given DEX.

<mark style="color:blue;">`GET`</mark> `https://api.expand.network/dex/getindividualposition`

#### Query Parameters

| Name                                            | Type   | Description                                                                     |
| ----------------------------------------------- | ------ | ------------------------------------------------------------------------------- |
| rpc                                             | String | Remote procedural call URL.                                                     |
| poolAddresses<mark style="color:red;">\*</mark> | String | The pool Addresses whose liquidity is to be fetched. *(Comma-separated vaules)* |
| dexId<mark style="color:red;">\*</mark>         | String | Refer to [DexId](https://docs.expand.network/ids/dex-ids) page for details.     |
| address<mark style="color:red;">\*</mark>       | String | The public address of the liquidity holder.                                     |

{% tabs %}
{% tab title="Sample Request" %}

```url
https://api.expand.network/dex/getindividualposition?address=0xb6ab494d9b20ede5e57b42b6d7f058a9c802b0e2&poolAddresses=0x191a182fb17f2f675975e53ee879fac113e848ab&dexId=3800
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "aggregatedLiquidity": "95899567691827176369068",
        "poolAddresses": {
            "KSPoUSDT": {
                "0x21eCDFb99772b10fb913a6F4658A9F97185C82Be": "47575488039154"
            },
            "oWBTCoETH": {
                "0x3EBAa1bc3a4812bEFAa1Ba3f611FA3C7B75dAb43": "59972988388"
            },
            "WKLAYKCD": {
                "0xBaD00f23c69Ef33260Bc238C382263EDE81F2788": "8312675688443705086"
            },
            "WKLAYSKLAY": {
                "0x15b6cdf8Ba5E1843f05D21e48DE4E2f726B8A66f": "18206220498940597001"
            },
            "WKLAYoORC-S": {
                "0x3Da5272C3A0E3d41De4F7601054155461E4ec897": "88423114140914193068966"
            },
            "WKLAYKTU": {
                "0x9F694553Dbc2E420E160383a988Fb8197af339b4": "1224290378684356488636"
            },
            "WKLAYKSP": {
                "0x033255aB9B4a267D1eb5621c3B95007F2048b1F3": "53948147290090809095"
            },
            "WKLAYGXA": {
                "0x71F4F8832a8DeF3C148DD5c4FAE1C84a54938100": "498456459756672919440"
            },
            "WKLAYoWEMIX": {
                "0x0c4E316F4B9DcDEA6bA3da96BbB5567dD955E0b6": "12745500112011056148"
            },
            "oUSDCoUSDT": {
                "0x5a41C41A3141a89ea3618269A4Abe9e5EbEbE8c0": "30035837"
            },
            "oWBTCsBWPM": {
                "0x4bbB84D768F744B0bd32aafA0264c3d31e63153E": "18954365326"
            },
            "KSPoORC-S": {
                "0x01d24357809E0642EedAc745271202f56Ad197f5": "379815573924825280104"
            },
            "oWBTCoUSDT": {
                "0x5D6E306D0d534C439C356c6a7E4cbA15fd0564AB": "371081"
            },
            "oETHoUSDT": {
                "0x6B0177E96C3623B6F6940dA18378d52f78CeA12D": "797227830299"
            },
            "BORAWKLAY": {
                "0x9DD1F13a16d2A3924Df105a86E027C1C43490D5E": "33019012257688786308"
            },
            "KSPMBX": {
                "0x2e8561D0A2153978335cF8e8446C61C76c5C704A": "4765578435449351382564"
            },
            "oWBTCWKLAY": {
                "0xf1Bbb24132d3Ed2C6067130300289baf0e5e2A57": "846114215623"
            },
            "oWEMIXKSP": {
                "0xD7A7cB5Fe4488f2Fa7f23c2E7052a66191bA6d84": "235011202306965828567"
            },
            "GRNDoUSDT": {
                "0x7957FF7046b2794E65D1731349A67319ec38EE3a": "29810379550317"
            },
            "GXAoUSDT": {
                "0x1636762D565cA8E875aBc8DF26Ea0652693a8021": "188327754363788"
            },
            "oWEMIXoUSDT": {
                "0xd01e0c5f2F8037Da5d612ec5989b1A1FfD28a72B": "7100179676421"
            },
            "WKLAYMBX": {
                "0x277E85A9228d7711586F4156D3937B35CBAc7792": "29077301190037109023"
            },
            "GPCKSP": {
                "0x14CB95Aa0cA7188EFC5254bAA488aab09990e0C4": "11741096247189138247"
            },
            "WKLAYKDAI": {
                "0x63893baA4F92A248c93937ef2Bab3b72B658Cf04": "8853785335843203425"
            },
            "oBNBoUSDT": {
                "0x14aFEda13bC2028cEf34d3F45d1b4e3f44747b9a": "267539133370"
            },
            "oSOL-BoUSDT": {
                "0x3f18F2c3525CF0413FA0AB68726aA6e82F6764f2": "1110841467450"
            },
            "KDAIMBX": {
                "0xDC4eC1AFA3308C249499172f7fc65223F1B36AC2": "6073058497386581511"
            },
            "oWEMIXoUSDC": {
                "0x080bF7534c359980D918D7A43e4Dcd8f21ee8Aae": "6781306522085"
            },
            "KDAIKSP": {
                "0x0a7e1D8a48AfD2281074C082873d655Bd017C68c": "105175768862008026115"
            },
            "WKLAYoETH": {
                "0xFeED282a0d6F1Dd86838997E80B7A2CF5b5bE483": "706150521601985135"
            },
            "WKLAYoUSDT": {
                "0x2C081F2EE4aC7C695CAf6ae0fCB83Ca4EdD0F61f": "33908276261960"
            },
            "WKLAYoUSDC": {
                "0x5bCeDc22468095DafeAE066f3951232c24FC0fb1": "11211293483872"
            },
            "KDAIoUSDT": {
                "0x8d688181b13482863eD748af440eda1093504a62": "50012116822185"
            },
            "KDAIoORC-S": {
                "0xFC65C95333058aA489a4d6D5b7785956CC19cc47": "83591495010689904499"
            },
            "CLAMoUSDT": {
                "0x633fD7084e9B2c098B88E90A2FCb582AF5d9b0E1": "49174702660525"
            },
            "oETHKSP": {
                "0xBBEB70f8448Aa4047aF3Ab70d3f8dB72a98ed240": "148569593208348109"
            },
            "oUSDCKSP": {
                "0xc21cFA4F55Dc0ce9c310159196Cf9f5532943777": "28470471174324"
            },
            "WKLAYoSOL-B": {
                "0x5B774FC45ffcc64123036d6AF952D7b353342890": "1702264213023189084"
            }
        }
    }
}




```

{% endtab %}
{% endtabs %}

[back to top](#endpoints-available)

### /getpoolliquidity

Returns the total liquidity for a specified pool.

<mark style="color:blue;">`GET`</mark> `https://api.expand.network/dex/getpoolliquidity`

#### Query Parameters

| Name                                          | Type   | Description                                                                  |
| --------------------------------------------- | ------ | ---------------------------------------------------------------------------- |
| rpc                                           | String | Remote procedural call URL.                                                  |
| poolAddress<mark style="color:red;">\*</mark> | String | Pool address whose liquidity is to be fetched.                               |
| dexId<mark style="color:red;">\*</mark>       | String | Refer to [DEX ID](https://docs.expand.network/ids/dex-ids) page for details. |

{% tabs %}
{% tab title="Sample Request" %}

```url
https://api.expand.network/dex/getpoolliquidity?poolAddress=0x191a182fb17f2f675975e53ee879fac113e848ab&dexId=3800
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "totalLiquidity": "10313363211346636331660"
    }
}
```

{% endtab %}
{% endtabs %}

[back to top](#endpoints-available)

### /getpool

&#x20;Returns poolAddress, tickSpacing, poolFees, tokensLiquidity and liquidity data based on tokenA and tokenB

<mark style="color:blue;">`GET`</mark> `https://api.expand.network/dex/getpool`

#### Query Parameters

{% tabs %}
{% tab title="Sample Request" %}

```url
https://api.expand.network/dex/getpool?tokenA=0x19aac5f612f524b754ca7e7c41cbfa2e981a4432&tokenB=0xe815a060b9279eba642f8c889fab7afc0d0aca63&dexId=3800
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": [
        {
            "poolAddress": "0x179f9e9a643988f4fBC5b7F0A718EF7cc16dC0D2",
            "poolFees": "100",
            "tickSpacing": "1",
            "tokensLiquidity": {
                "WKLAY": "0",
                "META": "0"
            },
            "liquidity": "0"
        },
        {
            "poolAddress": "0x191A182Fb17F2F675975e53ee879faC113e848Ab",
            "poolFees": "2000",
            "tickSpacing": "40",
            "tokensLiquidity": {
                "WKLAY": "40433694414507887756",
                "META": "507645839619610930096654"
            },
            "liquidity": "10313363211346636331660"
        },
        {
            "poolAddress": "0x938c55c1a75bE120928fF6Fd6F0E6C2b9FF85f9f",
            "poolFees": "10000",
            "tickSpacing": "200",
            "tokensLiquidity": {
                "WKLAY": "117848622190866910092",
                "META": "32091197095856557038939"
            },
            "liquidity": "1879931609622313478885"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

### /gettokenliquidity

Returns the individual token liquidity within the specified liquidity pool.

<mark style="color:blue;">`GET`</mark> `https://api.expand.network/dex/gettokenliquidity`

#### Query Parameters

| Name                                          | Type   | Description                                                                  |
| --------------------------------------------- | ------ | ---------------------------------------------------------------------------- |
| rpc                                           | String | Remote procedural call URL.                                                  |
| poolAddress<mark style="color:red;">\*</mark> | String | The pool address.                                                            |
| dexId<mark style="color:red;">\*</mark>       | String | Refer to [DEX ID](https://docs.expand.network/ids/dex-ids) page for details. |

{% tabs %}
{% tab title="Sample Request" %}

```
https://api.expand.network/dex/gettokenliquidity?poolAddress=0x191a182fb17f2f675975e53ee879fac113e848ab&vsCurrencies=inr&dexId=3800
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "WKLAY": "40433694414507887756",
        "META": "507645839619610930096654",
        "prices": {
            "usd": [
                {
                    "WKLAY": "0.1511168281459648"
                },
                {
                    "META": "0.000551120861421028"
                }
            ],
            "inr": [
                {
                    "WKLAY": "13.409397080580627"
                },
                {
                    "META": "0.04890387497445336"
                }
            ]
        }
    }
}
```

{% endtab %}
{% endtabs %}

[back to top](#endpoints-available)

### /swap

Initiate a swap transaction on a specified DEX.

<mark style="color:green;">`POST`</mark> `https://api.expand.network/dex/swap`

#### Request Body

<table><thead><tr><th width="233.6796875">Name</th><th width="203.71484375">Type</th><th>Description</th></tr></thead><tbody><tr><td>rpc</td><td>String</td><td>Remote procedural call URL.</td></tr><tr><td>dexId<mark style="color:red;">*</mark></td><td>String</td><td>Refer to the <a href="../../ids/dex-ids">DEX ID</a> page for details. </td></tr><tr><td>path<mark style="color:red;">*</mark></td><td>Array</td><td>Comma-separated values of token addresses, inside an array, to swap.</td></tr><tr><td>amountIn<mark style="color:red;">*</mark></td><td>String</td><td>Amount of token to be swapped.</td></tr><tr><td>amountOutMin</td><td>String</td><td>Minimum amount accepted as a result of swap.</td></tr><tr><td>to<mark style="color:red;">*</mark></td><td>String</td><td>Address of the recipient of the token.</td></tr><tr><td>from<mark style="color:red;">*</mark></td><td>String</td><td>Address of the sender of the token.</td></tr><tr><td>gas</td><td>String</td><td>Maximum gas limit provided by the sender, for the transaction.</td></tr><tr><td>poolFees</td><td>String</td><td>Different pool based on the fees. By default, it is selected as 3000.</td></tr><tr><td>gasPriority</td><td>String</td><td>low, medium, or high.</td></tr><tr><td>slippage</td><td>String</td><td><p>Percentage of total swap value. <br>By default, 1.</p><p>0 &#x3C;= slippage  value &#x3C;= 100</p></td></tr><tr><td>deadline<mark style="color:red;">*</mark></td><td>String</td><td>Deadline for the transaction to be executed (UNIX Timestamp).</td></tr></tbody></table>

{% tabs %}
{% tab title="Sample Request" %}

```json
{
    "path": [
        "0x19aac5f612f524b754ca7e7c41cbfa2e981a4432",
        "0xe815a060b9279eba642f8c889fab7afc0d0aca63"
    ],
    "amountIn": "100000000000",
    "deadline": "1799212923",
    "to": "0xb6ab494d9b20ede5e57b42b6d7f058a9c802b0e2",
    "from": "0xb6ab494d9b20ede5e57b42b6d7f058a9c802b0e2",
    "amountOutMin": "10",
    "gas": "1000000",
    "poolFees": "100",
    "gasPriority": "high",
    "slippage": "30",
    "dexId": "3800"
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId": "8217",
        "from": "0xb6ab494d9b20ede5e57b42b6d7f058a9c802b0e2",
        "to": "0x7F102E3340eb649550A48AC40013A56136FDefB5",
        "gas": "1000000",
        "value": "0",
        "data": "0x414bf38900000000000000000000000019aac5f612f524b754ca7e7c41cbfa2e981a4432000000000000000000000000e815a060b9279eba642f8c889fab7afc0d0aca630000000000000000000000000000000000000000000000000000000000000064000000000000000000000000b6ab494d9b20ede5e57b42b6d7f058a9c802b0e2000000000000000000000000000000000000000000000000000000006b3dcf7b000000000000000000000000000000000000000000000000000000174876e800000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000",
        "gasPrice": "41250000000",
        "estimationCheck": true,
        "referenceId": "fefa062c922642cf860857baf0ddb270"
    }
}
```

{% endtab %}
{% endtabs %}

[back to top](#endpoints-available)
