npm package: @steelswap/steelswap-sdk
Description: SDK for the SteelSwap DEX Aggregator API on Cardano
Author: SteelSwap
Latest version: 1.3.3

# @steelswap/steelswap-sdk

TypeScript SDK for the [SteelSwap](https://steelswap.io) DEX Aggregator API on Cardano.

## Installation

```bash
npm install @steelswap/steelswap-sdk
```

## Quick Start

```typescript
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.totalOutput)
```

## Configuration

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

```typescript
// 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...', index: 0 }],
  ttl: 900,
})
```

### Token Operations

```typescript
const tokens = await client.getTokens()
const price = await client.getTokenPriceUsd('policy.asset')
const icon = await client.getTokenIcon('policy.asset')
const pairs = await client.findTradingPairs('policy.asset', ['dex-to-ignore'])
const orders = await client.getOrders({ tokenA: '', tokenB: 'policy.asset' })
const pools = await client.getPools({ tokenA: '', tokenB: 'policy.asset' })
```

### Wallet Operations

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

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

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

### Utility

```typescript
const dexes = await client.getDexList()
const stats = await client.getStatistics()
```

## Numeric Handling

**Input:** All numeric parameters accept `string | number | bigint | Big`

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

```typescript
// Get Big.js instances for calculations
const client = new SteelSwapClient({ numericFormat: 'Big' })
const estimate = await client.estimateSwap({ ... })
const withFee = estimate.totalOutput.times('0.997')
```

## API Environments

| Environment | URL |
|-------------|-----|
| Production | `https://api.steelswap.io` (default) |
| Development | `https://apidev.steelswap.io` |

## Documentation

Full documentation: [https://github.com/SteelSwap/steelswap-sdk](https://github.com/SteelSwap/steelswap-sdk)

## License

MIT