SteelSwapClient
The main client class for interacting with the SteelSwap API.
Constructor
new SteelSwapClient(config?: SteelSwapConfig)See Configuration for available options.
Swap Methods
estimateSwap(params)
Estimate a token swap and get routing information across DEXs.
const estimate = await client.estimateSwap({
tokenA: '',
tokenB: 'policy.asset',
quantity: 10_000_000,
hop: false,
})Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
tokenA | string | Yes | Input token (hex encoded, empty for ADA) |
tokenB | string | Yes | Output token (hex encoded) |
quantity | number | Yes | Amount in smallest unit |
predictFromOutputAmount | boolean | No | Calculate input from desired output |
ignoreDexes | string[] | No | DEXs to exclude from routing |
partner | Partner | No | Partner identifier |
hop | boolean | No | Enable multi-hop routing |
Returns: Promise<SplitOutput | HopSplitOutput>
buildSwap(params)
Build an unsigned swap transaction.
const result = await client.buildSwap({
tokenA: '',
tokenB: 'policy.asset',
quantity: 10_000_000,
address: 'addr1...',
utxos: ['txhash#0'],
slippage: 100,
})Parameters:
Includes all estimateSwap parameters plus:
| Name | Type | Required | Description |
|---|---|---|---|
address | string | Yes | Sender's bech32 address |
utxos | string[] | Yes | Available UTXOs |
slippage | number | Yes | Slippage in basis points |
collateral | string[] | No | Collateral UTXOs |
changeAddress | string | No | Change address |
ttl | number | No | Time-to-live in seconds (default: 900) |
Returns: Promise<BuildSwapResponse>
cancelSwap(params)
Create a cancellation transaction for pending swaps.
const tx = await client.cancelSwap({
txList: [{ txHash: 'abc...', index: 0 }],
ttl: 900,
})Returns: Promise<string> - Unsigned transaction hex
Token Methods
getTokens()
Get list of all available tokens.
const tokens = await client.getTokens()Returns: Promise<TokenSummary[]>
getTokenPriceUsd(token)
Get token price in USD (as millionths).
const price = await client.getTokenPriceUsd('policy.asset')
// 621512 = $0.621512Returns: Promise<number | null>
getTokenIcon(token)
Get base64-encoded token icon.
const icon = await client.getTokenIcon('policy.asset')Returns: Promise<string | null>
findTradingPairs(token)
Find tokens that can be traded for a given token.
const pairs = await client.findTradingPairs('policy.asset')Returns: Promise<TokenSummary[]>
getOrders(params)
Get global swap orders for a token pair.
const orders = await client.getOrders({
tokenA: '',
tokenB: 'policy.asset',
limit: 10,
})Returns: Promise<OrderStatusResponse>
getPools(params)
Get DEX pool information for a token pair.
const pools = await client.getPools({
tokenA: '',
tokenB: 'policy.asset',
})Returns: Promise<PoolSummaryResponse>
Wallet Methods
getWalletHistory(params)
Get swap history for wallet addresses.
const history = await client.getWalletHistory({
addresses: ['addr1...'],
page: 0,
pageSize: 25,
})Returns: Promise<OrderStatusResponse>
getWalletPending(params)
Get pending swap orders for wallet addresses.
const pending = await client.getWalletPending({
addresses: ['addr1...'],
})Returns: Promise<OrderStatusResponse>
notifySubmitted(params)
Notify the backend of a submitted transaction.
await client.notifySubmitted({
txHash: 'abc123...',
})Returns: Promise<void>
Utility Methods
getDexList()
Get list of available DEXs.
const dexes = await client.getDexList()
// ['sundaeswap', 'minswap', 'wingriders', ...]Returns: Promise<string[]>
getStatistics()
Get SteelSwap usage statistics.
const stats = await client.getStatistics()Returns: Promise<SteelSwapStatistics | null>
Error Handling
The client throws SteelSwapError for API errors:
import { SteelSwapError } from 'steelswap-sdk'
try {
await client.estimateSwap({ ... })
} catch (error) {
if (error instanceof SteelSwapError) {
console.log('Status:', error.statusCode)
console.log('Body:', error.responseBody)
}
}