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
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
69 changes: 69 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Code of Conduct

## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, 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

### Positive Behavior
* 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

### 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 in a professional setting
* Manipulation of smart contract vulnerabilities
* Intentional exploitation of security flaws
* Malicious attacks on the network or contract

## Project Maintainers' Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to:
* Remove, edit, or reject comments, commits, code, issues, and other contributions
* Ban temporarily or permanently any contributor for behaviors deemed inappropriate, threatening, offensive, or harmful
* Protect users and stakeholders of the smart contract
* Maintain the integrity of the codebase

## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.

## Enforcement

### Reporting
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team. All complaints will be reviewed and investigated promptly and fairly.

### Enforcement Guidelines
Project maintainers will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

1. **Correction**
- Community Impact: Use of inappropriate language or other behavior deemed unprofessional.
- Consequence: Private, written warning with clarity of violation and explanation of why the behavior was inappropriate.

2. **Warning**
- Community Impact: A violation through a single incident or series of actions.
- Consequence: Warning with consequences for continued behavior.

3. **Temporary Ban**
- Community Impact: A serious violation of community standards.
- Consequence: Temporary ban from any sort of interaction or public communication with the community.

4. **Permanent Ban**
- Community Impact: Demonstrating a pattern of violation of community standards.
- Consequence: Permanent ban from any sort of public interaction within the community.

## Smart Contract Specific Guidelines
1. Report security vulnerabilities responsibly
2. Do not attempt to exploit contract weaknesses
3. Respect the financial stakes of other users
4. Follow proper upgrade and governance procedures
5. Maintain transparency in proposal creation and voting

## Attribution
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
108 changes: 108 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Contributing to Stacks Fund Smart Contract

## Welcome!

Thank you for considering contributing to the Stacks Fund Smart Contract. This document provides guidelines and workflows for contributing to this project.

## Code of Conduct

This project adheres to our [Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.

## How Can I Contribute?

### Reporting Bugs

Before submitting a bug report:

1. Check the existing issues
2. Test with the latest version
3. Collect relevant information:
- Steps to reproduce
- Expected vs actual behavior
- Contract state when the bug occurred
- Transaction hash (if applicable)

### Suggesting Enhancements

Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion:

1. Use a clear and descriptive title
2. Provide detailed description of the proposed functionality
3. Explain why this enhancement would be useful
4. Consider security implications

### Pull Requests

1. Fork the repository
2. Create a new branch for your feature
3. Implement your changes
4. Write or update tests
5. Update documentation
6. Submit a pull request

#### Pull Request Process

1. Update the README.md with details of changes if applicable
2. Update the documentation
3. Add tests for new functionality
4. Ensure all tests pass
5. Get approval from maintainers

## Development Workflow

### Setting Up Development Environment

1. Install Clarity CLI tools
2. Set up a local Stacks blockchain
3. Configure testing environment

### Testing Guidelines

- Write unit tests for all new functions
- Test edge cases and failure scenarios
- Include integration tests where applicable
- Maintain test coverage above 90%

### Coding Standards

- Follow Clarity best practices
- Use meaningful variable and function names
- Comment complex logic
- Keep functions focused and modular
- Add appropriate error handling

### Documentation Standards

- Document all public functions
- Include usage examples
- Update constant definitions
- Maintain clear error code documentation

## Smart Contract Specifics

### Making Changes to Core Functions

1. Understand existing security measures
2. Consider backward compatibility
3. Document state changes
4. Add appropriate checks and balances

### Adding New Features

1. Ensure compatibility with existing functions
2. Follow established patterns
3. Consider gas optimization
4. Add appropriate events/logs

## Review Process

1. Technical review
2. Security review
3. Documentation review
4. Testing verification

## Questions?

Feel free to contact the maintainers or open an issue for clarification.

Thank you for contributing!
22 changes: 12 additions & 10 deletions Clarinet.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@

[project]
name = "StacksFund"
authors = []
description = ""
telemetry = true
requirements = []
[contracts.stacksfund]
path = "contracts/stacksfund.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 = []
37 changes: 37 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# MIT License

Copyright (c) 2024 Nicholas Ekpenyong

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

## Additional Blockchain-Specific Terms

1. **No Warranty for Smart Contract Operation**: The smart contract code is provided as-is, and no warranty is provided for its operation on any blockchain network.

2. **Risk Acknowledgment**: Users acknowledge that interacting with smart contracts carries inherent risks, including but not limited to:

- Potential loss of funds
- Smart contract vulnerabilities
- Network-related issues
- Front-running attacks
- Other blockchain-specific risks

3. **No Financial Advice**: Nothing in this software constitutes financial advice. Users are responsible for their own financial decisions.

4. **Regulatory Compliance**: Users are responsible for ensuring their use of this smart contract complies with their local regulations.
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Stacks Fund Smart Contract

## Overview

The Stacks Fund Smart Contract is a decentralized fund management system built on the Stacks blockchain. It enables users to participate in collective fund management through a transparent and secure smart contract system.

## Features

- **Deposit Management**: Secure deposit of STX tokens with minimum deposit requirements
- **Token System**: Automatic minting and burning of fund tokens representing shares
- **Proposal System**: Create and vote on fund allocation proposals
- **Democratic Governance**: Token-weighted voting system for proposal decisions
- **Time-Locked Deposits**: Security mechanism to prevent rapid withdrawals
- **Automated Execution**: Secure execution of approved proposals

## Core Functions

### User Functions

- `deposit`: Deposit STX tokens into the fund
- `withdraw`: Withdraw STX tokens after lock period
- `create-proposal`: Submit new fund allocation proposals
- `vote`: Participate in proposal voting
- `execute-proposal`: Execute approved proposals

### Read-Only Functions

- `get-balance`: Check account balance
- `get-total-supply`: View total token supply
- `get-proposal`: Retrieve proposal details
- `get-deposit-info`: View deposit information
- `get-vote`: Check voting records

## Technical Details

### Constants

- Minimum deposit: 1,000,000 microSTX
- Lock period: ~10 days (1440 blocks)
- Minimum proposal duration: 1 day (144 blocks)
- Maximum proposal duration: 14 days (20,160 blocks)

### Error Codes

- `100`: Owner-only operation
- `101`: Contract not initialized
- `102`: Already initialized
- `103`: Insufficient balance
- `104`: Invalid amount
- (See contract for complete error code listing)

## Getting Started

### Prerequisites

- Stacks wallet
- Minimum deposit amount in STX
- Understanding of smart contract interactions

### Interacting with the Contract

1. **Initialize Contract** (owner only)
2. **Make Deposit**
```clarity
(contract-call? .stacks-fund deposit u1000000)
```
3. **Create Proposal**
```clarity
(contract-call? .stacks-fund create-proposal "Proposal Description" u500000 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM u2880)
```

## Security Considerations

- Funds are time-locked after deposit
- Proposal execution requires majority approval
- Built-in checks for balance verification
- Contract owner privileges are limited

## Development Status

This contract is in production-ready state but should undergo thorough security audit before mainnet deployment.

## Contributing

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.

## Security

For security concerns, please review our [SECURITY.md](SECURITY.md) file.
Loading