Prerequisites

1. NPM install

npm install @cetusprotocol/aggregator-sdk

2. Setting Up Configuration

Initialize mainnet Aggregator 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.

circle-check

Example

  1. Fast create mainnet aggregator client default.

import { AggregatorClient } from "@cetusprotocol/aggregator-sdk"

const client = new AggregatorClient({})
  1. (Enhance) Customer create aggregator client by your self rpc node.

import { AggregatorClient } from "@cetusprotocol/aggregator-sdk"
import { SuiGrpcClient } from "@mysten/sui/grpc"
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 SuiGrpcClient({
    network: 'mainnet',
    baseUrl: fullNodeURL,                                                                                                                                            
})

// 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({
  // endpoint, // If you do not have a exclusive aggregator api domain,just use cetus default aggregator endpoints.
  signer: wallet,
  client: suiClient,
  env: Env.Mainnet,
  pythUrls?: ["YOUR_PYTH_URL", "ANOTHER_PYTH_URL"], // Optional. Custom Pyth price feed URLs. Defaults to null (uses built-in endpoints).
  partner?: "YOUR_CETUS_CLMM_PARTNER_ID", // Optional. Partner ID for CLMM fee sharing. Set once during initialization instead of per swap. Defaults to null (no fee sharing).
  cetusDlmmPartner?: "YOUR_CETUS_DLMM_PARTNER_ID", // Optional. Partner ID for DLMM fee sharing. Defaults to null (no fee sharing).
  overlayFeeRate?: 0.01, // Optional. Overlay fee rate (0.01 represents 1%). Defaults to 0 (no overlay fee).
  overlayFeeReceiver?: "0x..", // Optional. Address to receive the overlay fees. Defaults to null. Required if overlayFeeRate is set.
})

Notes: Some providers, such as HaedalHMM, Metastable, Steamm Omm, SevenK, rely on Pyth oracle prices when build transactions. Currently, we have a default configuration that connects to Pyth's publicly available node. However, if you frequently build transactions, we recommend setting up a private Pyth node interface as an additional backup. This will ensure uninterrupted access to those providers, even if the public node experiences occasional downtime.

  1. (Project integration) Increase QPS limit through specific domain name and API key

Last updated