API
This section will walk you through the required steps to get quote and submit a swap using Mosaic Aggregator.
Last updated
This section will walk you through the required steps to get quote and submit a swap using Mosaic Aggregator.
Last updated
To retrieve the best swap rate, send the following HTTP request to get a quote:
This will return the best available quote for swapping the source asset (AptosCoin) into the destination asset (USDC) based on current market conditions.
Here is a detailed guide using Typescript:
Import the required libraries and initialize your connection to the Aptos testnet using the AptosConfig
and Aptos
objects from the @aptos-labs/ts-sdk
. This sets up your environment for making requests to the Mosaic Aggregator API and interacting with Aptos.
Here, you will create an Aptos account using the user's private key. You need to fill in your own private key when initializing the account.
Specify the assets to swap and the amount (in APTOS decimals):
Retrieve the best swap rate by making a GET request to the Mosaic API.
Once you have the quote, you use the returned data (function, type arguments, and function arguments) to build a transaction that will perform the swap.
After building the transaction, you sign it using the user's private key and submit the transaction to the Aptos blockchain. The transaction hash will be logged, which can be used to check the transaction status on the explorer.
By following this guide, you will be able to integrate the Mosaic Aggregator API for performing token swaps on the Aptos network. For further assistance or inquiries, feel free to reach out to the Mosaic support team on Discord or Telegram. \
All requests to Mosaic’s API must include an X-API-Key
header for authentication. The API key is used to track your usage and ensure secure access. To obtain an API key, please contact the Mosaic team via Discord or Telegram or
Find the best quote to swap with Mosaic Aggregator
/v1/quote
0x1::aptos_coin::AptosCoin
0x275f508689de8756169d1ee02d889c777de1cebda3a7bbcce63ba8a27c563c6f::tokens::USDC
Amount of the token to be swapped
100000000
Whether the fee is in the source asset
true
Fee in basis points
30
Fee receiver address
0x0145f3f2a68d9bcf8f5a1ae2ca34760c76a9742c7b22b36a54f706dd587cc26c
Slippage tolerance in basis points
10
Sender address
0x0145f3f2a68d9bcf8f5a1ae2ca34760c76a9742c7b22b36a54f706dd587cc26c
Receiver address. If not provided, the sender address will be used.
0x0145f3f2a68d9bcf8f5a1ae2ca34760c76a9742c7b22b36a54f706dd587cc26c