Skip to content

feat(setup): show live Base USDC balance + OKX-specific fund walkthrough#9

Closed
KillerQueen-Z wants to merge 3 commits into
mainfrom
fix/balance-and-fund-hint
Closed

feat(setup): show live Base USDC balance + OKX-specific fund walkthrough#9
KillerQueen-Z wants to merge 3 commits into
mainfrom
fix/balance-and-fund-hint

Conversation

@KillerQueen-Z

Copy link
Copy Markdown
Collaborator

Why

PR #8 added a static `Fund / send USDC on Base` line in the wallet-ready box. Eden's follow-up: the user still didn't know whether they actually had to fund or where on OKX to send it from — they asked both questions after seeing the box.

What

When `xclawrouter setup` finishes (either freshly logged in OR already-signed-in path), query the OKX wallet's Base-chain USDC balance via the existing `BalanceMonitor`, then render a severity-tagged balance row + a concrete OKX-side funding walkthrough only when the user actually needs to fund.

Live demo output (empty wallet path):

```
┌──────────────────────────────────────────────────────────────────┐
│ ✓ Wallet ready │
│ │
│ EVM address │
│ 0xe34c9d531953a1c51164ecd943b5a6cb81d910f0 │
│ │
│ Email andy@blockrun.ai
│ Signing OKX TEE (no local private key) │
│ │
│ Balance $0.00 USDC on Base ⚠ empty — fund to unlock paid models │
│ │
│ Fund via OKX (Base network, USDC): │
│ 1. Open the OKX app → Wallet │
│ 2. Send USDC on Base to the address above │
│ 3. ~$5 covers thousands of paid requests │
└──────────────────────────────────────────────────────────────────┘
```

When the wallet is funded (≥ $1), the line collapses to green `✓ ready for paid models` and the funding walkthrough is hidden — re-running `setup` on a healthy install stays tight.

Severity buckets

Balance Label Color
< $0.0001 `⚠ empty — fund to unlock paid models` yellow
$0.0001 – $1 `⚠ low (recommend $5+ for stable paid usage)` yellow
≥ $1 `✓ ready for paid models` green

Resilience

Network or RPC failure is non-fatal — the box prints `(could not query Base RPC — check your network)` and the funding walkthrough still appears as a fallback.

`BalanceMonitor` is dynamic-imported so the CLI doesn't pull viem (heavy) until setup is actually run.

Test plan

  • Live test: setup hits Base RPC, returns $0.00 for an empty wallet, renders the yellow ⚠ row + funding steps
  • `npm run typecheck` clean, `npx vitest run src/` 460 tests pass, prettier + eslint clean

After eden's "show what chain to fund + how much" request. The PR #8
wallet-ready box hinted at funding but had no live balance check and
no concrete OKX-side steps. Users still asked "do I actually need to
fund?" and "where on OKX do I send from?".

Changes:

- Query Base-chain USDC balance via the existing BalanceMonitor right
  after OKX login completes (or right after detecting an existing
  session in the already-signed-in branch). Network/RPC failure is
  non-fatal — we render "could not query Base RPC" instead of aborting
  setup.

- Add a balance row to the wallet-ready summary box, severity-tagged:
    empty  (< $0.0001)   →  yellow ⚠ "fund to unlock paid models"
    low    ($0.0001..$1) →  yellow ⚠ "recommend $5+"
    ok     (≥ $1)        →  green ✓  "ready for paid models"

- Only render the funding walkthrough when balance is missing/empty/low.
  Already-funded users see a tight 6-line box; users that need money
  see the OKX-specific 3-step guide:

    Fund via OKX (Base network, USDC):
      1. Open the OKX app → Wallet
      2. Send USDC on Base to the address above
      3. ~$5 covers thousands of paid requests

  Naming OKX explicitly + naming Base explicitly avoids users bridging
  to a wrong network (the recurring support footgun).

- Lazy-import BalanceMonitor so the CLI doesn't pull viem until setup
  actually needs to query a balance.
@KillerQueen-Z KillerQueen-Z force-pushed the fix/balance-and-fund-hint branch from fead5b0 to c31a46d Compare May 14, 2026 21:37
- onchainos-adapter: `payment x402-pay` → `payment pay`. onchainos v3.3+
  renamed the subcommand; OKX-wallet paid-model calls returned HTTP 500
  ("unrecognized subcommand 'x402-pay'") otherwise.
- cli: auto-switch the persisted payment chain to Base for OKX (EVM-only)
  wallets, unless the user pinned a chain via XCLAWROUTER_PAYMENT_CHAIN.
- cli: force blocking stdout in non-TTY contexts so the Agentic Wallet status
  block and funding hints flush under systemd / Docker / PM2 / pipes.
- cli: framed "Send USDC on Base" funding guidance for OKX wallets at $0 balance.
- extract the three startup behaviours into src/cli-startup.ts with unit tests.
- correct xai/grok-4-0709 pricing $0.20/$1.50 → $3.00/$15.00 (and move it from
  the Budget table to Premium, matching its real ~$0.0090/request).
- standardize the free-model prefix nvidia/ → free/ (canonical catalog id) and
  the free-tier count to 10 across the README.
- document 8 catalog models that were missing from the price tables
  (gpt-5.4-nano/mini, gemini-3.1-flash-lite, grok-4(.1)-fast-non-reasoning,
  grok-4.20-reasoning/non-reasoning/multi-agent), with features matched to the
  catalog flags.
- unify the advertised model count to "60+" across README, CLI, CLAUDE.md and
  openclaw.plugin.json (64 real models; /v1/models lists more by design because
  it includes aliases).
@KillerQueen-Z

Copy link
Copy Markdown
Collaborator Author

Superseded by #10 (rebuilt on current main / v0.12.190). Closing.

@KillerQueen-Z KillerQueen-Z deleted the fix/balance-and-fund-hint branch June 11, 2026 20:22
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