Configure SDK
Learn how to configure the Sodax SDK for your application. The SDK supports both Swaps (intent-based solver swaps) and Money Market (cross-chain lending and borrowing) services. Both configurations are optionalβyou can use just the features you need.
Basic Configuration
Default Configuration
Initialize the SDK with default Sonic mainnet configurations (no fees):
import { Sodax } from '@sodax/sdk';
const sodax = new Sodax();Dynamic Configuration
For the latest tokens and chains, initialize the instance before usage. By default, the SDK uses configuration from the specific SDK version you're using:
await sodax.initialize();Partner Fees
Configure partner fees for swaps and/or money market operations. See Monetize SDK for detailed fee configuration options.
import { Sodax, PartnerFee } from '@sodax/sdk';
const partnerFee: PartnerFee = {
address: '0x0000000000000000000000000000000000000000', // address to receive fee
percentage: 100, // 100 = 1%, 10000 = 100%
};
// Fee on swaps only
const sodaxWithSwapFees = new Sodax({
swap: { partnerFee },
});
// Fee on money market only
const sodaxWithMoneyMarketFees = new Sodax({
moneyMarket: { partnerFee },
});
// Fees on both features
const sodaxWithFees = new Sodax({
swap: { partnerFee },
moneyMarket: { partnerFee },
});Custom Configuration
Partner Fees
Partner fees can be defined as a percentage or a definite token amount:
Solver Configuration
Solver config is optional and required only for intent-based swaps. You can use a custom config or the default one (based on hub chain IDβdefaults to Sonic).
Money Market Configuration
Money market config is optional and required only for cross-chain lending and borrowing.
Hub Provider Configuration
Configure the hub chain provider for cross-chain operations:
Complete Custom Configuration
Combine all configurations:
Additional Resources
SDK constants.ts - Additional static constants and configurations
Monetize SDK - Detailed fee configuration guide
Last updated