# Alex

### Supported Chains

Available on **Stacks 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 Uniswap 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;">**/**</mark>](#getliquidityholders)[<mark style="color:blue;">**gettokenidprice**</mark><mark style="color:blue;">**`GET`**</mark>](#gettokenidprice) - Returns the USD price of the liquidity token of a particular pool.&#x20;
* [<mark style="color:blue;">**/swap**</mark>](#swap) <mark style="color:green;">`POST`</mark> - Initiate a swap transaction on 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 Alex. 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 |
| -------- | ------ | ------ |
| Alex     | Stacks | 3100   |

## 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?path=SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-wstx,SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.brc20-db20&amountIn=100&dexId=3100
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "amountIn": "100",
        "path": [
            "SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-wstx",
            "SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.brc20-db20"
        ],
        "amountsOut": [
            "100",
            "2603"
        ]
    }
}
```

{% endtab %}
{% endtabs %}

### /getuserliquidity

Returns the total liquidity (amount of liquidity pool token) that a user holds.

<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.                                            |
| poolId<mark style="color:red;">\*</mark>  | String | pool id of pair                                                                  |

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

```url
https://api.expand.network/dex/getuserliquidity?dexId=3100&poolId=13&address=SP16PBYTMSTXSQY9F0CFNFNYSZ1JD3JGEPM4AZBTD
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "poolId": "13",
        "liquidity": "7031371207288",
        "tokenA": "1047964",
        "tokenB": "21118906"
    }
}
```

{% 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. |
| poolId<mark style="color:red;">\*</mark> | String | Pool Id whose liquidity is to be fetched.                                        |

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

```url
https://api.expand.network/dex/getpoolliquidity?dexId=3100&poolId=59
```

{% endtab %}

{% tab title="Sample Response" %}

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

{% 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. |
| poolId<mark style="color:red;">\*</mark> | String | Pool Id whose liquidity is to be fetched.                                        |

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

```url
https://api.expand.network/dex/gettokenliquidity?dexId=3100&poolId=117
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "token-wstx-v2": "79571081726",
        "token-wchillguy": "115134358586619695"
    }
}
```

{% endtab %}
{% endtabs %}

### /gettokenidprice

Returns the USD price of the liquidity token of a particular pool.&#x20;

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

#### 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. |
| poolId<mark style="color:red;">\*</mark> | String | Pool Id whose USD price of liquidity token is to be fetched.                     |

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

```url
https://api.expand.network/dex/gettokenidprice?dexId=3100&poolId=14
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "poolId": "14",
        "price": "0.9698074551870216"
    }
}
```

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

<table><thead><tr><th width="191">Name</th><th width="109">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="https://docs.expand.network/ids/dex-ids">DEX ID</a> page for details.</td></tr><tr><td>path<mark style="color:red;">*</mark></td><td>String</td><td>Comma-separated values of token addresses, inside an array, to swap.<br>Note: For assets other than XLM (Native token), the token issuer is required.</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 the result of swap.</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>slippage</td><td>String</td><td><p>Percentage of total swap value. By default, 1.</p><p>0 &#x3C;= slippage value &#x3C;= 10</p></td></tr></tbody></table>

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

```json
{
    "dexId": "3100",
    "path": [
        "SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.token-wstx-v2",
        "sp102v8p0f7jx67arq77wea3d3cfb5xw39redt0am.token-alex"
    ],
    "amountIn": "1000",
    "from": "SP16PBYTMSTXSQY9F0CFNFNYSZ1JD3JGEPM4AZBTD",
    "amountOutMin": "0",
    "slippage": "10"
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId": "1700",
        "from": "SP16PBYTMSTXSQY9F0CFNFNYSZ1JD3JGEPM4AZBTD",
        "data": "ey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