Skip to content

Bitcoin-Native Overcollateralized Stablecoin Protocol#1

Open
gid-ctl wants to merge 6 commits into
mainfrom
feat/implement
Open

Bitcoin-Native Overcollateralized Stablecoin Protocol#1
gid-ctl wants to merge 6 commits into
mainfrom
feat/implement

Conversation

@gid-ctl

@gid-ctl gid-ctl commented Feb 20, 2025

Copy link
Copy Markdown
Owner

Overview

This PR implements a comprehensive Bitcoin-native stablecoin protocol leveraging Stacks Layer 2 capabilities. The protocol enables users to mint USD-pegged stablecoins using native Bitcoin as collateral, with built-in security measures and efficient capital utilization.

Key Features

  • Native Bitcoin collateralization without wrapped tokens
  • Capital-efficient 150% collateralization ratio
  • Dynamic liquidation system with 120% threshold
  • Trustless price oracle integration with validity windows
  • Flash loan attack protection
  • Comprehensive position management system

Technical Implementation

  1. Core Infrastructure

    • Implemented error handling system with descriptive codes
    • Set up data structures for user positions and liquidation history
    • Established configurable protocol parameters
    • Added block height-based timestamp management
  2. Position Management

    • Deposit collateral with minimum amount validation
    • Mint stablecoins with collateral ratio checks
    • Repay debt with position updates
    • Withdraw collateral with safety checks
    • Liquidate undercollateralized positions
  3. Security Features

    • Price validity windows to prevent stale data
    • Position health checks before critical operations
    • Access control for administrative functions
    • Atomic settlement guarantees

Documentation

  • Added comprehensive README
  • Included technical specifications
  • Provided integration guide
  • Documented all functions and error codes
  • Added security considerations

Next Steps

  • Deploy to testnet for further validation
  • Set up monitoring system for positions
  • Implement frontend interface
  • Conduct security audit
  • Establish oracle network

Review Focus

Please pay special attention to:

  • Collateralization ratio calculations
  • Liquidation mechanism safety
  • Price oracle integration
  • Access control implementation
  • Error handling completeness

Checklist

  • Implemented core protocol functions
  • Added comprehensive tests
  • Updated documentation
  • Reviewed security considerations
  • Validated Bitcoin compliance
  • Checked Stacks L2 compatibility

…stablecoin protocol

- Define constants for error codes, collateral ratios, and minimum deposit amounts
- Add data variables for contract owner, price oracle, total supply, BTC price, and last price update
- Create data maps for user positions and liquidation history
- Implement read-only functions to get user positions, collateral ratios, and current BTC price
- Add private functions to check price freshness, minimum collateral, and position health
…lecoins

- Implement `deposit-collateral` to allow users to deposit Bitcoin collateral.
- Implement `mint-stablecoin` to allow users to mint stablecoins based on their collateral.
- Ensure collateral and debt are updated correctly in user positions.
- Validate minimum collateral amount and price freshness before processing transactions.
- Update total supply of stablecoins upon successful minting.
…ateral, and liquidating positions

- Implement `repay-stablecoin` to allow users to repay their stablecoin debt.
- Implement `withdraw-collateral` to allow users to withdraw their Bitcoin collateral.
- Implement `liquidate-position` to allow liquidation of undercollateralized positions.
- Ensure collateral and debt are updated correctly in user positions.
- Validate debt amount, collateral amount, and position health before processing transactions.
- Record liquidation history and update total supply of stablecoins upon successful liquidation.
…ateral, and liquidating positions

- Implement `repay-stablecoin` to allow users to repay their stablecoin debt.
- Implement `withdraw-collateral` to allow users to withdraw their Bitcoin collateral.
- Implement `liquidate-position` to allow liquidation of undercollateralized positions.
- Ensure collateral and debt are updated correctly in user positions.
- Validate debt amount, collateral amount, and position health before processing transactions.
- Record liquidation history and update total supply of stablecoins upon successful liquidation.
…ice updates and position management

- Ensure consistency by using stacks-block-height for last price update and position management.
- Update block height references in public functions for depositing collateral, minting stablecoins, repaying stablecoins, withdrawing collateral, and liquidating positions.
…cations, and integration guide

- Include an overview of the SatoshiStable protocol and its key features.
- Provide technical specifications including collateralization parameters and smart contract functions.
- Detail user operations such as depositing collateral, minting stablecoins, repaying stablecoins, and withdrawing collateral.
- Explain the liquidation mechanism and read-only functions.
- Outline administrative functions for setting price and price oracle.
- List error codes and security considerations.
- Offer an integration guide for initializing positions, managing risk, and preventing liquidation.
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