DAI Stablecoin Framework: Sovereign CDPs with W Collateral for Bitcoin DeFi

Reply
L
laz1m0v
🏆Newbie
Posts: 8
Joined: 10/8/2025
Posted: 10/8/2025, 8:06:09 PM
#1

Abstract

This OPI specifies a comprehensive framework for creating and managing sovereign Collateralized Debt Positions (CDPs) on the Universal Protocol. It introduces a new set of logical operations—cdp-open, cdp-close, cdp-liquidate—which are contextual interpretations of base BRC-20 instructions. This framework allows any user to lock an approved Sovereign Collateralized Asset (SCA), such as "W", in a specialized CDP Vault and mint a corresponding stablecoin (e.g., "DAI") pegged to a real-world asset.

What is DAI? DAI is a BRC-20 stablecoin minted through OPI2 CDPs, pegged to 1 USD using W (a Sovereign Collateralized Asset, where 1 W = 1 BTC) as collateral. It is created via the cdp-open operation, where users lock W in a Taproot-based CDP Vault and mint DAI with a minimum collateral ratio (CR) of 150%, validated by WITNESS's Sovereign Oracle (W/DAI VWAP). DAI fuels the W/DAI AMM pool, enabling the Triangulation Oracle V11 to derive BTC/USD prices trustlessly.

The system's integrity is guaranteed by our core technological trinity: OP_RETURN for intent signaling, MAST for encoding the vault's state machine, and W_PROOF for cryptographic validation. Crucially, it introduces time-locked operations (lock) as a fundamental mechanism for risk management and economic stability. The entire framework is designed to be incentive-compatible, trust-minimized, and verifiable by our network of stateless Provers.


Copyright

This OPI is released under the MIT License.


Motivation

The final primitive required for a complete, sovereign financial system on Bitcoin is a stable unit of account. Existing stablecoins are either centralized and custodial, or they rely on complex, fragile cross-chain bridges. This OPI is necessary to:

  1. Establish a Standard for Sovereign Stablecoins: To provide a single, open-source, and auditable framework for creating collateral-backed stablecoins on Bitcoin L1.
  2. Integrate a Trustless Price Oracle: To leverage our existing Sovereign Oracle (deriving BTC/USD price from UTXOracle and sats/TOKEN from OPReturnOracleEngine) as the immutable source of truth for collateralization ratios and liquidations.
  3. Formalize Time-Locks as a Core Economic Primitive: To introduce mandatory lock periods on CDP operations, which act as a crucial defense against bank runs, mitigate short-term market volatility, and create a more predictable economic environment.
  4. Create a Capital-Efficient Flywheel: To transform dormant collateral (W) into a productive debt instrument (DAI), which can then be used in other DeFi protocols (like our AMM), creating a powerful cycle of value creation.

Use Case: Leveraged Trading in the LOL/WTF AMM with DAI

Scenario: Alice, a Bitcoin DeFi user, wants to speculate on the price of WTF (a BRC-20 token) against LOL in the LOL/WTF AMM pool without selling her W (1 W = 1 BTC). She uses an OPI2 CDP to mint DAI, which she then swaps for WTF to gain leveraged exposure while maintaining her W holdings.

