BitVault Protocol: Bitcoin-Backed Stablecoin Implementation#1
Open
promise-code wants to merge 7 commits into
Open
BitVault Protocol: Bitcoin-Backed Stablecoin Implementation#1promise-code wants to merge 7 commits into
promise-code wants to merge 7 commits into
Conversation
- Added protocol configuration variables for stablecoin name, symbol, total supply, collateralization ratio, and liquidation threshold. - Defined protocol parameters including mint and redemption fees, and maximum mint limit. - Introduced oracle system with BTC price oracles and last BTC price mapping. - Established vault system with mappings for vaults and a vault counter. - Included SIP-010 token trait definition for compliance with Stacks token standard. - Added error codes for common protocol operations and security constants for validation. This commit sets up the foundational components for the Bitcoin-backed stablecoin protocol.
- Implemented `add-btc-price-oracle` to allow the contract owner to authorize new BTC price oracles. - Added `update-btc-price` to enable authorized oracles to update the BTC price with validation for price and timestamp limits. - Included error handling for unauthorized access and invalid parameters. These functions establish the decentralized oracle system for secure and reliable BTC price updates.
…nting - Implemented `create-vault` to allow users to create new vaults with an initial collateral amount. - Added `mint-stablecoin` to enable vault owners to mint stablecoins based on their collateral and BTC price. - Included validations for vault ID, collateralization ratio, mint limits, and under-collateralization. - Updated vault and total supply mappings upon successful minting. These functions establish the core vault system for managing collateralized debt positions and stablecoin issuance.
- Implemented `liquidate-vault` to allow liquidation of under-collateralized vaults. - Validates vault ID, collateralization ratio, and ensures the caller is not the vault owner. - Updates the total supply and removes the vault from the system upon successful liquidation. - Handles errors for invalid parameters, unauthorized actions, and failed liquidation attempts. This function enforces the protocol's risk management by ensuring vaults maintain sufficient collateralization.
- Implemented `redeem-stablecoin` to allow vault owners to redeem stablecoins and reduce their debt. - Validates vault ID, ensures the caller is the vault owner, and checks for sufficient stablecoin balance. - Updates the vault's stablecoin-minted value and decreases the total supply upon successful redemption. This function enables users to manage their debt positions by redeeming stablecoins against their collateral.
- Implemented `update-collateralization-ratio` to allow the contract owner to update the collateralization ratio within a valid range (100% to 300%). - Added `get-latest-btc-price` to retrieve the most recent BTC price from the oracle system. - Added `get-vault-details` to fetch details of a specific vault by owner and ID. - Added `get-total-supply` to retrieve the current total supply of stablecoins. These functions enhance protocol governance and provide essential read-only access for monitoring system state.
- Included usage examples for creating vaults, minting stablecoins, and liquidating vaults. - Documented key features, contract architecture, and core functions. - Added error codes, security considerations, and governance parameters. - Provided clarity on system constants, data storage, and risk management.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This pull request implements the core functionality for BitVault - a secure, over-collateralized stablecoin protocol leveraging Bitcoin on Stacks L2. The implementation establishes a complete system for managing Bitcoin-collateralized debt positions with robust risk management and decentralized price feeds.
Key Deliverables:
Changes Included
1. Core Protocol Infrastructure
2. Oracle Management System
3. Vault Operations
4. Risk Management
5. Governance Features
6. Documentation
Documentation Updated
Review Checklist
Notes for Reviewers