deviant/scripts/sim-anthemus-usd-buffer.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

106 lines
7.7 KiB
JavaScript
Raw 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-buffer.mjs — can a unified "USD on Bitcoin Cash" hold a HARD 1=1 even if one
* component stablecoin DIES on its home chain? Tests the user's stronger claim and finds the exact
* mechanism that makes it true (spoiler: diversification + per-issuer caps + a BUFFER sized to the
* cap; the P2P fiat ramp anchors the peg + adds demand but does not manufacture backing).
*
* Naming decision (stated, not simulated): the UNIFIED basket has NO single source to mark, so it
* is just "USD" on BCH — no ε/τ prefix, no issuer suffix. The per-source markers (εUSDC/τUSDt) were
* for DISTINCT wrapped assets; the unified pool is ONE asset. Components live in the BACKEND ledger.
*
* Run: node scripts/sim-anthemus-usd-buffer.mjs
*/
const $=(n)=>(n<0?'-':'')+'$'+Math.abs(Math.round(n*100)/100).toLocaleString('en-US',{minimumFractionDigits:2,maximumFractionDigits:2});
const pct=(n)=>(n*100).toFixed(2)+'%';
const div=(c='=')=>console.log(c.repeat(94));
const head=(t)=>{console.log('\n');div();console.log(t);div();};
// ════════════════════════════════════════════════════════════════════════════
head('PART 1 — DEPEG vs DEATH: the two events, and the buffer each needs to hold a HARD 1=1.');
{
console.log(' A DEPEG is temporary + partial (USDC −13% at SVB, recovered in 3 days). A DEATH is permanent');
console.log(' (issuer → $0). On a diversified basket with a per-issuer CAP, the loss is bounded:\n');
console.log(['event','component weight','basket loss','buffer to hold 1=1'].map(s=>s.padStart(22)).join(''));
div('-');
const rows=[
['DEPEG 13% · 10 issuers', 0.10, 0.10*0.13],
['DEPEG 13% · 5 issuers', 0.20, 0.20*0.13],
['DEATH →$0 · cap 10%', 0.10, 0.10*1.00],
['DEATH →$0 · cap 15%', 0.15, 0.15*1.00],
['DEATH →$0 · cap 20%', 0.20, 0.20*1.00],
];
for(const [label,w,loss] of rows){
console.log([label, pct(w), pct(loss), pct(loss)].map(s=>String(s).padStart(22)).join(''));
}
console.log('\n => YOUR CLAIM IS ACHIEVABLE — with a BUFFER (over-collateralization) sized to the loss:');
console.log(' • a DEPEG needs a TINY buffer (~1–3%) — diversification already shrinks it (report-9).');
console.log(' • a full DEATH needs buffer = the per-issuer CAP (10–20%). Cap each issuer, buffer to the cap,');
console.log(' and ANY single issuer can go to zero while USD-on-BCH stays exactly $1. That is a hard peg.');
console.log(' No major USD stablecoin has ever gone to $0 — so in practice the buffer covers DEPEGS with room');
console.log(' to spare; the cap-sized buffer is the extreme-tail guarantee.');
}
// ════════════════════════════════════════════════════════════════════════════
head('PART 2 — is the buffer AFFORDABLE? It builds itself from the fees/spread we already modeled.');
{
const reserve=10_000_000; // $10M unified-USD reserve
const cap=0.10, targetBuffer=cap*reserve; // $1M buffer to survive any single death (cap 10%)
console.log(` Target: a ${pct(cap)} buffer on a ${$(reserve)} reserve = ${$(targetBuffer)} (survives any single-issuer death).\n`);
console.log(['daily volume','buffer accrual @0.05%','days to fund $1M','seed instead?'].map(s=>s.padStart(22)).join(''));
div('-');
for(const dv of [250_000, 1_000_000, 5_000_000]){
const daily=dv*0.0005; // 0.05% of volume → buffer (a slice of the spread/fee)
const days=targetBuffer/daily;
console.log([$(dv), $(daily)+'/d', Math.round(days)+' d', 'or genesis endow'].map(s=>String(s).padStart(22)).join(''));
}
console.log('\n => The buffer is a cheap, self-funding insurance fund: a 0.05% slice of volume (a fraction of the');
console.log(' 40/30/30 spread) builds a full death-proof buffer in months, or seed it once at genesis. This');
console.log(' is exactly a stablecoin SURPLUS/INSURANCE fund (MakerDAO-style) — but tiny, because the basket');
console.log(' already diluted the risk. Buffer + diversification + caps = a HARD 1=1 through any one issuer.');
}
// ════════════════════════════════════════════════════════════════════════════
head('PART 3 — the P2P fiat on/off ramp: what it DOES and does NOT do for the peg.');
console.log(`
DOES:
• Gives USD-on-BCH its OWN demand + liquidity — people buy it with local fiat to spend/receive on
BCH (<$0.001, offline), independent of the stablecoin bridges. It becomes first-class money, not
just a wrapper. Real demand is peg-supportive (buyers want dollars on BCH).
• Provides an INDEPENDENT peg REFERENCE + arbitrage path: if USD-on-BCH trades below the basket
value, arbers buy it cheap and redeem the basket; above, they mint and sell. This tightens the peg.
DOES NOT:
• Manufacture backing. A P2P market PRICES the real backing — if the basket (net of buffer) is worth
$0.98, the fiat ramp clears near $0.98, not $1. The ramp anchors + arbitrages the peg; the BUFFER
is what actually holds it at $1 through a loss. Ramp + buffer together = a hard, liquid, self-
sustaining dollar; ramp alone = an honest floating price.
• Remove the regulatory/operational lift: a fiat on/off ramp is a whole product (KYC/AML pressure,
money-transmission exposure, dispute resolution, local liquidity) — the ADR-0044/0045 P2P market.
`);
// ════════════════════════════════════════════════════════════════════════════
head('PART 4 — the ONE honest correction, and the ONE true residual.');
console.log(`
CORRECTION — "the value locks on BCH and the other side dying doesn't matter" is not quite right by
itself. When USDC is deposited, the BACKING is still that USDC on Ethereum; if it dies, that slice
of backing dies with it. What makes the other side's death "not matter" is the combination:
(1) DIVERSIFICATION — the dead slice is ≤ its cap (report-9), not the whole reserve;
(2) ACTIVE MANAGEMENT — the desk rotates OUT of a sickening issuer on the source chain before/as
it dies (eating a bounded, buffer-covered cost), so the reserve isn't caught holding much of it;
(3) the BUFFER — absorbs the residual so εUSD stays exactly $1.
With all three, a single issuer's death genuinely does not move USD-on-BCH. Without the buffer, it
floats (report-9). So the claim is TRUE — it just names a well-capitalized, actively-managed reserve,
not magic.
THE ONE TRUE RESIDUAL — SYSTEMIC risk. Diversification + buffer + caps kill IDIOSYNCRATIC (one-issuer)
risk completely. They do NOT cover a correlated collapse of the WHOLE USD-stablecoin system at once
(every component down together, beyond the buffer). That tail is un-diversifiable; the only hedges
are a larger buffer, or backing partly in a non-correlated asset (BCH itself — but that is FIATm, a
different product). Disclose it; don't pretend it away.
NET: "pure USD on Bitcoin Cash", one clean ticker, unified diversified basket in the backend, a
cap-sized self-funding buffer, active reserve management, and its own P2P fiat ramp = a hard-1=1,
liquid, self-sustaining dollar that survives ANY single issuer dying. It is the strongest form of the
design — provided the buffer + caps + management are real and the systemic tail is disclosed.
`);