Skip to content

SteelSwapClient

The main client class for interacting with the SteelSwap API.

Constructor

typescript
new SteelSwapClient(config?: SteelSwapConfig)

See Configuration for available options.

Swap Methods

estimateSwap(params)

Estimate a token swap and get routing information across DEXs.

typescript
const estimate = await client.estimateSwap({
  tokenA: '',
  tokenB: 'policy.asset',
  quantity: 10_000_000,
  hop: false,
})

Parameters:

NameTypeRequiredDescription
tokenAstringYesInput token (hex encoded, empty for ADA)
tokenBstringYesOutput token (hex encoded)
quantitynumberYesAmount in smallest unit
predictFromOutputAmountbooleanNoCalculate input from desired output
ignoreDexesstring[]NoDEXs to exclude from routing
partnerPartnerNoPartner identifier
hopbooleanNoEnable multi-hop routing

Returns: Promise<SplitOutput | HopSplitOutput>


buildSwap(params)

Build an unsigned swap transaction.

typescript
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:

NameTypeRequiredDescription
addressstringYesSender's bech32 address
utxosstring[]YesAvailable UTXOs
slippagenumberYesSlippage in basis points
collateralstring[]NoCollateral UTXOs
changeAddressstringNoChange address
ttlnumberNoTime-to-live in seconds (default: 900)

Returns: Promise<BuildSwapResponse>


cancelSwap(params)

Create a cancellation transaction for pending swaps.

typescript
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.

typescript
const tokens = await client.getTokens()

Returns: Promise<TokenSummary[]>


getTokenPriceUsd(token)

Get token price in USD (as millionths).

typescript
const price = await client.getTokenPriceUsd('policy.asset')
// 621512 = $0.621512

Returns: Promise<number | null>


getTokenIcon(token)

Get base64-encoded token icon.

typescript
const icon = await client.getTokenIcon('policy.asset')

Returns: Promise<string | null>


findTradingPairs(token)

Find tokens that can be traded for a given token.

typescript
const pairs = await client.findTradingPairs('policy.asset')

Returns: Promise<TokenSummary[]>


getOrders(params)

Get global swap orders for a token pair.

typescript
const orders = await client.getOrders({
  tokenA: '',
  tokenB: 'policy.asset',
  limit: 10,
})

Returns: Promise<OrderStatusResponse>


getPools(params)

Get DEX pool information for a token pair.

typescript
const pools = await client.getPools({
  tokenA: '',
  tokenB: 'policy.asset',
})

Returns: Promise<PoolSummaryResponse>

Wallet Methods

getWalletHistory(params)

Get swap history for wallet addresses.

typescript
const history = await client.getWalletHistory({
  addresses: ['addr1...'],
  page: 0,
  pageSize: 25,
})

Returns: Promise<OrderStatusResponse>


getWalletPending(params)

Get pending swap orders for wallet addresses.

typescript
const pending = await client.getWalletPending({
  addresses: ['addr1...'],
})

Returns: Promise<OrderStatusResponse>


notifySubmitted(params)

Notify the backend of a submitted transaction.

typescript
await client.notifySubmitted({
  txHash: 'abc123...',
})

Returns: Promise<void>

Utility Methods

getDexList()

Get list of available DEXs.

typescript
const dexes = await client.getDexList()
// ['sundaeswap', 'minswap', 'wingriders', ...]

Returns: Promise<string[]>


getStatistics()

Get SteelSwap usage statistics.

typescript
const stats = await client.getStatistics()

Returns: Promise<SteelSwapStatistics | null>

Error Handling

The client throws SteelSwapError for API errors:

typescript
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)
  }
}