Skip to content

feat: add yellow.pro trading tools (auth, balances, orders, deposits, withdrawals)#2

Open
calj wants to merge 2 commits into
masterfrom
feat/yellow-pro-tools
Open

feat: add yellow.pro trading tools (auth, balances, orders, deposits, withdrawals)#2
calj wants to merge 2 commits into
masterfrom
feat/yellow-pro-tools

Conversation

@calj
Copy link
Copy Markdown

@calj calj commented Apr 4, 2026

Summary

14 new MCP tools for direct yellow.pro exchange integration. The agent handles trading, deposits, and withdrawals entirely through mcp-beehive — no tower proxy needed.

New Tools

Auth

Tool Description
yellow_auth(wallet_name) Full challenge→sign→verify in one call. JWT stored in memory.
yellow_auth_status() Check current session
yellow_logout() Clear session

Market Data (public, no auth)

Tool Description
yellow_exchange_info() Trading pairs, fees, filters
yellow_klines(symbol, interval) OHLCV candles

Account

Tool Description
yellow_balances() Available, locked, USD value

Trading

Tool Description
yellow_place_order(market, side, amount, price) Place a spot order
yellow_cancel_order(order_id, market) Cancel an open order
yellow_open_orders() List open orders
yellow_order_history() All orders (filled + cancelled)
yellow_trades() Executed trade history

Deposits (on-chain)

Tool Description
yellow_deposit_prepare(asset, amount) Build unsigned tx steps (for manual execution)
yellow_deposit(wallet, asset, amount) Full deposit: approve→wait→deposit→wait

Withdrawals

Tool Description
yellow_withdraw(asset, amount) Request via yellow.pro API
yellow_withdrawals() Withdrawal history

Architecture

  • beehive/yellow_pro.py — API client, session management (in-memory JWT), ABI encoding for custody contract
  • beehive/tools/yellow.py — 14 @mcp.tool definitions
  • httpx added as dependency for HTTP calls

Key design decisions

  • yellow_auth() is a single tool — the agent calls it once and the entire challenge→sign→verify flow happens internally. No multi-step orchestration needed.
  • yellow_deposit() is all-in-one — builds calldata, signs approve tx, waits for confirmation, signs deposit tx, waits again. Returns success/failure with all tx hashes.
  • Session in memory — JWT is stored in-process, not on disk. Lost on restart (agent just calls yellow_auth() again).
  • Custody contract: 0x3a9624f9BB2Dc43E90c0699DDc4A9b6BEc147Cde (Ethereum mainnet)
  • Supported assets: ETH (native), USDT (6 dec), WBTC (8 dec), YELLOW (18 dec)

Tests

28 new integration tests covering:

  • ABI encoding (parse_units, encode_approve, encode_deposit)
  • Deposit step building (ETH 1-step, ERC20 2-step, edge cases)
  • Session management (set, get, clear, require)
  • Token config validation
  • deposit_prepare tool (no network)
196 passed, 1 warning in 5.21s

All 196 tests pass (151 existing + 17 signing PR + 28 new).

Dependencies

calj added 2 commits April 5, 2026 00:14
Two new MCP tools for off-chain message signing:

sign_message(wallet_name, message):
  EIP-191 personal_sign. Returns address + hex signature.
  Use case: web3 authentication challenges, proof of ownership.

sign_typed_data(wallet_name, domain, types, primary_type, message):
  EIP-712 structured data signing (signTypedData_v4 compatible).
  Use case: permits, gasless approvals, order signatures.

Both tools use the existing wallet.derive_account() infrastructure.
No new dependencies — eth_account (transitive dep of web3) provides
encode_defunct and encode_typed_data.

17 integration tests covering signature generation, recovery,
wallet name formats, and complex EIP-712 structures (ERC20 Permit).
…, withdrawals

14 new MCP tools for direct yellow.pro integration:

Auth:
  yellow_auth(wallet_name) — full challenge→sign→verify in one call
  yellow_auth_status() — check session
  yellow_logout() — clear session

Market data (public):
  yellow_exchange_info() — trading pairs, fees, filters
  yellow_klines(symbol, interval) — OHLCV candles

Account:
  yellow_balances() — available, locked, USD value

Trading:
  yellow_place_order(market, side, amount, price)
  yellow_cancel_order(order_id, market)
  yellow_open_orders(), yellow_order_history(), yellow_trades()

Deposits (on-chain):
  yellow_deposit_prepare(asset, amount) — build unsigned tx steps
  yellow_deposit(wallet, asset, amount) — sign + broadcast all-in-one

Withdrawals:
  yellow_withdraw(asset, amount) — request via API
  yellow_withdrawals() — history

Architecture:
- beehive/yellow_pro.py: API client, session management, ABI encoding
- beehive/tools/yellow.py: MCP tool definitions
- Session stored in-process memory (JWT from auth_verify)
- Deposit flow: approve→wait→deposit→wait (ERC20) or deposit (ETH)
- Custody contract: 0x3a9624f9BB2Dc43E90c0699DDc4A9b6BEc147Cde
- Supported: ETH, USDT (6 dec), WBTC (8 dec), YELLOW (18 dec)
- httpx added as dependency for yellow.pro API calls

28 new tests, 196 total (all passing).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant