# Liquidswap

### Supported Chains

Available on **Aptos 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 Liquidswap.
* [<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;">**/**</mark>](#swap)[<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;">**/**</mark>](#swap)[<mark style="color:blue;">**removeliquidity**</mark>](#removeliquidity)<mark style="color:green;">`POST`</mark> - Remove liquidity from a specified pool for a specified DEX.

### DEX IDs

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

Below is a list of DEX IDs related to Liquidswap. 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 |
| ---------- | ------------- | ------ |
| Liquidswap | Aptos Mainnet | 3200   |

## Endpoint Details

### /getprice

Returns the swap quotation for a given token pair.

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

#### Query Parameter

| Name                                       | Type   | Description                                                                      |
| ------------------------------------------ | ------ | -------------------------------------------------------------------------------- |
| rpc                                        | String | Remote procedural call URL.                                                      |
| dexId<mark style="color:red;">\*</mark>    | String | Refer to the [DEX ID](https://docs.expand.network/ids/dex-ids) page for details. |
| amountIn<mark style="color:red;">\*</mark> | String | Amount of token.                                                                 |
| path<mark style="color:red;">\*</mark>     | String | Comma separated values of token addresses whose price is to be fetched.          |

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

```url
https://api.expand.network/dex/getprice?dexId=3200&path=0x1::aptos_coin::AptosCoin,0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC&amountIn=10000000
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "amountIn": "10000000",
        "path": [
            "0x1::aptos_coin::AptosCoin",
            "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC"
        ],
        "amountsOut": [
            "10000000",
            "864252"
        ]
    }
}
```

{% endtab %}
{% endtabs %}

### /getuserliquidity

Returns  the balance of a particular token pair of an account.

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

#### Query Parameter

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

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

```url
https://api.expand.network/dex/getuserliquidity?dexId=3200&poolAddress=0x61d2c22a6cb7831bee0f48363b0eec92369357aece0d1142062f7d5d85c7bef8::lp_coin::LP<0x1::aptos_coin::AptosCoin, 0x111ae3e5bc816a5e63c2da97d0aa3886519e0cd5e4b046659fa35796bd11542a::stapt_token::StakedApt, 0x163df34fccbf003ce219d3f1d9e70d140b60622cb9dd47599c25fb2f797ba6e::curves::Uncorrelated>&address=0x485300d3fc4fb6b0bcf4431556b13a2e55eec71cbbb33a770aad8958d63c13fd
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "pairAddress": "0x61d2c22a6cb7831bee0f48363b0eec92369357aece0d1142062f7d5d85c7bef8::lp_coin::LP<0x1::aptos_coin::AptosCoin, 0x111ae3e5bc816a5e63c2da97d0aa3886519e0cd5e4b046659fa35796bd11542a::stapt_token::StakedApt, 0x163df34fccbf003ce219d3f1d9e70d140b60622cb9dd47599c25fb2f797ba6e::curves::Uncorrelated>",
        "liquidity": "25368400",
        "tokenA": "29931130",
        "tokenB": "27129313"
    }
}
```

{% endtab %}
{% endtabs %}

### /getpoolliquidity

Returns the total liquidity for a specified pool.

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

#### Query Parameter

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

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

```url
https://api.expand.network/dex/getpoolliquidity?dexId=3200&poolAddress=0x61d2c22a6cb7831bee0f48363b0eec92369357aece0d1142062f7d5d85c7bef8::lp_coin::LP<0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT,0x9770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da3::fa_to_coin_wrapper::WrappedUSDT,0x163df34fccbf003ce219d3f1d9e70d140b60622cb9dd47599c25fb2f797ba6e::curves::Stable>
```

{% endtab %}

{% tab title="Sample Response" %}

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

{% 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 Parameter

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

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

```url
https://api.expand.network/dex/gettokenliquidity?dexId=3200&poolAddress=0x61d2c22a6cb7831bee0f48363b0eec92369357aece0d1142062f7d5d85c7bef8::lp_coin::LP<0x1::aptos_coin::AptosCoin, 0xf8fa55ff4265fa9586f74d00da4858b8a0d2320bbe94cb0e91bf3a40773eb60::GREATDANE::GREATDANE, 0x163df34fccbf003ce219d3f1d9e70d140b60622cb9dd47599c25fb2f797ba6e::curves::Uncorrelated>
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "APT": "6649459",
        "GREATDANE": "60847704895806"
    }
}
```

{% endtab %}
{% endtabs %}

### /swap

Initiate a swap transaction on a specified DEX.

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

#### Request Body

| Name                                       | Type   | Description                                                                           |
| ------------------------------------------ | ------ | ------------------------------------------------------------------------------------- |
| rpc                                        | String | Remote procedural call URL.                                                           |
| dexId<mark style="color:red;">\*</mark>    | String | Refer to the [DEX ID](https://docs.expand.network/ids/dex-ids) page for details.      |
| path<mark style="color:red;">\*</mark>     | String | Comma separated values of token addresses.                                            |
| amountIn<mark style="color:red;">\*</mark> | String | Amount of token to be swapped.                                                        |
| gas                                        | String | Maximum gas limit provided by the sender, for the transaction.                        |
| from<mark style="color:red;">\*</mark>     | String | Address of the sender of the token.                                                   |
| slippage                                   | String | <p>Percentage of total swap value. By default, 1.</p><p>0 <= slippage value <= 10</p> |

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

```json
{
    "amountIn": "100000",
    "from": "0xa182b65f4bf10be7ef870496893c170af3079a2540c63b470445417fcfb21c5b",
    "path": [
        "0x1::aptos_coin::AptosCoin",
        "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC"
    ],
    "slippage": "99",
    "dexId": "3200",
    "gas": "10000"
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId": "1400",
        "from": "0xa182b65f4bf10be7ef870496893c170af3079a2540c63b470445417fcfb21c5b",
        "to": "0x61d2c22a6cb7831bee0f48363b0eec92369357aece0d1142062f7d5d85c7bef8",
        "data": "oYK2X0vxC+fvhwSWiTwXCvMHmiVAxjtHBEVBf8+yHFsOAAAAAAAAAAIBY980/MvwA84hnT8dnnDRQLYGIsud1HWZwl+y95e6bgdzY3JpcHRzBHN3YXADBwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABCmFwdG9zX2NvaW4JQXB0b3NDb2luAAfyK+3iN6B+EhtW2RpJHre839H1kHkmqeWDOPlkoBsX+gVhc3NldARVU0RDAAcBY980/MvwA84hnT8dnnDRQLYGIsud1HWZwl+y95e6bgZjdXJ2ZXMMVW5jb3JyZWxhdGVkAAIIoIYBAAAAAAAIXAAAAAAAAAAQJwAAAAAAAGQAAAAAAAAAqWRpZwAAAAAB",
        "referenceId": "c20cdb1e18534d62bc8188b3381b0354"
    }
}
```

{% endtab %}
{% endtabs %}

### /addliquidity

Add liquidity to a specified pool in a specified DEX.

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

#### Request Body

| Name                                       | Type   | Description                                                                                                              |
| ------------------------------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------ |
| rpc                                        | String | Remote procedural call URL.                                                                                              |
| dexId<mark style="color:red;">\*</mark>    | String | Refer to the [DEX ID](https://docs.expand.network/ids/dex-ids) page for details.                                         |
| path<mark style="color:red;">\*</mark>     | String | Comma separated values of token addresses.                                                                               |
| amountIn<mark style="color:red;">\*</mark> | String | Amount of token0 and token1 to be added.                                                                                 |
| slippage                                   | String | <p>Percentage of total swap value. By default, 1.</p><p>0 <= slippage value <= 10</p>                                    |
| from<mark style="color:red;">\*</mark>     | String | Address of the sender of the token.                                                                                      |
| gas                                        | String | Maximum gas limit provided by the sender, for the transaction.                                                           |
| curveType                                  | String | <p>Type of curve for pool pair.<br><code>stable</code>/<code>uncorrelated</code>.<br>By Default, <code>stable</code></p> |

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

```json
{
    "amountIn": ["733700","529428"],
    "from": "0xa182b65f4bf10be7ef870496893c170af3079a2540c63b470445417fcfb21c5b",
    "path": [
        "0x1::aptos_coin::AptosCoin",
        "0x53a30a6e5936c0a4c5140daed34de39d17ca7fcae08f947c02e979cef98a3719::coin::LSD"
    ],
    "slippage": "50",
    "dexId": "3200",
    "gas":"10000"
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId": "1400",
        "from": "0xa182b65f4bf10be7ef870496893c170af3079a2540c63b470445417fcfb21c5b",
        "to": "0x61d2c22a6cb7831bee0f48363b0eec92369357aece0d1142062f7d5d85c7bef8",
        "data": "oYK2X0vxC+fvhwSWiTwXCvMHmiVAxjtHBEVBf8+yHFsOAAAAAAAAAAIBY980/MvwA84hnT8dnnDRQLYGIsud1HWZwl+y95e6bgdzY3JpcHRzDWFkZF9saXF1aWRpdHkDB1OjCm5ZNsCkxRQNrtNN450Xyn/K4I+UfALpec75ijcZBGNvaW4DTFNEAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQphcHRvc19jb2luCUFwdG9zQ29pbgAHAWPfNPzL8APOIZ0/HZ5w0UC2BiLLndR1mcJfsveXum4GY3VydmVzBlN0YWJsZQAECBQUCAAAAAAACAoKBAAAAAAACAQyCwAAAAAACAKZBQAAAAAAECcAAAAAAABkAAAAAAAAAMlkaWcAAAAAAQ==",
        "referenceId": "4125a4481a984782b9077efd85275e83"
    }
}
```

{% endtab %}
{% endtabs %}

### /removeliquidity

Remove liquidity from a specified pool for a specified DEX.

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

#### Request Body

| Name                                        | Type   | Description                                                                                                              |
| ------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------ |
| rpc                                         | String | Remote procedural call URL.                                                                                              |
| dexId<mark style="color:red;">\*</mark>     | String | Refer to the [DEX ID](https://docs.expand.network/ids/dex-ids) page for details.                                         |
| path<mark style="color:red;">\*</mark>      | String | Comma separated values of token addresses.                                                                               |
| slippage                                    | String | <p>Percentage of total swap value. By default, 1.</p><p>0 <= slippage value <= 10</p>                                    |
| from<mark style="color:red;">\*</mark>      | String | Address of the sender of the token.                                                                                      |
| liquidity<mark style="color:red;">\*</mark> | String | The liquidity to be removed.                                                                                             |
| gas                                         | String | Maximum gas limit provided by the sender, for the transaction.                                                           |
| curveType                                   | String | <p>Type of curve for pool pair.<br><code>stable</code>/<code>uncorrelated</code>.<br>By Default, <code>stable</code></p> |

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

```json
{
    "liquidity": "10000",
    "from": "0xa182b65f4bf10be7ef870496893c170af3079a2540c63b470445417fcfb21c5b",
    "path": [
        "0x1::aptos_coin::AptosCoin",
        "0x53a30a6e5936c0a4c5140daed34de39d17ca7fcae08f947c02e979cef98a3719::coin::LSD"
    ],
    "slippage": "50",
    "dexId": "3200",
    "curveType": "uncorrelated",
    "gas":"10000"
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId": "1400",
        "from": "0xa182b65f4bf10be7ef870496893c170af3079a2540c63b470445417fcfb21c5b",
        "to": "0x61d2c22a6cb7831bee0f48363b0eec92369357aece0d1142062f7d5d85c7bef8",
        "data": "oYK2X0vxC+fvhwSWiTwXCvMHmiVAxjtHBEVBf8+yHFsOAAAAAAAAAAIBY980/MvwA84hnT8dnnDRQLYGIsud1HWZwl+y95e6bgdzY3JpcHRzEHJlbW92ZV9saXF1aWRpdHkDB1OjCm5ZNsCkxRQNrtNN450Xyn/K4I+UfALpec75ijcZBGNvaW4DTFNEAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQphcHRvc19jb2luCUFwdG9zQ29pbgAHAWPfNPzL8APOIZ0/HZ5w0UC2BiLLndR1mcJfsveXum4GY3VydmVzDFVuY29ycmVsYXRlZAADCBAnAAAAAAAACJZBAAAAAAAACDAJAAAAAAAAECcAAAAAAABkAAAAAAAAAA5laWcAAAAAAQ==",
        "referenceId": "4f3ac95b6cb54eeea6fb74573def0a57"
    }
}
```

{% endtab %}
{% endtabs %}
