-
Couldn't load subscription status.
- Fork 0
Implement StacksFund Smart Contract Core Functionality #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nicholas-source
wants to merge
15
commits into
main
Choose a base branch
from
add-contract
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
- Added contract title, summary, and description. - Defined various error constants for contract operations. - Set minimum and maximum duration constants for proposals.
- Defined data variables for total supply, minimum deposit, lock period, initialization status, last rebalance, and proposal count. - Added data maps for tracking balances and deposits.
- Defined a data map for proposals with fields for proposer, description, amount, target, expiration, execution status, and vote counts. - Added a data map for tracking votes by proposal ID and voter.
- Added `is-contract-owner` to check if the transaction sender is the contract owner. - Added `check-initialized` to ensure the contract is initialized. - Added `calculate-voting-power` to determine the voting power of a given voter.
- Added `transfer-tokens` function to handle token transfers between sender and recipient. - Ensures sender has sufficient balance before transferring tokens. - Updates balances of sender and recipient accordingly.
- Added `mint-tokens` function to mint new tokens for a specified account. - Updates the account balance and total supply accordingly.
- Added `burn-tokens` function to burn tokens from a specified account. - Ensures the account has sufficient balance before burning tokens. - Updates the account balance and total supply accordingly.
- Added `initialize` function to set the contract as initialized by the contract owner. - Added `deposit` function to allow users to deposit STX, update deposit records, and mint fund tokens.
- Added `withdraw` function to allow users to withdraw their deposited STX. - Ensures the contract is initialized and the lock period has expired. - Burns the corresponding fund tokens before transferring STX back to the user.
- Added `create-proposal` function to allow users to create new proposals. - Validates input parameters including description, amount, target, and duration. - Ensures the proposer has a positive balance and updates the proposal count.
- Added `vote` function to allow users to vote on proposals. - Ensures the contract is initialized and the proposal exists. - Validates the voter's power, proposal expiration, and if the user has already voted. - Records the vote and updates the proposal's vote counts.
- Added `execute-proposal` function to execute approved proposals. - Ensures the contract is initialized and the proposal exists. - Validates the proposal's execution status, expiration, and vote counts. - Transfers funds as specified in the proposal and marks it as executed.
- Added `get-balance` to retrieve the balance of a specified account. - Added `get-total-supply` to get the total supply of tokens. - Added `get-proposal` to fetch details of a specific proposal. - Added `get-deposit-info` to get deposit information for a specified account.
- Added `validate-proposal-id` private function to ensure proposal ID is valid. - Updated `vote` and `execute-proposal` functions to use `validate-proposal-id` for proposal ID validation.
- Added LICENSE file to specify the project's license. - Added CONTRIBUTING file to guide contributors. - Added README file to provide an overview and instructions for the project. - Added SECURITY file to outline the security policy and contact information.
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 the core functionality for the StacksFund smart contract, a decentralized fund management system built on the Stacks blockchain. The implementation includes deposit handling, proposal management, voting mechanisms, and fund execution capabilities.
Changes
Contract Structure
Core Features
Fund Management
Proposal System
Access Control
Technical Implementation
Added data maps for:
Implemented private functions:
is-contract-ownercheck-initializedcalculate-voting-powertransfer-tokensmint-tokensburn-tokensvalidate-proposal-idAdded public functions:
initializedepositwithdrawcreate-proposalvoteexecute-proposalImplemented read-only functions:
get-balanceget-total-supplyget-proposalget-deposit-infoget-voteTesting
Security Considerations
Documentation
Implementation Details
Constants
Key Functions
TODO
Deployment Plan
Checklist
Reviewers
@smart-contract-team @security-team