Getting Started
Installation
bash
npm install @steelswap/steelswap-sdkQuick Start (v1 API)
typescript
import { SteelSwapClient } from '@steelswap/steelswap-sdk'
const client = new SteelSwapClient({
token: 'your-api-token', // Authentication token
partner: 'examplepartner', // 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: 'lovelace', // Use "lovelace" for ADA
tokenB: 'policyId.assetName', // Replace with actual token
quantity: '10000000', // 10 ADA in lovelace (as string)
})
console.log(estimate)Quick Start (v2 API)
typescript
import { SteelSwapV2Client, C3PriceClient } from '@steelswap/steelswap-sdk'
// v2 Orders & Partner Management
const v2Client = new SteelSwapV2Client({
bearerToken: 'your-v2-bearer-token',
})
const orders = await v2Client.getOpenOrders({
addresses: ['addr1...'],
})
// C3 Price & Chart Data
const priceClient = new C3PriceClient({
bearerToken: 'your-c3-bearer-token',
})
const price = await priceClient.getCurrentPrice({ policy: 'policyId.assetName' })
console.log(price.current_price)Basic Usage
Estimating a Swap
Before executing a swap, you can estimate the expected output:
typescript
const estimate = await client.estimateSwap({
tokenA: 'lovelace', // ADA
tokenB: 'your-token-policy.asset-name',
quantity: '50000000', // 50 ADA
})
console.log('Output quantity:', estimate.quantityB)
console.log('Total fee:', estimate.totalFee)
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: 'lovelace',
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, number, 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: 'lovelace',
tokenB: 'your-token-policy.asset-name',
quantity: amount,
address: 'addr1...',
utxos: ['txhash#0'],
slippage: slippage,
})
// Response values are strings by default - wrap in Big for calculations
const output = new Big(estimate.quantityB)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('Page:', history.page, 'of', history.lastPage)
console.log('Orders:', history.orders)Next Steps
- Configuration - Client configuration options for v1, v2, and C3 clients
- API Reference - Full v1 API documentation
- v2 Client - v2 Orders & Partner Management
- C3 Price Client - Token prices & chart data