From 9b57d0864bf1e731714de0b17c9b5029be123a8a Mon Sep 17 00:00:00 2001 From: Abhishek Krishna Date: Mon, 25 May 2026 22:00:39 +0530 Subject: [PATCH] =?UTF-8?q?feat(lab):=20CR8-USD=20+=20MUSD=20lifecycle=20i?= =?UTF-8?q?nteractive=20lab=20=E2=80=94=208=20scenes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Single-file static HTML canvas demo at lab/index.html (1305 lines) walking the stablecoin-toolkit primitives in eight scenes: 1. Mint with burn toll 1% toll routed to treasury 2. Redeem with burn toll 0.5% redemption toll 3. Idle yield park Treasury float → Lucidly syUSD 4. MUSD vs CR8-USD Side-by-side: MUSD no-toll micropayments rail vs CR8-USD burn-toll supply-discipline coin 5. Pull-payment royalty MUSD.batchRoyaltyDistribution + pendingWithdrawals + claimPayments pull pattern (matches actual contract) 6. Depeg circuit breaker Real DepegGuard state machine — Normal/Caution/Hard with cautionBps=50, hardBps=200, hardRedeemHaltSeconds=12h (matches in-tree defaults) 7. Multi-geography compliance ComplianceModule.checkCompliance with ISO bytes2 codes ('KP' restricted, 'US' allowed) — real revert GeographyRestricted 8. Reserve audit ReserveManager.pullPorReserve against Chainlink PoR (POR_RESERVE_ID = bytes32(0)); getReserveRatioBps vs totalSupplyTracked Palette: ok-green primary (money rails feel), cyan for collateral/yield, gold for treasury, hot-red for compliance + depeg. Background a green-leaning near-black (#050807). Real toolkit-repo references woven in (verified against in-tree source): - DepegGuard state machine + defaults - ComplianceModule.checkCompliance flow + bytes2 geography codes - Minter compliance → reserve-check → fee-split pipeline - ReserveManager.pullPorReserve + getReserveRatioBps - MUSD pendingWithdrawals + claimPayments pull pattern from kcolbchain/muzix/src/MUSD.sol The 1% / 0.5% tolls are framed as CR8-USD-specific parameterization (existing toolkit defaults are 10 bps); scene captions call this out. lab/SCENES.md (107 lines) documents the scene contract. JS syntax checked. --- lab/SCENES.md | 107 ++++ lab/index.html | 1305 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1412 insertions(+) create mode 100644 lab/SCENES.md create mode 100644 lab/index.html diff --git a/lab/SCENES.md b/lab/SCENES.md new file mode 100644 index 0000000..96c09bf --- /dev/null +++ b/lab/SCENES.md @@ -0,0 +1,107 @@ +# Stablecoin-toolkit lab — scene contract + +`lab/index.html` is a single-file static lab with no build step. It walks a reviewer through the full CR8-USD / MUSD lifecycle on the kcolbchain stablecoin-toolkit. Add a scene by appending one object to the `SCENES` array. + +## Scene shape + +```js +SCENES.push({ + name: "Your scene title", + captions: [ + "Markdown-lite caption for step 0 (intro / idle state)", + "Caption for step 1 — describe the on-chain action with Minter.mint(...)", + "Caption for step 2", + // ... + ], + setup() { + // Place agents on the canvas. cx, cy = stage center. + const cx = W / 2, cy = H / 2 - 20; + agents = { + user: makeAgent({ id: "user", name: "User", role: "KYC tier-1", type: "user", x: cx - 300, y: cy, usdc: 1000 }), + minter: makeAgent({ id: "minter", name: "Minter", role: "issuance gateway", type: "contract", x: cx, y: cy }), + stablecoin: makeAgent({ id: "stablecoin", name: "CR8-USD", role: "ERC-20 · 6 dec", type: "stablecoin", x: cx + 300, y: cy }), + }; + }, + steps: [ + () => { /* step 0: idle intro, no animation */ }, + (now) => { + addTx({ from: "user", to: "minter", color: "signal", label: "deposit 1,000 USDC", dur: 1500 }); + byId("minter").flash = 1; + // schedule follow-ups with setTimeout for staggered effects + }, + // ... + ], +}); +``` + +The number of `captions` should match the number of `steps`. The transport auto-advances every `STEP_INTERVAL` (default 1.8s) while playing; users can also `space` (play/pause), `n` (step), `r` (restart), or `←`/`→` to jump scenes. + +## Agent types (color / shape defaults) + +| type | shape | color | use for | +|---|---|---|---| +| `user` | circle | warm white (`--wallet`) | end-user wallet — depositor, redeemer, holder | +| `stablecoin` | hex | ok-green (`--ok`) | the issued coin itself — CR8-USD, MUSD | +| `treasury` | hex | gold (`--gold`) | fee collector / protocol treasury | +| `reserve` | hex | cyan (`--signal`) | USDC reserve vault / Chainlink PoR reserve | +| `lucidly` | diamond | cyan (`--signal`) | Lucidly syUSD adapter — idle yield destination | +| `oracle` | diamond | purple (`--dsp`) | Chainlink price feed / data oracle | +| `guard` | hex | hot red (`--hot`) | `DepegGuard` state machine | +| `venue` | square | orange (`--warn`) | DEX / CEX / off-chain trading venue | +| `compliance` | circle | hot red (`--hot`) | `ComplianceModule` — KYC / geography gatekeeper | +| `catalog` | hex | pink (`--label`) | `MuzixCatalog` — cap-table source for MUSD pulls | +| `contract` | hex | cyan (`--signal`) | generic toolkit contract (Minter, ReserveManager, etc.) | +| `holder` | circle | warm white (`--wallet`) | cap-table holder claiming a pull-payment | + +Override `r`, `color`, or `shape` directly in `makeAgent({...})` if a scene needs something custom (e.g. shrinking a contract to a satellite role with `r: 22`). + +## Transaction colors + +`addTx({ from, to, color, label, dur, curve, dotSize })` + +| color key | use for | +|---|---| +| `accent` / `ok` | money flow — mint, redeem payout, royalty fan-out (the protocol's primary color, green) | +| `signal` | contract → contract reads, USDC moving in/out of vault | +| `dsp` | oracle → contract pushes (Chainlink price, PoR feed) | +| `warn` | venue / DEX action — fills, off-peg prints | +| `hot` | compliance reverts, depeg trips, mint-paused signals | +| `muted` | low-emphasis tx (claims, withdrawals, follow-ups) | + +`curve` is a perpendicular offset (px) for parallel paths — use ±20–40 when multiple txs share the same endpoints so they don't overlap. + +## Balance / USDC display + +Agents can show one of two in-shape numbers: + +- `balance: 990` — renders as `$990` in green (stablecoin balance — CR8-USD or MUSD). +- `usdc: 1000` — renders as `$1k` in cyan (USDC / collateral side). + +Use one or the other per agent for the in-shape readout; both render in the tooltip if both are set. + +## Step pacing rules of thumb + +- Keep each step's effect under ~2s. The auto-advance interval is 1.8s; if you need longer, split into two steps or bump `STEP_INTERVAL`. +- Use `setTimeout` within a step for staggered fan-outs — see scene 1's burn-toll fan or scene 5's pull-payment claims. +- At each step boundary, `flash` decays by 70% and `glow` by 40%. Use `byId("x").glow = 1` to **sustain** attention across multiple steps. +- For state-machine scenes (depeg breaker), mutate the agent's `role` string to reflect the new state (`"state: Caution"`) and use `note` for the transient observation reason. + +## Naming style + +Match the existing voice: short verb-led titles ("Mint with burn toll", "Idle yield park"), captions that read like a protocol-engineer's narration plus the concrete contract call in ``. The goal is for a reviewer (auditor, integrator, regulator) to follow the on-chain flow without prior toolkit context. + +Reference real toolkit primitives by name — `Minter.mint`, `Stablecoin.burnFrom`, `ComplianceModule.checkCompliance`, `ReserveManager.pullPorReserve`, `DepegGuard.poke`, `MUSD.batchRoyaltyDistribution`, `claimPayments`. The strings in `` are load-bearing: they tell the reader exactly which function to grep for in `contracts/`. + +## Numbers style + +Use plausible production numbers, not toy ones: + +- Mint toll: **1%** for CR8-USD, **0%** for MUSD. +- Redeem toll: **0.5%** for CR8-USD. +- Default fee bps (per `Minter.sol`): **10 bps = 0.1%** is the floor used in fee-comparison scenes. +- Reserve ratio floor: **10,000 bps (100%)** for US/template, **10,500 (105%)** for India per `config/geographies/`. +- Depeg thresholds (per `DepegGuard.sol` defaults): `cautionBps = 50` (50 bps off peg), `hardBps = 200`, `recoveryCeilingBps = 25`, `minObservationSeconds = 600`, `minRecoverySeconds = 1800`, `hardRedeemHaltSeconds = 12 hours`. +- Accounting decimals: **6** (USDC-style) — match `Stablecoin.decimals()`. +- ISO geography codes per `ComplianceModule.AddressInfo.geography` (`bytes2`): `"US"`, `"IN"`, `"EU"`, restricted like `"KP"`. + +If you wander off these defaults, say so explicitly in the caption — reviewers benchmark against `contracts/` source. diff --git a/lab/index.html b/lab/index.html new file mode 100644 index 0000000..3100c54 --- /dev/null +++ b/lab/index.html @@ -0,0 +1,1305 @@ + + + + + +Stablecoin-toolkit — CR8-USD + MUSD lifecycle lab + + + + + + +
+
+ stablecoin lab + — CR8-USD + MUSD lifecycle +
+
kcolbchain · stablecoin-toolkit · v0
+ +
+ + + +
+ +
+ +
+
+
+
+ +
+ + + + + + scene 1/8 · step 0 +
+ +
+
+
+ +
+ + + +