# Chainge 2.0 API Documentation

1. **Supported Chains & Tokens**

## Get Chainge Supported Chains

<mark style="color:blue;">`GET`</mark> `https://api2.chainge.finance/v1/getChain`

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "code": 0,
  "data": {
    "version": 0,
    "list": [...]
  },
  "msg": "string",
}
```

{% endtab %}
{% endtabs %}

## Get Chainge Supported Tokens

<mark style="color:blue;">`GET`</mark> `https://api2.chainge.finance/v1/getAssets`

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "code": 0,
  "data": {
    "version": 0,
    "list": [...]
  },
  "msg": "string",
}
```

{% endtab %}
{% endtabs %}

## Get Chainge Supported Tokens for a specified chain

<mark style="color:blue;">`GET`</mark> `https://api2.chainge.finance/v1/getAssetsByChain`

#### Query Parameters

| Name                                    | Type   | Description                         |
| --------------------------------------- | ------ | ----------------------------------- |
| chain<mark style="color:red;">\*</mark> | String | chain name string from getChain API |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "code": 0,
  "data": {
    "version": 0,
    "list": [...]
  },
  "msg": "string",
}
```

{% endtab %}
{% endtabs %}

2. **Quote**

## Get a quote for a cross chain transaction

<mark style="color:blue;">`GET`</mark> `https://api2.chainge.finance/v1/getBridgeQuote`

#### Query Parameters

| Name                                        | Type   | Description                                                  |
| ------------------------------------------- | ------ | ------------------------------------------------------------ |
| amount<mark style="color:red;">\*</mark>    | String | User input quantity（Ex: 100000, 1 USDT）                      |
| symbol<mark style="color:red;">\*</mark>    | String | from token symbol from supported Tokens API request result   |
| fromChain<mark style="color:red;">\*</mark> | String | from chain nickName from supported Chains API request result |
| toChain<mark style="color:red;">\*</mark>   | String | from chain nickName from supported Chains API request result |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "code": 0,
    "msg": "success",
    "data": {
        "price": "2959.73491527866",
        "outAmount": "1000000000000000000",
        "outAmountUsd": "2959.734915278660082549",
        "serviceFee": "500000000000000",
        "gasFee": "101360428750341"
    }
}
```

{% endtab %}
{% endtabs %}

## Get a quote for a cross chain aggregator transaction

<mark style="color:blue;">`GET`</mark> `https://api2.chainge.finance/v1/getAggregateQuote`

#### Query Parameters

| Name                                               | Type   | Description                                                          |
| -------------------------------------------------- | ------ | -------------------------------------------------------------------- |
| fromAmount<mark style="color:red;">\*</mark>       | String | User input quantity（Ex: 100000, 1 USDT）                              |
| fromTokenAddress<mark style="color:red;">\*</mark> | String | from token contract address from supported Tokens API request result |
| fromDecimal<mark style="color:red;">\*</mark>      | String | from token contract decimal from supported Tokens API request result |
| fromChain<mark style="color:red;">\*</mark>        | String | from chain nickName from supported Chains API request result         |
| toTokenAddress<mark style="color:red;">\*</mark>   | String | from token contract address from supported Tokens API request result |
| toDecimal<mark style="color:red;">\*</mark>        | String | from token contract decimal from supported Tokens API request result |
| toChain<mark style="color:red;">\*</mark>          | String | from chain nickName from supported Chains API request result         |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "code": 0,
    "msg": "success",
    "data": {
        "chain": "1", 
        "chainDecimal": 18,
        "aggregator": "1inch",
        "outAmount": "2979357481475661701461",
        "outAmountUsd": "2936.584874",
        "minOutAmount": "",
        "serviceFee": "0",
        "gasFee": "13633955537026351104",
        "priceImpact": "-0.40"
    }
}
```

{% endtab %}
{% endtabs %}

3. **Swap**

## Get direct exchange trading information

<mark style="color:blue;">`GET`</mark> `https://api2.chainge.finance/v1/getAggregateSwap`

#### Query Parameters