Step-by-Step Process:

  1. Opening a CDP:

    • Alice locks 1 W (100M sats, worth $150,000 USD at a W/DAI VWAP of 150,000 DAI/W, per the Sovereign Oracle) in a CDP Vault using the cdp-open operation
    • She mints 100,000 DAI (worth $100,000 USD, as 1 DAI = 1 USD), maintaining a CR of 150% ($150,000 collateral / $100,000 debt)
    • The transaction includes two OP_RETURN payloads as specified in the transaction structure
  2. Swapping DAI for WTF:

    • Alice uses her 100,000 DAI in the LOL/WTF AMM pool to swap for WTF tokens, expecting WTF to appreciate against LOL
    • The swap is recorded on-chain via BRC-20 OP_RETURNs, contributing to the sats/WTF VWAP used by WITNESS's OPReturnOracleEngine
    • The W/DAI pool, deepened by Alice's minted DAI, ensures tight spreads and accurate pricing, reinforcing the Triangulation Oracle V11's BTC/USD derivation
  3. Monitoring and Managing the CDP:

    • Alice monitors her CDP's CR using the Sovereign Oracle's W/USD price
    • If the price of W drops (e.g., to 120,000 DAI/W), her CR falls to 120% ($120,000 / $100,000), risking liquidation
    • To avoid liquidation, Alice can deposit more W or repay part of the DAI debt using the cdp-close operation
    • The 10,000-block timelock prevents rapid withdrawals, stabilizing the system against market volatility
  4. Profiting from WTF Appreciation:

    • If WTF appreciates (e.g., doubles in value against LOL), Alice swaps her WTF back to DAI, potentially receiving 200,000 DAI
    • She uses 100,000 DAI to repay her CDP debt via cdp-close
    • Alice withdraws her 1 W collateral and keeps the remaining 100,000 DAI ($100,000 USD) as profit, all while retaining her original W exposure
  5. Liquidation Scenario:

    • If W's price crashes (e.g., to 100,000 DAI/W), the CR falls to 100% ($100,000 / $100,000), triggering a cdp-liquidate operation
    • A liquidator provides 100,000 DAI to repay Alice's debt, receiving her 1 W collateral (worth $100,000), a 3% reward ($3,000), and a 2% platform fee ($2,000)
    • Any surplus is returned to Alice

Benefits of DAI in This Use Case:

  • Stable Unit of Account: DAI's 1 USD peg allows Alice to engage in DeFi without exposure to W's volatility during trading
  • Leverage: By minting DAI against her W, Alice gains leveraged exposure to WTF without selling her W, preserving her long-term Bitcoin position
  • Liquidity Provision: The minted DAI deepens the W/DAI pool, improving WITNESS's oracle accuracy and enabling other users to trade or mint DAI
  • Trustlessness: The Sovereign Oracle, W_PROOF, and double-lock liquidation ensure all operations are verifiable on-chain, aligning with Bitcoin's ethos

Specification

DAI Stablecoin Clarification

What is DAI? DAI is a BRC-20 stablecoin minted through OPI2 CDPs, pegged to 1 USD using W (a Sovereign Collateralized Asset, where 1 W = 1 BTC) as collateral. It is created via the cdp-open operation, where users lock W in a Taproot-based CDP Vault and mint DAI with a minimum collateral ratio (CR) of 150%, validated by WITNESS's Sovereign Oracle (W/DAI VWAP). DAI fuels the W/DAI AMM pool, enabling the Triangulation Oracle V11 to derive BTC/USD prices trustlessly.

Key Properties:

  • Peg: 1 DAI = 1 USD (maintained through over-collateralization)
  • Collateral: W tokens (1 W = 1 BTC) locked in CDP Vaults
  • Minimum CR: 150% (ensuring system stability)
  • Oracle Integration: W/DAI VWAP from Sovereign Oracle validates pricing
  • Liquidity Role: Deepens W/DAI AMM pool for accurate price discovery
  • Trustlessness: All operations verifiable on-chain via W_PROOF and MAST

Economic Mechanism:

  • Users lock W collateral → Mint DAI stablecoin
  • DAI can be used in AMM pools for leveraged trading
  • Oracle monitors CR and triggers liquidations if CR < 150%
  • Time-locks prevent rapid withdrawals and bank runs
  • Liquidators earn rewards for maintaining system solvency

Transaction Structure

cdp-open Operation

ComponentDescription
Input[0]W collateral UTXO (via Taproot spend avec W_PROOF)
Output[0]OP_RETURN 1: deposit operation JSON
Output[1]OP_RETURN 2: borrow operation JSON
Output[2]CDP Vault P2TR: 100000000 sats W (script avec 4 chemins MAST)
Output[3]Change: Reste vers user

cdp-close Operation

ComponentDescription
Input[0]CDP Vault UTXO (via Cooperative Path si debt = 0)
Output[0]OP_RETURN 1: burn DAI operation JSON
Output[1]OP_RETURN 2: withdraw W operation JSON
Output[2]W collateral vers user: 100000000 sats W
Output[3]Fees/change

cdp-liquidate Operation

ComponentDescription
Input[0]CDP Vault UTXO (via Liquidation Path - MAST leaf 3)
Output[0]OP_RETURN: liquidate operation JSON
Output[1]Collateral vers liquidator
Output[2]Surplus vers user (si CR > 100% après pénalité)
Output[3]Protocol fee vers platform

