Skip to content

SteelSwapClient

The main client class for interacting with the SteelSwap v1 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: 'lovelace',
  tokenB: 'policy.asset',
  quantity: 10_000_000,
  hop: false,
})

Parameters:

NameTypeRequiredDescription
tokenAstringYesInput token ("lovelace" for ADA, or hex policy ID + asset name)
tokenBstringYesOutput token
quantityNumericInputYesAmount in smallest unit
predictFromOutputAmountbooleanNoCalculate input from desired output
ignoreDexesstring[]NoDEXs to exclude from routing
hopbooleanNoEnable multi-hop routing
daobject[] | string | nullNoAdditional data

Returns: Promise<SplitOutput<F> | HopSplitOutput<F>>

The response contains tokenA, tokenB, quantityA, quantityB, totalFee, totalDeposit, steelswapFee, bonusOut, price, and pools. For multi-hop swaps (hop: true), the response includes splitGroup: SplitOutput[][] and the top-level pools field is omitted — pools only exist inside each splitGroup entry.


buildSwap(params)

Build an unsigned swap transaction.

typescript
const result = await client.buildSwap({
  tokenA: 'lovelace',
  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
slippageNumericInputYesSlippage in basis points
collateralstring[]NoCollateral UTXOs
changeAddressstring | objectNoChange address
forwardAddressstringNoAddress to forward output to
pAddressstringNoPayment address
feeAdustbooleanNoAdjust fees automatically (note: API spells this "feeAdust")
ttlnumberNoTime-to-live in seconds (default: 900)

Returns: Promise<BuildSwapResponse>{ tx: string, p: boolean }


cancelSwap(params)

Create a cancellation transaction for pending swaps.

typescript
const tx = await client.cancelSwap({
  txList: [{ txHash: 'abc...', txIndex: 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<NumericOutput<F> | null>


getTokenIconUrl(token)

Get the URL for a token's icon image (PNG). No network request is made — use the returned URL directly in <img> tags and let the browser fetch and cache the image.

typescript
const iconUrl = client.getTokenIconUrl('policy.asset')
// Use in HTML: <img src={iconUrl} />

Parameters:

NameTypeRequiredDescription
tokenstringYesToken identifier (policy ID + asset name, or "lovelace")

Returns: string


findTradingPairs(token)

Find tokens that can be traded for a given token.

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

Parameters:

NameTypeRequiredDescription
tokenstringYesToken identifier (policy ID + asset name, or "lovelace")

Returns: Promise<TokenSummary[]>


getOrders(params)

Get global swap orders for a token pair.

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

Returns: Promise<OrderStatusResponse>{ orders, page, lastPage }


getPools(params)

Get DEX pool information for a token pair.

typescript
const pools = await client.getPools({
  tokenA: 'lovelace',
  tokenB: 'policy.asset',
})
// Returns Record<string, PoolSummary> (keyed by DEX name)

Returns: Promise<Record<string, PoolSummary<F>>> — A map from DEX name to pool summary.

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>{ orders, page, lastPage }


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()
console.log(stats.service) // "steelswap"
console.log(stats.totalWallets) // numeric value

Returns: Promise<SteelSwapStatistics<F> | null>

Error Handling

The client throws SteelSwapError for API errors and SteelSwapValidationError for response shape mismatches:

typescript
import { SteelSwapError, SteelSwapValidationError } from '@steelswap/steelswap-sdk'

try {
  await client.estimateSwap({ ... })
} catch (error) {
  if (error instanceof SteelSwapValidationError) {
    // API returned data that doesn't match the expected schema
    console.log('Endpoint:', error.endpoint)
    console.log('Validation error:', error.validationError)
    console.log('Raw data:', error.rawData)
  } else if (error instanceof SteelSwapError) {
    // API returned an HTTP error
    console.log('Status:', error.statusCode)
    console.log('Body:', error.responseBody)
  }
}

SteelSwapValidationError extends SteelSwapError, so existing catch (e instanceof SteelSwapError) blocks will still catch validation errors.

Cardano's DEX aggregator.