Add hashprice miner option vaults (BTC- and USD-quoted) - #57
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Playground PreviewA live preview of this PR's playground is available at:
|
Two-token range vaults on the hashprice index so miners can hedge mining revenue with BTC collateral: - examples/hashprice/hashprice_btc_vault.ark: sats-quoted band [lowPrice, highPrice]; pairs escrow exactly the band width, so every payoff is fully collateralized and settlement splits the pot with no division. Single oracle fixing within +/-settleWindow of maturity. - examples/hashprice/hashprice_usd_vault.ark: USD-cents-quoted band, settled in sats via a second BTC/USD attestation; each pair escrows a fixed pairCollateral that caps the UP payout (the max-loss bound that makes a BTC-margined USD short call writable). - examples/hashprice/hashprice.md: miner strategy guide — long put (buy DOWN), capped short call (mint pairs, sell UP via Arkade intents), collar across two vaults, sizing flexibility, collateral cap discussion. UP/DOWN legs are identity-mint-controlled Arkade Assets; issue/burn are 1:1 collateral ops, premium is discovered on the order book via Arkade intents, and post-settlement redemption drains pot and supply together for order-invariant pro-rata payouts. Tests: tests/examples/hashprice.rs (witness shapes, oracle opcode placement, pro-rata redemption, cooperative-leaf synthesis, param schema) plus roundtrip entries; registered in tests/examples.rs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019xSv5NJ3LFu9qSrZvbou1W
Registers the two hashprice range vaults as a playground project so the BTC- and USD-quoted contracts load from the sidebar (sources come from the auto-generated contracts.js bundle). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019xSv5NJ3LFu9qSrZvbou1W
…t structure Only two of the four option positions hedge mining revenue and are the primitives this design targets: buy put (insure downside) and sell call (monetise the upside the rig is already long). Buying a call or selling a put are directional speculation, already served by venues like Deribit. Document the counterparty asymmetry between the two hedges: - Sell call is desk-friendly RFQ: the miner writes and posts collateral, so the counterparty only pays a premium in cash. - Buy put needs a standing pool: a written put must keep BTC posted for the option's life, and one-directional miner demand cannot be met by on-demand desk RFQ. The two-token vault is that pool; LPs deploy BTC standing, sell DOWN legs as the puts, and shed residual UP to desks via the call-side RFQ. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019xSv5NJ3LFu9qSrZvbou1W
…parison refactor master's "generalize comparisons" change (PR #61) emits the unsuffixed int-arithmetic opcodes OP_MUL/OP_DIV instead of OP_MUL64/OP_DIV64. The hashprice vaults compile and behave identically; only the opcode spelling asserted by the redeem pro-rata and USD-settle conversion tests changed. Update the three assertions (and the BTC-settle no-division guard) to the canonical unsuffixed names so the suite is green on current master. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019xSv5NJ3LFu9qSrZvbou1W
8032dde to
f1d0063
Compare
Summary
Adds hashprice options for miners as two-token range vaults: everything is expressed with plain European options, sized freely, margined and settled in BTC.
Only these two positions hedge mining revenue and are what the design targets; buying a call or selling a put are directional speculation, left to venues like Deribit. The doc also covers the counterparty asymmetry: sell call is a desk-friendly RFQ (only the premium is given out), while buy put needs a standing pool — a written put must keep BTC posted for the option's life, so one-directional miner demand is served by the vault-as-pool rather than on-demand desk RFQ.
New contracts:
examples/hashprice/Both follow the two-token vault design (paired UP/DOWN mint gated by a contract-identity singleton, 1:1 issue/burn, oracle fixing inside
±settleWindowof maturity, order-invariant pro-rata redemption with the 330-sat dust convention):hashprice_btc_vault.ark(HashpriceBtcVault) — band quoted in sats per contract. The band width is the per-pair escrow, so every payoff is fully collateralized by construction and settlement splits the pot exactly, with no division. Single oracle attestation (sha256(ticker || price || time)viacheckSigFromStack).hashprice_usd_vault.ark(HashpriceUsdVault) — band quoted in USD cents, paid in sats. Settlement requires two attestations (hashprice + BTC/USD) and converts the USD intrinsic at the attested BTC/USD price. Since a USD payoff backed by BTC can never be fully collateralized, each pair escrows a fixedpairCollateralsats that caps the UP payout — the on-chain form of capping a short-call writer's maximum loss (band top ≈ 2–3× spot hashprice), with the residual joint-tail risk left to the market maker's premium.hashprice.md— miner strategy guide (strategies, pool-vs-RFQ market structure, cap economics, lifecycle, exit model, relation to the options/stability/bonds examples).Exit model matches the pooled-vault convention: no single CSV leaf can express per-holder exit, so
exitparameterizes the off-chain recurrent exit tree and the oracle-liveness assumption is documented.Tests
tests/examples/hashprice.rs(registered intests/examples.rs, plus roundtrip entries): group counts, permissionlessamount-only witnesses on issue/burn/redeem, oracle opcodes confined tosettle(1 verification for BTC, 2 for USD, exactOP_CAT/OP_SHA256counts), no division in BTC settlement,OP_MUL/OP_DIVpro-rata redemption, identity/leg asset-group inspection, synthesized cooperative leaves with injected server/emulator sigs, and constructor schema (two-param asset ids; USD-onlybtcUsdTicker/pairCollateral). Full workspace suite green,cargo fmt --checkclean.Playground
playground/main.jsregisters a Hashprice project with both vaults; sources flow through the auto-generatedcontracts.jsbundle.🤖 Generated with Claude Code
https://claude.ai/code/session_019xSv5NJ3LFu9qSrZvbou1W
Generated by Claude Code