Skip to content

feat: add Chord action provider - #1566

Open
tuantqse90 wants to merge 1 commit into
coinbase:mainfrom
tuantqse90:feat/chord-action-provider
Open

tuantqse90 wants to merge 1 commit into
coinbase:mainfrom
tuantqse90:feat/chord-action-provider

Conversation

@tuantqse90

Copy link
Copy Markdown

Description

Adds a Chord action provider. Chord is a DEX aggregator: it quotes every venue it indexes on a chain, splits an order across venues when that gives a better output, and settles the trade through one router contract deployed at the same address (0x1b1fee89a381e595fe6536b99ba91f3e16e9601a) on each supported chain.

Actions:

  • search_tokens: searches Chord's token index on the wallet's chain by symbol, name or address, and flags whether each match is on the chain's curated list
  • get_swap_quote: best route, expected and minimum output, price impact, fee and venues; sends nothing
  • swap: approves the router for exactly the input amount when the allowance is too low, builds the transaction with the Chord API, refuses it unless it targets the Chord router on the wallet's chain, simulates it from the wallet, then sends it and reports the amount received

Networks: Ethereum (1), BNB Chain (56), Monad (143), Robinhood Chain (4663), Arc (5042), Base (8453), Arbitrum One (42161), Avalanche C-Chain (43114). supportsNetwork returns false elsewhere.

No API key is needed (public limit 60 requests per minute per IP); an optional apiKey / CHORD_API_KEY is sent as X-API-Key. Transactions are built unsigned and signed by the AgentKit wallet provider; Chord never takes custody of keys or funds.

Details handled in the provider:

  • token symbols and names from the API and from contracts go through a strict allowlist sanitizer before they reach the agent
  • USDT on Ethereum: the allowance is reset to zero before a new approval
  • Arc pays gas in USDC: the native coin maps to the USDC system contract (0x3600…0000, 6 decimals), approved and pulled like an ERC-20
  • the quote is fetched again after an approval transaction, since waiting for it can outlast the first quote

Tests

Unit tests: src/action-providers/chord/chordActionProvider.test.ts, 43 tests (schemas, token normalization, sanitizer, every action's success and failure paths, approval reset, Arc mapping, transaction target and chain checks, simulation failure, reverted receipts). Full suite: 63 suites, 947 tests passing. pnpm run lint, pnpm run format:check and tsc --noEmit pass.

Manual check against the live API, through AgentKit.from with a ViemWalletProvider on a fresh, unfunded key (no chatbot, so no LLM in the loop; the action is invoked directly as the chatbot would):

Network: Base mainnet (8453)
Setup: new random key, zero balance

search_tokens {"query":"USDC"}
{"success":true,"chainId":8453,"tokens":[{"address":"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913","symbol":"USDC","name":"USD Coin","decimals":6,"verified":true},{"address":"0xd04383398dd2426297da660f9cca3d439af9ce1b","symbol":"USDCx","name":"Super USDC","decimals":18,"verified":true}, ...]}

get_swap_quote {"fromToken":"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913","toToken":"0x0000000000000000000000000000000000000000","amount":"100","slippageBps":50}
{"success":true,"network":"Base","chainId":8453,"fromToken":{"address":"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913","symbol":"USDC","amount":"100"},"toToken":{"address":"0x0000000000000000000000000000000000000000","symbol":"ETH"},"expectedAmountOut":"0.040493452111308976","minimumAmountOut":"0.040290984850752432","priceImpactPct":"0.0000","feeBps":0,"feeAmount":"0","slippageBps":50,"route":[{"dex":"metric","percent":100,...}],"gasEstimate":"900000","blockNumber":52685507}

swap (same arguments)
{"success":false,"error":"Insufficient USDC balance: have 0, need 100"}
Network: Arbitrum One (42161)
Setup: new random key, zero balance

get_swap_quote {"fromToken":"0xaf88d065e77c8cc2239327c5edb3a432268e5831","toToken":"0x0000000000000000000000000000000000000000","amount":"100","slippageBps":50}
{"success":true,"network":"Arbitrum One","chainId":42161,...,"expectedAmountOut":"0.040505131863111766","minimumAmountOut":"0.040302606203796208","priceImpactPct":"0.0000",...}

Checklist

  • Added documentation to all relevant README.md files
  • Added a changelog entry

Adds search_tokens, get_swap_quote and swap actions backed by the Chord API (best-route swaps through one router contract on Ethereum, Base, Arbitrum One, BNB Chain, Avalanche C-Chain, Monad, Robinhood Chain and Arc), with unit tests, a README and a changeset.
@cb-heimdall

Copy link
Copy Markdown

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@github-actions github-actions Bot added documentation Improvements or additions to documentation action provider New action provider typescript labels Oct 16, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action provider New action provider documentation Improvements or additions to documentation typescript

Development

Successfully merging this pull request may close these issues.

2 participants