deviant/contracts/PotidaeaEpochState.cash
walerikus 35076606c7 chore: checkpoint in-flight work across shell, contracts, and docs
Snapshot of the shared working tree's outstanding changes (multiple
concurrent workstreams), excluding generated runtime state files
(.football-tote-state.json, .tote-platform-state.json, .usdm-historical-chart.html).

Spans: wallet shell (connect/, keystore MultiKeyStore+vault, screens,
currency picker, sign-message), verify artifacts, new Potidaea/DRA/tote
contracts + regtest suites, cross-chain/T6 + WalletConnect Parameters,
a telegram-orderbook subproject, design mockups, and docs. See
shells/app/WALLET-COORDINATION.md for the per-file ownership split.

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

45 lines
2.5 KiB
Text
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.

pragma cashscript ^0.12.0;
// PotidaeaEpochState — the global marketplace counter, EPOCH-BATCH variant (ADR-0048).
//
// Same state as PotidaeaOlympiaListing (A|L|notches|lastHeight) but writes happen via a
// once-per-epoch FOLD instead of one tx per listing. Users drop independent
// PotidaeaListingRequest UTXOs (zero contention); a permissionless folder co-spends the
// single state UTXO + a batch of requests and applies them together — so there is exactly ONE
// state-mutating tx per epoch, and the BATCH SIZE is the velocity signal: folding N listings
// climbs M by N notches (many listings in one epoch = hype). No CLTV height trick needed.
//
// This demo ships fixed-size folds (settle2 = a batch of exactly 2); production offers a few
// sizes (settle1/settle2/settle4/…) or an accumulator. Each request self-verifies its own fee
// reached treasury at its mirror output index (input k ↔ output k), so this covenant only
// bumps the counter and checks the treasury outputs carry DEA.
//
// settle2 layout: inputs [state(0), request(1), request(2), funding(3+)]
// outputs [newState(0), treasuryFee(1), treasuryFee(2), change(3+)]
contract PotidaeaEpochState(
bytes deaCategory, // consensus-order DEA category (fee currency)
bytes treasuryLockingBytecode // platform treasury (25 bytes)
) {
// Fold a batch of exactly 2 listing requests. L += 2, notches += 2 (M ×+0.2 this epoch).
function settle2() {
bytes aB, bytes r1 = tx.inputs[this.activeInputIndex].nftCommitment.split(4);
bytes lB, bytes r2 = r1.split(4);
bytes nB, bytes hB = r2.split(4);
// A unchanged (listings, not creations); L and notches climb by the batch size (2).
bytes newCommitment = aB + bytes4(int(lB) + 2) + bytes4(int(nB) + 2) + hB;
// out 0: the state NFT back, same category, folded commitment.
require(tx.outputs[0].lockingBytecode == tx.inputs[this.activeInputIndex].lockingBytecode);
require(tx.outputs[0].tokenCategory == tx.inputs[this.activeInputIndex].tokenCategory);
require(tx.outputs[0].nftCommitment == newCommitment);
require(tx.outputs[0].value >= 546);
// out 1, out 2: the two requests' fees to treasury (each request checks its own amount).
require(tx.outputs[1].lockingBytecode == treasuryLockingBytecode);
require(tx.outputs[1].tokenCategory == deaCategory);
require(tx.outputs[2].lockingBytecode == treasuryLockingBytecode);
require(tx.outputs[2].tokenCategory == deaCategory);
}
}