| Name                                               | Type    | Description                                                          |
| -------------------------------------------------- | ------- | -------------------------------------------------------------------- |
| fromAmount<mark style="color:red;">\*</mark>       | String  | User input quantity（eg: 100000, 1 USDT）                              |
| fromTokenAddress<mark style="color:red;">\*</mark> | String  | from token contract address from supported Tokens API request result |
| fromDecimal<mark style="color:red;">\*</mark>      | String  | from token contract decimal from supported Tokens API request result |
| toTokenAddress<mark style="color:red;">\*</mark>   | String  | from token contract address from supported Tokens API request result |
| toDecimal<mark style="color:red;">\*</mark>        | String  | from token contract decimal from supported Tokens API request result |
| chain<mark style="color:red;">\*</mark>            | String  | from chain nickName from supported Chains API request result         |
| aggregator                                         | String  | from Aggregator Quote API request result                             |
| sender<mark style="color:red;">\*</mark>           | String  | User address                                                         |
| recipient<mark style="color:red;">\*</mark>        | String  | Receiver address                                                     |
| slippage<mark style="color:red;">\*</mark>         | String  | slippage(eg: 100 === 1%)                                             |
| allowPartialFill<mark style="color:red;">\*</mark> | Boolean | true                                                                 |
| routeSummary                                       | String  | from Aggregator Quote API request result                             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "code": 0,
    "msg": "success",
    "data": {
        "amountOut": "84640",
        "from": "0xbda05e4421bf7e682635b7b18978f2dad4ecc059",
        "to": "0x62bc5327868a998e1b3d9fe6037273e642a137ae",
        "gas": "0",
        "value": "0",
        "data": "0x38ed17390000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000001475200000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000bda05e4421bf7e682635b7b18978f2dad4ecc0590000000000000000000000000000000000000000000000000000000065d9d6140000000000000000000000000000000000000000000000000000000000000002000000000000000000000000ab1f7e5bf2587543fe41f268c59d35da95f046e00000000000000000000000008a20c13b42d7fe418f10f922f2cee06246c24269"
    }
}
```

{% endtab %}
{% endtabs %}

4. **Order**

## Submit order

<mark style="color:green;">`POST`</mark> `https://api2.chainge.finance/v1/submitOrder`

#### Headers

| Name                                         | Type   | Description          |
| -------------------------------------------- | ------ | -------------------- |
| Evmaddress<mark style="color:red;">\*</mark> | String | Current user address |
| Signature<mark style="color:red;">\*</mark>  | String | Signature info       |

#### Request Body

| Name                                           | Type   | Description                                               |
| ---------------------------------------------- | ------ | --------------------------------------------------------- |
| channel<mark style="color:red;">\*</mark>      | String | Apply to Chaing.Finance                                   |
| execStrategy<mark style="color:red;">\*</mark> | String | Default Value: ""                                         |
| extra<mark style="color:red;">\*</mark>        | String | Default Value: ""                                         |
| orderType<mark style="color:red;">\*</mark>    | String | <p>Cross Chain: 1</p><p>Aggregate:2</p>                   |
| slippage<mark style="color:red;">\*</mark>     | String | <p>Cross Chain: 0</p><p>Aggregate: (eg: 100 == 1%)</p>    |
| sourceCerts<mark style="color:red;">\*</mark>  | String | Order information，Hex string                              |
| timeout<mark style="color:red;">\*</mark>      | String | Default: 0                                                |
| toAddr<mark style="color:red;">\*</mark>       | String | Receiver address                                          |
| toChain                                        | String | from supported Chains API request result                  |
| toIndex<mark style="color:red;">\*</mark>      | String | from token index from supported Tokens API request result |
| triggerPrice<mark style="color:red;">\*</mark> | String | Default: 0                                                |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "code": 0,
    "msg": "success",
    "data": {
        "id": "19026",
    }
}
```

{% endtab %}
{% endtabs %}

## Check order status

<mark style="color:blue;">`GET`</mark> `https://api2.chainge.finance/v1/checkOrder`

#### Query Parameters

