deviant/scripts/sim-anthemus-usd-chain-death.mjs
Local Dev debd6a6fbb chore: sweep in-flight work across all domains
Snapshot commit rolling up ~255 files of coherent-but-multi-domain in-flight
work that had accumulated on this branch. Split by area:

Contracts + covenants
- New: AsmFxSwap, DeviantOpenMintNBA, DeviantTieredMintOracleFT,
  TermCouponVault, UniformReserve, UniformReserveAggregate.
- Verify-artifact refresh (src/verify/artifacts/*.json + canonical.ts).

Wallet + shell (shells/app + src/wallet)
- App.tsx, MainScreen, ArtemisionScreen, AssetDetail, AgoraScreen,
  SettingsScreen, Unlock, TokenImportModal, UniformFiat/DepositPanel,
  KatalogosPanel (renamed from PinaxPanel), shell.css.
- src/wallet: wallet.ts, runtime.ts, index.ts. Core registry/chipnetFile.
- Deleted stale hook: useAllDevBalances.ts.

Cross-chain + correspondent (services/correspondent + scripts)
- Correspondent server/bch/config updates for PYUSD Solana, EURC Sepolia,
  aggregate reserve flows.
- New scripts: PYUSD roundtrip, EURC onboarding, GMX game loop /
  genesis / mint sanity, tiered mint fee, aggregate reserve, product2
  shares dividends, product3 t-bond, uniform fiat cell tests.

Telegram order-book (P2PExchange bot)
- db.ts, index.ts, en/ru locales — updates upstream from the extracted
  standalone repo at D:/Dev/P2PExchange.

Docs — Parameters (specs), wiki, snapshots, design mockups
- Parameters: FIATm/MBA_Shares/Potidaea/Anthemus refinements +
  ASM_CrossChain/DebitCredit + UniformFiat + Anthemus DEX MVP prompt +
  Artemision + Athenae Politeia + Philosophy + SSHkeyServer runbook +
  new dApp/{Artemision,Katalogos,Pinax,Pari_escrow,SURFACES}.
- wiki: cross-chain, games-tote, glossary, governance/voting-systems,
  infra, wallet, wallet-ui-design, decisions (ADR log).
- snapshots: catch-up entries and INDEX regeneration.
- design: mockups refreshed (agora, asset-detail, assets-tab, potidaea)
  + Potidaea assets + tote deploy notes.

Housekeeping
- .gitignore: exclude the new root test/session state files
  (.sol-vault-keys.json, .football-tote-state.json,
  .tote-platform-state.json, .redeem-roundtrip-state.json,
  .eurc-onboard-state.json — some contain oracle privkeys / vault
  secretKeyBase58; NEVER commit) + the .usdm-historical-chart.html
  chart output + MS Office `~$*` lock files + scripts/bundle-surfaces
  `build/` output. Also add scripts/bundle-surfaces.mjs.
- CLAUDE.md, WALLET-COORDINATION.md, snapshots/INDEX.md, design/README.md
  refreshed.
- package.json / package-lock.json bumps.

Verified: sensitive files at repo root confirmed ignored (git check-ignore
each). No `.env`, no raw WIF/xprv/mnemonic/secretKey/oraclePriv strings in
the staged diff. MS Word autosave file (`Parameters/Philosophy/~$*.docx`)
excluded and gitignored.

The WizardConnect responder work landed separately in the previous commit
(6987591); this is everything else that had accumulated alongside it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-29 01:14:33 +02:00

107 lines
7.7 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
/**
* sim-anthemus-usd-chain-death.mjs — separating THREE risks I wrongly lumped as one "systemic" caveat:
* 1. ISSUER death (a stablecoin bank fails, e.g. Circle) — a COLUMN of the (issuer×chain) matrix → 0.
* 2. CHAIN death (a source rail dies, e.g. Ethereum halts) — a ROW of the matrix → 0.
* 3. DOLLAR-SYSTEM collapse (every dollar everywhere fails at once) — the WHOLE matrix → 0.
*
* The user's two points, both correct:
* (a) #3 is NOT uniform-USD's job to survive. No dollar instrument survives the end of the dollar; a
* thing that did would not be a dollar (it would be gold/BCH — i.e. FIATm, a different product).
* So #3 is a CATEGORY TRUTH, not a flaw to disclose as a risk. I over-caveated. Conceded.
* (b) #2 (chain death) is where uniform-USD SHINES: once value is onboarded to BCH, the money lives on
* BCH rails; a source chain dying prunes one reserve ROW + blocks withdrawals to it, but internal
* 1=1 holds by moneyness. Banking analogy: banks close/merge, the DOLLAR persists; people move to a
* new bank. Chains are the banks/rails; BCH is where the money now lives.
*
* Result: #1 and #2 are the SAME bounded, handled event under (issuer × chain) diversification + caps +
* moneyness (report-11). Diversify + cap on BOTH axes → any single column OR row death is ≤ its cap.
*
* Run: node scripts/sim-anthemus-usd-chain-death.mjs
*/
const pct=(n)=>(n*100).toFixed(1)+'%';
const div=(c='=')=>console.log(c.repeat(94));
const head=(t)=>{console.log('\n');div();console.log(t);div();};
// an illustrative diversified basket, capped ~35% per issuer AND ~35% per chain
const positions=[
{issuer:'USDT', chain:'Tron', w:0.25},
{issuer:'USDC', chain:'Ethereum', w:0.20},
{issuer:'USDT', chain:'BSC', w:0.10},
{issuer:'USDC', chain:'Base', w:0.10},
{issuer:'DAI', chain:'Ethereum', w:0.15},
{issuer:'PYUSD', chain:'Solana', w:0.10},
{issuer:'FDUSD', chain:'BSC', w:0.10},
];
const sumBy=(key)=>{const m={};for(const p of positions)m[p.issuer!==undefined&&key==='issuer'?p.issuer:p.chain]=(m[p.issuer!==undefined&&key==='issuer'?p.issuer:p.chain]||0)+p.w;return m;};
const issuerW={}, chainW={};
for(const p of positions){issuerW[p.issuer]=(issuerW[p.issuer]||0)+p.w; chainW[p.chain]=(chainW[p.chain]||0)+p.w;}
// ════════════════════════════════════════════════════════════════════════════
head('PART 1 — the (issuer × chain) basket: diversify + cap on BOTH axes.');
{
console.log(' Reserve spread across issuers (columns) AND chains (rows). Per-issuer and per-chain weights:\n');
console.log(' by ISSUER: ' + Object.entries(issuerW).map(([k,v])=>`${k} ${pct(v)}`).join(' · '));
console.log(' by CHAIN : ' + Object.entries(chainW).map(([k,v])=>`${k} ${pct(v)}`).join(' · '));
console.log(`\n Max issuer ${pct(Math.max(...Object.values(issuerW)))}, max chain ${pct(Math.max(...Object.values(chainW)))} — both under a ~35% cap.`);
console.log(' Honest constraint: stablecoin supply is concentrated on Ethereum + Tron, so chain-');
console.log(' diversification means SOURCING coins on their less-common chains (USDC on Base/Solana/Arb).');
console.log(' Feasible (USDC is native on ~34 chains) but more operational work — the price of chain-resilience.');
}
// ════════════════════════════════════════════════════════════════════════════
head('PART 2 — ISSUER death (column) vs CHAIN death (row): both bounded by their cap.');
{
const worstIssuer=Object.entries(issuerW).sort((a,b)=>b[1]-a[1])[0];
const worstChain=Object.entries(chainW).sort((a,b)=>b[1]-a[1])[0];
const flow=0.15; // ~15% of supply ever in the withdrawal flow (moneyness, report-11)
console.log(['event','what dies','reserve loss','reserve after','flow','internal 1=1?'].map(s=>s.padStart(16)).join(''));
div('-');
for(const [label,name,loss] of [
[`ISSUER death`, worstIssuer[0]+' fails', worstIssuer[1]],
[`CHAIN death`, worstChain[0]+' dies', worstChain[1]],
]){
const after=1-loss;
console.log([label, name, pct(loss), pct(after), pct(flow), after>flow?'HOLDS ✓':'RUN'].map(s=>String(s).padStart(16)).join(''));
}
console.log('\n => Both are the SAME event: a bounded slice (≤ cap) of the reserve vanishes, the reserve stays');
console.log(' FAR above the withdrawal flow, so internal 1=1 HOLDS by moneyness. The only difference:');
console.log(' a CHAIN death also blocks WITHDRAWALS to that chain (reroute to a live chain / atomic-swap).');
console.log(' Tighter caps (15–20%) leave the reserve even higher after a death — at the cost of wider sourcing.');
}
// ════════════════════════════════════════════════════════════════════════════
head('PART 3 — the banking analogy, made exact (the user is right).');
console.log(`
uniform USD = THE DOLLAR (the unit of account + medium of exchange on BCH)
a STABLECOIN issuer = a BANK (holds dollars; can fail, be acquired, merge)
a source CHAIN = a CLEARING NETWORK / rail (a way banks move dollars)
Bitcoin Cash = where the money now LIVES and circulates
When a bank closes, your dollars don't vanish — they move to another bank (or insurance covers them),
and the DOLLAR is unaffected. When a clearing rail fails, the currency persists on other rails. Uniform
USD is the same: an issuer failing or a whole CHAIN dying prunes one branch of the reserve tree; the
money keeps working on BCH because BCH — not the source chain — is now its home. If you have onboarded
$200B and Ethereum dies, that $200B keeps transacting on BCH; Ethereum's death costs you the Ethereum
reserve ROW (≤ its cap) and withdrawals TO Ethereum, nothing more.
=> This is the settlement-hub thesis realized: BCH OUTLIVES its source chains and source issuers.
`);
// ════════════════════════════════════════════════════════════════════════════
head('VERDICT — three risks, three honest answers.');
console.log(`
1. ISSUER death → HANDLED. Diversify + cap across issuers → lose ≤ issuer cap → moneyness holds. (A bank fails.)
2. CHAIN death → HANDLED, and a STRENGTH. Diversify + cap across chains → lose ≤ chain cap → moneyness
holds; the money lives on BCH and keeps working. Only withdrawals TO the dead chain stop.
(A clearing rail fails; the dollar persists.) This is why onboarding value to BCH is
RESILIENT — BCH outlives its sources.
3. DOLLAR-SYSTEM collapse → NOT uniform-USD's job. No dollar survives the end of the dollar; one that did
would not be a dollar (that is gold/BCH-backing = FIATm, a different product). This is a
CATEGORY TRUTH, not a flaw. CONCEDED — I over-caveated last turn; drop it as a "residual risk."
SO THE ONLY THING TO DISCLOSE is what uniform-USD IS: "a dollar — a diversified, transparent, on-chain
claim on USD stablecoins, resilient to any single issuer OR chain failing, that lives on Bitcoin Cash."
Not "warning: could fail if the dollar fails" — every dollar carries that, and it is not a disclosure, it
is a definition. The design's job is #1 and #2, and it does both. The rest is simply being a dollar.
`);