> For the complete documentation index, see [llms.txt](https://docs.gmgn.ai/cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gmgn.ai/cn/he-zuo-api-ji-cheng-gmgn-ethbasebsc-jiao-yi-api/huo-qu-ethbasebsc-jiao-yi-ke-yong-de-lu-you.md).

# 获取ETH/Base/BSC交易可用的路由

该接口分为2个，一个是精确指定输入，获得输出币种数量； 另外一个是精确指定输出，获得输入币种最小数量。

## 1. 精确输入

接入点：/defi/router/v1/tx/available\_routes\_exact\_in

请求方式：GET

输入参数：

| **参数名字**            | **参数说明**                  | **是否必须** | **举例**                                     |
| ------------------- | ------------------------- | -------- | ------------------------------------------ |
| token\_in\_chain    | 网络代号，比如eth/polygon/arb等   | 是        | eth                                        |
| token\_out\_chain   | 网络代号，比如eth/polygon/arb等   | 是        | eth                                        |
| token\_in\_address  | 输入token的合约地址              | 是        | 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 |
| token\_out\_address | 输出token的合约地址              | 是        | 0xb44C0A4624eaEd2C41EB8437d0Fb5A28F91E7335 |
| in\_amount          | 输入token的数量，以最小单位计         | 是        | 100000000                                  |
| src                 | 来源，可以选择gmgn或者swapx，默认gmgn | 否        | gmgn                                       |

返回参数：

| **参数名字** | **参数说明**                                                                                                                                                                                                                                                                                                         | **举例**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| msg      | 出错信息                                                                                                                                                                                                                                                                                                             | amountIn is required                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| code     | 正确0，错误-1                                                                                                                                                                                                                                                                                                         | 0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| data     | <p>返回跨链交易的基本信息，主要包含以下信息：</p><p>来源链ID：chain\_id，</p><p>合约地址：to，</p><p>源币种数量：amount\_in,</p><p>源币种USD价值：amount\_in\_usd,</p><p>获得币种数量：amount\_out,</p><p>获得币种USD价值：amount\_out\_usd,</p><p>购买币种地址：buy\_token\_address,</p><p>卖出币种地址：sell\_token\_address,</p><p>经过步骤列表：steps,</p><p>(其中steps有id/type/tool三个字段)</p> | **{**`"routes": [{"chain_id": 1,"to": "0x4313C378Cc91eA583C91387B9216e2c03096b27f","amount_in": "10000000000000000","amount_out": "299609399139476657","input_token_address": "0x0000000000000000000000000000000000000000","output_token_address": "0x81de6d37439afb8c5c0a6d6e39e764c89e81d6b5","type": "v2","path": ["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x81de6d37439afb8c5c0a6d6e39e764c89e81d6b5"],"pool_address": "0xc8d39a869dee360e19d2a2f189c5b87f013d9f85","factory_address": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f","fee": 3000,"steps": [{"id": 1,"type": "swap","tool": "uniswapv2"`**}]**,`"token_in_usd_price": "2246.46","amount_in_usd": "22.4646","token_out_usd_price": "0.00000008532060895067131","amount_out_usd": "25.56285638192488514528660222461067","value": "10000000000000000","price_impact": "0.01","gas_limit": "221343"`**}]**,`"volatilities": {"token_in": 0,"token_out": 10}` |

返回data的routes字段说明

