Skip to content

Implement Governance Engine, Tiered Staking System & Comprehensive Documentation#1

Open
israel-capslock wants to merge 9 commits into
mainfrom
feat/implement
Open

Implement Governance Engine, Tiered Staking System & Comprehensive Documentation#1
israel-capslock wants to merge 9 commits into
mainfrom
feat/implement

Conversation

@israel-capslock

Copy link
Copy Markdown
Owner

Overview
This PR introduces core functionality for Bitstack Analytics Protocol - a decentralized data intelligence platform combining stakeholder governance with multi-tiered financial incentives. Key architectural components include:

New Features Implemented

Decentralized Governance System

  • Proposals registry with creator details/voting timelines
  • Stake-weighted voting power calculations
  • Quorum-enforced proposal execution

Tiered Financial Positions

  • Silver/Gold/Platinum tiers with progressive benefits
  • Time-locked staking bonuses (1.25x-1.5x multipliers)
  • Cooldown-protected unstaking mechanism

Dynamic Reward Infrastructure

  • APR-based rewards with tier/lock period multipliers
  • Real-time health factor calculations
  • Auto-compounding claim system

Security Architecture

  • Multi-sig emergency pause/resume
  • Voting period constraints (100-2880 blocks)
  • Cooldown-protected withdrawals

Impact Analysis
This implementation enables:

  1. Community-Led Protocol Evolution - Stakeholders now control parameter updates via binding votes
  2. Institutional-Grade Staking - Tier-based access to advanced analytics feeds
  3. Anti-Flash Loan Protections - 24h cooldown on large withdrawals
  4. Transparent Reward Flow - On-chain verifiable APY calculations

Documentation

  • Full technical spec in README.md
  • Error code reference table
  • Deployment checklist for mainnet
  • Risk parameter explanations

- Introduced a `Proposals` map to store governance proposal data.
- Each proposal includes creator, description, start and end blocks, execution status, votes for and against, and minimum votes required.
- This enhancement supports decentralized decision-making by allowing stakeholders to vote on protocol changes.
…on maps

- Introduced `UserPositions` map to track user financial data including collateral, debt, health factor, staked STX, token balance, voting power, tier level, and rewards multiplier.
- Added `StakingPositions` map to manage staking details such as staked amount, start block, last claim, lock period, cooldown start, and accumulated rewards.
- Implemented `TierLevels` map to define tier configurations with minimum stake, reward multiplier, and enabled features for each tier.
…, and reward calculation

- Implemented `get-tier-info` to determine user tier based on staked amount, categorizing into Silver, Gold, and Platinum tiers.
- Added `calculate-lock-multiplier` to compute bonus multipliers based on lock periods, with higher multipliers for longer lock durations.
- Developed `calculate-rewards` function to calculate user rewards based on staked amount, base rate, multiplier, and number of blocks.
- Implemented `is-valid-description` to validate proposal descriptions based on length constraints.
- Added `is-valid-lock-period` to ensure lock periods are either 0, 1 month, or 2 months.
- Developed `is-valid-voting-period` to validate voting periods within a specified block range.
- Created `initialize-contract` public function to set up the tier system with Silver, Gold, and Platinum tiers, each with specific minimum stakes, reward multipliers, and enabled features.
- Added `stake-stx` public function to allow users to stake STX with a specified lock period.
- Validates lock period, contract pause state, and minimum stake amount.
- Transfers STX from the user to the contract.
- Calculates new total stake, tier level, and reward multiplier based on the stake amount and lock period.
- Updates the user's staking position and financial position with new tier and reward information.
- Updates the total STX pool in the protocol.
- Implemented `initiate-unstake` public function to start the unstaking process by setting a cooldown period.
  - Validates the user's staking position and ensures no active cooldown.
  - Updates the staking position with the current block height as the cooldown start.

- Added `complete-unstake` public function to finalize the unstaking process after the cooldown period.
  - Validates the cooldown period has passed.
  - Transfers the staked STX back to the user.
  - Clears the user's staking position from the map.
- Implemented `create-proposal` public function to allow users to create governance proposals.
  - Validates the user's voting power, proposal description, and voting period.
  - Generates a new proposal ID and sets the proposal details including creator, description, start and end blocks, execution status, votes for and against, and minimum votes required.
  - Updates the proposal count and returns the new proposal ID.
- Implemented `vote-on-proposal` public function to allow users to vote on governance proposals.
  - Validates the proposal ID, voting period, and user's voting power.
  - Updates the proposal with the user's vote (for or against) and their voting power.

- Added admin controls:
  - `pause-contract` to allow the contract owner to pause the protocol.
  - `resume-contract` to allow the contract owner to resume the protocol.

- Created read-only functions:
  - `get-contract-owner` to return the contract owner.
  - `get-stx-pool` to return the total STX liquidity in the protocol.
  - `get-proposal-count` to return the current number of proposals.
- Detailed introduction and protocol highlights.
- Description of core components including token economy, tiered staking, governance engine, and reward system.
- Documentation of smart contract functions for staking, governance, and administrative controls.
- Explanation of reward calculation formula and example.
- Security features including cooldown system, tiered safeguards, and governance checks.
- Error reference table with codes, descriptions, and resolutions.
- Development guide with requirements and deployment checklist.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant