Add x402 monetization - let AI agents pay per API call#3
Add x402 monetization - let AI agents pay per API call#3sam00101011 wants to merge 34 commits intookx:masterfrom
Conversation
…ackage-lock.json)
Unit tests should import from the module under test, not through the top-level entrypoint re-export. This decouples help.test.ts from index.ts so the test won't silently break if the re-export is ever removed. Closes #40 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
smol-toml was added as an explicit CLI dependency in MR !85 to fix an undeclared implicit dep. This completes the fix by removing the direct declaration — TOML functionality is now fully provided through @agent-tradekit/core which bundles smol-toml internally. - Remove smol-toml from packages/cli/package.json dependencies - Remove smol-toml from tsup.config.ts noExternal list - Update bundle.test.ts noExternal array to match Closes #39 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ll-notice.js Add `scripts/postinstall-notice.js` at monorepo root as the single source of truth. The build step now copies it to each package's `scripts/` dir; generated copies are gitignored. Resolves #50. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace Unix-only `2>/dev/null || true` with cross-platform `|| exit 0` so postinstall does not fail on Windows cmd.exe - Expand `clean` script to also remove generated `scripts/` directory in addition to `dist/`, ensuring thorough cleanup of all build outputs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Change /npm/dm/ to /npm/dt/ in both README.md and README.zh-CN.md - Update badge labels to "mcp+total+downloads" / "cli+total+downloads" - Affects 4 badge URLs total; click-through links unchanged Closes #52
- Move earn.ts → tools/earn/savings.ts - Move onchain-earn.ts → tools/earn/onchain.ts - Add tools/earn/index.ts to aggregate exports - Update all import paths - Consistent with bot/ sub-module pattern Closes #64 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
New tool `market_get_stock_tokens` fetches all instruments via GET /api/v5/public/instruments and filters client-side by instCategory=3 (stock tokens, e.g. AAPL-USDT-SWAP). - packages/core: add market_get_stock_tokens ToolSpec - packages/cli: add cmdMarketStockTokens, wire okx market stock-tokens - help: add stock-tokens entry to market command list - docs: update CHANGELOG (EN/ZH), README (EN/ZH) tool count 95→96 Closes #65 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- core/test/tools.test.ts: 9 cases covering endpoint routing, default instType=SWAP, instId passthrough, client-side filtering by instCategory=3, empty result, and non-array passthrough - cli/test/index.test.ts: dispatch coverage for handleMarketPublicCommand stock-tokens action + cmdMarketStockTokens table/JSON/empty output Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
earn.savings, earn.onchain, and earn.dcd are now included when using --modules all. Previously required explicit --modules all,earn opt-in. Closes #66 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Extend spot_place_algo_order ordType enum with "move_order_stop" and add callbackRatio, callbackSpread, activePx optional fields to schema and handler - Extend swap_place_algo_order similarly so it supports trailing stop natively - Update spot_get_algo_orders parallel queries from 2 to 3 (add move_order_stop) - Add CLI cmdSpotAlgoTrailPlace and route "okx spot algo trail" subcommand - Mark swap_place_move_stop_order as [DEPRECATED] (kept for backward compat) - Update tests: fix spot_get_algo_orders parallel count assertions (2 → 3) - Add spot-trail CLI unit tests covering callbackRatio, callbackSpread, output - Update CHANGELOG.md and CHANGELOG.zh-CN.md Closes #67 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…asing OKX API expects callBackRatio and callBackSpread (capital B) but we were sending callbackRatio and callbackSpread (lowercase b), causing sCode 50015 errors on move_order_stop algo orders. Fixed both swap_place_algo_order and swap_place_move_stop_order handlers. MCP input schema parameter names remain unchanged (callbackRatio/callbackSpread). Added unit tests asserting capital-B key names in POST body. Closes #69 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…criptions - Replace per-module normalize() with shared normalizeResponse from helpers.ts - Extract buildAttachAlgoOrds() for TP/SL parameter assembly - Trim verbose tool schema descriptions Closes #70 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…helper, trim tool descriptions - Remove 9 local normalize() copies; use shared normalizeResponse from helpers.ts - Extract buildAttachAlgoOrds() helper in helpers.ts, replace 5 inline TP/SL blocks in spot/swap/futures trade handlers - Trim rate-limit and endpoint-type labels from tool descriptions (~token reduction) - Update CHANGELOG.md and CHANGELOG.zh-CN.md Closes #70 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add 7 futures core tools: futures_amend_order, futures_close_position, futures_set_leverage, futures_get_leverage, futures_batch_orders, futures_batch_amend, futures_batch_cancel - Add 5 futures algo tools (registerFuturesAlgoTools): futures_place_algo_order, futures_place_move_stop_order, futures_amend_algo_order, futures_cancel_algo_orders, futures_get_algo_orders - Fix swap_get_algo_orders hardcoded instType: add optional instType param (default "SWAP", supports "FUTURES") instead of hardcoding "SWAP" - Update CLI futures.ts to call futures_* tools directly (no longer re-exporting swap functions), giving futures its own dedicated API surface - Update tests, CHANGELOG, README tool counts (96 → 108, futures 6 → 18) Closes #71 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…se 2) - Add attachAlgoOrds (TP/SL) to option_place_order - Add option_place_algo_order, option_amend_algo_order, option_cancel_algo_orders, option_get_algo_orders - Add CLI commands: option algo place/amend/cancel/orders - Update docs and CHANGELOG Closes #72 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add option algo entries to [Unreleased] in CHANGELOG.md and CHANGELOG.zh-CN.md: 4 new core tools (option_place_algo_order/amend/cancel/get_algo_orders), option_place_order TP/SL attach support, and 4 new CLI subcommands (okx option algo place/amend/cancel/orders) Closes #72
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add callbackRatio, callbackSpread, activePx to opts type of cmdSpotAlgoPlace, cmdSwapAlgoPlace, cmdFuturesAlgoPlace - Pass the three params through to the tool runner in each function - Update handleSpotAlgoCommand, handleSwapAlgoCommand, handleFuturesAlgoCommand "place" branches in index.ts to forward the params from CliValues - Add unit tests for ordType=move_order_stop scenario across all three modules, plus no-regression tests for conditional ordType Previously, passing --callbackRatio/--callbackSpread/--activePx via algo place was silently dropped, causing API error 50015 (missing required param) for trailing stop orders. Closes #74 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cmdSwapAlgoCancel was passing { instId, algoId } directly to
swap_cancel_algo_orders, but the handler expects { orders: [{ instId, algoId }] },
causing "orders must be a non-empty array" error at runtime.
Wraps the args in the orders array, consistent with futures/option
cancel commands. Adds unit test to verify correct param format.
Closes #76
- Add CHANGELOG.md / CHANGELOG.zh-CN.md entries for #76 fix under [1.2.4-beta.6] ### Fixed (blocker resolved) - Refactor muteStdout as a wrapper around captureStdout to eliminate duplicated stdout-patching logic in swap-algo-cancel.test.ts (nit resolved) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hi @sam00101011 , Thanks for the idea and PR! x402 is an interesting protocol, but it doesn't fit That said, there's a related effort where x402 could be valuable: the Agent Skills ecosystem. I'm involved in discussions around a standardized Skills Marketplace (see agentskills/agentskills Discussion #252). One open question is how to create sustainable incentives for skill authors. x402's pay-per-call model could be a great fit here — imagine skill creators earning revenue when agents use their skills. If you're interested in exploring this direction, I'd suggest joining that discussion. The Skills layer is where monetization makes architectural sense, and x402 could be a strong building block for the ecosystem. Closing this PR since it doesn't apply to |
What is this?
x402 is an open protocol that lets AI agents pay for API calls using the HTTP 402 status code. Instead of API keys and billing dashboards, agents pay per call in USDC on Base.
This PR adds the foundation for monetizing okx/agent-trade-kit's API endpoints. We found 10 endpoints in your README that agents could pay to access.
Why agents would pay for okx/agent-trade-kit
Each of these capabilities becomes a pay-per-call endpoint that AI agents discover and pay for automatically:
With x402, every feature above is instantly monetizable. Agents on Claude, Cursor, and any MCP client can discover and pay for access via 402.bot.
What's included
.well-known/x402.jsonx402-middleware-example.ts402and verifies paymentsHow it works
Settlement is instant. No intermediary holds funds. Revenue goes directly to your wallet.
What you'd earn
~$1500/mo projected (10 endpoints x ~150 agent calls/mo x $0.01)
To activate
YOUR_WALLET_ADDRESSin.well-known/x402.jsonwith your Base walletx402-middleware-example.ts)Your endpoints will automatically appear in Claude, Cursor, and any MCP-compatible agent via the 402.bot MCP server.
Live demo
See how okx/agent-trade-kit works on the x402 network ->
Links
This PR was opened by 402.bot. x402 is an open protocol - you keep 100% of revenue. We just route agents to providers. If this isn't relevant, feel free to close.