Swaps (Solver)
import { Sodax, SpokeChainId, Token } from "@sodax/sdk";
const sodax = new Sodax();
// All swap methods are available through sodax.swap
const quote = await sodax.swaps.getQuote(quoteRequest);Using SDK Config and Constants
import { SpokeChainId, Token, Sodax } from "@sodax/sdk";
const sodax = new Sodax();
// if you want dynamic (backend API based - contains latest tokens) configuration make sure to initialize instance before usage!
// by default configuration from specific SDK version you are using is used
await sodax.initialize();
// all supported spoke chains
const spokeChains: SpokeChainId[] = sodax.config.getSupportedSpokeChains();
// using spoke chain id to retrieve supported tokens for swap (solver intent swaps)
// NOTE: empty array indicates no tokens are supported, you should filter out empty arrays
const supportedSwapTokensForChainId: readonly Token[] = sodax.swaps.getSupportedSwapTokensByChainId(spokeChainId);
// object containing all supported swap tokens per chain ID
const supportedSwapTokensPerChain: Record<SpokeChainId, readonly Token[]> = sodax.swaps.getSupportedSwapTokens();
// check if token address for given spoke chain id is supported in swaps
const isSwapSupportedToken: boolean = isSwapSupportedToken(spokeChainId, token)Available Methods
Quote & Fee Methods
Intent Creation & Execution
Intent Management
Token Approval
Utility Methods
Initialising Spoke Provider
Request a Quote
Create Intent Params
Function Parameters Structure
Get Fees
Get Partner Fee
Get Solver Fee
Get Swap Deadline
Token Approval Flow
Stellar Trustline Requirements
Estimate Gas for Raw Transactions
Create And Submit Intent Order (Swap)
Swap (Recommended Method)
Create And Submit Intent (Alternative Method - Equal to Swap)
Create Intent Only
Submit Intent to Relay API
Post Execution to Solver API
Get Intent Order
Get Filled Intent
Cancel Intent Order
Get Intent Status
Get Solved Intent Packet
Get Intent Hash
Error Handling
Error Types and Helper Functions
Handling swap (a.k.a. createAndSubmitIntent) Errors
swap (a.k.a. createAndSubmitIntent) ErrorsHandling createIntent Errors
createIntent ErrorsLast updated