# Swap transaction simulation (ETH/Base/BSC)

After the user selects a specific route, the route information is passed to the interface as a parameter, along with the caller's wallet address and slippage value (a number above %). The interface will return the parameters required for submitting to the chain, such as inputdata, value, and gas\_limit. The interface will perform a simulated transaction. If gas\_limit = 0, it means that the transaction will fail.

#### 1. Accurate input <a href="#id-1.-jing-que-shu-ru" id="id-1.-jing-que-shu-ru"></a>

Access point: /defi/router/v1/tx/simulate\_route\_exact\_in

Request method: POST

Input parameters:

| **Parameter name** | **Parameter Description**         | **Is it necessary** | **Example**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ------------------ | --------------------------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| route              | a route returned by the interface | yes                 | { "chain\_id": 1, "to": "0x2abbEAf73456b6c0b1a1E7e32Dbd63Bf4fafAC40", "amount\_in": "100000000000000000", "amount\_out": "36565987379429384449", "input\_token\_address": "0x0000000000000000000000000000000000000000", "output\_token\_address": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984", "type": "v2", "path": \[ "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984" ], "pool\_address": "0xdafd66636e2561b0284edde37e42d192f2844d40", "factory\_address": "0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac", "fee": 3000, "steps": \[ { "id": 1, "type": "swap", "tool": "sushiswapv2" } ], "token\_in\_usd\_price": "1636.24949802", "amount\_in\_usd": "163.624949802", "token\_out\_usd\_price": 0, "amount\_out\_usd": "0", "value": "100000000000000000" } |
| slippage           | slippage                          | yes                 | 10                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| from\_address      | call wallet address               | yes                 | 0x21A2c6c70Bbbe32A9C865a305C1c490E3F40Ad36                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |

Return parameter:

| **Parameter name** | **Parameter Description** | **Example**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ------------------ | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| msg                | error message             | amountIn is required                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| code               | correct 0, incorrect -1   | 0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| data               | tx                        | {chain\_id: 1,to: '0x2abbEAf73456b6c0b1a1E7e32Dbd63Bf4fafAC40',amount\_in: '1000000000000',amount\_out: '9287306518470736046',buy\_token\_address: '0x0000000000000000000000000000000000000000',sell\_token\_address: '0xF2a79EF11ACBba33abAA7bACE0178eA66e6d80b8',type: 'v2',path: \['0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6','0xF2a79EF11ACBba33abAA7bACE0178eA66e6d80b8'],pool\_address: '0xeb56b2cc0d2eaf6e04a52dc809019431b3b040f0',fee: 3000,steps: \[ { id: 1, type: 'swap', tool: 'uniswapv2' } ],token\_in\_usd\_price: 0.001,amount\_in\_usd: '1e-9',token\_out\_usd\_price: 0.001,amount\_out\_usd: '0.009776112124706037943',value: '1000000000000',data: '0x5b9e90060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f2a79ef11acbba33abaa7bace0178ea66e6d80b8000000000000000000000000000000000000000000000000000000e8d4a5100000000000000000000000000000000000000000000000000080e32412819e38ae000000000000000000000000eb56b2cc0d2eaf6e04a52dc809019431b3b040f0',gas\_limit: '166773'} |

### 2. Accurate output <a href="#id-2.-jing-que-shu-chu" id="id-2.-jing-que-shu-chu"></a>

Access point: /defi/router/v1/tx/simulate\_route\_exact\_out

Request method: POST

Input parameters:

| **Parameter name** | **Parameter Description**                                     | **Is it necessary** | **Example**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ------------------ | ------------------------------------------------------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| route              | one of the routes returned by the available routing interface | yes                 | <p>{<br>"chain\_id": 1,<br>"to": "0x2abbEAf73456b6c0b1a1E7e32Dbd63Bf4fafAC40",<br>"amount\_in": "100000000000000000",<br>"amount\_out": "36565987379429384449",<br>"input\_token\_address": "0x0000000000000000000000000000000000000000",<br>"output\_token\_address": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",<br>"type": "v2",<br>"path": \[<br>"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",<br>"0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"<br>],<br>"pool\_address": "0xdafd66636e2561b0284edde37e42d192f2844d40",<br>"factory\_address": "0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac",<br>"fee": 3000,<br>"steps": \[<br>{<br>"id": 1,<br>"type": "swap",<br>"tool": "sushiswapv2"<br>}<br>],<br>"token\_in\_usd\_price": "1636.24949802",<br>"amount\_in\_usd": "163.624949802",<br>"token\_out\_usd\_price": 0,<br>"amount\_out\_usd": "0",<br>"value": "100000000000000000"<br>}</p> |
| slippage           | slippage                                                      | yes                 | 10                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| from\_address      | call wallet address                                           | yes                 | 0x21A2c6c70Bbbe32A9C865a305C1c490E3F40Ad36                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |

Return parameter:

| **Parameter name** | **Parameter Description** | **Example**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ------------------ | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| msg                | error message             | amountIn is required                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| code               | correct 0, Incorrect -1   | 0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| data               | tx                        | {chain\_id: 1,to: '0x2abbEAf73456b6c0b1a1E7e32Dbd63Bf4fafAC40',amount\_in: '1000000000000',amount\_out: '9287306518470736046',buy\_token\_address: '0x0000000000000000000000000000000000000000',sell\_token\_address: '0xF2a79EF11ACBba33abAA7bACE0178eA66e6d80b8',type: 'v2',path: \['0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6','0xF2a79EF11ACBba33abAA7bACE0178eA66e6d80b8'],pool\_address: '0xeb56b2cc0d2eaf6e04a52dc809019431b3b040f0',fee: 3000,steps: \[ { id: 1, type: 'swap', tool: 'uniswapv2' } ],token\_in\_usd\_price: 0.001,amount\_in\_usd: '1e-9',token\_out\_usd\_price: 0.001,amount\_out\_usd: '0.009776112124706037943',value: '1000000000000',data: '0x5b9e90060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f2a79ef11acbba33abaa7bace0178ea66e6d80b8000000000000000000000000000000000000000000000000000000e8d4a5100000000000000000000000000000000000000000000000000080e32412819e38ae000000000000000000000000eb56b2cc0d2eaf6e04a52dc809019431b3b040f0',gas\_limit: '166773'} |

<br>


---

# 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://docs.gmgn.ai/index/cooperation-api-integrate-gmgn-eth-base-bsc-trading-api/swap-transaction-simulation-eth-base-bsc.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.
