Skip to content

BitVault Protocol: Bitcoin-Backed Stablecoin Implementation#1

Open
promise-code wants to merge 7 commits into
mainfrom
feat/develop
Open

BitVault Protocol: Bitcoin-Backed Stablecoin Implementation#1
promise-code wants to merge 7 commits into
mainfrom
feat/develop

Conversation

@promise-code

Copy link
Copy Markdown
Owner

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:

  • SIP-010 compliant stablecoin system
  • Decentralized oracle infrastructure
  • Non-custodial vault management
  • Automated liquidation mechanisms
  • Protocol governance framework
  • Comprehensive technical documentation

Changes Included

1. Core Protocol Infrastructure

  • Implemented SIP-010 token standard integration
  • Established vault system with collateral tracking
  • Configured risk parameters:
    • 150% initial collateralization ratio
    • 125% liquidation threshold
    • 0.5% mint/redemption fees
  • Added security constants for price/time validation

2. Oracle Management System

  • Multi-signer price feed architecture
  • Authorized oracle management functions
  • Time-stamped BTC price updates
  • Price validation safeguards (0 < price ≤ 1e12)

3. Vault Operations

  • Vault creation with initial collateral
  • Collateralized stablecoin minting:
    (mint-stablecoin 'owner-address vault-id amount)
  • Debt redemption mechanism
  • Real-time collateral health checks

4. Risk Management

  • Public liquidation function
  • Collateralization ratio enforcement
  • Automated debt cleanup
  • Anti-self-liquidation protection

5. Governance Features

  • Owner-controlled parameter updates
  • Collateral ratio adjustment (100-300%)
  • System monitoring functions:
    (get-vault-details) (get-total-supply)

6. Documentation

  • Technical specification document
  • Usage examples & error code reference
  • Security audit checklist
  • System architecture diagrams

Documentation Updated

  • Complete protocol documentation in README.md
  • Function-level code comments
  • Error code reference table
  • Parameter change log

Review Checklist

  • Verify SIP-010 compliance
  • Confirm oracle authorization logic
  • Validate collateral ratio calculations
  • Review fee parameter handling
  • Confirm documentation accuracy

Notes for Reviewers

  1. Price oracle updates require authorized signer
  2. Vault IDs increment sequentially from 1
  3. All timestamps use Stacks block height
  4. Governance functions are owner-restricted

- 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.
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.

1 participant