Skip to content

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

Open
KillerQueen-Z wants to merge 1 commit into
mainfrom
fix/balance-and-fund-hint
Open

feat(setup): show live Base USDC balance + OKX-specific fund walkthrough#9
KillerQueen-Z wants to merge 1 commit 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
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