
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
navi-aggregator-sdk-dev
Advanced tools
This TypeScript SDK simplifies integration with decentralized exchanges (DEXs) on the Sui blockchain, allowing developers to execute token swaps in Move-based PTB applications or directly leverage the SDK for optimized token swaps across multiple sources for the best prices.
For full details, please see the Documentation.
npm i navi-aggregator-sdk
Pass in the fromCoin, toCoin, and amountIn. The output will be the quote for the swap.
import { getRoute } from 'navi-aggregator-sdk';
const quote = await getRoute(fromCoin: string, toCoin: string, amountIn: number | string | bigint);
console.log(`Amount In: ${quote.amount_in}, Amount Out: ${quote.amount_out}`);
console.log(`Routes: ${quote.routes}`);
Pass in a coinObject as the coin parameter. The output will be the final coin object after the swap.
import { swapPTB } from 'navi-aggregator-sdk';
const coinB = await swapPTB(
address: string,
txb: Transaction,
fromCoin: string,
toCoin: string,
coin: TransactionResult,
amountIn: number | string | bigint,
minAmountOut: number,
swapOptions: SwapOptions = { referer: 'https://www.navi.ag/', dexList: [], byAmountIn: true, depth: 3 }
)
The swap function is a wrapper for the getRoute and swapPTB functions. Set isDryRun
from swapOptions
to true to get a dry run result and balance changes. It will submit the transaction and return the result if a keypair
is provided.
import { swap } from 'navi-aggregator-sdk';
const result = await swap(
address: string,
client: SuiClient,
fromCoin: string,
toCoin: string,
amountIn: number | string | bigint,
minAmountOut: number,
swapOptions: SwapOptions = { referer: 'https://www.navi.ag/', dexList: [], byAmountIn: true, depth: 3, isDryRun: true, keypair: undefined }
);
See the demo for examples of how to use the SDK with NAVI-SDK.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.