Pathfinder API - Requesting a Route

Requesting a Route

A route request JSON object contains the following fields:

  • chain_id: ID number of the chain to search

  • amount_in: Hex-string formatted swap amount in

  • token_in: Hex-string formatted swap input token address

  • token_out: Hex-string formatted swap output token address

  • max_hops: The maximum number of hops a trade may use between input and output

  • min_splits: The minimum number of split paths to accept for a trade route

  • max_splits: The maximum number of split paths to accept for a trade route

  • count: The number of best routes to return (currently returns 1 regardless of input)

Sample CURL request

curl -X POST https://api.braindex.io/app/myAppId \
    -H "Content-Type: application/json" \
    -d '{
	    	"chain_id":1284,
	    	"amount_in":"0x0579a814e10a740000",
	    	"token_in":"0xAcc15dC74880C9944775448304B263D191c6077F",
	    	"token_out":"0x818ec0a7fe18ff94269904fced6ae3dae6d6dc0b",
	    	"max_hops":3,
	    	"min_splits":0,
	    	"max_splits":3,
	    	"count":5
    	}'

Route Request Parameters In-Depth

In order to preserve pathfinder performance and to prevent unnecessarily deep searches, we have defined several parameter ranges for the route request object.

chain_id

You must submit a chain_id parameter in number format with your query -- this includes single-chain protocols. For multi-chain protocols, you may change your chain_id to route through your protocols' pools on the corresponding chain. You do not have to change your DEX ID.

Requests for routes via a chain on which you have no pools will result in a HTTP error 469: No Route Found.

amount_in

amount_in must be a hex-string formatted integer value of max uint128.

token_in

token_in must be a valid token for the chain_id submitted along with the request.

Requests for routes with invalid tokens will result in a HTTP error 469: No Route Found.

token_out

token_out must be a valid token for the chain_id submitted along with the request.

Requests for routes with invalid tokens will result in a HTTP error 469: No Route Found.

max_hops

For performance reasons, max_hops is capped at 4 for most networks.

Requests for routes with max_hops too high will result in HTTP error 403: Forbidden.

min_splits

min_splits must be smaller than max_splits.

Requests for routes with min_splits larger than max_splits will result in HTTP error 403: Forbidden.

max_splits

For performance reasons, max_splits is capped at 4 for most networks.

Requests for routes with max_splits too high will result in HTTP error 403: Forbidden.

count

While a count value must be passed along with the JSON object, the parameter is currently unused internally and the route request will return a single route regardless of count.

Last updated