This Clarity smart contract implements a Bitcoin-backed stablecoin system on the Stacks blockchain, providing a robust mechanism for creating, minting, redeeming, and liquidating crypto-collateralized stablecoins.
-
Vault Management
- Create Bitcoin-collateralized vaults
- Mint stablecoins against Bitcoin collateral
- Redeem stablecoins
- Liquidate undercollateralized vaults
-
Advanced Security
- Strict authorization checks
- Input validation
- Comprehensive error handling
- Configurable governance parameters
-
Oracle Integration
- Multiple price oracle support
- Bitcoin price tracking
- Price update mechanism
-
Vaults
- Unique vault creation for each user
- Tracks collateral amount, minted stablecoins, and vault creation timestamp
- Supports multiple vaults per user
-
Stablecoin Configuration
- Configurable name and symbol
- Dynamic total supply management
- Adjustable collateralization ratio
-
Governance
- Contract owner controls critical parameters
- Ability to update collateralization ratio
- Oracle management
The contract includes detailed error codes for various scenarios:
- Unauthorized actions
- Insufficient balances
- Invalid collateral
- Undercollateralization
- Oracle price unavailability
- Liquidation failures
- Minting limit exceedance
- Creates a new vault for a user
- Requires valid collateral amount
- Generates a unique vault ID
- Allows minting stablecoins against collateral
- Validates:
- Vault ownership
- Collateralization ratio
- Minting limits
- Oracle price
- Enables users to redeem stablecoins
- Reduces vault's minted amount
- Updates total supply
- Triggers vault liquidation when collateralization falls below threshold
- Prevents self-liquidation
- Removes undercollateralized vault
add-btc-price-oracle
: Add trusted price oraclesupdate-btc-price
: Update Bitcoin priceupdate-collateralization-ratio
: Adjust system parameters
-
Collateralization
- Minimum ratio: 150%
- Liquidation threshold: 125%
-
Fees
- Minting fee: 0.5%
- Redemption fee: 0.5%
-
Limits
- Maximum mint limit: 1,000,000 tokens
- Maximum Bitcoin price: 1,000,000,000,000
- Strict access controls
- Price oracle validation
- Comprehensive input validation
- Prevents excessive vault and token creation
- Configurable liquidation mechanisms
- Stacks blockchain
- Clarity smart contract support
- Bitcoin price oracle infrastructure
- Deploy the contract on Stacks
- Configure initial parameters
- Add trusted price oracles
- Set initial collateralization ratio
- Dynamic fee adjustments
- More granular liquidation mechanisms
- Enhanced oracle redundancy
- Cross-chain collateral support
This smart contract is provided as-is. Users and developers should conduct thorough audits and testing before production use.
This project is licensed under the MIT License. See the LICENSE file for details.
We welcome contributions to DAF Smart Contract! Please see our Guide for details on how to get started.