Initialize mainnetAggregator client. There are two ways to initialize the aggregator client. One is straightforward, using the default mainnet client, while the other supports a high level of customization.
Example
Fast create mainnet aggregator client default.
import { AggregatorClient } from "@cetusprotocol/aggregator-sdk"
const client = new AggregatorClient()
(Enhance) Customer create aggregator client by your self rpc node.
import { AggregatorClient } from "@cetusprotocol/aggregator-sdk"
import type { SuiClient } from '@mysten/sui/client';
import dotenv from 'dotenv'
dotenv.config()
// used to do simulate swap and swap
// https://fullnode.mainnet.sui.io:443
const fullNodeURL = process.env.SUI_RPC!
const suiClient = new SuiClient({
url: fullNodeURL,
})
// provider by cetus
const aggregatorURL = "https://api-sui.cetus.zone/router_v2/find_routes"
// set your wallet address, used to do simulate
const wallet = "0x..."
// import { Env } from "@cetusprotocol/aggregator-sdk"
// Currently, we provide full support for Mainnet,
// while Testnet is only supported for Cetus and DeepBook providers.
const client = new AggregatorClient(aggregatorURL, wallet, suiClient, Env.Mainnet)