deviant/KnowledgeBase/07_project_source_material/deviant_ecosystem_overview.md
walerikus 518a3ce174 chore: initial project baseline — full Deviant codebase under version control
Brings the whole project into git (previously only the on-ramp feature and
a few parallel files were tracked). Includes: wallet core (src/), CashScript
contracts/, the Capacitor shell (shells/), scripts/, tests, and the docs
corpus (wiki/, snapshots/, Parameters/, Archive/, KnowledgeBase text).

Excluded via .gitignore: node_modules/, dist/, .env (secrets), testnet WIF
key files (.chipnet-*.json, devWallets.ts), KnowledgeBase/RAW media (~9.6 GB),
transcripts/ (session logs), and machine-local config (.claude/*.local,
*.lock). Secret-scanned before commit — no credentials in the tree.

Note: src/swapMath.ts, src/swapBuilder.ts, contracts/OpenMintToken.cash are
legacy (OP_RETURN era) but still imported; committed as-is, flagged for a
separate removal once de-referenced.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-13 20:38:07 +02:00

9.3 KiB
Raw Blame History

Deviant — Project Ecosystem Overview

Reference document for Claude Code sessions. Read this before the technical spec for context.


What Deviant Is

A non-custodial BCH wallet with two instrument classes:

  1. Standard CashTokens — supported alongside everything else on the market
  2. Mathematically Backed Assets (MBAs) — a new instrument class, BCH-backed, unconditionally redeemable at a fixed rate without a custodian, purely based on mathematics

The wallet does not replace tokens. It offers something tokens cannot be.


The Core Idea

Every existing asset class — fiat, equities, real estate, crypto tokens — has a single point of failure. A custodian, an issuer, a counterparty who can fail, freeze, or disappear.

The MBA Standard eliminates the single point of failure from asset backing by construction. Not through regulation. Not through trust. Through mathematics.

The BCH base layer is the environment — predetermined, permanent, not affected by what is built on it. 21,000,000 unit supply cap. Fixed at protocol genesis. Everything else evolves within it.


Asset Types — Eight Combinations

Three binary parameters: Mint rule × Rate × Supply

# Mint Peg Supply Name ASM Verdict
1 Open Fixed Limited DEA-L Until depleted Novel
2 Open Fixed Unlimited DEA Full Novel — primary innovation
3 Open No peg Limited — No Degenerate (rate-0 bricked or T-001)
4 Open No peg Unlimited — No Degenerate (rate-0 bricked or T-001)
5 Closed Fixed Limited DMA-L No Viable — hard-capped issuer-backed
6 Closed Fixed Unlimited DMA No Viable — stablecoin home (Architecture A only)
7 Closed No peg Limited — No Viable — tickets, credentials, membership
8 Closed No peg Unlimited — No Conventional — current CashTokens market

Key distinction: Fixed rate = MBA. No fixed rate = Token. The line is binary and exact.

DEA — Deviant Equilibrium Asset is the primary innovation. Open mint + fixed rate + unlimited reservoir = Nash Equilibrium where the contract replaces counterparty, market maker, and liquidity provider simultaneously. Validated on chipnet.

DEA-L deflationary property: Redemption burns FTs permanently — they do not return to the reservoir. Total supply = initial_supply - redeemed. Each redemption reduces total supply permanently. At full depletion the token category is extinct. Once the reservoir empties, ASM stops — holders must use traditional markets for exchange, though the Protocol Net Value floor remains redeemable at any time.


Architecture Modes

Architecture B — Soft Layer

  • Standard BCH UTXOs, no contract locking
  • Rules enforced by wallet software only
  • For closed, mutually-trusting groups only
  • External wallets see standard CashTokens
  • Ships first — works immediately

Architecture A — Hard Layer

  • CashScript P2SH32 contracts on BCH
  • On-chain enforcement via introspection opcodes (live May 2022)
  • Reservoir model: 10^18 FTs seeded at genesis, claim() transfers from reservoir
  • Self-backed FT UTXOs: each carries tokenAmount × backingRateSats BCH inside it
  • Redemption = standard P2PKH spend, no contract function needed
  • Ossified at deployment — no upgrade, no admin, no selfdestruct
  • Validated on chipnet (snapshots 0001–0021)

Hybrid

  • Same tokenId across both architectures
  • Elevation interface escalates B → A without changing identity

The Contract — DeviantOpenMintFT.cash

Single function: claim(tokenAmount, recipientLockingBytecode)

Constructor parameters (invariant after genesis):

  • categoryId — token category in consensus byte order (little-endian — use .reverse())
  • backingRateSats — BCH sats per unit, must be standard tier
  • feeBps — founder fee 0–500 bps
  • founderAddress — P2PKH hash for fee routing

Fee only on claim(). No fee on redemption. Redemption is a free P2PKH spend.


Rate Tiers — ALLOWED_RATE_TIERS

Powers of 10 only. Arbitrary rates break the Universal Exchange Rate calculation.

Sats/unit BCH/unit
1,000 0.00001 BCH — minimum
10,000 0.0001 BCH
100,000 0.001 BCH
1,000,000 0.01 BCH
100,000,000 1 BCH
1,000,000,000 10 BCH — high-value / institutional

Minimum 1,000 sats is load-bearing, not advisory. The dust limit + value == grossSats enforcement makes rate-0 canonical contracts bricked by consensus — not free-money faucets.


The Swap Mechanism

Any open mint DEA can swap with any other open mint DEA atomically:

redeem Token A (P2PKH spend)    → receive rateA sats per unit
claim Token B (contract call)   → pay rateB sats per unit

Universal Exchange Rate: UER = rateA / rateB — deterministic, no oracle, no counterparty.

Requires TransactionBuilder({ allowImplicitFungibleTokenBurn: true }) for swap transactions.


Security Threats and Defenses

T-001 — Non-Canonical Contract Rug

Malicious founder deploys a contract that looks like Deviant standard but contains a backdoor minting function. Receive-time risk only — users who minted via claim() are safe.

  • D-1 — Reconstruct canonical P2SH32 address from published parameters. Compare to on-chain address. PoC validated chipnet (snapshot 0020). Production module unbuilt.
  • D-2 — Per-UTXO backing check: expected_bch = ft_amount × satsPerUnit. Flag underbacked UTXOs at receive time. PoC validated. Production unbuilt.
  • D-3 — Embedded canonical bytecode hash constant in wallet.

T-002 — B-Model Definition Poisoning

Architecture B token identity lives entirely in local wallet definitions. Poisoned definition can cause misvaluation on receive or overpayment on send.

  • D-4 — Raw BCH co-display on all B-token figures (mandatory)
  • D-5 — Import friction + raw BCH confirmation on every B-token send
  • D-6 — Non-authoritative rendering — B tokens never visually equivalent to A-model verified tokens
  • D-7 — Optional issuer signature on B definitions (open question Q-T5)
  • D-8 — Ecosystem plurality

Primary control: Architecture B for closed, mutually-trusting groups only.


UI — Four Interfaces

Name Function Description
AVALANCHE Create Genesis event. Set parameters, lock BCH, deploy contract. Irreversible.
SPECTRUM View Portfolio — all asset positions across every dimension simultaneously.
ELEVATION Upgrade Architecture B → A escalation. Identity preserved.
ORBITAL NETWORK Interact DEA swap interface. Zero counterparty. UER-priced.

Implementation Status

Component Status
Basic wallet — key gen, BCH send/receive ✅ Done
Architecture A contract — DeviantOpenMintFT.cash ✅ Validated on chipnet
Atomic swap — claim + P2PKH redeem ✅ Validated · 450+ chipnet tests to date (swaps, claims, redemptions, attack/defense)
Token metadata database ✅ Done
Registry sync + server ✅ Done (23 tests passing)
UTXO classification engine ✅ Done
T-001 PoC (attack + defense) ✅ Validated on chipnet
Architecture B display layer 🔧 Next
Architecture B send/receive 🔧 Next
D-1 production module 🔧 PoC done, production unbuilt
D-2 production module 🔧 PoC done, production unbuilt
D-3 canonical hash constant 🔧 Unbuilt
Avalanche UI 🔧 Unbuilt
Spectrum UI 🔧 Unbuilt
Elevation UI 🔧 Unbuilt
Orbital Network UI 🔧 Unbuilt

Key Files

contracts/
  DeviantOpenMintFT.cash          — canonical contract
  DeviantOpenMintFT_Backdoor.cash — T-001 PoC (test only)

src/
  tokenMetadata.ts   — TokenMetadata type, ALLOWED_RATE_TIERS
  tokenId.ts         — deriveTokenId, OP_RETURN encode/parse
  tier.ts            — TierBToken/TierAToken, assertEscalationIntegrity
  swapMath.ts        — computeRedemption, computeSwap
  token/portable.ts  — JSON wire format
  token/sync.ts      — registry sync client
  registry/server.ts — HTTP registry server

wiki/
  architecture.md    — architecture + stablecoin worked example
  fee-economics.md   — rate-tier viability, dust/fee-floor governance
  risks.md           — R-011 (T-001), R-012 (T-002)

Critical Developer Notes

  • Category byte order: TXIDs displayed big-endian, CashTokens consensus is little-endian. txidToConsensusBytes(hex) = hexToBin(hex).reverse(). Apply to all constructor categoryId arguments.
  • Compiler package: cashc@0.12.1 is separate from cashscript runtime. Do not import compileFile from cashscript — it silently fails.
  • Swap flag: TransactionBuilder({ allowImplicitFungibleTokenBurn: true }) required for all swaps.
  • Fee estimates: CashTokens FT transfers cost ~2,000 sats, not 220. Use 1.5–2× safety multiplier.
  • Rate validation: Reject non-standard rates at Avalanche deployment. Minimum 1,000 sats is consensus-enforced, not advisory.
  • Stablecoins: Architecture A only, closed mint. Architecture B cannot carry a stablecoin.

Active Reference Documents

  • deviant_technical_spec_v2.md — full technical specification, verified against snapshots 0001–0021
  • This file — ecosystem overview for new sessions

Last updated: 2026-05-15