DAI Stablecoin Framework: Sovereign CDPs with W Collateral for Bitcoin DeFi
ReplyAbstract
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:
- Establish a Standard for Sovereign Stablecoins: To provide a single, open-source, and auditable framework for creating collateral-backed stablecoins on Bitcoin L1.
- Integrate a Trustless Price Oracle: To leverage our existing Sovereign Oracle (deriving
BTC/USDprice fromUTXOracleandsats/TOKENfromOPReturnOracleEngine) as the immutable source of truth for collateralization ratios and liquidations. - Formalize Time-Locks as a Core Economic Primitive: To introduce mandatory
lockperiods on CDP operations, which act as a crucial defense against bank runs, mitigate short-term market volatility, and create a more predictable economic environment. - 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:
-
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
-
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
-
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
-
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
-
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
| Component | Description |
|---|---|
| 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
| Component | Description |
|---|---|
| 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
| Component | Description |
|---|---|
| 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
- Parse OP_RETURN Operations: Extract both
depositandborrowoperations from the transaction - W_PROOF Validation: Verify that Input[0] contains a valid
W_PROOFin the witness data - Vault Address Validation: Ensure Output[2] is a valid P2TR address with correct MAST script
- Oracle Price Query: Query the Sovereign Oracle for
W/USDprice at the current block height - Collateral Ratio Calculation: Calculate
CR = (collateral_amt Ă— W_USD_price) / borrow_amt - CR Threshold Check: Verify that
CR ≥ 1.5(150% minimum collateralization) - Lock Period Validation: Ensure
lock ≥ 10000blocks (minimum time-lock period) - State Update: If all validations pass, mint
borrow_amtDAI in the indexer state
cdp-close Validation
- Parse OP_RETURN Operations: Extract both
burnandwithdrawoperations - Debt Verification: Confirm that the vault has
debt = 0(fully repaid) - Burn DAI: Destroy
burn_amtDAI in the indexer state - Release Collateral: Transfer ownership of W collateral back to user
- Vault Closure: Mark vault status as
CLOSED
cdp-liquidate Validation
- Parse OP_RETURN Operation: Extract
liquidateoperation - Oracle Price Query: Get current
W/USDprice from Sovereign Oracle - Collateral Ratio Check: Verify that
CR < 1.5(under-collateralized) - Liquidation Path Verification: Confirm transaction spends vault via Liquidation Path (MAST leaf 3)
- Distribution Calculation:
debt_value = vault.debt(in DAI)collateral_value = vault.collateral Ă— W_USDpenalty = collateral_value Ă— 0.05liquidator_reward = collateral_value Ă— 0.03platform_fee = collateral_value Ă— 0.02surplus = collateral_value - debt_value - penalty - liquidator_reward - platform_fee
- 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)
- CDP Vault Address Calculator:
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.
View Signature
wow !!!! Loving what I'm reading here !!!
View Signature
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.
View Signature
Very good