swap.thorchain: Instructions file for Codex

AGENTS.md

swap.thorchain AGENTS.md is an instructions file for Codex, OpenCode from thorchain/swap.thorchain. It costs 2,939 tokens per session, scanned A, original, MIT.

A repository instruction file for a web application that lets users make cross-chain cryptocurrency swaps through THORChain and Maya Protocol. It documents the architecture, commands, APIs, and coding conventions.

In plain words
What is it for?
Use it when developing, type-checking, building, or investigating the swap.thorchain.org codebase.
Why use it?
It gives coding agents the project context and checks needed to change the swap interface safely.

Instructions file for CodexOpenCode

Written for Codex and OpenCode: the file is AGENTS.md. Also seen: mentions AGENTS.md.

This is thorchain/swap.thorchain's own configuration. It tells Codex and OpenCode how to work on swap.thorchain itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything swap.thorchain configures →

Reuse

Borrowing it

Nothing to install: this file belongs to thorchain/swap.thorchain. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/thorchain/swap.thorchain/main/AGENTS.md
Clone the repo
git clone --depth 1 https://github.com/thorchain/swap.thorchain

Made for: Codex, OpenCode.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for swap.thorchain AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/thorchain/swap.thorchain/agents-md/github.svg)](https://agentmods.dev/instructions/thorchain/swap.thorchain/agents-md)
Your own site
<a href="https://agentmods.dev/instructions/thorchain/swap.thorchain/agents-md"><img src="https://agentmods.dev/badge/instructions/thorchain/swap.thorchain/agents-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for swap.thorchain AGENTS.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/thorchain/swap.thorchain/agents-md"><img src="https://agentmods.dev/badge/instructions/thorchain/swap.thorchain/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 2,939 This file is loaded in full into every session.
When invoked 2,939 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.02939 $0.02939
Opus 5.5 $0.01176 $0.01176
Sonnet 5.5 $0.00588 $0.00588
Haiku 4.5 $0.00294 $0.00294

Measured 4d ago against content hash 7dcfb3c4728b, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

swap.thorchain AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 111 lines

How it starts

The opening of the file, as written. The whole thing — 111 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AGENTS.md — working on this codebase

Instructions for AI coding agents contributing to swap.thorchain.org (the runtime guidance served to browsing agents lives at /AGENTS.md on the site, generated from src/lib/agent/discovery.ts — this file is about the code).

What this is

Next.js (App Router, TypeScript, Tailwind) web UI for native cross-chain swaps, powered by THORChain and Maya Protocol. Users sign in their own wallets, or use memoless ("instant") swaps with no wallet connection.

Two-component architecture:

  • UI — this repo.
  • Backend API — the swap aggregator: https://api.thorchain.org/v1 (quotes/routing, x-api-key gated) and https://api.thorchain.org/memoless/api/v1 (memoless swaps, no key). Protocol metadata (pools, mimir, THORNames, balances) comes from THORNode/Midgard gateways — see src/lib/api.ts and src/lib/thorchain-api.ts.

Commands

  • npm run dev — dev server (Turbopack). Check whether one is already running before starting another.
  • npx tsc --noEmit -p tsconfig.json — typecheck; this is the CI-relevant check (next lint is currently broken).
  • npm run build — production build (standalone output, single instance — in-memory rate limiting and idempotency stores rely on this).

Key areas

  • src/components/swap/ — swap flow UI; src/lib/wallets.ts — wallet/TCSwap SDK config (env vars in .env.example).
  • src/lib/tronlink.ts — a connector the SDK does not ship, registered in wallets.ts like any @tcswap/wallets/* one. Exodus is not one of these: it lives in the SDK as @tcswap/wallets/exodus (the browser extension), added in ../TCSwap. Mind the version — through 4.3.26 that subpath was an alias for Exodus's unrelated Passkeys wallet, which has always had its own @tcswap/wallets/passkeys export and still does; only 4.3.27 onwards carries the extension connector, so package.json must ask for at least that. Brave Wallet is in the SDK too, as @tcswap/wallets/brave (connectBrave, 4.3.34 onwards): it reaches both of Brave's accounts, EVM and Solana, through Brave's own providers, where connectEVMWallet with WalletOption.BRAVE gets the EVM account only, from whichever extension owns window.ethereum. Rabby is WalletOption.RABBY (4.3.35 onwards) on the SDK's connectEVMWallet, which uses the provider Rabby announces over EIP-6963 (rdns io.rabby) rather than window.ethereum — Rabby takes that from MetaMask only when set as the default wallet, and flags it isMetaMask too. Binance Wallet is the SDK's @tcswap/wallets/binance (connectBinance, 4.3.37 onwards): the Binance Web3 Wallet extension injects everything under the window.binancew3w namespace — an EIP-1193 EVM provider (ethereum, also announced over EIP-6963 as com.binance.wallet, the connector's last-resort lookup), a Phantom-shaped Solana one (solana), a Unisat-compatible Bitcoin one (bitcoin, mirrored as window.unisat flagged isBinance on builds without the namespaced copy), and its own Tron provider (tron), which answers getAccount()/signTransaction() rather than TronLink's tronWeb surface. The Bitcoin provider exists only in the Binance App's in-app dApp browser — the Chrome extension serves EVM, Solana and TRON only, so the app filters BTC out of the wallet's chain list (supportedChains in src/lib/wallets.ts). WalletConnect is the SDK's @tcswap/wallets/walletconnect (connectWalletconnect), listed only when NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID is set. One QR scan connects every selected chain the wallet supports; the app warns about the rest. A reload restores the stored sessions without a QR code (restoreOnly), and a session ended from the phone removes its chains (onWalletconnectDisconnect, then disconnectWallet(WALLETCONNECT, chains)). The connect dialog calls preloadWalletconnect when it opens, so the QR modal opens at once, and isWalletconnectDismissed tells a closed QR modal from a real error. Needs @tcswap/wallets 4.3.36 or later.
  • Disconnect a wallet with core's disconnectWallet (@tcswap/core 4.1.36 or later), not disconnectChain per chain. A chain holds only the last wallet connected on it, so disconnectChain may hit another wallet; disconnectWallet ends only this wallet's sessions and hands each chain back to another connected wallet.
  • isPrivateSwap in src/store/limit-swap-store.ts — the PRIVATE tab: the swap is routed through Houdini Swap (AppConfig.privateProvider, providers: ["HOUDINI"] on the aggregator, @tcswap/plugins/houdini in the SDK) instead of the native protocols. Each tab has its own asset list (useModeAssets in src/hooks/use-assets.ts), and a private route is priced floating and tracked by its Houdini order id (Transaction.providerSwapId). See docs/private-swaps.md before touching any HOUDINI branch.
  • public/widget.js + src/app/widget/ — the embeddable swap iframe. The loader mirrors the host page's dark/light mode into the iframe: it reads the effective background painted behind the widget (so a .dark class, data-theme, or a CSS-variable swap all work without configuration), boots the iframe with ?theme=, and pushes later changes over postMessage — src/app/widget/theme.ts holds that contract plus the pre-paint script that stops the embed flashing the wrong theme. Keep widget.js plain unbundled ES5-style script — it runs as-is on third-party sites.
  • src/lib/agent/discovery-files.ts — single registry of every static discovery file (/llms.txt, /AGENTS.md, /openapi.json, /.well-known/*, …), served by src/proxy.ts before filesystem routes. Add new agent/developer surfaces here, not as route folders.
  • src/lib/agent/discovery.ts — markdown content for /AGENTS.md, /llms.txt, /llms-full.md, /auth.md, and the agent skill; src/lib/agent/openapi.ts — the OpenAPI document.
  • src/lib/agent/developer-portal.ts — content for /developers.md; src/app/developers/page.tsx is a hand-built HTML mirror — keep the two in sync.
  • src/lib/agent/developer-docs.ts — the named developer resources at /developers/<topic> (quickstart, api, mcp, auth, sdks, webhooks). One markdown source per topic feeds both the HTML page (src/app/developers/[topic]/page.tsx, rendered by src/components/markdown-article.tsx) and the .md twin, so they cannot drift. Topic metadata lives in developer-topics.ts — split out so developer-portal.ts can link the pages without an import cycle.
  • The MCP server is anonymous and must stay that way: publish no /.well-known/oauth-* metadata and no registration endpoint, and never link one from a discovery document either — a linked path reads as published metadata. MCP connectors read protected-resource metadata as "OAuth required" and then fail a sign-in flow against a site with no accounts — see the note in docs/agent-readiness/orank.md, testNoAuthorizationSurfaceBlocksConnectors, and the link guard in testDiscoveryDocsAreTruthful (test/agent-contracts.test.mjs), which also asserts that every own-origin URL a discovery document links resolves.
  • sdk/python, sdk/go — dependency-free clients over this site's keyless public surfaces (the MCP tools and the support endpoints). The TypeScript SDK is the already-published @tcswap/sdk from the TCSwap monorepo — do not add a second npm client for the same APIs. src/lib/agent/sdks.ts is the single list the developer docs, llms.txt, and AGENTS.md render from; PyPI publication is still a manual step (see docs/agent-readiness/orank.md).
  • src/lib/agent/skills.ts — published agent skills (one per capability area, YAML frontmatter); routes and the skills index are generated from AGENT_SKILLS.
  • src/lib/agent/markdown-pages.ts — markdown twins: .md appended to any content page URL, plus Accept: text/markdown negotiation, resolved in src/proxy.ts.
  • src/lib/agent/pricing.ts — content for /pricing.md; src/lib/agent/agent-mode.ts — the /?mode=agent view (JSON or markdown by Accept), derived from MCP_TOOLS and developerEndpoints so it stays in sync.
  • src/lib/agent/mcp-tools.ts — tool definitions and the server card (edge-safe, no node:crypto); src/lib/agent/mcp-server.ts + src/lib/agent/mcp-ui.ts — public MCP server at /mcp (stateless streamable HTTP, read-only THORNode tools, MCP Apps quote view). public/robots.txt carries AI Content-Signal lines whose ordering matters.
  • src/app/api/ — support endpoints (/api/v1/* canonical, unversioned aliases kept); JSON errors via src/lib/api-error.ts, idempotency via src/lib/agent/idempotency.ts.
  • src/lib/rate-limit.ts — per-client limiter shared by /mcp and the support endpoints. Key on cf-connecting-ip (or the last forwarded hop), never the first x-forwarded-for entry: the edge appends to whatever the caller sent, so the leftmost value is forgeable.
  • src/components/chatwoot-widget.tsx — the live-chat widget (a Chatwoot Website-channel inbox), rendered only when NEXT_PUBLIC_CHATWOOT_WEBSITE_TOKEN is set. There is no bug-report form or /api/report-bug endpoint any more — support is live chat and email.
  • server.json (repo root) + src/app/.well-known/mcp-registry-auth/route.ts — the official MCP Registry record and its domain-ownership proof (served from MCP_REGISTRY_AUTH). Keep server.json's version in step with MCP_SERVER_INFO.version; publishing steps are in docs/agent-readiness/mcp-registry.md.
  • docs/agent-readiness/ — notes on agent-readiness scanners and decisions; read before changing discovery surfaces.
  • src/lib/banner.ts + src/app/api/banner/route.ts + src/hooks/use-banner.ts — the announcement banner. It is content owned by the affiliate admin (swap.thorchain-admin, admin-only /banner, published at its /api/banner), not by this repo: this app proxies that endpoint through its own origin (30s cache, BANNER_API_URL) and each tab polls every 10 min once the browser is idle, so a banner goes up without a deploy and never competes with the swap's own requests. An icon uploaded there is proxied the same way at /api/banner/icon, so the banner is always same-origin. Nothing is bundled — an unreachable admin means the last-seen banner, or none. Its copy is translated by the admin on save and is deliberately not in src/i18n/messages. See docs/banner.md.

Read the full file on GitHub · 111 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago Changed · +6 lines · +224 tokens per session 7dcfb3c4728b
  2. 11d ago Changed · +8 lines · +248 tokens per session 56b88711d891
  3. 14d ago Changed · +2 lines · +84 tokens per session a56f17efdc73
  4. 19d ago Changed · +2 lines · +86 tokens per session 8a22af7dbf10
  5. 26d ago Changed 47959bbdad6e
  6. 1mo ago Changed · -2 lines · -86 tokens per session ac7689119b4b
  7. 1mo ago Changed · +4 lines · +135 tokens per session 25f5cc4a4ced
  8. 2mo ago Changed · +4 lines · +154 tokens per session a5c5468dd288
  9. 2mo ago Changed · +1 lines · +42 tokens per session dc95a5a52267
  10. 2mo ago First seen · 86 lines · 2,052 tokens per session scan A b1925b3f85f7

Subscribe to this mod's changes

swap.thorchain AGENTS.md is an instructions file published in the GitHub repository thorchain/swap.thorchain (2 stars, last pushed today), licensed MIT. It adds 2,939 tokens to every session, about $0.0118 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

swap.thorchain AGENTS.md compared with instructions from other repositories

swap.thorchain AGENTS.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
swap.thorchain AGENTS.mdthorchain/swap.thorchainInstructions file2todayMITA2,939Codex, OpenCode
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143ktodayMITA7,461Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA5,649GitHub Copilot
langchain AGENTS.mdlangchain-ai/langchainInstructions file149ktodayMITA4,680Codex, OpenCode
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA3,093GitHub Copilot
vscode model-prompts.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA2,022GitHub Copilot