1inch_v6_0_classic_swap_quote
The 1inch_v6_0_classic_swap_quote method returns best quote from 1inch classic swap API version 6.0.
Refer to the 1inch Classic Swap documentation for more information.
Arguments
| Structure | Type | Description |
|---|---|---|
| base | string | Base coin name |
| rel | string | Rel coin name (must be from the same EVM chain as the base coin) |
| amount | numeric string or rational | Swap amount (in coins units) |
| fee | Float | Optional. Partner fee, percentage of src token amount will be sent to referrer address, min: 0; max: 3. Should be the same for quote and swap rpc. Default is 0 |
| protocols | string | Optional. Specify liquidity sources e.g.: &protocols=WETH,CURVE,BALANCER,…,ZRX (by default - all used) |
| gas_price | numeric string | Optional. Network price per gas, in Gwei. 1inch takes in account gas expenses to determine exchange route. Should be the same for a quote and swap |
| complexity_level | numeric | Optional. Maximum number of token-connectors to be used in a transaction, min: 0; max: 3; default: 2 |
| parts | numeric | Optional. Limit maximum number of parts each main route parts can be split into. Should be the same for a quote and swap. Default: 20; max: 100 |
| main_route_parts | numeric | Optional. Limit maximum number of main route parts. Should be the same for a quote and swap. Default: 20; max: 50 |
| gas_limit | numeric | Optional. Maximum amount of gas for a swap. Should be the same for a quote and swap. Default: 11500000; max: 11500000 |
| include_tokens_info | boolean | Optional. Return fromToken and toToken info in response (default is true) |
| include_protocols | boolean | Optional. Return used swap protocols in response (default is true) |
| include_gas | boolean | Optional. Include estimated gas in return value (default is true) |
| connector_tokens | boolean | Optional. Token-connectors can be specified via this parameter. If not set, default token-connectors will be used |
Response
| Structure | Type | Description |
|---|---|---|
| dst_amount | rational number | Destination token amount, in coins units. |
| src_token | object | Source (base) token information. A standard 1inchTokenInfo object. |
| dst_token | object | Destination (rel) token info. A standard 1inchTokenInfo object. |
| protocols | list | Optional. A list of standard 1inchProtocolInfo objects, used as liquidity sources used to route trade. |
| gas | numeric | Optional. Estimated gas. |
📌 Examples
Command
POST 1inch_v6_0_classic_swap_quote
{
"mmrpc": "2.0",
"userpass": "RPC_UserP@SSW0RD",
"method": "1inch_v6_0_classic_swap_quote",
"params": {
"base": "ETH",
"rel": "USDC-ERC20",
"amount": 0.1,
"include_tokens_info": true,
"include_protocols": true,
"include_gas": true,
"fee": 0,
"complexity_level": 3,
"gas_limit": 11500000,
"main_route_parts": 50,
"parts": 100,
"protocols": ""
}
} curl --url "http://127.0.0.1:7783" --data '{
"mmrpc": "2.0",
"userpass": "RPC_UserP@SSW0RD",
"method": "1inch_v6_0_classic_swap_quote",
"params": {
"base": "ETH",
"rel": "USDC-ERC20",
"amount": 0.1,
"include_tokens_info": true,
"include_protocols": true,
"include_gas": true,
"fee": 0,
"complexity_level": 3,
"gas_limit": 11500000,
"main_route_parts": 50,
"parts": 100,
"protocols": ""
}
}' import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"mmrpc": "2.0",
"userpass": "RPC_UserP@SSW0RD",
"method": "1inch_v6_0_classic_swap_quote",
"params": {
"base": "ETH",
"rel": "USDC-ERC20",
"amount": 0.1,
"include_tokens_info": true,
"include_protocols": true,
"include_gas": true,
"fee": 0,
"complexity_level": 3,
"gas_limit": 11500000,
"main_route_parts": 50,
"parts": 100,
"protocols": ""
}
}
response = requests.post(url, json=payload)
print(json.dumps(response.json(), indent=2)) const payload = {
"mmrpc": "2.0",
"userpass": "RPC_UserP@SSW0RD",
"method": "1inch_v6_0_classic_swap_quote",
"params": {
"base": "ETH",
"rel": "USDC-ERC20",
"amount": 0.1,
"include_tokens_info": true,
"include_protocols": true,
"include_gas": true,
"fee": 0,
"complexity_level": 3,
"gas_limit": 11500000,
"main_route_parts": 50,
"parts": 100,
"protocols": ""
}
};
const response = await fetch("http://127.0.0.1:7783", {
method: "POST",
body: JSON.stringify(payload),
});
console.log(await response.json()); <?php
$payload = <<<'JSON'
{
"mmrpc": "2.0",
"userpass": "RPC_UserP@SSW0RD",
"method": "1inch_v6_0_classic_swap_quote",
"params": {
"base": "ETH",
"rel": "USDC-ERC20",
"amount": 0.1,
"include_tokens_info": true,
"include_protocols": true,
"include_gas": true,
"fee": 0,
"complexity_level": 3,
"gas_limit": 11500000,
"main_route_parts": 50,
"parts": 100,
"protocols": ""
}
}
JSON;
$ch = curl_init("http://127.0.0.1:7783");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch);
curl_close($ch);
echo $response; package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
payload := []byte(`{"mmrpc":"2.0","userpass":"RPC_UserP@SSW0RD","method":"1inch_v6_0_classic_swap_quote","params":{"base":"ETH","rel":"USDC-ERC20","amount":0.1,"include_tokens_info":true,"include_protocols":true,"include_gas":true,"fee":0,"complexity_level":3,"gas_limit":11500000,"main_route_parts":50,"parts":100,"protocols":""}}`)
resp, err := http.Post("http://127.0.0.1:7783", "application/json", bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
} require 'net/http'
require 'json'
require 'uri'
uri = URI("http://127.0.0.1:7783")
payload = {
"mmrpc": "2.0",
"userpass": "RPC_UserP@SSW0RD",
"method": "1inch_v6_0_classic_swap_quote",
"params": {
"base": "ETH",
"rel": "USDC-ERC20",
"amount": 0.1,
"include_tokens_info": true,
"include_protocols": true,
"include_gas": true,
"fee": 0,
"complexity_level": 3,
"gas_limit": 11500000,
"main_route_parts": 50,
"parts": 100,
"protocols": ""
}
}
response = Net::HTTP.post(uri, payload.to_json, 'Content-Type' => 'application/json')
puts JSON.pretty_generate(JSON.parse(response.body)) Show Response
Response
{
"mmrpc": "2.0",
"result": {
"dst_amount": {
"amount": "347.810213",
"amount_fraction": {
"numer": "347810213",
"denom": "1000000"
},
"amount_rat": [
[
1,
[
347810213
]
],
[
1,
[
1000000
]
]
]
},
"src_token": {
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"symbol": "ETH",
"name": "Ether",
"decimals": 18,
"eip2612": false,
"isFoT": false,
"logoURI": "https://tokens.1inch.io/0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.png",
"tags": [
"crosschain",
"GROUP:ETH",
"native",
"PEG:ETH"
]
},
"dst_token": {
"address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"symbol": "USDT",
"name": "Tether USD",
"decimals": 6,
"eip2612": false,
"isFoT": false,
"logoURI": "https://tokens-data.1inch.io/images/1/0xdac17f958d2ee523a2206206994597c13d831ec7.webp",
"tags": [
"crosschain",
"GROUP:USDT",
"PEG:USD",
"tokens"
]
},
"protocols": [
[
[
{
"name": "PMM15",
"part": 100,
"fromTokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"toTokenAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7"
}
]
]
],
"gas": 174132
},
"id": null
} Show Error Responses
Error: Configuration missing
The 1inch_api url not set in your MM2.json file.
{
"mmrpc": "2.0",
"error": "No API config param",
"error_path": "rpcs.client",
"error_trace": "rpcs:137] client:105]",
"error_type": "InvalidParam",
"error_data": "No API config param",
"id": null
}Error: Authentication failure
ONE_INCH_API_TEST_AUTH environment variable not set, or incorrect.
{
"mmrpc": "2.0",
"error": "1inch API error: General API error: Unauthorized description: ",
"error_path": "rpcs.client",
"error_trace": "rpcs:140] client:152]",
"error_type": "OneInchError",
"error_data": {
"GeneralApiError": {
"error_msg": "Unauthorized",
"description": "",
"status_code": 401
}
},
"id": null
}