OP_RETURN Payload

cdp-open

OP_RETURN 1 (Deposit Collateral):

{
  "p": "cdp",
  "op": "deposit",
  "tick": "W", 
  "amt": "100000000",
  "lock": "10000"
}

OP_RETURN 2 (Borrow Stablecoin):

{
  "p": "cdp",
  "op": "borrow",
  "tick": "DAI",
  "amt": "1000"
}

cdp-close

OP_RETURN 1 (Repay Debt):

{
  "p": "brc-20",
  "op": "burn",
  "tick": "DAI",
  "amt": "1000"
}

OP_RETURN 2 (Withdraw Collateral):

{
  "p": "cdp",
  "op": "withdraw",
  "tick": "W"
}

cdp-liquidate

{
  "p": "cdp",
  "op": "liquidate",
  "vault_id": "<txid_of_vault>",
  "liquidator": "<address_of_liquidator>"
}

Indexer Validation Rules

cdp-open Validation

  1. Parse OP_RETURN Operations: Extract both deposit and borrow operations from the transaction
  2. W_PROOF Validation: Verify that Input[0] contains a valid W_PROOF in the witness data
  3. Vault Address Validation: Ensure Output[2] is a valid P2TR address with correct MAST script
  4. Oracle Price Query: Query the Sovereign Oracle for W/USD price at the current block height
  5. Collateral Ratio Calculation: Calculate CR = (collateral_amt Ă— W_USD_price) / borrow_amt
  6. CR Threshold Check: Verify that CR ≥ 1.5 (150% minimum collateralization)
  7. Lock Period Validation: Ensure lock ≥ 10000 blocks (minimum time-lock period)
  8. State Update: If all validations pass, mint borrow_amt DAI in the indexer state

cdp-close Validation

  1. Parse OP_RETURN Operations: Extract both burn and withdraw operations
  2. Debt Verification: Confirm that the vault has debt = 0 (fully repaid)
  3. Burn DAI: Destroy burn_amt DAI in the indexer state
  4. Release Collateral: Transfer ownership of W collateral back to user
  5. Vault Closure: Mark vault status as CLOSED

cdp-liquidate Validation

  1. Parse OP_RETURN Operation: Extract liquidate operation
  2. Oracle Price Query: Get current W/USD price from Sovereign Oracle
  3. Collateral Ratio Check: Verify that CR < 1.5 (under-collateralized)
  4. Liquidation Path Verification: Confirm transaction spends vault via Liquidation Path (MAST leaf 3)
  5. Distribution Calculation:
    • debt_value = vault.debt (in DAI)
    • collateral_value = vault.collateral Ă— W_USD
    • penalty = collateral_value Ă— 0.05
    • liquidator_reward = collateral_value Ă— 0.03
    • platform_fee = collateral_value Ă— 0.02
    • surplus = collateral_value - debt_value - penalty - liquidator_reward - platform_fee
  6. State Updates: Burn debt DAI, distribute collateral according to calculated amounts, mark vault as LIQUIDATED

Rationale

Design Decisions

Two OP_RETURN Structure: The atomic cdp-open operation requires both deposit and borrow to happen simultaneously. Using two separate OP_RETURN outputs allows for clear separation of concerns while maintaining atomicity within a single transaction.

W_PROOF Integration: Rather than duplicating cryptographic linking in OP_RETURN payloads, the existing W_PROOF mechanism handles all cryptographic validation. This follows the KISS principle and leverages existing infrastructure.

Time-Lock Requirements: Mandatory 10,000 block lock periods prevent bank runs and provide stability against short-term market volatility. This creates economic incentives for long-term participation.

MAST Vault Structure: The 4-path MAST structure provides:

  • Cooperative Path: Normal operations (User + Platform)
  • Sovereign Path: Emergency recovery (User alone after CSV timeout)
  • Liquidation Path: Automated liquidation (Platform alone when CR < 150%)
  • Emergency Path: Protocol-wide safety mechanism

Trade-offs

Simplicity vs. Flexibility: The design prioritizes simplicity and security over complex features. This reduces attack surface and makes the protocol more auditable.

On-Chain vs. Off-Chain: Critical operations (deposit, borrow, repay, withdraw) happen on-chain for transparency, while price calculations happen off-chain via the Sovereign Oracle for efficiency.


