Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
9df17ca
Add constants and error codes for stablecoin vault contract
timileyin-create Dec 28, 2024
e6158de
Add data variables and storage mappings for stablecoin vault contract
timileyin-create Dec 28, 2024
af1aaf9
Add validation functions for price, ratio, and fee in stablecoin vaul…
timileyin-create Dec 28, 2024
c9196e3
Add public functions for initialization and vault creation in stablec…
timileyin-create Dec 28, 2024
44b36cf
Add public functions for minting stablecoins and repaying debt in sta…
timileyin-create Dec 28, 2024
9b76ada
Add public function for withdrawing collateral in stablecoin vault co…
timileyin-create Dec 28, 2024
c6cf216
Add public function for liquidating undercollateralized vaults in sta…
timileyin-create Dec 28, 2024
108cfd2
Add public function for updating price in stablecoin vault contract
timileyin-create Dec 28, 2024
7d87d07
Add governance functions for setting collateral and liquidation ratio…
timileyin-create Dec 28, 2024
76eb3cf
Add governance functions for managing stability fee and liquidators i…
timileyin-create Dec 28, 2024
761fcfa
Add governance functions for managing price oracles in stablecoin vau…
timileyin-create Dec 28, 2024
11a8982
Add emergency function for triggering emergency shutdown in stablecoi…
timileyin-create Dec 28, 2024
d2dec66
Add read-only functions for retrieving vault details and collateral r…
timileyin-create Dec 28, 2024
5e343a5
Add read-only functions for checking authorized liquidators and oracl…
timileyin-create Dec 28, 2024
3196b91
Add Code of Conduct, Contributing Guidelines, Security Policy, and Te…
timileyin-create Dec 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to a positive environment:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior:

- The use of sexualized language or imagery
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information without explicit permission
- Other conduct which could reasonably be considered inappropriate

## Enforcement Responsibilities

Project maintainers are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the project maintainers responsible for enforcement. All complaints will be reviewed and investigated promptly and fairly.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html).
53 changes: 53 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Contributing Guidelines

Thank you for your interest in contributing to the Stablecoin Vault Contract! This document provides guidelines and instructions for contributing.

## Development Process

1. Fork the repository
2. Create a new branch for your feature/fix
3. Write tests for your changes
4. Implement your changes
5. Run tests and ensure they pass
6. Submit a pull request

## Code Style Guidelines

- Follow the Clarity style guide
- Use meaningful variable and function names
- Add comments for complex logic
- Keep functions focused and small
- Include proper error handling

## Testing Requirements

- Write unit tests for new functions
- Include integration tests for complex interactions
- Test edge cases and error conditions
- Ensure all tests pass before submitting PR

## Security Considerations

- Always validate input parameters
- Check for arithmetic overflow/underflow
- Implement proper access controls
- Follow the principle of least privilege
- Add relevant security tests

## Pull Request Process

1. Update documentation for any changes
2. Add tests for new functionality
3. Ensure CI passes
4. Request review from maintainers
5. Address review feedback

## Getting Help

- Open an issue for questions
- Join our community chat
- Read the technical documentation

## Code Review Process

All submissions require review. We use GitHub pull requests for this purpose.
22 changes: 12 additions & 10 deletions Clarinet.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@

[project]
name = "bitstable"
authors = []
description = ""
telemetry = true
requirements = []
[contracts.bitstable]
path = "contracts/bitstable.clar"
depends_on = []

[repl]
costs_version = 2
parser_version = 2

[repl.analysis]
passes = ["check_checker"]

[repl.analysis.check_checker]
# If true, inputs are trusted after tx_sender has been checked.
strict = false
trusted_sender = false
# If true, inputs are trusted after contract-caller has been checked.
trusted_caller = false
# If true, untrusted data may be passed into a private function without a
# warning, if it gets checked inside. This check will also propagate up to the
# caller.
callee_filter = false

# [contracts.counter]
# path = "contracts/counter.clar"
# depends_on = []
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Stablecoin Vault Contract

A decentralized stablecoin system built on Stacks that enables users to create collateralized debt positions (CDPs) using STX as collateral.

## Overview

The Stablecoin Vault Contract implements a decentralized stablecoin system where users can:

- Create vaults by depositing STX as collateral
- Mint stablecoins against their collateral
- Manage their positions (repay debt, withdraw collateral)
- Get liquidated if their position falls below the liquidation ratio

## Key Features

- **Collateralized Debt Positions (CDPs)**

- Minimum collateralization ratio: 150%
- Liquidation threshold: 120%
- Dynamic stability fee mechanism

- **Price Oracle Integration**

- Real-time collateral valuation
- Multiple oracle support
- Price validity checks

- **Risk Management**
- Liquidation mechanism
- Emergency shutdown capability
- Governance controls for risk parameters

## Quick Start

1. Initialize the contract with a valid price:

```clarity
(contract-call? .stablecoin-vault initialize u50000000)
```

2. Create a vault and deposit collateral:

```clarity
(contract-call? .stablecoin-vault create-vault u1000000)
```

3. Mint stablecoins against your collateral:

```clarity
(contract-call? .stablecoin-vault mint-stablecoin u500)
```

## Documentation

- [Technical Specification](docs/technical-specification.md)
- [Security Policy](SECURITY.md)
- [Contributing Guidelines](CONTRIBUTING.md)
- [Code of Conduct](CODE_OF_CONDUCT.md)

## Contract Parameters

- Minimum Collateral Ratio: 150%
- Liquidation Ratio: 120%
- Stability Fee: 2% annual
- Maximum Price: 1,000,000,000
- Minimum Price: 1
- Maximum Ratio: 1000%
- Minimum Ratio: 101%
- Maximum Fee: 100%
59 changes: 59 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Security Policy

## Reporting a Vulnerability

If you discover a security vulnerability in the Stablecoin Vault Contract, please follow these steps:

1. **Do NOT disclose the vulnerability publicly**
2. Email the security team at timileyincreate4@gmail.com
3. Include detailed information about the vulnerability
4. Provide steps to reproduce if possible

## Security Measures

The contract implements several security measures:

### Access Controls

- Owner-only functions for critical operations
- Role-based access for oracles and liquidators
- Emergency shutdown capability

### Price Safety

- Valid price range checks
- Multiple oracle support
- Price staleness checks

### Collateral Management

- Minimum collateralization ratio
- Liquidation threshold
- Safe math operations

### System Parameters

- Maximum and minimum bounds for all parameters
- Governance controls for parameter updates
- Emergency shutdown mechanism

## Security Considerations

When using the contract:

1. **Price Oracle**

- Ensure multiple reliable oracles
- Implement price validity checks
- Monitor for price manipulation

2. **Collateral Management**

- Maintain healthy collateralization ratio
- Monitor liquidation risk
- Understand stability fee implications

3. **System Parameters**
- Review parameter changes
- Understand impact on positions
- Monitor governance decisions
Loading