Skip to content

Add hashprice miner option vaults (BTC- and USD-quoted) - #57

Draft
tiero wants to merge 4 commits into
masterfrom
claude/hashprice-miner-options-1ao3fu
Draft

Add hashprice miner option vaults (BTC- and USD-quoted)#57
tiero wants to merge 4 commits into
masterfrom
claude/hashprice-miner-options-1ao3fu

Conversation

@tiero

@tiero tiero commented Jul 21, 2026

Copy link
Copy Markdown
Member

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.

  • Long put on hashprice — miner buys DOWN tokens; pays exactly the shortfall in mining revenue below the strike.
  • Short call on hashprice — miner mints pairs (escrowing the band width), keeps DOWN, sells UP on the order book; the sale price is the premium and the payout of the increase is capped at the band top.
  • Revenue lock (collar) — combine both across two series in any ratio; every leg is a fungible Arkade Asset, so miners buy extra coverage or sell only part of the upside via Arkade intents (standing orders) — the premium never touches the contract.

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 ±settleWindow of 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) via checkSigFromStack).
  • 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 fixed pairCollateral sats 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 exit parameterizes the off-chain recurrent exit tree and the oracle-liveness assumption is documented.

Tests

tests/examples/hashprice.rs (registered in tests/examples.rs, plus roundtrip entries): group counts, permissionless amount-only witnesses on issue/burn/redeem, oracle opcodes confined to settle (1 verification for BTC, 2 for USD, exact OP_CAT/OP_SHA256 counts), no division in BTC settlement, OP_MUL/OP_DIV pro-rata redemption, identity/leg asset-group inspection, synthesized cooperative leaves with injected server/emulator sigs, and constructor schema (two-param asset ids; USD-only btcUsdTicker/pairCollateral). Full workspace suite green, cargo fmt --check clean.

Rebased onto current master (02d10ff), whose "generalize comparisons" refactor emits the unsuffixed int-arithmetic opcodes OP_MUL/OP_DIV in place of OP_MUL64/OP_DIV64; the redeem and USD-settle assertions were updated to match. Contract behavior is unchanged.

Playground

playground/main.js registers a Hashprice project with both vaults; sources flow through the auto-generated contracts.js bundle.

🤖 Generated with Claude Code

https://claude.ai/code/session_019xSv5NJ3LFu9qSrZvbou1W


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 25160e49-42cb-45cf-bf07-58c716a9d36f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/hashprice-miner-options-1ao3fu

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Playground Preview

A live preview of this PR's playground is available at:
https://arkade-os.github.io/compiler/pr-previews/pr-57/

Built from commit e43eae392a665aef3a78fb7f3f5aa3dff017471c · Workflow run

claude added 4 commits July 27, 2026 20:14
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants