Solver API endpoints
Error handling conventions: Direct callers of
SolverApiService(used by lower-level scripts and tests) still receiveSolverErrorResponsewithdetail.code/detail.message. The swap module'spostExecutionwraps these intoSodaxErrorwith codeEXTERNAL_API_ERROR; the originalSolverIntentErrorCodeis onresult.error.context.solverCodeand the fulldetailis onresult.error.context.solverDetail— see SWAPS.md Error Handling.
Mainnet production
URL: https://api.sodax.com/v1/intent
Mainnet staging
URL: https://staging-new-world.iconblockchain.xyz
Note Staging endpoint contains features to be potentially released and is subject to frequent change!
Overview
The SODAX solver API drives the intent-based swap feature. SwapService (accessed via sodax.swaps) is the public entry point — it delegates all HTTP communication to the stateless SolverApiService class. External callers should use SwapService rather than calling SolverApiService directly.
Three endpoints are exposed:
/quote
POST
Get a price quote for a token pair and amount
/execute
POST
Notify the solver that an intent is live on the hub chain
/status
POST
Poll the execution status of a submitted intent
Error handling
All three solver methods return Promise<Result<T, SolverErrorResponse>>. On HTTP errors or network failures, result.ok is false and result.error is a SolverErrorResponse:
SolverIntentErrorCode is an enum defined in @sodax/sdk. On unhandled exceptions the code is SolverIntentErrorCode.UNKNOWN.
To branch on solver errors, inspect result.error.detail.code:
POST /quote — Get a price quote
POST /quote — Get a price quoteCalled via SwapService.getQuote(payload).
Request (SolverIntentQuoteRequest)
SolverIntentQuoteRequest)token_src
string
Source token address on its spoke chain
token_dst
string
Destination token address on its spoke chain
token_src_blockchain_id
string
Source spoke chain relay ID (e.g. '0x38.bsc')
token_dst_blockchain_id
string
Destination spoke chain relay ID (e.g. '0xa4b1.arbitrum')
amount
bigint
Input amount in the source token's smallest unit
quote_type
string
'exact_input' or 'exact_output'
SwapService.getQuote automatically adjusts amount by the configured partner fee before forwarding to the solver, so the returned quoted_amount reflects the net output the user receives.
Token addresses are validated against the active ConfigService and translated to their hub (Sonic) equivalents before the request is sent.
Response (SolverIntentQuoteResponse)
SolverIntentQuoteResponse)quoted_amount is in the destination token's smallest unit.
Example
POST /execute — Notify solver of a live intent
POST /execute — Notify solver of a live intentCalled via SwapService.postExecution(request). Invoked automatically by SwapService.swap() after the relay packet lands on the hub — call this manually only when orchestrating swap steps yourself.
Request (SolverExecutionRequest)
SolverExecutionRequest)intent_tx_hash
Hex
Hub-chain (Sonic) transaction hash where the intent was registered
The request is retried automatically on transient network failures.
Response (SolverExecutionResponse)
SolverExecutionResponse)Example
POST /status — Poll intent execution status
POST /status — Poll intent execution statusCalled via SwapService.getStatus(request).
Request (SolverIntentStatusRequest)
SolverIntentStatusRequest)intent_tx_hash
Hex
Hub-chain (Sonic) tx hash of the intent. This is the dst_tx_hash from the relay packet returned by swap() or relayTxAndWaitPacket.
Response (SolverIntentStatusResponse)
SolverIntentStatusResponse)status
SolverIntentStatusCode
Numeric status code (see below)
fill_tx_hash
string | undefined
Solver's fill tx hash — present only when status === SolverIntentStatusCode.SOLVED (3)
SolverIntentStatusCode is an enum in @sodax/sdk. The value 3 (SOLVED) indicates the solver has filled the intent.
Example
Full swap flow
SwapService.swap() orchestrates the complete lifecycle. The steps below show what happens internally and where each solver endpoint is called:
Polling intent status and waiting for fill delivery are separate steps the caller performs after swap() returns:
Complete example
Chain keys
Use ChainKeys.* from @sodax/sdk for all chain references. SpokeChainKey is the union of ChainKeys values. XToken.chainKey (not xChainId) carries the chain key on token objects.
Intent.srcChain and Intent.dstChain are bigint relay chain IDs (not chain keys) — use getIntentRelayChainId(chainKey) from @sodax/sdk to convert between them.
Related source files
packages/sdk/src/swap/SolverApiService.ts— stateless HTTP client for the three solver endpointspackages/sdk/src/swap/SwapService.ts— public service facade; usesodax.swapspackages/sdk/src/swap/EvmSolverService.ts— EVM-level intent ABI encoding/decoding and event parsingpackages/sdk/docs/SWAPS.md— full swap feature documentationpackages/sdk/docs/ARCHITECTURE_REFACTOR_SUMMARY.md— v2 architecture reference (chain keys,Result<T>, error convention)packages/sdk/CHAIN_ID_MIGRATION.md— mapping from old*_CHAIN_IDconstants toChainKeys.*
Last updated