Lend / Borrow (Money Market)
import { Sodax, type SpokeChainId, type Token } from "@sodax/sdk";
const sodax = new Sodax();
// All money market methods are available through sodax.moneyMarket
const supplyResult = await sodax.moneyMarket.supply(supplyParams, spokeProvider);Using SDK Config and Constants
await sodax.initialize();import { Sodax, type SpokeChainId, type Token, type Address } from "@sodax/sdk";
const sodax = new Sodax();
await sodax.initialize(); // Initialize for dynamic config (optional)
// All supported spoke chains (general config)
const spokeChains: SpokeChainId[] = sodax.config.getSupportedSpokeChains();
// Get supported money market tokens for a specific chain
const supportedMoneyMarketTokens: readonly Token[] = sodax.moneyMarket.getSupportedTokensByChainId(chainId);
// Get all supported money market tokens per chain
const allMoneyMarketTokens = sodax.moneyMarket.getSupportedTokens();
// Get all supported reserves (hub chain token addresses, i.e. money market on Sonic chain)
const supportedReserves: readonly Address[] = sodax.moneyMarket.getSupportedReserves();
// Check if token address for given spoke chain id is supported (through config service)
const isMoneyMarketSupportedToken: boolean = sodax.config.isMoneyMarketSupportedToken(chainId, token);
// Alternative: Access through config service
const moneyMarketTokensFromConfig: readonly Token[] = sodax.config.getSupportedMoneyMarketTokensByChainId(chainId);
const allMoneyMarketTokensFromConfig = sodax.config.getSupportedMoneyMarketTokens();Available Methods
Token & Reserve Configuration
Allowance & Approval
Money Market Operations
Data Retrieval & Formatting
Utility Methods
Initialising Spoke Provider
Function Parameters Structure
Allowance and Approval
Checking Allowance
Setting Allowance
Supported Actions by Provider Type
Stellar Trustline Requirements
Complete Example
Estimate Gas for Raw Transactions
Supply Tokens
Borrow Tokens
Withdraw Tokens
Repay Tokens
Error Handling
Error Types
Using Error Type Guards
Handling Money Market Operation Errors
Handling Create Intent Errors
Handling Allowance and Approval Errors
Error Data Structure
Best Practices for Error Handling
Data Retrieval and Formatting
Available Data Methods
Reserve Data
User Data
E-Mode Data
Data Formatting
Formatting Reserve Data
Formatting User Data
Complete Example: Fetching and Formatting Data
Step-by-Step Data Retrieval Process
1. Fetch Raw Data
2. Build Formatting Requests
3. Format Data
Data Structure Examples
Formatted Reserve Data
Formatted User Summary
Utility Functions
Last updated