Rooster Protocol
HomeSwapAdd LiquidityTokens
  • Overview
    • RWA Liquidity Hub
    • AMM
    • Flywheel
    • Tokenomics
      • veROOSTER
      • Token Distribution
  • Get Started
    • For Traders
    • For LPs
      • Yield Accruing Positions
    • For RWAs
      • How Rooster Supports Nest Vaults on Plume
  • Developers
    • Contract Addresses
    • Routes API
    • Call Data API
    • Security
  • Community and Support
    • Protocol Updates
    • Community Articles
    • Contact the Team
    • Brand Assets
Powered by GitBook
On this page
  1. Developers

Routes API

PreviousContract AddressesNextCall Data API

Last updated 1 month ago


RPC Calls to Quoter

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

function calculateMultiHopSwap(bytes memory path, uint256 amount, bool exactOutput)
    external
    returns (uint256 returnAmount, uint256 gasEstimate);

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).

With the paths, a user can use RPC calls to the contract and calculateMultiHopSwap function to get the prices.

MaverickV2Quoter
  • POSTCalculate Optimal Swap Paths
  • RPC Calls to Quoter

Calculate Optimal Swap Paths

post

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.

Body
amountstring · decimalRequired

The amount of the input token to swap, represented as a string to preserve precision.

Example: 10.34
inputTokenAddressstring · addressRequired

The contract address of the token being swapped FROM.

Example: 0xEa237441c92CAe6FC17Caaf9a7acB3f953be4bd1Pattern: ^0x[a-fA-F0-9]{40}$
outputTokenAddressstring · addressRequired

The contract address of the token being swapped TO.

Example: 0xdddD73F5Df1F0DC31373357beAC77545dC5A6f3FPattern: ^0x[a-fA-F0-9]{40}$
Responses
200
Successfully calculated and returned the top swap paths.
application/json
400
Bad Request - Missing or invalid required parameters.
application/json
500
Internal Server Error - Failed to calculate swap routes.
application/json
post
POST /api/swap HTTP/1.1
Host: api.rooster-protocol.xyz
Content-Type: application/json
Accept: */*
Content-Length: 149

{
  "amount": "10.34",
  "inputTokenAddress": "0xEa237441c92CAe6FC17Caaf9a7acB3f953be4bd1",
  "outputTokenAddress": "0xdddD73F5Df1F0DC31373357beAC77545dC5A6f3F"
}
{
  "paths": [
    [
      "0x4a14398c5c5b4b7913954cb82521fb7afa676314",
      false
    ],
    [
      "0x10b02da17f82f263252c6ac9e2f785cb9fe4d544",
      false,
      "0x8872127381209fd106e48666b2ecad4a151c9ea9",
      true
    ],
    [
      "0x098dbf700286109e3bcd1465f00a6554488ec148",
      false,
      "0xb1ac405847eaa909a67a7e5d67d61115303f6fa0",
      false
    ]
  ]
}