-
Notifications
You must be signed in to change notification settings - Fork 0
StakeStream Protocol: Tiered Staking & Governance Implementation #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
ud-cmd
wants to merge
8
commits into
main
Choose a base branch
from
feat/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
- Define `Proposals` map to store proposal details, including: - `creator`, `description`, `start-block`, and `end-block`. - Voting-related fields: `executed`, `votes-for`, `votes-against`, and `minimum-votes`. - Enables on-chain governance functionality with proposal management. This commit lays the groundwork for decentralized governance within the StakeStream protocol.
- Define `UserPositions` map to track user-specific staking and governance data. - Define `StakingPositions` map to manage individual staking details. - Define `TierLevels` map to configure tier-based staking rewards and features. - Implement `initialize-contract` function to set up initial tier levels: - Bronze (1M uSTX, 1x multiplier). - Silver (5M uSTX, 1.5x multiplier). - Gold (10M uSTX, 2x multiplier). This commit establishes the core data structures and initialization logic for the StakeStream protocol.
- Add `stake-stx` public function to enable users to stake STX tokens. - Validate lock period, contract state, and minimum stake amount. - Transfer staked STX to the contract securely. - Calculate and update user tier level and rewards multiplier based on total stake and lock period. - Update `StakingPositions` and `UserPositions` maps with staking details. - Increment the STX pool variable to reflect the new stake. This commit introduces the core staking mechanism for the StakeStream protocol.
- Implement `initiate-unstake` function: - Validates staking position and ensures no active cooldown. - Sets a cooldown period for unstaking. - Implement `complete-unstake` function: - Validates cooldown completion before transferring STX back to the user. - Clears the user's staking position after successful unstaking. - Implement `create-proposal` function: - Allows users with sufficient voting power to create governance proposals. - Validates proposal description and voting period. - Tracks proposals in the `Proposals` map and increments the proposal count. This commit enhances the protocol with unstaking operations and governance proposal creation.
- Implement `vote-on-proposal` function: - Allows users to cast votes on governance proposals. - Updates `votes-for` or `votes-against` based on the user's choice and voting power. - Validates proposal existence, voting period, and user's voting power. - Add administrative functions: - `pause-contract`: Enables the contract owner to pause the protocol. - `resume-contract`: Allows the contract owner to resume the protocol. - Add read-only functions: - `get-contract-owner`: Returns the contract owner. - `get-stx-pool`: Retrieves the current STX pool balance. This commit finalizes governance voting, administrative controls, and essential read-only queries for the StakeStream protocol.
…tions - Implement `get-tier-info`: - Determines the user's tier level and reward multiplier based on their stake amount. - Implement `calculate-lock-multiplier`: - Calculates a multiplier based on the lock period (1x for no lock, 1.25x for 1 month, 1.5x for 2 months). - Implement `calculate-rewards`: - Computes staking rewards based on stake amount, base rate, multiplier, and elapsed blocks. - Add validation functions: - `is-valid-description`: Ensures proposal descriptions meet length requirements. - `is-valid-lock-period`: Validates lock periods (no lock, 1 month, or 2 months). - `is-valid-voting-period`: Validates voting periods (minimum 100 blocks, maximum 2880 blocks). - Add `get-proposal-count` read-only function: - Returns the current proposal count for governance tracking. This commit introduces essential utility and validation functions to support staking, rewards, and governance operations.
…r block references - Updated `stake-stx` function to use `stacks-block-height` for `start-block` and `last-claim` fields in `StakingPositions`. - Modified `initiate-unstake` to set `cooldown-start` using `stacks-block-height`. - Adjusted `complete-unstake` to calculate cooldown duration using `stacks-block-height`. - Updated `create-proposal` and `vote-on-proposal` functions to reference `stacks-block-height` for proposal start and end blocks. This ensures consistent and accurate block height references across staking and governance operations.
- Documented key features: - Tiered staking system with multipliers and lock periods. - Governance engine with proposal creation and voting. - Adaptive reward calculation formula. - Added technical architecture: - Core data structures for tiers, user positions, and staking positions. - Detailed staking operations: - `stake-stx`, `initiate-unstake`, and `complete-unstake` workflows. - Explained governance functionality: - Proposal creation and voting mechanics with validation rules. - Highlighted security model: - Cooldown enforcement, emergency toggle, and input validation. - Included installation and usage instructions: - Deployment steps and sample contract interactions. This README provides a complete overview of the StakeStream protocol for developers and users.
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 introduces the core functionality for StakeStream - a Bitcoin-native DeFi protocol combining tiered staking with on-chain governance. The implementation establishes secure STX staking mechanics, decentralized decision-making, and adaptive reward systems while maintaining compliance with Stacks L2 standards.
Key Features
Tiered Staking Architecture
Rewards = (Stake × Base Rate × Tier Multiplier × Lock Multiplier × Blocks) / 14,400,000On-Chain Governance Engine
Enterprise-Grade Security
Technical Implementation
Core Components
ProposalsUserPositionsTierLevelsValidation Framework
Documentation
Review Notes
Please pay special attention to:
This implementation establishes StakeStream as a foundational DeFi primitive for Bitcoin ecosystem, combining yield generation with decentralized governance. Looking forward to community feedback to strengthen protocol security and functionality.