deviant/contracts/DeviantOracleMBA_DraFee.cash
Local Dev 631541c98c docs(reorg): regroup native-ASM specs under ASM_Native + move Pari_P2P into Betting
Four moves (git mv, history preserved on all 39 files):
- ASM_Potidaea_OrbitalSwap -> ASM_Native/Potidaea_OrbitalSwap  (renamed, dropped the ASM_ prefix; now nested under ASM_Native)
- MBA_Shares               -> ASM_Native/MBA_Shares
- FIATm                    -> ASM_Native/FIATm
- Pari_P2P                 -> Betting/Pari_P2P

ASM_Native now groups the native-BCH swap (Potidaea) with the native asset families it swaps (FIATμ/BCHm, MBA/shares). Rewrote ASM_Native/README.md from a pointer stub into a real folder index describing the contained subfolders + how they fit (mechanism vs assets).

Rewrote every reference: Potidaea internal links (depth +1; self-folder refs collapsed), external links from DEX_Anthemus/wiki/ASM_CrossChain, prose/path refs across Parameters + wiki + CLAUDE.md + docs + code-comment doc-pointers (scripts/src/contracts), memory, and .gitignore (transcripts ignore rule). Co-moved siblings (FIATm<->MBA_Shares) kept their ../sibling links untouched since they stayed siblings under ASM_Native.

Verified with a link-resolver: all 453 relative links across 165 files resolve.
Snapshots keep old paths (historical changelog). Parallel FX-desk/uniform-reserve track left untouched.

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

91 lines
4.6 KiB
Text

pragma cashscript ^0.12.0;
// DeviantOracleMBA_DraFee — DeviantOracleMBA sibling with DRA fee redirection.
//
// Same FIATm-family semantics as DeviantOracleMBA (oracle-priced, self-backed
// per-unit lock, magical-redemption property preserved at §4), but every claim
// routes a small additional fee slice to a DRA pool address. The DRA pool
// covenant (DeviantReflectiveDRA) absorbs these inflows into per-DRA NAV via
// its receiveFees() function, lifting the pool's value for all DRA holders.
//
// This is the on-chain fee-revenue redirection for the FIATm-family flagship
// DRA design — Parameters/ASM_Native/FIATm/dra_dynamic-rate-asset_FOR-design-record.md §2.
//
// Sibling-not-replacement: existing chipnet-validated USDm/EURm/etc. deployed
// on DeviantOracleMBA continue to operate unchanged. NEW FIATm currencies
// deploy on this variant when they want to feed the DRA pool. Same per-unit
// self-backed property (§4 magical redemption); same oracle stack (§14); just
// adds output [3] for the DRA pool deposit.
//
// Output layout (claim):
// [0] reservoir back to contract (FT reduced, category preserved)
// [1] FT to recipient, self-backed at tokenAmount * price sats
// [2] DRA pool fee deposit (REQUIRED — min dust if computed fee < 546)
// [3] founder fee (only if >= dust; sub-dust waived per existing pattern)
// [4+] BCH change (unconstrained)
//
// The DRA-pool output is at fixed index [2] (NOT [3]) so the layout is
// deterministic regardless of founder-fee dust threshold. This makes it
// easier for the DRA covenant's receiveFees() to identify and absorb the
// inflow in a follow-up consolidation transaction.
contract DeviantOracleMBA_DraFee(
bytes tokenCategory, // bare 32-byte category id (consensus LE order)
pubkey oraclePk, // founder price-oracle public key
int founderFeeBps, // e.g. 5 = 0.05%, 500 = 5%
bytes founderLockingBytecode, // 25-byte P2PKH of fee recipient
int draFeeBps, // NEW — DRA pool fee BPS (e.g. 5 = 0.05% on mint/redeem)
bytes draPoolLockingBytecode // NEW — P2SH32 of DRA pool covenant
) {
function claim(
int tokenAmount,
bytes recipientLockingBytecode,
datasig oracleSig,
bytes oracleMessage
) {
require(tokenAmount > 0);
// --- oracle price attestation (forward swap only, same as DeviantOracleMBA) ---
require(checkDataSig(oracleSig, oracleMessage, oraclePk));
require(oracleMessage.length == 16);
bytes head, bytes priceBytes = oracleMessage.split(12);
require(head.length == 12);
int price = int(priceBytes);
require(price > 0);
int grossSats = tokenAmount * price;
int founderFee = grossSats * founderFeeBps / 10000;
int draFee = grossSats * draFeeBps / 10000;
// DRA fee floors at dust (546 sats) — sub-dust mints still pay 546 to
// DRA pool. For any mint over ~109,200 sats (~$0.11 at BCH=$200 with
// 5 bps fee) the actual fee dominates dust. Sub-dust subsidy is the
// chipnet-stage simplification; mainnet recalibration per §2.
if (draFee < 546) { draFee = 546; }
// [0] reservoir back to this contract, FT reduced by tokenAmount.
require(tx.outputs[0].lockingBytecode == tx.inputs[this.activeInputIndex].lockingBytecode);
require(tx.outputs[0].tokenCategory == tx.inputs[this.activeInputIndex].tokenCategory);
require(tx.outputs[0].tokenAmount == tx.inputs[this.activeInputIndex].tokenAmount - tokenAmount);
require(tx.outputs[0].value >= 546);
// [1] FT to recipient, self-backed at the oracle price (redeemable, no oracle).
require(tx.outputs[1].lockingBytecode == recipientLockingBytecode);
require(tx.outputs[1].tokenCategory == tokenCategory);
require(tx.outputs[1].tokenAmount == tokenAmount);
require(tx.outputs[1].value == grossSats);
// [2] DRA pool fee deposit — REQUIRED, at fixed position for deterministic layout.
// The DRA covenant's receiveFees() consolidates these into the pool's main UTXO.
require(tx.outputs[2].lockingBytecode == draPoolLockingBytecode);
require(tx.outputs[2].value == draFee);
require(tx.outputs[2].tokenCategory == 0x);
// [3] founder fee — enforced only when it clears dust; sub-dust waived.
if (founderFee >= 546) {
require(tx.outputs[3].lockingBytecode == founderLockingBytecode);
require(tx.outputs[3].value == founderFee);
require(tx.outputs[3].tokenCategory == 0x);
}
}
}