Bitcoin Investment DAO Smart Contract Implementation#1
Open
samuel-dafeta wants to merge 19 commits intomainfrom
Open
Bitcoin Investment DAO Smart Contract Implementation#1samuel-dafeta wants to merge 19 commits intomainfrom
samuel-dafeta wants to merge 19 commits intomainfrom
Conversation
- Added metadata including title, summary, and description for the Bitcoin Investment DAO smart contract. - Defined error constants for various contract operations such as authorization, invalid amounts, proposal status, and balance checks.
- Defined `dao-owner` to store the principal of the DAO owner. - Added `total-staked` to track the total amount of tokens staked. - Included `proposal-count` to keep a count of proposals. - Set `quorum-threshold` to define the required quorum in basis points. - Defined `proposal-duration` to specify the duration of proposals in blocks. - Added `min-proposal-amount` to set the minimum amount required for a proposal in uSTX.
- Defined `members` map to store information about each member. - Each member entry includes: - `staked-amount`: The amount of tokens staked by the member. - `last-reward-block`: The block number when the member last claimed rewards. - `rewards-claimed`: The total rewards claimed by the member.
- Defined `proposals` map to store information about each proposal. - Each proposal entry includes: - `proposer`: The principal who created the proposal. - `title`: The title of the proposal. - `description`: A detailed description of the proposal. - `amount`: The amount of tokens involved in the proposal. - `recipient`: The principal who will receive the tokens if the proposal is approved. - `start-block`: The block number when the proposal starts. - `end-block`: The block number when the proposal ends. - `yes-votes`: The number of votes in favor of the proposal. - `no-votes`: The number of votes against the proposal. - `status`: The current status of the proposal. - `executed`: A boolean indicating whether the proposal has been executed.
- Defined `votes` map to store votes for each proposal. - Each vote entry includes: - `proposal-id`: The ID of the proposal being voted on. - `voter`: The principal of the voter. - `vote`: A boolean indicating the vote (true for yes, false for no).
- Added `is-dao-owner` function to check if the transaction sender is the DAO owner. - Added `is-member` function to check if a given address is a member with a staked amount greater than zero.
- Added `get-proposal-status` function to retrieve the status of a proposal by its ID. - Returns the status if the proposal exists, otherwise returns "NOT_FOUND".
- Added `calculate-voting-power` function to determine the voting power of a given address. - Returns the staked amount of the member if they exist, otherwise returns zero.
- Added `initialize` function to set a new DAO owner. - Checks if the transaction sender is the current DAO owner. - Sets the new owner if the check passes.
- Added `stake-tokens` function to allow members to stake tokens. - Retrieves the current balance of the member or initializes it if not present. - Asserts that the amount to stake is valid. - Transfers the specified amount of tokens from the sender to the contract. - Updates the member's staked amount, last reward block, and total staked tokens.
- Added `unstake-tokens` function to allow members to unstake tokens. - Retrieves the current balance of the member or initializes it if not present. - Asserts that the member has sufficient staked balance to unstake the specified amount. - Transfers the specified amount of tokens from the contract to the sender. - Updates the member's staked amount, last reward block, and total staked tokens.
- Added `create-proposal` function to allow members to create new proposals. - Generates a new proposal ID and calculates the proposer's voting power. - Asserts that the proposer has sufficient stake and the amount is valid. - Sets the proposal details including title, description, amount, recipient, start and end blocks, votes, status, and execution status. - Updates the proposal count and returns the new proposal ID.
- Added `vote` function to allow members to vote on proposals. - Retrieves the proposal and calculates the voter's voting power. - Asserts that the voter is a member, the proposal is active, the proposal has not expired, and the voter has not already voted. - Records the vote and updates the proposal's yes or no votes based on the voter's choice.
- Added `execute-proposal` function to execute proposals after voting ends. - Retrieves the proposal and checks if it exists. - Asserts that the proposal has ended and has not been executed yet. - Checks if the proposal meets the quorum threshold and has more yes votes than no votes. - If approved, transfers the proposal amount to the recipient and updates the proposal status to "EXECUTED". - If rejected, updates the proposal status to "REJECTED".
- Added `get-member-info` function to retrieve information about a member. - Added `get-proposal-info` function to retrieve information about a proposal. - Added `get-vote-info` function to retrieve information about a vote on a proposal.
- Added `get-dao-info` function to retrieve overall information about the DAO. - Returns the total staked amount, proposal count, quorum threshold, and minimum proposal amount.
…rity and efficiency
… main branch - Added comprehensive overview of the Bitcoin Investment DAO smart contract. - Included features such as token staking, proposal creation, voting, and execution. - Detailed constants, core functionality, and read-only functions. - Provided usage examples for staking tokens, creating proposals, voting, and executing proposals. - Outlined security considerations, error codes, and development/testing instructions. - Listed current limitations and potential future improvements.
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 Decentralized Autonomous Organization (DAO) smart contract for collective Bitcoin investment management on the Stacks blockchain. The implementation includes core DAO functionality such as membership management, proposal creation, voting mechanisms, and automated execution systems.
Changes
Data Structure Implementation
Core Functionality
Membership System
Proposal Management
Voting System
Execution System
Read-Only Functions
Testing
Security Considerations
Documentation
Future Improvements
Checklist
Deployment Notes
The contract should be deployed with initial parameters:
Review Guidelines
Please review: