2️⃣Aggregator SDK
Last updated
Last updated
The Aggregator is integrated within the NAVI SDK. Install it via npm:
To use all functions of the NAVI Aggregator, you need to initialize the NAVISDKClient
. For detailed steps on setting up NAVISDKClient
and an account, please refer to the Getting Started Section.
The NAVISDKClient.getQuote
method retrieves a quote and the route for swapping one coin to another.
fromCoinAddress
String
The token address you are swapping from (e.g., Sui-0x2::sui::SUI
).
toCoinAddress
String
The token address you want to swap to (e.g., NAVX-0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX
).
amountIn
Number
The amount of the fromCoinAddress
token to swap, specified with decimals (e.g., 1e9
for 1,000,000,000
).
apiKey
String(optional)
A string used for API authentication. Leave empty for limited access.
swapOptions
(optional) baseUrl: String
depth: Number byAmountIn: Boolean dexList: Enum List
baseUrl - The base URL for the NAVI Aggregator API.
depth - The algorithm depth for route calculation. Default is 3
.
byAmountIn - A boolean to indicate if the calculation is based on the input token amount. Please only use True
.
dexList - A list of DEXs to use for swaps. If empty, all supported DEXs will be used. Supported DEXs include:
The account.swap
method performs a complete swap action by using the best quote it got from the aggregator.
fromCoinAddress
String
The token address you are swapping from (e.g., Sui-0x2::sui::SUI
).
toCoinAddress
String
The token address you want to swap to (e.g., NAVX-0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX
).
amountIn
Number
The amount of the fromCoinAddress
token to swap, specified with decimals (e.g., 1e9
for 1,000,000,000
).
minAmountOut
Number
The minimum output amount of the target token, specified with decimals, used to validate slippage.
(e.g., 1e9
or 1,000,000,000
)
apiKey
String(optional)
A string used for API authentication. Leave empty for limited access.
swapOptions
(optional) baseUrl: String
depth: Number byAmountIn: Boolean dexList: Enum List feeOption: {fee: number, receiverAddress: String}
baseUrl - The base URL for the NAVI Aggregator API.
depth - The algorithm depth for route calculation. Default is 3
.
byAmountIn - A boolean to indicate if the calculation is based on the input token amount. Please only use True
.
feeOption: { fee: number - 0.01 represents 1% fee, receiverAddress - Address to receive the fee}
dexList - A list of DEXs to use for swaps. If empty, all supported DEXs will be used. Supported DEXs include:
The account.dryRunSwap
method simulates a swap without executing it on-chain, offering a risk-free way to preview the results.
fromCoinAddress
String
The token address you are swapping from (e.g., Sui-0x2::sui::SUI
).
toCoinAddress
String
The token address you want to swap to (e.g., NAVX-0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX
).
amountIn
Number
The amount of the fromCoinAddress
token to swap, specified with decimals (e.g., 1e9
for 1,000,000,000
).
minAmountOut
Number
The minimum output amount of the target token, specified with decimals, used to validate slippage.
(e.g., 1e9
or 1,000,000,000
)
apiKey
String(optional)
A string used for API authentication. Leave empty for limited access.
swapOptions
(optional) baseUrl: String
depth: Number byAmountIn: Boolean dexList: Enum List feeOption: {fee: number, receiverAddress: String}
baseUrl - The base URL for the NAVI Aggregator API.
depth - The algorithm depth for route calculation. Default is 3
.
byAmountIn - A boolean to indicate if the calculation is based on the input token amount. Please only use True
.
feeOption: { fee: number - 0.01 represents 1% fee, receiverAddress - Address to receive the fee}
dexList - A list of DEXs to use for swaps. If empty, all supported DEXs will be used. Supported DEXs include:
If you'd like to create your own PTB code using a quote, we've provided an easy-to-use interface to help you get started.
userAddress
String
The user Address that will run the PTB
txb
Transaction Block from Sui SDK
Sui programmable transaction blocks
minAmountOut
Number
The minimum output amount of the target token, specified with decimals, used to validate slippage.
(e.g., 1e9
or 1,000,000,000
)
coinIn
Transaction Object
The transaction Object of Coin that will be swapped.
(e.g., const coinIn = txb.splitCoins(txb.gas, [amount]);
)
quote
Quote
Quote from getQuote()
referral
Number
Used to identify the swap service provider, default to 0
This function returns a coin object from the transaction, which can be used in further PTB code.
If you'd like to create your own PTB code without managing a quote, we've provided an easy-to-use interface for developers to customize swap fee and receiving address.
userAddress
String
The user Address that will run the PTB
txb
Transaction Block from Sui SDK
Sui programmable transaction blocks
fromCoinAddress
String
The token address you are swapping from (e.g., Sui-0x2::sui::SUI
).
toCoinAddress
String
The token address you want to swap to (e.g., NAVX-0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX
).
coin
Transaction Object
The transaction Object of Coin that will be swapped.
(e.g., const coinIn = txb.splitCoins(txb.gas, [amount]);
)
amountIn
Number
The amount of the fromCoinAddress
token to swap, specified with decimals (e.g., 1e9
for 1,000,000,000
).
minAmountOut
Number
The minimum output amount of the target token, specified with decimals, used to validate slippage.
(e.g., 1e9
or 1,000,000,000
)
apiKey
String(optional)
A string used for API authentication. Leave empty for limited access.
swapOptions
(optional) baseUrl: String
depth: Number byAmountIn: Boolean dexList: Enum List feeOption: {fee: number, receiverAddress: String}
baseUrl - The base URL for the NAVI Aggregator API.
depth - The algorithm depth for route calculation. Default is 3
.
byAmountIn - A boolean to indicate if the calculation is based on the input token amount. Please only use True
.
feeOption: { fee: number - 0.01 represents 1% fee, receiverAddress - Address to receive the fee}
dexList - A list of DEXs to use for swaps. If empty, all supported DEXs will be used. Supported DEXs include:
This function returns a coin object from the transaction after swapping, which can be used in further PTB code.
Swap fee will be processed in voloSui
We’ve prepared a demo to help developers get started quickly and easily.