Aggregator Swap Integration

Architecture diagram

Get quote

GET:

Retrieves the optimal trading route and price quote between two tokens

Parameters

  • tokenIn : token input address

  • tokenOut: token output address

  • amountIn: amount of token input (in wei)

  • exchanges (optional): comma-separated list of decentralized exchange ids used in the route, if it will be blank so the system will route through all existing liquid sources availability.

  • gasPrice (optional): custom gas price (in wei)

Response

  • amountIn: amount input in wei

  • amountInUsd: amount input in USD

  • amountOut: amount output in wei

  • amountOutUsd: amount output in USD

  • splits

    • amountIn: amount token in (in wei)

    • amountOut: amount token out (in wei)

    • swaps: paths in detailed

Get swap data

GET:

Generates the transaction data needed to execute the swap through the router contract

Parameters

Includes all Quote API parameters, plus:

  • receiver: recipient address for output token

  • slippage: maximum acceptable slippage (0-1, e.g., 0.01 = 1%)

  • minAmountOut: custom minimum acceptable output amount

  • deadline(optional): transaction deadline in Unix seconds (default: now + 20 mins)

Response

Includes Quote API response, plus:

  • tx

    • data: encoded calldata for router

    • router: router contract address

Code example

Resources

Swagger:

https://agg-api.nep.finance/v1/swell/swagger/index.html

Last updated