Skip to content

feat: add Agent Data APIs action provider (x402-paid token risk, counterparty and sanctions checks) - #1657

Open
dagu3371 wants to merge 2 commits into
coinbase:mainfrom
dagu3371:feat/agent-data-apis-provider
Open

dagu3371 wants to merge 2 commits into
coinbase:mainfrom
dagu3371:feat/agent-data-apis-provider

Conversation

@dagu3371

@dagu3371 dagu3371 commented Nov 17, 2026 •

Copy link
Copy Markdown

Description

Adds an agentDataApisActionProvider with three safety checks that agents can call before they trade or pay. Each check is paid per call with x402 (USDC on Base) from the agent's own wallet, so no API key or account is needed.

Action When the agent should call it Returns
check_token_risk Before buying, swapping into or accepting a token avoid / caution / ok; buy/sell tax and round-trip cost from a simulated buy then sell on the token's deepest ETH/WETH pool (Uniswap V2, V3 and V4 plus Aerodrome on Base; Uniswap V2, V3 and V4 on Ethereum), catching honeypots including V4 hooks that confiscate sells; owner powers (mint, pause, blacklist, fee changes, trading switch); upgradeable proxy; liquidity; sanctioned owner; EIP-191 signed receipt
check_payment_counterparty Before sending funds, including to x402 payTo addresses block / review / clear; sanctioned crypto address match (OFAC, UK, EU lists); x402 seller reputation; live on-chain facts; optional name screening; signed receipt
screen_sanctions KYC/KYB-style name checks Scored candidate matches against OFAC (SDN + Consolidated), UN, EU and UK lists

Safety

  • Before paying, the provider reads the price from the HTTP 402 PAYMENT-REQUIRED challenge and refuses to pay if it exceeds maxPaymentUsdc (default 0.05 USDC, or AGENT_DATA_APIS_MAX_PAYMENT_USDC) or if no USDC-on-Base option is offered.
  • Payment uses the same @x402/fetch + registerExactEvmScheme pattern as the existing x402 action provider.
  • supportsNetwork is limited to base-mainnet, since payment is in USDC on Base.

Update: the token check now simulates on the deepest pool across Uniswap V2/V3/V4 and Aerodrome (previously Uniswap V2 only). README and action description updated accordingly; provider code and tests are unchanged.

Tests

Unit tests in agentDataApisActionProvider.test.ts (6/6 passing): network support, paid success path, spending-limit refusal, refusal when no USDC-on-Base option is offered, parameter passing, network-error handling. eslint, prettier --check and tsc pass for the changed files.

Manual end-to-end test calling the provider directly (not through an example chatbot/LLM):

Setup: compiled agentkit (tsc), ViemWalletProvider on Base mainnet with ~1.3 USDC
Network: base-mainnet

supportsNetwork(wallet.getNetwork()) -> true
getActions(wallet) -> AgentDataApisActionProvider_check_token_risk,
                      AgentDataApisActionProvider_check_payment_counterparty,
                      AgentDataApisActionProvider_screen_sanctions

checkTokenRisk({ tokenAddress: "0x6CA15965A6CCE396D8254a0b3379d13752D72E4F", chain: "ethereum" })
  -> verdict "caution", sell tax 19.93%, paid 0.01 USDC (settled on Base), signed receipt included

checkTokenRisk(...) with maxPaymentUsdc: 0.001
  -> "Error: the check costs 0.01 USDC, above the configured limit of 0.001 USDC; not paying."

Happy to run it through one of the example chatbots and add the transcript if that would help review.

Checklist

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

Adds x402-paid pre-trade and pre-payment safety checks: check_token_risk, check_payment_counterparty and screen_sanctions.
@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
1 if authored by an app that is not allowlisted and lacks verified human attribution 0
Sum 1

@github-actions github-actions Bot added documentation Improvements or additions to documentation action provider New action provider typescript labels Nov 17, 2026
The token check now simulates on the deepest ETH/WETH pool across Uniswap V2, V3 and V4 plus Aerodrome (Base), detects V4 hooks that confiscate sells, and reports round-trip cost.

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