Getting Started
Installation
bash
npm install steelswap-sdkQuick Start
typescript
import { SteelSwapClient } from 'steelswap-sdk'
const client = new SteelSwapClient({
token: 'your-api-token', // Authentication token
partner: 'eternl', // Partner identifier
})
// Get available tokens
const tokens = await client.getTokens()
console.log(tokens)
// Estimate a swap (ADA to some token)
const estimate = await client.estimateSwap({
tokenA: '', // Empty string represents ADA
tokenB: 'policyId.assetName', // Replace with actual token
quantity: '10000000', // 10 ADA in lovelace (as string)
})
console.log(estimate)Basic Usage
Estimating a Swap
Before executing a swap, you can estimate the expected output:
typescript
const estimate = await client.estimateSwap({
tokenA: '', // ADA
tokenB: 'your-token-policy.asset-name',
quantity: '50000000', // 50 ADA
})
console.log('Expected output:', estimate.totalOutput) // string
console.log('Pools used:', estimate.pools)Building a Swap Transaction
Once you have an estimate, build the transaction:
typescript
const buildResult = await client.buildSwap({
tokenA: '',
tokenB: 'your-token-policy.asset-name',
quantity: '50000000',
address: 'addr1...', // Your wallet address
utxos: ['txhash#index', ...], // Your available UTXOs
slippage: '100', // 1% slippage (100 basis points)
})
// Sign the transaction with your wallet
const unsignedTx = buildResult.txWorking with Big.js
The SDK accepts string, bigint, or Big instances for numeric inputs:
typescript
import Big from 'big.js'
const amount = new Big('50000000')
const slippage = new Big('100')
const buildResult = await client.buildSwap({
tokenA: '',
tokenB: 'your-token-policy.asset-name',
quantity: amount,
address: 'addr1...',
utxos: ['txhash#0'],
slippage: slippage,
})
// Response values are strings - wrap in Big for calculations
const output = new Big(estimate.totalOutput)Getting Token Information
typescript
// List all available tokens
const tokens = await client.getTokens()
// Get USD price for a token
const price = await client.getTokenPriceUsd('policy.assetname')
// Price is in millionths (e.g., "621512" = $0.621512)
// Find tradeable pairs
const pairs = await client.findTradingPairs('policy.assetname')Checking Wallet History
typescript
const history = await client.getWalletHistory({
addresses: ['addr1...', 'addr2...'],
page: 0,
pageSize: 25,
})
console.log('Total swaps:', history.total)
console.log('Orders:', history.orders)Next Steps
- Configuration - Learn about client configuration options
- API Reference - Full API documentation