Stablecoin Vault Contract Implementation#1
Open
timileyin-create wants to merge 15 commits into
Open
Conversation
- Define contract owner and various error codes - Set maximum and minimum price limits - Establish collateral ratio and stability fee limits
- Define collateral ratio, liquidation ratio, stability fee, and initialization flags - Add mappings for vaults, liquidators, and price oracles
…t contract - Implement `is-valid-price` to check price within allowed range - Implement `is-valid-ratio` to check ratio within allowed range - Implement `is-valid-fee` to check fee within allowed range
…oin vault contract - Implement `initialize` to set up the contract with initial BTC price - Implement `create-vault` to allow users to create vaults by depositing collateral
…blecoin vault contract - Implement `mint-stablecoin` to allow users to mint stablecoins against their collateral - Implement `repay-debt` to allow users to repay their debt and reduce their vault's debt balance
…ntract - Implement `withdraw-collateral` to allow users to withdraw collateral while maintaining the minimum collateral ratio
…blecoin vault contract - Implement `liquidate` to allow authorized liquidators to liquidate vaults below the liquidation ratio
- Implement `update-price` to allow authorized oracles to update the BTC price
…s in stablecoin vault contract - Implement `set-minimum-collateral-ratio` to allow the contract owner to update the minimum collateral ratio - Implement `set-liquidation-ratio` to allow the contract owner to update the liquidation ratio
…n stablecoin vault contract - Implement `set-stability-fee` to allow the contract owner to update the stability fee - Implement `add-liquidator` to allow the contract owner to add authorized liquidators - Implement `remove-liquidator` to allow the contract owner to remove authorized liquidators
…lt contract - Implement `add-oracle` to allow the contract owner to add authorized price oracles - Implement `remove-oracle` to allow the contract owner to remove authorized price oracles
…n vault contract - Implement `trigger-emergency-shutdown` to allow the contract owner to initiate an emergency shutdown
…atio in stablecoin vault contract - Implement `get-vault` to retrieve vault details for a given owner - Implement `get-collateral-ratio` to calculate and return the collateral ratio for a given owner
…es, and retrieving stability parameters in stablecoin vault contract - Implement `is-authorized-liquidator` to check if an address is an authorized liquidator - Implement `is-authorized-oracle` to check if an address is an authorized oracle - Implement `get-stability-parameters` to retrieve current stability parameters of the contract
…chnical Specification documentation
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 PR implements a comprehensive stablecoin vault system that allows users to create collateralized debt positions (CDPs) using STX as collateral. The implementation includes core functionality, governance controls, and security measures.
Changes
Core Contract Implementation
Constants and Error Codes
Data Structure
Validation Functions
is-valid-price: Price range validationis-valid-ratio: Collateral ratio validationis-valid-fee: Fee validationCore Functions
Oracle Integration
Governance Controls
Read-Only Functions
Documentation
Security Considerations
Deployment Steps
Future Improvements
Checklist