@steelswap/steelswap-sdk
v1.7.1
Published
SDK for the SteelSwap DEX Aggregator API on Cardano
Maintainers
Readme
@steelswap/steelswap-sdk
TypeScript SDK for the SteelSwap DEX Aggregator API on Cardano.
Installation
npm install @steelswap/steelswap-sdkQuick Start
import { SteelSwapClient } from '@steelswap/steelswap-sdk'
const client = new SteelSwapClient({
token: process.env.STEELSWAP_TOKEN,
partner: 'examplepartner',
})
// Get available tokens
const tokens = await client.getTokens()
// Estimate a swap (ADA to token)
const estimate = await client.estimateSwap({
tokenA: '', // Empty string = ADA
tokenB: 'policyId.assetName',
quantity: '10000000', // 10 ADA in lovelace
})
console.log('Expected output:', estimate.quantityB)Configuration
const client = new SteelSwapClient({
// API URL (default: https://api.steelswap.io)
baseUrl: process.env.STEELSWAP_API_URL,
// Authentication token (sent as 'token' header)
token: process.env.STEELSWAP_TOKEN,
// Partner ID (auto-injected into swap requests)
partner: 'examplepartner',
// Output format for numeric values
// 'string' (default) | 'number' | 'bigint' | 'Big'
numericFormat: 'string',
// Request timeout in ms (default: 30000)
timeout: 30000,
})API Methods
Swap Operations
// Estimate swap routing
const estimate = await client.estimateSwap({
tokenA: '',
tokenB: 'policy.asset',
quantity: '10000000',
hop: false, // Enable multi-hop routing
})
// Build unsigned transaction
const { tx } = await client.buildSwap({
tokenA: '',
tokenB: 'policy.asset',
quantity: '10000000',
address: 'addr1...',
utxos: ['txhash#0', ...],
slippage: '100', // 1% in basis points
})
// Cancel pending swap
const cancelTx = await client.cancelSwap({
txList: [{ txHash: 'abc...', txIndex: 0 }],
ttl: 900,
})Token Operations
const tokens = await client.getTokens()
const price = await client.getTokenPriceUsd('policy.asset')
const iconUrl = client.getTokenIconUrl('policy.asset')
const pairs = await client.findTradingPairs('policy.asset')
const orders = await client.getOrders({ tokenA: '', tokenB: 'policy.asset' })
const pools = await client.getPools({ tokenA: '', tokenB: 'policy.asset' })Wallet Operations
const history = await client.getWalletHistory({
addresses: ['addr1...'],
page: 0,
pageSize: 25,
})
const pending = await client.getWalletPending({
addresses: ['addr1...'],
})
await client.notifySubmitted({ txHash: 'abc123...' })Utility
const dexes = await client.getDexList()
const stats = await client.getStatistics()Numeric Handling
Input: All numeric parameters accept string | number | bigint | Big
import Big from 'big.js'
// All valid
await client.estimateSwap({ ..., quantity: 10000000 })
await client.estimateSwap({ ..., quantity: '10000000' })
await client.estimateSwap({ ..., quantity: 10000000n })
await client.estimateSwap({ ..., quantity: new Big('10000000') })Output: Controlled by numericFormat config
// Get Big.js instances for calculations
const client = new SteelSwapClient({ numericFormat: 'Big' })
const estimate = await client.estimateSwap({ ... })
const withFee = estimate.quantityB.times('0.997')API Environments
| Environment | URL | Clients |
|-------------|-----|---------|
| v1 Production | https://api.steelswap.io (default) | SteelSwapClient |
| v1 Development | https://apidev.steelswap.io | SteelSwapClient |
| v2 (default) | https://cicdapi.steelswap.io | SteelSwapV2Client, SteelSwapV2OTCClient, AnalyticsClient |
API Reference (source of truth)
The v2 (cicd) endpoints implemented by this SDK are documented by the API itself:
- ReDoc: https://cicdapi.steelswap.io/redoc
- OpenAPI spec (machine-readable): https://cicdapi.steelswap.io/openapi.json
- Swagger UI at
/docsis currently down — use ReDoc or the raw spec above instead
The v1 endpoints are documented at https://apidev.steelswap.io/openapi.json.
Documentation
Full documentation: https://github.com/SteelSwap/steelswap-sdk
License
MIT
