Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
70fe979
Add initial BitStack Analytics Contract with token definitions and co…
tari-ctrl Nov 27, 2024
2205290
Add data variables and maps for BitStack Analytics Contract
tari-ctrl Nov 27, 2024
a8ee073
Add Proposals data map to BitStack Analytics Contract
tari-ctrl Nov 27, 2024
064588c
Add UserPositions, StakingPositions, and TierLevels data maps
tari-ctrl Nov 27, 2024
dcc0ae6
Add initialize-contract function to set up tier levels
tari-ctrl Nov 27, 2024
912aab2
Add stake-stx function for staking STX tokens with optional lock period
tari-ctrl Nov 27, 2024
b673461
Add initiate-unstake function to start the unstaking process
tari-ctrl Nov 27, 2024
3d43633
Add complete-unstake function to finalize the unstaking process
tari-ctrl Nov 27, 2024
b995c70
Add create-proposal function for governance proposals
tari-ctrl Nov 27, 2024
9f37471
Add vote-on-proposal function for governance voting
tari-ctrl Nov 27, 2024
bebf418
Add functions to pause and resume the contract
tari-ctrl Nov 27, 2024
b5432ef
Add read-only functions for contract owner, STX pool balance, and pro…
tari-ctrl Nov 27, 2024
f354940
Add private functions for tier info and lock multiplier calculations
tari-ctrl Nov 27, 2024
8575a2b
Add private functions for reward calculation and description validation
tari-ctrl Nov 27, 2024
605cf5e
Add private functions for lock period and voting period validation
tari-ctrl Nov 27, 2024
c444946
Update README with detailed overview and features of BitStack Analytics
tari-ctrl Nov 27, 2024
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
30 changes: 14 additions & 16 deletions Clarinet.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
[project]
name = "bitstack-decentralized-analytics"
description = ""
name = 'bitstack-decentralized-analytics'
description = ''
authors = []
telemetry = true
cache_dir = "./.cache"

# [contracts.counter]
# path = "contracts/counter.clar"

cache_dir = './.cache'
requirements = []
[contracts.bitStack-analytics]
path = 'contracts/bitStack-analytics.clar'
clarity_version = 2
epoch = 2.5
[repl.analysis]
passes = ["check_checker"]
check_checker = { trusted_sender = false, trusted_caller = false, callee_filter = false }
passes = ['check_checker']

# Check-checker settings:
# trusted_sender: if true, inputs are trusted after tx_sender has been checked.
# trusted_caller: if true, inputs are trusted after contract-caller has been checked.
# callee_filter: 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.
# More informations: https://www.hiro.so/blog/new-safety-checks-in-clarinet
[repl.analysis.check_checker]
strict = false
trusted_sender = false
trusted_caller = false
callee_filter = false
116 changes: 116 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# BitStack Analytics Smart Contract

## Overview

BitStack Analytics is a comprehensive DeFi (Decentralized Finance) smart contract built on the Stacks blockchain, providing advanced staking, governance, and analytics capabilities. The contract offers a multi-tier staking system with flexible rewards, governance mechanisms, and robust security features.

## Features

### 1. Multi-Tier Staking System

- Three distinct staking tiers with increasing benefits
- Tier Levels:
- Tier 1: Minimum 1M uSTX
- Tier 2: Minimum 5M uSTX
- Tier 3: Minimum 10M uSTX
- Progressive reward multipliers and unlockable features

### 2. Flexible Staking Options

- Optional lock periods:
- No lock: 1x reward multiplier
- 1-month lock: 1.25x reward multiplier
- 2-month lock: 1.5x reward multiplier
- Minimum stake amount of 1,000,000 uSTX
- 24-hour cooldown period for unstaking

### 3. Governance Mechanism

- Proposal creation and voting system
- Voting power based on staked amount
- Proposal requirements:
- Minimum voting power of 1,000,000
- Proposal description (10-256 characters)
- Voting period (100-2,880 blocks)

### 4. Security Features

- Contract owner controls
- Emergency pause/resume functionality
- Robust error handling with specific error codes

## Contract Constants and Error Codes

### Error Codes

- `ERR-NOT-AUTHORIZED (u1000)`: Unauthorized access attempt
- `ERR-INVALID-PROTOCOL (u1001)`: Invalid protocol parameters
- `ERR-INVALID-AMOUNT (u1002)`: Invalid token amount
- `ERR-INSUFFICIENT-STX (u1003)`: Insufficient STX balance
- `ERR-COOLDOWN-ACTIVE (u1004)`: Cooldown period is active
- `ERR-NO-STAKE (u1005)`: No active stake found
- `ERR-BELOW-MINIMUM (u1006)`: Stake below minimum threshold
- `ERR-PAUSED (u1007)`: Contract is paused

### Key Parameters

- Base Reward Rate: 5% (500 basis points)
- Bonus Rate: 1% (100 basis points)
- Minimum Stake: 1,000,000 uSTX
- Cooldown Period: 24 hours (1,440 blocks)

## Main Functions

### Staking

- `stake-stx`: Stake STX tokens with optional lock period
- `initiate-unstake`: Begin unstaking process with cooldown
- `complete-unstake`: Finalize unstaking after cooldown

### Governance

- `create-proposal`: Create a new governance proposal
- `vote-on-proposal`: Vote on an existing proposal

### Contract Management

- `pause-contract`: Pause contract operations
- `resume-contract`: Resume contract operations

## Tier Benefits

### Tier 1

- Basic staking
- Standard reward multiplier
- Limited features

### Tier 2

- Enhanced staking
- Increased reward multiplier
- Additional governance features

### Tier 3

- Premium staking
- Highest reward multiplier
- Full feature set

## Security Considerations

- Only contract owner can initialize and manage critical functions
- Implemented cooldown and unstaking mechanisms
- Emergency pause functionality
- Strict validation of stake amounts, lock periods, and proposals

## Installation and Deployment

1. Ensure Stacks blockchain environment is set up
2. Deploy the contract using a Stacks-compatible wallet or development tool
3. Call `initialize-contract` to set up tier levels
4. Users can begin staking and interacting with the contract

## Contribution

Contributions are welcome! Please submit pull requests or open issues on the project repository.
Loading