Minima Docs
  • Minima DeFi Router
  • Quick Start
  • Supported Protocols and Functions
  • Swaps
    • Good to know
    • Query a Swap
    • Exclude Protocols from Route
    • Execute a Swap
  • Reference
    • API Reference
      • Querying a Swap Route
      • Deposit
      • Withdraw
Powered by GitBook
On this page
  1. Swaps

Query a Swap

Query a swap from the API

PreviousGood to knowNextExclude Protocols from Route

Last updated 2 years ago

Follow the above OpenAPI spec to query the routes endpoint, and receive a swap quote.

The return data will have the shape:

interface ReturnData {
    expectedOut: string,
    routerAddress: Address,
    details: {
        path: Address[],
        pairs: Address[],
        extras: string[],
        inputAmount: BigNumberString,
        expectedOutputAmount: BigNumberString,
        deadline: number,
        partner: number,
        sig: string
    }
}

type Address = string
type BigNumberString = string
Field
Description

expectedOut

Non decimal-adjusted output amount for the given trade. When displayed on a UI, you will have to account for decimals.

routerAddress

Address at the correct router implementation to perform the swap

details

Information necessary to perform the swap on chain. Some details, such as path, may be interesting to the end user. See for a deeper breakdown of the details` object.

Execute a Swap
get

Get a swap route from one token to another

Authorizations
Path parameters
tokenInstring · 20 byte EVM addressRequired

Input token for swap

tokenOutstring · 20 byte EVM addressRequired

Output token

amountInstring · Raw uint256 valueRequired

Total amount of input token to be traded

fromstring · 20 byte EVM addressOptional

Transaction originator. If present, will return a transaction ready to be signed

slippageinteger · BPSOptional

Allowed slippage, in bips. Can be congifigured at transaction, defaults to 10 BPS

tostring · 20 byte EVM addressOptional

Recipient of trade. Defaults to from

deadlineMsinteger · Unix SecondsOptional

Deadline for quote, defaults to 5 minutes

chainIdinteger · enumOptional

Chain to perform swap on, defaults to 42220 (CELO). More chains coming soon.

Possible values:
Responses
200
Path found Successfully
application/json
get
GET /routes HTTP/1.1
Host: router.nodefinance.org
X-API-KEY: YOUR_API_KEY
Accept: */*
200

Path found Successfully

{
  "expectedOut": "text",
  "routerAddress": "text",
  "details": {
    "path": [
      "text"
    ],
    "pairs": [
      "text"
    ],
    "extras": [
      "text"
    ],
    "inputAmount": "text",
    "expectedOutputAmount": "text",
    "deadline": 1,
    "partner": 1,
    "sig": "text"
  }
}