Skip to main content
Install the SDK, request a quote, sign one transaction, and track it to completion.

Requirements

  • Node 18 or later.
  • A wallet holding the input token on the source chain, plus enough native gas for one transaction.
  • An ethers v6 signer connected to a provider when the source chain is EVM, or a @solana/web3.js connection and signing callback when it is Solana.

Sample transaction

The steps below move 100 USDC on Arbitrum into SOL on Solana. Any pair works, so substitute your own tokens and chains once the flow runs end to end.
1

Install the SDK

The SDK wraps the Quote API and builds the transaction for you, which is why it is the shortest path to a working swap.
2

Get a quote

fetchQuote returns the routes available for the pair. By default it returns at most two, the quickest route first and the best-return route second, and when one route is both you get a single item.
slippageBps: "auto" lets Mayan set a safe level for the pair. Pass a number in basis points instead, such as 300 for 3%, when you want to control it yourself.
3

Read the quote before you sign

Show the user what they are agreeing to. These are the fields that matter in a confirmation screen.
On Swift quotes, swiftAuctionMode tells you how the output amount is determined. Mode 2 settles at or above minAmountOut, typically near expectedAmountOut. Mode 3 is exact-out, which means the user receives exactly expectedAmountOut. See Guaranteed Price for which routes support it.
4

Execute the swap

The destination address belongs to the destination chain, so this example takes a Solana address even though the funds leave from Arbitrum.
The user signs once on the source chain. Everything after that, including delivery on the destination chain, happens without further action from them.
5

Track it to completion

Pass the source transaction hash to the Explorer API and read clientStatus.
Poll until the status leaves INPROGRESS. Most swaps settle in seconds. REFUNDED means the order was not filled before its deadline and the input returned to the sender, which is covered in Refunds.

Complete example

Next steps

SDK

Quotes, execution and every supported chain.

Track Transactions

Status handling and what each state means for your interface.

Fees & Earning

Set a referrer address and earn on every swap you route.