bitflow-market-maker-public/SECURITY.md
Bought 16075e509b feat: local web console with sBTC and USDCx bridging
Adds a local web console for running and managing the market maker, with built-in bridging.

**Console** (`npm run ui`, http://127.0.0.1:5191)
- Fleet overview with total value, PnL vs HODL, and a Pause all button
- Per-bot pages: decisions, settings with validation, manual swap/add/withdraw, cash out to a saved payout address, dry-run to live checklist
- New-bot flow: create or import a wallet (key or recovery phrase), back up the key, fund it, pick a pool
- Bots are spawned as child processes with argv (no shell); key and phrase stay in the 0600 env file

**Bridging**
- BTC ↔ sBTC: deposit address per bot (sbtc library defaults), withdrawals via `initiate-withdrawal-request`, status from Emily
- USDC ↔ USDCx: deposits from an Ethereum wallet (EIP-6963) through Circle xReserve, withdrawals via `usdcx-v1.burn`; payouts are followed on Ethereum window by window
- Activity list with status and per-chain transaction links

**Security**
- Binds to 127.0.0.1 only; checks Host, Origin and Sec-Fetch-Site; JSON-only writes
- Routes that reveal a key or send funds to a typed address answer only the page
- Settings writes are allowlisted and validated; secrets are never returned

Tested end to end on mainnet in every bridge direction. `npm run build`, `npm test` (215 passing) and the UI build all pass. Docs: README, AGENTS.md, docs/RECOVERY.md, ROADMAP.
2026-10-28 16:13:58 -07:00

2.1 KiB

Security

This bot signs mainnet transactions with a private key you give it. Read this before running it live.

Keys and wallet

  • Use a dedicated Stacks account for the bot. Never reuse a wallet that holds anything else.
  • SIGNER_KEY lives only in your local .env.<pool> file. Those files are gitignored; keep them that way. Do not paste the key into issues, logs, chat, or screenshots.
  • A wallet the page creates comes from one recovery phrase kept in .mm-wallet (gitignored, readable only by your user). That phrase controls every bot the page made a wallet for, so treat it like all of their keys at once. A phrase you import is never stored; only the chosen account's key is.
  • The bot never sends tokens to any address other than the pool contracts and back to SIGNER_ADDRESS, except three things you start yourself on the page: cash out (to the payout address you saved), an sBTC withdrawal (to the Bitcoin address you typed on the Bridge page) and a USDCx withdrawal (to the Ethereum address you typed there). These routes answer only the page, not the API. USDC deposits are signed in your own Ethereum wallet; the console never holds that key. If you see anything else in a transaction preview, stop and report it.
  • At startup in live mode the bot refuses to run if SIGNER_KEY does not derive to SIGNER_ADDRESS.

Metrics API

The read-only HTTP API (/health, /status, /metrics, /history) binds to 127.0.0.1 by default. It exposes your address, balances, positions and tick history. Do not set METRICS_HTTP_HOST to 0.0.0.0 or a public IP. If you need remote access, use an SSH tunnel.

What this bot does not protect against

  • A compromised machine. Anyone who can read your env file can spend the wallet.
  • Bugs in third-party dependencies or in the on-chain contracts.
  • Market risk. Halts and caps limit the bot's actions; they do not limit what the market does to a position that is already deployed.

Reporting a vulnerability

To report a vulnerability, please use GitHub's private vulnerability reporting on this repository ("Security" tab, "Report a vulnerability").