On this page

latest contributor to this doc

Last Edit:

@smk762

1inch_v6_0_classic_swap_liquidity_sources

The 1inch_v6_0_classic_swap_liquidity_sources method returns liquidity sources for classic swaps from 1inch API version 6.0.

To use methods which interface with the 1inch API, you need to set the 1inch_api url in your MM2.json file. You'll also need to set your 1inch API key as an environment variable called ONE_INCH_API_TEST_AUTH, e.g. ONE_INCH_API_TEST_AUTH="Bearer YourAPIkey".

As this feature is still experimental, you will need to build KDF from source on the dev branch with a build flag, e.g. cargo build --features test-ext-api.

Refer to the 1inch Classic Swap documentation for more information.

StructureTypeDescription
chain_idnumericChain id

StructureTypeDescription
dst_amountrational numberDestination token amount, in coins units.
protocolslistOptional. A list of standard 1inchProtocolImage objects.

POST
1inch_v6_0_classic_swap_liquidity_sources
{
  "mmrpc": "2.0",
  "userpass": "RPC_UserP@SSW0RD",
  "method": "1inch_v6_0_classic_swap_liquidity_sources",
  "params": {
    "chain_id": 1
  }
}

{
"mmrpc": "2.0",
"result": {
  "protocols": [
    {
      "id": "UNISWAP_V1",
      "title": "Uniswap V1",
      "img": "https://cdn.1inch.io/liquidity-sources-logo/uniswap.png",
      "img_color": "https://cdn.1inch.io/liquidity-sources-logo/uniswap_color.png"
    },
    {
      "id": "UNISWAP_V2",
      "title": "Uniswap V2",
      "img": "https://cdn.1inch.io/liquidity-sources-logo/uniswap.png",
      "img_color": "https://cdn.1inch.io/liquidity-sources-logo/uniswap_color.png"
    },
    {
      "id": "SUSHI",
      "title": "SushiSwap",
      "img": "https://cdn.1inch.io/liquidity-sources-logo/sushiswap.png",
      "img_color": "https://cdn.1inch.io/liquidity-sources-logo/sushiswap_color.png"
    }
  ]
}
}

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
}

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
}