| **字段名字**               | **类型**              | **模拟是否用到** | **举例**                                                                                                                                                                                               |
| ---------------------- | ------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| chain\_id              | number              | 是          | 1                                                                                                                                                                                                    |
| to                     | string              | 是          | 0xb2C435F236AE7697341beb0D98EceD5AB7d35052                                                                                                                                                           |
| amount\_in             | string              | 是          | 129470074265000000                                                                                                                                                                                   |
| amount\_in2            | string              | 是          | 1232343                                                                                                                                                                                              |
| amount\_out            | string              | 是          | 1000000000                                                                                                                                                                                           |
| input\_token\_address  | string              | 是          | 0x0c48250eb1f29491f1efbeec0261eb556f0973c7                                                                                                                                                           |
| output\_token\_address | string              | 是          | 0x75c97384ca209f915381755c582ec0e2ce88c1ba                                                                                                                                                           |
| type                   | string              | 是          | v0, v2, v3, v2-v2, v2-v3, v3-v2                                                                                                                                                                      |
| path                   | string \| string\[] | 是          | <p>\[</p><p>  '0x0c48250eb1f29491f1efbeec0261eb556f0973c7',</p><p>        '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',</p><p>        '0x75c97384ca209f915381755c582ec0e2ce88c1ba'</p><p>      ]</p> |
| path\_bytes            | string              | 是，V3多跳用    |                                                                                                                                                                                                      |
| pool\_address          | string \| string\[] | 是          | <p> \[</p><p>        '0xe05d099bfd7f4aa9f2e696f6c3ebe181479961a5',</p><p>        '0xb54ce26f2e30f64c5b684b141311ce138ab5e00e'</p><p>      ]</p>                                                      |
| factory\_address       | string \| string\[] | 是，V2多跳用    | 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f                                                                                                                                                           |
| fee                    | string \| string\[] | 是，V3用      | 3000                                                                                                                                                                                                 |
| steps                  | array               | 否          | \[ { id: 1, type: 'swap', tool: 'uniswapv2' } ]                                                                                                                                                      |
| token\_in\_usd\_price  | string              | 否          | 10.3099800923283                                                                                                                                                                                     |
| amount\_in\_usd        | string              | 否          | 1.334833                                                                                                                                                                                             |
| token\_out\_usd\_price | string              | 否          | 0.00000000474642715895                                                                                                                                                                               |
| amount\_out\_usd       | string              | 否          | 1.3226                                                                                                                                                                                               |
| value                  | string              | 是          | 10000                                                                                                                                                                                                |
| gas\_limit             | string              | 否          | 21000                                                                                                                                                                                                |
| from\_address          | string              | 是          | 发起交易的钱包地址， 例如0xb2bA9EA690428E01d82572438De4514F16446251                                                                                                                                              |

返回data的`volatilities`字段说明：

| **字段名字**   | **类型**              | **举例** |
| ---------- | ------------------- | ------ |
| token\_in  | Int, 5分钟价格波动率%上面的部分 | 5      |
| token\_out | Int，5分钟价格波动率%上面的部分  | 10     |
| is\_fomo   | bool, true or false | true   |

## 2. 精确输出

接入点：/defi/router/v1/tx/available\_routes\_exact\_out&#x20;

请求方式：GET

输入参数：

| **参数名字**            | **参数说明**                  | **是否必须** | **举例**                                     |
| ------------------- | ------------------------- | -------- | ------------------------------------------ |
| token\_in\_chain    | 网络代号，比如eth/polygon/arb等   | 是        | eth                                        |
| token\_out\_chain   | 网络代号，比如eth/polygon/arb等   | 是        | arb                                        |
| token\_in\_address  | 输入token的合约地址              | 是        | 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 |
| token\_out\_address | 输出token的合约地址              | 是        | 0xb44C0A4624eaEd2C41EB8437d0Fb5A28F91E7335 |
| out\_amount         | 输出token的数量，以最小单位计         | 是        | 100000000                                  |
| src                 | 来源，可以选择gmgn或者swapx，默认gmgn | 否        | swapx                                      |

返回参数：

| **参数名字** | **参数说明**                                                                                                                                                                                                                            | **举例**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| msg      | 出错信息                                                                                                                                                                                                                                | amountIn is required                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| code     | 正确0，错误-1                                                                                                                                                                                                                            | 0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| data     | 返回跨链交易的基本信息，主要包含以下信息：来源链ID：chain\_id，合约地址：to，源币种数量：amount\_in,源币种USD价值：amount\_in\_usd,输出币种数量：amount\_out,获得币种USD价值：amount\_out\_usd,购买币种地址：buy\_token\_address,卖出币种地址：sell\_token\_address,经过步骤列表：steps,(其中steps有id/type/tool三个字段) | {"routes":\[{"chain\_id":1,"to":"0x2abbEAf73456b6c0b1a1E7e32Dbd63Bf4fafAC40","amount\_in":"987855194221161593","amount\_out":"100000000000000000","input\_token\_address":"0x481c4572e017e636177920D79db157c0Cf3A4697","output\_token\_address":"0x2C3Bc638031AAbB701EA5f30c522379dEE5c2B22","type":"v3","path":\["0x481c4572e017e636177920D79db157c0Cf3A4697","0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6","0x2C3Bc638031AAbB701EA5f30c522379dEE5c2B22"],"pool\_address":\["0x717BFacEBD23A5505b061Cf15a9C0fB2Ac1CABE4","0x20A741900D8b8Fcd10b4Af1822EE07622aF165C3"],"fee":\[3000,3000],"steps":\[{"id":1,"type":"swap","tool":"uniswapv3"}],"token\_in\_usd\_price":0,"amount\_in\_usd":"0","token\_out\_usd\_price":0,"amount\_out\_usd":"0","value":0}]} |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://docs.gmgn.ai/cn/he-zuo-api-ji-cheng-gmgn-ethbasebsc-jiao-yi-api/huo-qu-ethbasebsc-jiao-yi-ke-yong-de-lu-you.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.
