{"id":"1dfdc57b-000d-4be7-a388-1ece84a94f2e","shortId":"aNV4Pm","kind":"skill","title":"haystack-router","tagline":">-","description":"# Haystack Router\n\nHaystack Router is a DEX aggregator and smart order routing protocol on Algorand. It finds optimal swap routes across multiple DEXes (Tinyman V2, Pact, Folks) and LST protocols (tALGO, xALGO), then executes them atomically through on-chain smart contracts.\n\nFormerly known as Deflex (originally developed by Defly and Alammex), acquired by TxnLab and rebranded as Haystack Router.\n\n## Package\n\n`@txnlab/haystack-router` — TypeScript SDK for DEX-aggregated swaps. Requires `algosdk` (v3+) as a peer dependency.\n\n```bash\nnpm install @txnlab/haystack-router algosdk\n```\n\n**API key required.** A free tier key is available for immediate use — see [configuration.md](references/configuration.md) for details.\n\n## Core Flow\n\n```typescript\nimport { RouterClient } from '@txnlab/haystack-router'\n\n// 1. Initialize\nconst router = new RouterClient({\n  apiKey: '1b72df7e-1131-4449-8ce1-29b79dd3f51e', // Free tier (60 requests/min)\n})\n\n// 2. Get a quote\nconst quote = await router.newQuote({\n  fromASAID: 0, // ALGO\n  toASAID: 31566704, // USDC\n  amount: 1_000_000, // 1 ALGO (base units)\n  address: activeAddress,\n})\n\n// 3. Execute the swap\nconst swap = await router.newSwap({\n  quote,\n  address: activeAddress,\n  signer: transactionSigner,\n  slippage: 1, // 1%\n})\nconst result = await swap.execute()\n```\n\nThe SDK is the **only** supported integration path. Do not call the API directly.\n\n## Key Concepts\n\n- **Amounts** are always in base units (microAlgos for ALGO, smallest unit for ASAs)\n- **ASA IDs**: 0 = ALGO, 31566704 = USDC, etc.\n- **Quote types**: `fixed-input` (default) — specify input amount; `fixed-output` — specify desired output\n- **Slippage**: Percentage tolerance on output (e.g., 1 = 1%). Applied to the final output, not individual hops\n- **Routing**: Supports multi-hop and parallel (combo) swaps for optimal pricing\n- **Middleware**: Plugin system for custom pre/post-swap transactions (e.g., auto opt-out)\n\n## Reference Files\n\nRead the appropriate file based on the task:\n\n| Task                                  | Reference                                                 |\n| ------------------------------------- | --------------------------------------------------------- |\n| Install SDK, initialize RouterClient  | [getting-started.md](references/getting-started.md)       |\n| Get swap quotes, display pricing      | [quotes.md](references/quotes.md)                         |\n| Execute swaps, sign transactions      | [swaps.md](references/swaps.md)                           |\n| Build React swap UI with use-wallet   | [react-integration.md](references/react-integration.md)   |\n| Automate swaps from Node.js scripts   | [node-automation.md](references/node-automation.md)       |\n| RouterClient config, slippage, assets | [configuration.md](references/configuration.md)           |\n| Fee structure, referral program       | [fees-and-referrals.md](references/fees-and-referrals.md) |\n| Migrate from @txnlab/deflex           | [migration.md](references/migration.md)                   |\n| Full API surface and types            | [api-reference.md](references/api-reference.md)           |","tags":["haystack","router","skills","txnlab","agent-skills","algorand","claude-code","haystack-router","nfd","use-wallet"],"capabilities":["skill","source-txnlab","skill-haystack-router","topic-agent-skills","topic-algorand","topic-claude-code","topic-haystack-router","topic-nfd","topic-use-wallet"],"categories":["skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/TxnLab/skills/haystack-router","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add TxnLab/skills","source_repo":"https://github.com/TxnLab/skills","install_from":"skills.sh"}},"qualityScore":"0.453","qualityRationale":"deterministic score 0.45 from registry signals: · indexed on github topic:agent-skills · 6 github stars · SKILL.md body (3,126 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T19:14:23.141Z","embedding":null,"createdAt":"2026-05-18T13:21:59.962Z","updatedAt":"2026-05-18T19:14:23.141Z","lastSeenAt":"2026-05-18T19:14:23.141Z","tsv":"'-1131':117 '-4449':118 '-8':119 '0':136,202 '000':143,144 '1':109,142,145,165,166,228,229 '1b72df7e':116 '2':127 '29b79dd3f51e':122 '3':151 '31566704':139,204 '60':125 'acquir':56 'across':24 'activeaddress':150,161 'address':149,160 'aggreg':11,71 'alammex':55 'algo':137,146,195,203 'algorand':18 'algosdk':74,84 'alway':189 'amount':141,187,215 'api':85,183,328 'api-reference.md':332 'apikey':115 'appli':230 'appropri':266 'asa':199,200 'asset':313 'atom':39 'auto':258 'autom':303 'avail':93 'await':133,157,169 'base':147,191,268 'bash':80 'build':293 'call':181 'ce1':121 'ce1-29b79dd3f51e':120 'chain':43 'combo':245 'concept':186 'config':311 'configuration.md':98,314 'const':111,131,155,167 'contract':45 'core':102 'custom':254 'default':212 'deflex':49 'defli':53 'depend':79 'desir':220 'detail':101 'develop':51 'dex':10,26,70 'dex-aggreg':69 'direct':184 'display':283 'e.g':227,257 'etc':206 'execut':37,152,287 'fee':316 'fees-and-referrals.md':320 'file':263,267 'final':233 'find':20 'fix':210,217 'fixed-input':209 'fixed-output':216 'flow':103 'folk':30 'former':46 'free':89,123 'fromasaid':135 'full':327 'get':128,280 'getting-started.md':278 'haystack':2,4,6,62 'haystack-rout':1 'hop':237,242 'id':201 'immedi':95 'import':105 'individu':236 'initi':110,276 'input':211,214 'instal':82,274 'integr':177 'key':86,91,185 'known':47 'lst':32 'microalgo':193 'middlewar':250 'migrat':322 'migration.md':325 'multi':241 'multi-hop':240 'multipl':25 'new':113 'node-automation.md':308 'node.js':306 'npm':81 'on-chain':41 'opt':260 'opt-out':259 'optim':21,248 'order':14 'origin':50 'output':218,221,226,234 'packag':64 'pact':29 'parallel':244 'path':178 'peer':78 'percentag':223 'plugin':251 'pre/post-swap':255 'price':249,284 'program':319 'protocol':16,33 'quot':130,132,159,207,282 'quotes.md':285 'react':294 'react-integration.md':301 'read':264 'rebrand':60 'refer':262,273 'references/api-reference.md':333 'references/configuration.md':99,315 'references/fees-and-referrals.md':321 'references/getting-started.md':279 'references/migration.md':326 'references/node-automation.md':309 'references/quotes.md':286 'references/react-integration.md':302 'references/swaps.md':292 'referr':318 'requests/min':126 'requir':73,87 'result':168 'rout':15,23,238 'router':3,5,7,63,112 'router.newquote':134 'router.newswap':158 'routercli':106,114,277,310 'script':307 'sdk':67,172,275 'see':97 'sign':289 'signer':162 'skill' 'skill-haystack-router' 'slippag':164,222,312 'smallest':196 'smart':13,44 'source-txnlab' 'specifi':213,219 'structur':317 'support':176,239 'surfac':329 'swap':22,72,154,156,246,281,288,295,304 'swap.execute':170 'swaps.md':291 'system':252 'talgo':34 'task':271,272 'tier':90,124 'tinyman':27 'toasaid':138 'toler':224 'topic-agent-skills' 'topic-algorand' 'topic-claude-code' 'topic-haystack-router' 'topic-nfd' 'topic-use-wallet' 'transact':256,290 'transactionsign':163 'txnlab':58 'txnlab/deflex':324 'txnlab/haystack-router':65,83,108 'type':208,331 'typescript':66,104 'ui':296 'unit':148,192,197 'usdc':140,205 'use':96,299 'use-wallet':298 'v2':28 'v3':75 'wallet':300 'xalgo':35","prices":[{"id":"d9ba4ff5-e3a9-4982-a95f-36e4b1ef7758","listingId":"1dfdc57b-000d-4be7-a388-1ece84a94f2e","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"TxnLab","category":"skills","install_from":"skills.sh"},"createdAt":"2026-05-18T13:21:59.962Z"}],"sources":[{"listingId":"1dfdc57b-000d-4be7-a388-1ece84a94f2e","source":"github","sourceId":"TxnLab/skills/haystack-router","sourceUrl":"https://github.com/TxnLab/skills/tree/main/skills/haystack-router","isPrimary":false,"firstSeenAt":"2026-05-18T13:21:59.962Z","lastSeenAt":"2026-05-18T19:14:23.141Z"}],"details":{"listingId":"1dfdc57b-000d-4be7-a388-1ece84a94f2e","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"TxnLab","slug":"haystack-router","github":{"repo":"TxnLab/skills","stars":6,"topics":["agent-skills","ai","algorand","claude-code","haystack-router","nfd","use-wallet"],"license":"mit","html_url":"https://github.com/TxnLab/skills","pushed_at":"2026-02-19T16:56:59Z","description":"Curated agent skills for TxnLab's Algorand ecosystem — NFDomains, use-wallet, Haystack Router","skill_md_sha":"4a3a410f9dce226e6c23ae93e5da2e87419ff542","skill_md_path":"skills/haystack-router/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/TxnLab/skills/tree/main/skills/haystack-router"},"layout":"multi","source":"github","category":"skills","frontmatter":{"name":"haystack-router","description":">-"},"skills_sh_url":"https://skills.sh/TxnLab/skills/haystack-router"},"updatedAt":"2026-05-18T19:14:23.141Z"}}