Skip to content

Commit cb9a1fe

Browse files
twzrd-solclaude
andcommitted
docs(wzrd-markets): L-03 comment + wzrd-rails→markets upgrade runbook
L-03: expand MAX_MARKET_DURATION_SLOTS comment to document the ~150-day worst-case fund lock (resolve deadline + dispute window + one extension stack additively). Prevents UIs/SDKs from mis-documenting 90-day ceiling. Also adds docs/wzrd-rails-to-markets-upgrade.md: on-chain state audit results, accepted write-offs (internal CCM only), pre-upgrade checklist, and exact solana-program upgrade commands. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c0e2705 commit cb9a1fe

2 files changed

Lines changed: 115 additions & 0 deletions

File tree

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# wzrd-rails → wzrd-markets Upgrade Runbook
2+
3+
**Program ID (mutable):** `BdSv824hvYeGAWQZUcypRzAor8yJit2qeqCHty3CSZy9`
4+
**Current binary:** wzrd-rails (MasterChef CCM staking + listen payout)
5+
**Target binary:** wzrd-markets (prediction markets CPMM)
6+
**Date assessed:** 2026-06-23
7+
8+
---
9+
10+
## On-Chain State Audit Summary
11+
12+
| Account | Address | Lamports | Notes |
13+
|---------|---------|---------|-------|
14+
| Config PDA | `7pwUU1hv...` | ~1,100 | Orphaned after upgrade |
15+
| StakePool PDA | `6oQDChd9...` | ~2,200 | Orphaned after upgrade |
16+
| UserStake (agent-058) | `DZZCvBvoLPc3eJM8jCS6fRW3s52GZZQs7UcnEqZgacE7` | ~2,000 | 449 CCM staked — UNLOCKED |
17+
| UserStake (seed-cohort) | `HnR59DAGJNiW4q8ZHzgQzWYJcMYPiWrFhb733Tcqxb34` | ~2,000 | 3.1M CCM staked — UNLOCKED |
18+
| stake_vault | `H8uqT29s3Kc9JLR3s6G2L3ZyF9avz2CJKfhPK1EbcmXr` || 3,116,139.77 CCM |
19+
| reward_vault | `4HnYVcAs...` || 99.5 CCM |
20+
21+
Both UserStake positions belong to **internal WZRD wallets** (not external users).
22+
Both locks have expired as of 2026-06-23.
23+
24+
**Accepted write-offs (internal wallets only):**
25+
- 3.1M CCM in stake_vault — seed-cohort keypair unavailable; treated as permanent stake
26+
- 99.5 CCM in reward_vault — negligible
27+
- ~0.007 SOL across orphaned PDAs — negligible
28+
29+
---
30+
31+
## Pre-Upgrade Checklist
32+
33+
- [ ] **Optional**: Drain agent-058 position (449 CCM)
34+
```bash
35+
# Keypair: /home/twzrd/security/swarm-keys/agent-058.json
36+
# Requires read access to that file (root-owned, enter as sudo or via founder terminal)
37+
# See: ops/scripts/smoke-rails-canary.sh for account addresses
38+
anchor idl type /home/twzrd/attention-oracle-program/target/idl/wzrd_rails.json
39+
# Call unstake with pool_id=0, wallet=agent-058.json
40+
```
41+
- [ ] Ensure upgrade authority wallet has **≥ 5.1 SOL liquid** (5.089 SOL buffer + fees)
42+
- Buffer wallet is returned after upgrade completes
43+
- Program data account: `~731,120 bytes → ~5.089 SOL buffer`
44+
- [ ] Build release binary:
45+
```bash
46+
cd /home/twzrd/attention-oracle-program
47+
anchor build --program-name wzrd_markets -- --release
48+
# Binary: target/deploy/wzrd_markets.so
49+
```
50+
- [ ] Verify binary size is within buffer capacity:
51+
```bash
52+
ls -la target/deploy/wzrd_markets.so
53+
# Must be ≤ 731,120 bytes to fit current program data account
54+
# If larger, additional SOL is needed for the expanded buffer
55+
```
56+
57+
---
58+
59+
## Upgrade Command (requires founder wallet + SOL)
60+
61+
```bash
62+
# Step 1: Write buffer account
63+
solana program write-buffer \
64+
target/deploy/wzrd_markets.so \
65+
--keypair /path/to/upgrade-authority.json \
66+
--url mainnet-beta
67+
68+
# Note the buffer address printed above, then:
69+
70+
# Step 2: Upgrade program
71+
solana program upgrade \
72+
<BUFFER_ADDRESS> \
73+
BdSv824hvYeGAWQZUcypRzAor8yJit2qeqCHty3CSZy9 \
74+
--keypair /path/to/upgrade-authority.json \
75+
--url mainnet-beta
76+
77+
# Buffer SOL is returned to the payer automatically on success.
78+
```
79+
80+
---
81+
82+
## Post-Upgrade Verification
83+
84+
```bash
85+
# Confirm new program is active
86+
solana program show BdSv824hvYeGAWQZUcypRzAor8yJit2qeqCHty3CSZy9
87+
88+
# Smoke test: initialize_markets_config should work with canonical USDC
89+
# anchor test --skip-local-validator (requires RPC config)
90+
```
91+
92+
---
93+
94+
## What Changes After Upgrade
95+
96+
| Before | After |
97+
|--------|-------|
98+
| wzrd-rails instructions (stake/unstake/claim/listen payout) | wzrd-markets instructions (create/resolve/deposit/redeem) |
99+
| StakePool/UserStake accounts (owned by program, no close instruction) | Orphaned — ~0.007 SOL permanently locked |
100+
| stake_vault CCM (3.1M + 449 CCM) | Permanently locked (no instruction to drain) |
101+
| reward_vault CCM (99.5 CCM) | Permanently locked |
102+
103+
All orphaned amounts are internal WZRD wallets only — no external user funds at risk.

programs/wzrd-markets/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,18 @@ pub const INVALID_RECOVERY_GRACE_SLOTS: u64 = 216_000;
131131
/// `resolve_deadline_slot`. ~90 days at 400 ms/slot. Without an upper bound,
132132
/// an admin can create a market whose deadline is years away, permanently locking
133133
/// collateral even when the market is stale (L-01).
134+
///
135+
/// NOTE (L-03): This constant bounds the *resolution deadline only*, not the total
136+
/// fund-lock period. User collateral is unlocked at `settle_unlock_slot`, which is
137+
/// set at resolution time and can extend beyond this window. Worst-case stack:
138+
/// resolve_deadline ≤ MAX_MARKET_DURATION_SLOTS (~90 days)
139+
/// + dispute window ≤ MAX_DISPUTE_WINDOW_SLOTS (~30 days, added at resolve)
140+
/// + one extension ≤ MAX_DISPUTE_WINDOW_SLOTS (~30 days, additive from unlock)
141+
/// ─────────────────────────────────────────────────────────────────────────────
142+
/// max fund lock (~150 days)
143+
///
144+
/// UIs, SDKs, and user agreements should document the ~150-day worst-case lock
145+
/// rather than the ~90-day value implied by this constant alone.
134146
pub const MAX_MARKET_DURATION_SLOTS: u64 = 19_440_000;
135147

136148
// ─── settle_unlock helpers (L-03) ─────────────────────────────────────────────

0 commit comments

Comments
 (0)