Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions skills/haystack-router/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ Formerly known as Deflex (originally developed by Defly and Alammex), acquired b
npm install @txnlab/haystack-router algosdk
```

**API key required.** Request one from support@txnlab.dev.
**API key required.** A free tier key is available for immediate use — see [configuration.md](references/configuration.md) for details.

## Core Flow

```typescript
import { RouterClient } from '@txnlab/haystack-router'

// 1. Initialize
const router = new RouterClient({ apiKey: 'your-api-key' })
const router = new RouterClient({
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)
})

// 2. Get a quote
const quote = await router.newQuote({
Expand Down
31 changes: 22 additions & 9 deletions skills/haystack-router/references/configuration.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
# Configuration

## API Key Tiers

| Tier | Key | Rate Limit | Use Case |
| -------------- | -------------------------------------- | --------------- | --------------------------------------------- |
| **Free** | `1b72df7e-1131-4449-8ce1-29b79dd3f51e` | 60 requests/min | Development, testing, low-volume integrations |
| **Production** | Request from support@txnlab.dev | Higher limits | Production applications |

The free tier key requires no registration and works immediately. The rate limit applies to all API calls (both `fetchQuote` and `fetchExecuteSwapTxns`), not just quotes.

For production integrations with higher rate limits, contact support@txnlab.dev for a dedicated key.

## RouterClient Options

```typescript
import { RouterClient } from '@txnlab/haystack-router'

const router = new RouterClient({
// Required
apiKey: 'your-api-key',
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)

// Optional
apiBaseUrl: undefined, // Override API endpoint (SDK manages defaults)
Expand All @@ -27,7 +38,9 @@ const router = new RouterClient({
### MainNet (Default)

```typescript
const router = new RouterClient({ apiKey: 'your-api-key' })
const router = new RouterClient({
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e',
})
```

Uses default Nodely MainNet algod endpoint.
Expand All @@ -36,7 +49,7 @@ Uses default Nodely MainNet algod endpoint.

```typescript
const router = new RouterClient({
apiKey: 'your-api-key',
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)
algodUri: 'https://testnet-api.4160.nodely.dev/',
})
```
Expand All @@ -45,7 +58,7 @@ const router = new RouterClient({

```typescript
const router = new RouterClient({
apiKey: 'your-api-key',
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)
algodUri: 'http://localhost:4001',
algodToken:
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
Expand Down Expand Up @@ -78,7 +91,7 @@ Slippage is verified on the **final output** of the swap, not on individual hops

```typescript
const router = new RouterClient({
apiKey: 'your-api-key',
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)
feeBps: 15, // 0.15% output fee
})
```
Expand All @@ -94,7 +107,7 @@ Earn 25% of swap fees by setting a referrer address:

```typescript
const router = new RouterClient({
apiKey: 'your-api-key',
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)
referrerAddress: 'YOUR_ALGORAND_ADDRESS',
})
```
Expand All @@ -107,7 +120,7 @@ When `autoOptIn: true`, the SDK automatically checks if the user needs to opt in

```typescript
const router = new RouterClient({
apiKey: 'your-api-key',
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)
autoOptIn: true,
})

Expand All @@ -133,7 +146,7 @@ const autoOptOut = new AutoOptOutMiddleware({
})

const router = new RouterClient({
apiKey: 'your-api-key',
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)
middleware: [autoOptOut],
})
```
Expand All @@ -144,7 +157,7 @@ See [api-reference.md](api-reference.md) for the `SwapMiddleware` interface.

```typescript
const router = new RouterClient({
apiKey: 'your-api-key',
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)
debugLevel: 'info',
})
```
Expand Down
4 changes: 2 additions & 2 deletions skills/haystack-router/references/fees-and-referrals.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

```typescript
const router = new RouterClient({
apiKey: 'your-api-key',
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)
feeBps: 15, // 0.15%
})
```
Expand All @@ -36,7 +36,7 @@ Pass your Algorand address as the `referrerAddress` when creating the RouterClie

```typescript
const router = new RouterClient({
apiKey: 'your-api-key',
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)
referrerAddress: 'YOUR_ALGORAND_ADDRESS',
})
```
Expand Down
11 changes: 6 additions & 5 deletions skills/haystack-router/references/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

## Prerequisites

- **API key** — request from support@txnlab.dev
- **Node.js** >= 20
- **algosdk** 3.x (peer dependency)

Expand All @@ -18,15 +17,15 @@ npm install @txnlab/haystack-router algosdk
import { RouterClient } from '@txnlab/haystack-router'

const router = new RouterClient({
apiKey: 'your-api-key',
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)
})
```

### With Options

```typescript
const router = new RouterClient({
apiKey: 'your-api-key',
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)
autoOptIn: true, // Auto-detect asset opt-in needs
referrerAddress: 'ABC...', // Earn 25% of swap fees
feeBps: 15, // Fee in basis points (default: 10)
Expand All @@ -40,7 +39,7 @@ Override the algod connection and API base URL for TestNet:

```typescript
const router = new RouterClient({
apiKey: 'your-api-key',
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)
algodUri: 'https://testnet-api.4160.nodely.dev/',
// Set apiBaseUrl if using a TestNet-specific API endpoint
})
Expand All @@ -51,7 +50,9 @@ const router = new RouterClient({
```typescript
import { RouterClient } from '@txnlab/haystack-router'

const router = new RouterClient({ apiKey: 'your-api-key' })
const router = new RouterClient({
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)
})

// Get a quote: swap 1 ALGO → USDC
const quote = await router.newQuote({
Expand Down
2 changes: 1 addition & 1 deletion skills/haystack-router/references/node-automation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ npm install @txnlab/haystack-router algosdk

```bash
# .env
HAYSTACK_API_KEY=your-api-key
HAYSTACK_API_KEY=1b72df7e-1131-4449-8ce1-29b79dd3f51e # Free tier (60 requests/min)
MNEMONIC=your-25-word-mnemonic
```

Expand Down
9 changes: 7 additions & 2 deletions skills/haystack-router/references/quotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
```typescript
import { RouterClient } from '@txnlab/haystack-router'

const router = new RouterClient({ apiKey: 'your-api-key' })
const router = new RouterClient({
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)
})

const quote = await router.newQuote({
fromASAID: 0, // ALGO
Expand Down Expand Up @@ -120,7 +122,10 @@ Before quoting, check if the user needs to opt into the output asset:

```typescript
// Option 1: Set autoOptIn on the client
const router = new RouterClient({ apiKey: 'key', autoOptIn: true })
const router = new RouterClient({
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)
autoOptIn: true,
})
const quote = await router.newQuote({
fromASAID: 0,
toASAID: 31566704,
Expand Down
4 changes: 3 additions & 1 deletion skills/haystack-router/references/swaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
```typescript
import { RouterClient } from '@txnlab/haystack-router'

const router = new RouterClient({ apiKey: 'your-api-key' })
const router = new RouterClient({
apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)
})

// 1. Get a quote
const quote = await router.newQuote({
Expand Down