Backwards Compatibility

This OPI is fully backwards compatible with existing BRC-20 operations. The new cdp protocol namespace does not conflict with existing brc-20 operations. Existing BRC-20 tokens can be used as collateral (like "W") and the new stablecoin ("DAI") follows standard BRC-20 mint/burn semantics.

The framework extends rather than replaces existing functionality, ensuring no disruption to current BRC-20 ecosystem participants.


Reference Implementation

  • Repo: <repo-url>
  • Branch: main
  • Examples:
    • CDP Vault Address Calculator: /workflow-cdp-psbts/Step1-Calculate-Vault-Address.cjs
    • Atomic Open Operation: /workflow-cdp-psbts/Step2-Create-Deposit-Borrow-PSBT.cjs
    • Close Operation: /workflow-cdp-psbts/Step3-Create-Repay-PSBT.cjs
    • Withdraw Operation: /workflow-cdp-psbts/Step4-Create-Withdraw-PSBT.cjs
    • Oracle Integration: /oracles.py (Sovereign Composite Oracle)
    • Indexer Logic: /cdp-indexer/ (State machine and validation)

Security Considerations

Risk Mitigation

Oracle Manipulation: The Sovereign Oracle uses multiple independent price sources (UTXO patterns + BRC-20 trade data) with outlier filtering and VWAP calculations to prevent price manipulation attacks.

Front-Running: The mandatory 10,000 block lock period creates a buffer against short-term price manipulation and front-running attacks.

Collateral Forgery: The W_PROOF mechanism ensures that only authentic, on-chain collateral can be used for CDP operations, preventing fake token attacks.

Platform Censorship: The Sovereign Recovery Path allows users to reclaim collateral after the CSV timeout, even if the platform becomes unresponsive.

Liquidation Attacks: Liquidators must provide the full debt amount in DAI to trigger liquidation, creating economic disincentives for malicious liquidations.

Attack Vectors

Recombination Attacks: Prevented by the W_PROOF cryptographic linking mechanism that ties operations to specific UTXOs.

State Corruption: Multiple independent indexers with consensus mechanisms prevent single points of failure in state management.

Economic Attacks: Game-theoretic analysis shows that honest behavior is the dominant strategy for all participants, with clear economic incentives aligned with protocol security.

Cryptographically Signed
View Signature
IDfeJGcV15VZGBpjKrQXqSTE/6c/0QC6DUU2+mhlG5pRN9/pztU2RwDCRyZ6eAiDV6EoBS/EEkX3idkStLNk9c0=
D
D0zy
🏆Member
Posts: 36
Joined: 10/8/2025
Posted: 10/8/2025, 8:15:36 PM
#2

wow !!!! Loving what I'm reading here !!!

The sun is good for your health
Cryptographically Signed
View Signature
IBM+xHXK30scyzYbC2jxOuZR86oBWyBOWsZc07fIjXXYeAyEDaycohu52Hlj9Pm6aBDXTSNfnEKUo1e+l1zhbjI=
W
wj
🏆Newbie
Posts: 9
Joined: 10/8/2025
Posted: 10/9/2025, 1:06:45 PM
#3

Stablecoins are crucial to the ecosystem, and security is paramount. I believe developers have done a lot of work on this. Please conduct extensive extreme testing before releasing your app. Ensure there are no major security vulnerabilities after delivery. Kudos to the developers.

op_return 🟨 🟦🟩
Cryptographically Signed
View Signature
HzXwEYrk1OWy4CrmHRO/6+oF332RIz2GCzUPgsJur8qgYbbnUXglRuDNHhph+EHYSdFEeLuIN6PUv3wwlLFljt0=
B
bc1pkhhl2…8e0a
🏆Member
Posts: 12
Joined: 11/11/2025
Posted: 11/27/2025, 9:40:28 AM
#4

Very good

Cryptographically Signed
View Signature
AkcwRAIgDWG5cfrSif0w0nJSf4HD6/ib9nCvkWuTLZcRdy7/tUQCIFO1qMTFO1SSo8LXOh2P+dqbNJZISYkWV4+Dhzc6pt0HASEDlOKV5qIalK4+DXLHKDSXEaN2Oynb5lofys51JiY9Y1k=