| Name                                 | Type   | Description                          |
| ------------------------------------ | ------ | ------------------------------------ |
| id<mark style="color:red;">\*</mark> | String | from Submit order API request result |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "code": 0,
    "msg": "success",
    "data": {
        "status": "Succeeded",
        "timestamp": 1708675586,
        "execHash": "0x5bc094751492e27d9e32f388432b943dbf19388ea3b6091bac5c0722a90d4f86",
        "reason": "",
        "amountOut": "4897500"
    }
}
```

{% endtab %}
{% endtabs %}

5. **Other helpful APIs**

## Get user balance

<mark style="color:blue;">`GET`</mark> `https://api2.chainge.finance/v1/getBalance`

#### Query Parameters

| Name                                              | Type   | Description                              |
| ------------------------------------------------- | ------ | ---------------------------------------- |
| chain<mark style="color:red;">\*</mark>           | String | from supported Chains API request result |
| contractAddress<mark style="color:red;">\*</mark> | String | from supportd Tokens API request result  |
| address<mark style="color:red;">\*</mark>         | String | user address                             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "code": 0,
    "msg": "success",
    "data": {
        "balance": "0",
        "hrpBalance": "0"
    }
}
```

{% endtab %}
{% endtabs %}

## Get token price

<mark style="color:blue;">`GET`</mark> `https://api2.chainge.finance/v1/getPrice`

#### Query Parameters

| Name                                              | Type   | Description                              |
| ------------------------------------------------- | ------ | ---------------------------------------- |
| chain<mark style="color:red;">\*</mark>           | String | from supported Chains API request result |
| contractAddress<mark style="color:red;">\*</mark> | String | from supportd Tokens API request result  |
| symbol<mark style="color:red;">\*</mark>          | String | from supportd Tokens API request result  |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "code": 0,
    "msg": "success",
    "data": {
        "price": "382.09024375746236",
        "updateTime": "2024-02-22 18:29:06.444159295 +0800 GMT",
        "source": "cmc"
    }
}
```

{% endtab %}
{% endtabs %}

6. **Ticket**

## Submit ticket

<mark style="color:green;">`POST`</mark> `https://api2.chainge.finance/v1/submitTicket`

#### Headers

| Name                                         | Type   | Description    |
| -------------------------------------------- | ------ | -------------- |
| EvmAddress<mark style="color:red;">\*</mark> | String | User address   |
| Signature<mark style="color:red;">\*</mark>  | String | Signature Info |

#### Request Body

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| hash  | String | Problematic transaction hash             |
| chain | String | from supported Chains API request result |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "code":0,
    "msg":"success",
    "data":{
        "ticketId":10000464
    }
}
```

{% endtab %}
{% endtabs %}

## Get tickets for user address

<mark style="color:blue;">`GET`</mark> `https://api2.chainge.finance/v1/getAllTicketByAddress`

#### Query Parameters

| Name                                      | Type   | Description                             |
| ----------------------------------------- | ------ | --------------------------------------- |
| address<mark style="color:red;">\*</mark> | String | user address                            |
| filter<mark style="color:red;">\*</mark>  | String | status(eg: Unknown, Pending, Succeeded) |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "code": 0,
    "msg": "success",
    "data": {
        "list": [
            {
                "ticketId": 10000175,
                "address": "0x42a6685ef29886Cbcb595Aa903f00dea0d1787d8",
                "chain": "POLYGON",
                "hash": "0xd1c5fd95357b651c871e72d396500d97e7bf8208589624f58502162a58e26a5f",
                "succeeded": true,
                "solution": "refund"
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

## Check ticket status

<mark style="color:blue;">`GET`</mark> `https://api2.chainge.finance/v1/checkTicket`

#### Query Parameters

| Name                                       | Type   | Description                                  |
| ------------------------------------------ | ------ | -------------------------------------------- |
| ticketId<mark style="color:red;">\*</mark> | String | from getAllTicketByAddress Api return result |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "code": 0,
    "msg": "success",
    "data": {
        "succeeded": true,
        "solution": "refund"
    }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://chainge-finance.gitbook.io/chainge-finance/get-started/chainge-2.0-api-documentation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
