When an alert fires, the Slack message now includes the full roster — low (🔴) and healthy (🟢) wallets alike — each with its complete, copy-pasteable address (backticked), instead of only the low wallets with a truncated address. The posting trigger and dedup/reminder logic are unchanged: still silent when all wallets are healthy; the buyer (normally healthy) now appears for context. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2.6 KiB
wallet-monitor
One-shot wallet-balance Slack alerter for the vector-marketplace mainnet box.
Checks every wallet in wallets.json against a threshold (default 10 APEX),
posts a combined Slack message when any wallet is below it, re-reminds every
reminder_hours while a wallet stays low, and posts a recovery message when it
climbs back above. Each alert lists every monitored wallet — low (🔴) and
healthy (🟢) — with its full, copy-pasteable address; it stays fully silent
when all wallets are healthy. Balances are read from Ogmios via
ReadOnlyOgmiosProvider (@marketplace/shared/chain) — the same client behind
the buyer's /v1/wallet/balance and buyer/scripts/monitor-wallets.ts.
It is not a long-running server: it runs once and exits, invoked hourly by
cron through docker compose run --rm. Dedup state lives in
wallet-monitor/data/state.json (bind-mounted, gitignored).
Files
| File | Purpose |
|---|---|
src/index.ts |
one-shot check + classify + Slack post + state |
src/config.ts |
env loading + wallets.json parsing/validation |
src/slack.ts |
postSlack() Incoming-Webhook helper |
wallets.json |
the wallet list + thresholds (gitignored; see wallets.example.json) |
.env |
SLACK_WEBHOOK_URL (gitignored; see .env.example) |
Deploy on the box (one-time)
- Generate
wallets.json. From a laptop with SSH access, runpnpm tsx buyer/scripts/monitor-wallets.ts --jsonand copy theaddressof each of the 7*@vector-marketplacerows intowallet-monitor/wallets.json(start fromwallets.example.json). Per-walletmin_ap3xis optional. - Set the webhook.
cp wallet-monitor/.env.example wallet-monitor/.envand fill inSLACK_WEBHOOK_URL. - Build.
docker compose -f deploy/mainnet/docker-compose.wallet-monitor.yml build - Smoke-test the webhook.
docker compose -f deploy/mainnet/docker-compose.wallet-monitor.yml run --rm -e TEST=1 wallet-monitor→ expect a "✅ wallet-monitor configured" message in Slack. - Schedule it. Add
/etc/cron.d/wallet-monitor:0 * * * * root cd /root/agents-marketplace && docker compose -f deploy/mainnet/docker-compose.wallet-monitor.yml run --rm wallet-monitor >> /var/log/wallet-monitor.log 2>&1
Behaviour notes
- Failures don't alert. If Ogmios is unreachable or a wallet query errors, the run logs to stderr and exits non-zero — no Slack noise — and that wallet's state is left untouched (an Ogmios blip is never mistaken for a recovery).
- State only advances on a successful post. A failed Slack POST leaves the state file unchanged so the alert retries on the next run.