-
Notifications
You must be signed in to change notification settings - Fork 0
Add Mempool Real-Time Live Tracker Smart Contract #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
emmanuelist
wants to merge
25
commits into
main
Choose a base branch
from
add-smart-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
…ng and fee management
- Added error code constants for various error scenarios: - ERR-NOT-AUTHORIZED (u1000) - ERR-INVALID-PARAMS (u1001) - ERR-NOT-FOUND (u1002) - ERR-ALREADY-EXISTS (u1003) - ERR-INVALID-FEE (u1004) - Included the use of ft-trait from sip-010-trait-ft-standard
- Defined `tracked-transactions` map to store transaction details including tx-id, fee-rate, size, priority, timestamp, confirmed status, category, and prediction.
- Added error code constants for various error scenarios. - Defined `tracked-transactions` map to store transaction details. - Defined `user-watchlists` map to store user-specific watchlist details.
- Defined `fee-stats` map to store fee statistics per block height: - avg-fee: uint - min-fee: uint - max-fee: uint - recommended-low: uint - recommended-medium: uint - recommended-high: uint - total-tx-count: uint
- Defined `mempool-metrics` map to store metrics related to the mempool: - timestamp: uint - size: uint - tx-count: uint - avg-confirmation-time: uint - congestion-level: uint
- Defined data variables: - contract-owner: principal - last-update: uint - total-tracked-tx: uint - min-fee-threshold: uint (in sats/byte)
- Defined private function `is-contract-owner` to verify if the transaction sender is the contract owner.
- Defined private function `validate-fee-rate` to check if the fee rate meets the minimum fee threshold.
- Defined private function `calculate-priority` to determine the priority of a transaction based on fee rate and size: - High priority: priority-score >= 100000 - Medium priority: priority-score >= 50000 - Low priority: priority-score < 50000
- Defined private function `estimate-confirmation-time` to calculate the estimated confirmation time based on fee rate and congestion level: - base-time: 10 minutes (600 seconds) - congestion-multiplier: 1 + (congestion / 100)
- Defined public function `track-transaction` to track a new transaction: - Calculates priority based on fee rate and size. - Retrieves current block time. - Validates fee rate and checks if the transaction already exists. - Stores transaction details in `tracked-transactions` map. - Updates total tracked transactions count.
- Defined public function `update-transaction-status` to update the confirmation status of a transaction: - Checks if the caller is the contract owner. - Retrieves the transaction data from `tracked-transactions` map. - Updates the `confirmed` status of the transaction.
- Defined public function `update-fee-statistics` to update fee statistics for a given block height: - Checks if the caller is the contract owner. - Updates the `fee-stats` map with the provided statistics.
- Defined read-only function `get-transaction-details` to retrieve details of a specific transaction: - Returns the transaction details from the `tracked-transactions` map.
- Defined read-only function `get-user-watchlist` to retrieve a user's watchlist: - Returns the watchlist details from the `user-watchlists` map.
- Defined read-only function `get-fee-statistics` to retrieve fee statistics for a given block height: - Returns the fee statistics from the `fee-stats` map.
- Defined private function `get-congestion-level` to retrieve the current congestion level from mempool metrics: - Uses the last update timestamp to fetch the metrics. - Returns the congestion level from the `mempool-metrics` map.
- Defined public function `update-mempool-metrics` to update mempool metrics: - Checks if the caller is the contract owner. - Retrieves the current block time. - Updates the `mempool-metrics` map with the provided metrics. - Sets the `last-update` variable to the current time.
- Defined public function `set-min-fee-threshold` to update the minimum fee threshold: - Checks if the caller is the contract owner. - Sets the `min-fee-threshold` variable to the new threshold value.
- Defined public function `transfer-ownership` to transfer contract ownership: - Checks if the caller is the contract owner. - Sets the `contract-owner` variable to the new owner.
- Added `use-trait ft-trait` for SIP-010 trait compliance. - Updated error codes to include only relevant ones. - Refactored `validate-fee-rate` to use `if` statement. - Adjusted `calculate-priority` to use `cond` for clarity. - Added validation checks in `track-transaction` and `update-transaction-status`. - Included `validate-user` and `validate-height` functions for user and height validation. - Added `validate-new-owner` function for ownership transfer validation. - Ensured all public functions have appropriate validation and authorization checks.
…mpool-tracker into add-smart-contract
- Added detailed overview of the smart contract features. - Included sections for transaction tracking, user watchlists, fee statistics, and mempool metrics. - Provided technical specifications including constants and data structures. - Listed public functions for transaction management, watchlist management, statistics, and metrics. - Documented administrative functions for setting fee thresholds and transferring ownership. - Added error codes and their descriptions. - Highlighted security features and considerations. - Provided installation and usage instructions.
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 a comprehensive smart contract for real-time mempool monitoring and transaction management on the Stacks blockchain. The contract provides robust functionality for tracking transactions, managing fee statistics, and monitoring mempool metrics.
Key Features
Technical Implementation
Changes Include
Data Structures
tracked-transactionsmap for transaction detailsuser-watchlistsmap for user-specific watchlistsfee-statsmap for block height-based fee statisticsmempool-metricsmap for real-time mempool monitoringCore Functionality
Administrative Features
Error Handling
Testing
Security Considerations
Documentation
Deployment Steps
Checklist