Skip to content

Commit e3cac42

Browse files
authored
fix(docs): revert documentation links to deflex-api and complete rebranding cleanup (#3)
* fix(docs): revert documentation links to deflex-api and complete rebranding cleanup The Haystack Router documentation on Gitbook is not yet available, so external documentation links have been reverted to point to the existing deflex-api docs until the new documentation is published. Documentation link fixes: - Revert all gitbook links from haystack-router-api to deflex-api - Add note indicating Haystack Router documentation is coming soon - Fix bundlejs badge link that still referenced @txnlab/deflex Rebranding cleanup: - Update anchor links from #deflexclient* to #routerclient* - Update source code comments (composer.ts, middleware.ts) - Rename test variables from *Deflex* to *Swap* naming - Update MIDDLEWARE.md examples and keywords - Add migration note to .claude/CLAUDE.md * style(tests): format swapTxns arrays to single line
1 parent 90abcf8 commit e3cac42

9 files changed

Lines changed: 41 additions & 47 deletions

File tree

.claude/CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
66

77
Haystack Router SDK is a TypeScript/JavaScript SDK for the Haystack Order Router - smart order routing and DEX aggregation on Algorand. This is a pnpm workspace monorepo containing the SDK package and example implementations.
88

9+
> **Note:** This SDK was migrated from `@txnlab/deflex` (TxnLab/deflex-js) to `@txnlab/haystack-router` (TxnLab/haystack-js) as part of a rebranding effort. See [MIGRATION.md](../MIGRATION.md) for details on migrating from the old package.
10+
911
## Commands
1012

1113
```bash

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This repository contains the Haystack Router SDK and example implementations for
88

99
### [@txnlab/haystack-router](./packages/haystack)
1010

11-
TypeScript/JavaScript SDK for [Haystack Order Router](https://txnlab.gitbook.io/haystack-router-api) - smart order routing and DEX aggregation on Algorand.
11+
TypeScript/JavaScript SDK for [Haystack Order Router](https://txnlab.gitbook.io/deflex-api) - smart order routing and DEX aggregation on Algorand.
1212

1313
- **Documentation**: [packages/haystack/README.md](./packages/haystack/README.md)
1414
- **npm**: [@txnlab/haystack-router](https://www.npmjs.com/package/@txnlab/haystack-router)
@@ -160,7 +160,7 @@ Root-level scripts:
160160

161161
- **SDK Documentation**: [packages/haystack/README.md](./packages/haystack/README.md)
162162
- **Examples Guide**: [examples/README.md](./examples/README.md)
163-
- **Haystack Router API Docs**: [https://txnlab.gitbook.io/haystack-router-api](https://txnlab.gitbook.io/haystack-router-api)
163+
- **API Docs**: [https://txnlab.gitbook.io/deflex-api](https://txnlab.gitbook.io/deflex-api) _(Haystack Router documentation coming soon)_
164164

165165
## Contributing
166166

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,4 @@ The monorepo structure enables a smooth development workflow:
124124

125125
- [GitHub Issues](https://github.com/TxnLab/haystack-js/issues)
126126
- [Discord](https://discord.gg/Ek3dNyzG)
127-
- [Documentation](https://txnlab.gitbook.io/haystack-router-api)
127+
- [Documentation](https://txnlab.gitbook.io/deflex-api)

examples/node-cli/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ async function executeSwap() {
9090
)
9191
console.log(` Slippage: ${config.slippage}%\n`)
9292

93-
// Initialize Deflex client
93+
// Initialize Haystack Router client
9494
const router = new RouterClient({
9595
apiKey: config.apiKey,
9696
autoOptIn: true,

packages/haystack/MIDDLEWARE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ async beforeSwap(context: SwapContext): Promise<TransactionWithSigner[]> {
336336
"default": "./dist/index.js"
337337
}
338338
},
339-
"keywords": ["deflex", "algorand", "dex", "middleware"],
339+
"keywords": ["haystack-router", "algorand", "dex", "middleware"],
340340
"peerDependencies": {
341341
"@txnlab/haystack-router": "^1.2.0",
342342
"algosdk": "^3.0.0"
@@ -351,7 +351,7 @@ Include clear usage instructions:
351351
````markdown
352352
# CustomAsset Haystack Router Middleware
353353

354-
Middleware for swapping CustomAsset tokens via Deflex.
354+
Middleware for swapping CustomAsset tokens via Haystack Router.
355355

356356
## Installation
357357

@@ -392,7 +392,7 @@ If your middleware adds ANY transactions via `beforeSwap()` or `afterSwap()`, yo
392392
**Why this is critical:**
393393
- Algorand has a hard limit of 16 transactions per atomic group
394394
- Haystack Router API will optimize routes to use as many transactions as the `maxGroupSize` allows
395-
- If Deflex returns a 16-transaction route and you try to add more, the transaction will **fail**
395+
- If Haystack Router returns a 16-transaction route and you try to add more, the transaction will **fail**
396396

397397
**Example:**
398398
```typescript

packages/haystack/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Haystack Router SDK
22

33
[![npm version](https://img.shields.io/npm/v/@txnlab/haystack-router.svg)](https://www.npmjs.com/package/@txnlab/haystack-router)
4-
[![bundle size](https://deno.bundlejs.com/badge?q=@txnlab/haystack-router@latest&treeshake=[*])](https://bundlejs.com/?q=%40txnlab%2Fdeflex%40latest&treeshake=%5B*%5D)
4+
[![bundle size](https://deno.bundlejs.com/badge?q=@txnlab/haystack-router@latest&treeshake=[*])](https://bundlejs.com/?q=%40txnlab%2Fhaystack-router%40latest&treeshake=%5B*%5D)
55
[![CI](https://github.com/TxnLab/haystack-js/actions/workflows/ci.yml/badge.svg)](https://github.com/TxnLab/haystack-js/actions/workflows/ci.yml)
66
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
77
[![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue.svg)](https://www.typescriptlang.org/)
88

9-
TypeScript/JavaScript SDK for [Haystack Order Router](https://txnlab.gitbook.io/haystack-router-api) - smart order routing and DEX aggregation on Algorand.
9+
TypeScript/JavaScript SDK for [Haystack Order Router](https://txnlab.gitbook.io/deflex-api) - smart order routing and DEX aggregation on Algorand.
1010

1111
## Prerequisites
1212

@@ -83,11 +83,11 @@ const router = new RouterClient({
8383
})
8484
```
8585

86-
By providing your Algorand address as the `referrerAddress` when initializing the client, you can earn 25% of the swap fees generated through your integration. Set the `feeBps` parameter to specify the total fee charged to users (default: 0.15%, max: 3.00%). Learn more about the [Haystack Router Referral Program](https://txnlab.gitbook.io/haystack-router-api/referral-treasury/referral-program).
86+
By providing your Algorand address as the `referrerAddress` when initializing the client, you can earn 25% of the swap fees generated through your integration. Set the `feeBps` parameter to specify the total fee charged to users (default: 0.15%, max: 3.00%). Learn more about the [Haystack Router Referral Program](https://txnlab.gitbook.io/deflex-api/referral-treasury/referral-program).
8787

8888
### Get a Swap Quote
8989

90-
The [`newQuote()`](#deflexclientnewquote) method returns a [`SwapQuote`](#deflexquote) object:
90+
The [`newQuote()`](#routerclientnewquote) method returns a [`SwapQuote`](#swapquote) object:
9191

9292
```typescript
9393
// Basic quote
@@ -101,7 +101,7 @@ const quote = await router.newQuote({
101101

102102
### Execute a Swap
103103

104-
The [`newSwap()`](#deflexclientnewswap) method returns a [`SwapComposer`](#swapcomposer) instance:
104+
The [`newSwap()`](#routerclientnewswap) method returns a [`SwapComposer`](#swapcomposer) instance:
105105

106106
```typescript
107107
import { useWallet } from '@txnlab/use-wallet-*' // react, vue, solid, or svelte
@@ -381,11 +381,11 @@ new RouterClient(config: ConfigParams)
381381
| `autoOptIn` | Auto-detect and add required opt-in transactions | `boolean` | `false` |
382382
| `middleware` | Array of middleware for custom asset requirements | `SwapMiddleware[]` | `[]` |
383383

384-
> **Referral Program**: By providing a `referrerAddress`, you can earn 25% of the swap fees generated through your integration. The `feeBps` parameter sets the total fee charged (default: 0.15%). Learn more about the [Haystack Router Referral Program](https://txnlab.gitbook.io/haystack-router-api/referral-treasury/referral-program).
384+
> **Referral Program**: By providing a `referrerAddress`, you can earn 25% of the swap fees generated through your integration. The `feeBps` parameter sets the total fee charged (default: 0.15%). Learn more about the [Haystack Router Referral Program](https://txnlab.gitbook.io/deflex-api/referral-treasury/referral-program).
385385
386386
#### RouterClient.newQuote()
387387

388-
Fetch a swap quote and return a [`SwapQuote`](#deflexquote) object.
388+
Fetch a swap quote and return a [`SwapQuote`](#swapquote) object.
389389

390390
```typescript
391391
async newQuote(params: FetchQuoteParams): Promise<SwapQuote>
@@ -434,7 +434,7 @@ async needsAssetOptIn(address: string, assetId: bigint | number): Promise<boolea
434434

435435
### SwapQuote
436436

437-
Plain object returned by [`newQuote()`](#deflexclientnewquote). Extends the raw API response with additional metadata.
437+
Plain object returned by [`newQuote()`](#routerclientnewquote). Extends the raw API response with additional metadata.
438438

439439
**Additional properties added by SDK:**
440440

@@ -468,7 +468,7 @@ Plain object returned by [`newQuote()`](#deflexclientnewquote). Extends the raw
468468

469469
### SwapComposer
470470

471-
Builder for constructing and executing atomic swap transaction groups, returned by [`newSwap()`](#deflexclientnewswap).
471+
Builder for constructing and executing atomic swap transaction groups, returned by [`newSwap()`](#routerclientnewswap).
472472

473473
| Method | Description | Parameters | Returns |
474474
| -------------------------------------- | ------------------------------------------------------------------------------ | -------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
@@ -485,7 +485,7 @@ Builder for constructing and executing atomic swap transaction groups, returned
485485

486486
## Documentation
487487

488-
For more information about the Haystack Order Router protocol, visit the [official documentation](https://txnlab.gitbook.io/haystack-router-api).
488+
For more information about the Haystack Order Router protocol, visit the [official documentation](https://txnlab.gitbook.io/deflex-api).
489489

490490
## License
491491

packages/haystack/src/composer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ export class SwapComposer {
630630
delete txn.group
631631

632632
if (swapTxn.signature !== false) {
633-
// Pre-signed transaction - use custom Deflex signer
633+
// Pre-signed transaction - use custom Haystack Router signer
634634
swapTxns.push({
635635
txn,
636636
signer: this.createSwapSigner(swapTxn.signature),
@@ -728,7 +728,7 @@ export class SwapComposer {
728728
}
729729

730730
/**
731-
* Creates a TransactionSigner function for Deflex pre-signed transactions
731+
* Creates a TransactionSigner function for Haystack Router pre-signed transactions
732732
*/
733733
private createSwapSigner(signature: Signature): TransactionSigner {
734734
return async (
@@ -744,7 +744,7 @@ export class SwapComposer {
744744
}
745745

746746
/**
747-
* Re-signs a Deflex transaction using the provided logic signature or secret key
747+
* Re-signs a Haystack Router transaction using the provided logic signature or secret key
748748
*/
749749
private signSwapTransaction(
750750
transaction: Transaction,

packages/haystack/src/middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export interface SwapContext {
4646
}
4747

4848
/**
49-
* Middleware interface for extending Deflex swap functionality
49+
* Middleware interface for extending Haystack Router swap functionality
5050
*
5151
* Middleware allows you to modify quote parameters and inject additional transactions
5252
* into the atomic swap group. This is useful for assets that require special handling,

packages/haystack/tests/composer.test.ts

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ describe('SwapComposer', () => {
967967
logicSig,
968968
)
969969

970-
const mockPreSignedDeflexTxn: SwapTransaction = {
970+
const mockPreSignedSwapTxn: SwapTransaction = {
971971
data: Buffer.from(
972972
algosdk.encodeUnsignedTransaction(preSignedTxn),
973973
).toString('base64'),
@@ -981,15 +981,11 @@ describe('SwapComposer', () => {
981981
logicSigBlob: false,
982982
}
983983

984-
const mockUserDeflexTxn: SwapTransaction = createMockSwapTxn()
984+
const mockUserSwapTxn: SwapTransaction = createMockSwapTxn()
985985

986986
const composer = new SwapComposer({
987987
quote: createMockQuote() as FetchQuoteResponse,
988-
swapTxns: [
989-
mockUserDeflexTxn,
990-
mockPreSignedDeflexTxn,
991-
mockUserDeflexTxn,
992-
],
988+
swapTxns: [mockUserSwapTxn, mockPreSignedSwapTxn, mockUserSwapTxn],
993989
algodClient: mockAlgodClient,
994990
address: validAddress,
995991
signer: async (
@@ -1024,7 +1020,7 @@ describe('SwapComposer', () => {
10241020
logicSig,
10251021
)
10261022

1027-
const mockPreSignedDeflexTxn: SwapTransaction = {
1023+
const mockPreSignedSwapTxn: SwapTransaction = {
10281024
data: Buffer.from(
10291025
algosdk.encodeUnsignedTransaction(preSignedTxn),
10301026
).toString('base64'),
@@ -1038,15 +1034,11 @@ describe('SwapComposer', () => {
10381034
logicSigBlob: false,
10391035
}
10401036

1041-
const mockUserDeflexTxn: SwapTransaction = createMockSwapTxn()
1037+
const mockUserSwapTxn: SwapTransaction = createMockSwapTxn()
10421038

10431039
const composer = new SwapComposer({
10441040
quote: createMockQuote() as FetchQuoteResponse,
1045-
swapTxns: [
1046-
mockUserDeflexTxn,
1047-
mockPreSignedDeflexTxn,
1048-
mockUserDeflexTxn,
1049-
],
1041+
swapTxns: [mockUserSwapTxn, mockPreSignedSwapTxn, mockUserSwapTxn],
10501042
algodClient: mockAlgodClient,
10511043
address: validAddress,
10521044
signer: async (
@@ -1552,7 +1544,7 @@ describe('SwapComposer', () => {
15521544
const txn = createMockTransaction(appAddress.toString())
15531545
const signedTxn = algosdk.signLogicSigTransactionObject(txn, logicSig)
15541546

1555-
const mockDeflexLsigTxn: SwapTransaction = {
1547+
const mockLsigSwapTxn: SwapTransaction = {
15561548
data: Buffer.from(algosdk.encodeUnsignedTransaction(txn)).toString(
15571549
'base64',
15581550
),
@@ -1568,7 +1560,7 @@ describe('SwapComposer', () => {
15681560

15691561
const composer = new SwapComposer({
15701562
quote: createMockQuote() as FetchQuoteResponse,
1571-
swapTxns: [mockDeflexLsigTxn],
1563+
swapTxns: [mockLsigSwapTxn],
15721564
algodClient: mockAlgodClient,
15731565
address: validAddress,
15741566
signer: async (txns: algosdk.Transaction[]) =>
@@ -1586,7 +1578,7 @@ describe('SwapComposer', () => {
15861578
const account = algosdk.generateAccount()
15871579
const txn = createMockTransaction(account.addr.toString())
15881580

1589-
const mockDeflexSkTxn: SwapTransaction = {
1581+
const mockSkSwapTxn: SwapTransaction = {
15901582
data: Buffer.from(algosdk.encodeUnsignedTransaction(txn)).toString(
15911583
'base64',
15921584
),
@@ -1602,7 +1594,7 @@ describe('SwapComposer', () => {
16021594

16031595
const composer = new SwapComposer({
16041596
quote: createMockQuote() as FetchQuoteResponse,
1605-
swapTxns: [mockDeflexSkTxn],
1597+
swapTxns: [mockSkSwapTxn],
16061598
algodClient: mockAlgodClient,
16071599
address: validAddress,
16081600
signer: async (txns: algosdk.Transaction[]) =>
@@ -1661,7 +1653,7 @@ describe('SwapComposer', () => {
16611653

16621654
await composer.addSwapTransactions()
16631655

1664-
// Error happens during signing when the Deflex signer is called
1656+
// Error happens during signing when the swap signer is called
16651657
await expect(composer.sign()).rejects.toThrow(
16661658
'Logic signature structure missing lsig field',
16671659
)
@@ -1693,7 +1685,7 @@ describe('SwapComposer', () => {
16931685

16941686
await composer.addSwapTransactions()
16951687

1696-
// Error happens during signing when the Deflex signer is called
1688+
// Error happens during signing when the swap signer is called
16971689
await expect(composer.sign()).rejects.toThrow(
16981690
'Unsupported signature type',
16991691
)
@@ -1770,7 +1762,7 @@ describe('SwapComposer', () => {
17701762
logicSig,
17711763
)
17721764

1773-
const mockPreSignedDeflexTxn: SwapTransaction = {
1765+
const mockPreSignedSwapTxn: SwapTransaction = {
17741766
data: Buffer.from(
17751767
algosdk.encodeUnsignedTransaction(preSignedTxn),
17761768
).toString('base64'),
@@ -1784,7 +1776,7 @@ describe('SwapComposer', () => {
17841776
logicSigBlob: false,
17851777
}
17861778

1787-
const mockUserDeflexTxn: SwapTransaction = {
1779+
const mockUserSwapTxn: SwapTransaction = {
17881780
data: Buffer.from(
17891781
algosdk.encodeUnsignedTransaction(createMockTransaction()),
17901782
).toString('base64'),
@@ -1797,7 +1789,7 @@ describe('SwapComposer', () => {
17971789

17981790
const composer = new SwapComposer({
17991791
quote: createMockQuote() as FetchQuoteResponse,
1800-
swapTxns: [mockPreSignedDeflexTxn, mockUserDeflexTxn],
1792+
swapTxns: [mockPreSignedSwapTxn, mockUserSwapTxn],
18011793
algodClient: mockAlgodClient,
18021794
address: validAddress,
18031795
signer: async (txns: algosdk.Transaction[]) =>
@@ -2023,7 +2015,7 @@ describe('SwapComposer', () => {
20232015
logicSig,
20242016
)
20252017

2026-
const mockPreSignedDeflexTxn: SwapTransaction = {
2018+
const mockPreSignedSwapTxn: SwapTransaction = {
20272019
data: Buffer.from(
20282020
algosdk.encodeUnsignedTransaction(preSignedTxn),
20292021
).toString('base64'),
@@ -2037,7 +2029,7 @@ describe('SwapComposer', () => {
20372029
logicSigBlob: false,
20382030
}
20392031

2040-
const mockUserDeflexTxn: SwapTransaction = {
2032+
const mockUserSwapTxn: SwapTransaction = {
20412033
data: Buffer.from(
20422034
algosdk.encodeUnsignedTransaction(createMockTransaction()),
20432035
).toString('base64'),
@@ -2048,7 +2040,7 @@ describe('SwapComposer', () => {
20482040

20492041
const composer = new SwapComposer({
20502042
quote: createMockQuote() as FetchQuoteResponse,
2051-
swapTxns: [mockPreSignedDeflexTxn, mockUserDeflexTxn],
2043+
swapTxns: [mockPreSignedSwapTxn, mockUserSwapTxn],
20522044
algodClient: mockAlgodClient,
20532045
address: validAddress,
20542046
signer: async (txns: algosdk.Transaction[]) =>

0 commit comments

Comments
 (0)