Quick Start

Initialize SDK

import { 
  initMainnetAggV2SDK, 
  initMainnetAggV2SDKWithMultiProviders,
  AggProvider 
} from '@ferra-labs/aggregator';

// Single provider initialization
const sdk = initMainnetAggV2SDK(
  AggProvider.CETUS,  // Primary provider
  "0xYourSuiAddress"  // Sender address
);

// Multi-provider initialization (for best price comparison)
const multiSdk = initMainnetAggV2SDKWithMultiProviders(
  [AggProvider.CETUS, AggProvider.FLOWX, AggProvider.BLUEFIN],
  "0xYourSuiAddress"
);

Get Quote and Execute Swap

API Reference

SDK Initialization

initMainnetAggV2SDK(provider, sender, sdkOptions?)

Initialize SDK with a single provider.

Parameter
Type
Description

provider

AggProvider

Primary provider (CETUS, FLOWX, BLUEFIN)

sender

string

Sender's Sui address

sdkOptions

Partial<SdkV2Options>

Optional SDK configuration

initMainnetAggV2SDKWithMultiProviders(providers, sender, sdkOptions?)

Initialize SDK with multiple providers for best price discovery.

Parameter
Type
Description

providers

AggProvider[]

Array of providers to enable

sender

string

Sender's Sui address

sdkOptions

Partial<SdkV2Options>

Optional SDK configuration

SDK Options

AggSwapV2Module

swap(params, slippageBps?)

Execute a swap transaction.

Returns: Promise<Transaction> - Sui transaction ready for signing

swapCustomizable(params, slippageBps?, tx?)

Execute a swap with customizable output handling. Returns both the transaction and output coin for further composition.

Use case: When you need to use the output coin in subsequent transaction steps (e.g., providing liquidity, staking).

swapWithInputCustomizable(params, slippageBps?, tx?)

Execute a swap with both input and output coins customizable. Input coin is passed as TransactionObjectArgument.

Use case: When input coin comes from a previous transaction step.

Transaction Composition Example

Build complex DeFi transactions by chaining swap operations:

Provider Selection Guide

Provider
Best For
Considerations

Cetus

Large trades, stable pairs

Deep liquidity, reliable routes

FlowX

DEX aggregation

Multi-hop optimization

Bluefin

Perpetuals, derivatives

Specialized markets

Configuration

Mainnet Configuration

Custom RPC Endpoint

Migration from V1

Key Changes

V1
V2

Internal routing

External provider quotes

Single DEX support

Multi-provider aggregation

FerraAggregatorSDK

FerraAggregatorV2SDK

initMainnetSDK()

initMainnetAggV2SDK()

Migration Steps

  1. Update imports to use V2 SDK

  2. Initialize with provider selection

  3. Fetch quotes from external providers

  4. Pass provider-specific quote data to swap functions

Support

License

MIT License - see LICENSE file for details.

Last updated