Routes API
Accepts an input token, output token, and the amount to swap. Queries available liquidity pools, calculates potential 1-hop, 2-hop, and 3-hop paths, checks for sufficient liquidity for the given amount, scores the paths based on liquidity, volume, and fees, and returns the top 5 ranked paths.
The amount of the input token to swap, represented as a string to preserve precision.
10.34The contract address of the token being swapped FROM.
0xEa237441c92CAe6FC17Caaf9a7acB3f953be4bd1Pattern: ^0x[a-fA-F0-9]{40}$The contract address of the token being swapped TO.
0xdddD73F5Df1F0DC31373357beAC77545dC5A6f3FPattern: ^0x[a-fA-F0-9]{40}$Successfully calculated and returned the top swap paths.
Bad Request - Missing or invalid required parameters.
Internal Server Error - Failed to calculate swap routes.
RPC Calls to Quoter
With the paths, a user can use RPC calls to the MaverickV2Quoter contract and calculateMultiHopSwap function to get the prices.
calculateMultiHopSwap
Calculates a multihop swap and returns the resulting amount and estimated gas. The gas estimate is only a rough estimate and may not match a swap's gas.
Copy
Parameters
path
bytes
The path of pools to swap through. Path is given by an packed array of (pool, tokenAIn) tuples. So each step in the path is 160 + 8 = 168 bits of data. e.g. path = abi.encodePacked(pool1, true, pool2, false);
amount
uint256
The raw input amount. (e.g. 1.0 in an 18-decimal token will be 1e18)
exactOutput
bool
A boolean indicating whether amount is the desired input amount (false) or the desired output amount (true).
Last updated