Repository navigation
Report keys staked via stake_keys in get_total_staked - #1026
Merged
Chucks1093 merged 1 commit intoOct 2, 2026
Merged
Chucks1093 merged 1 commit into
Chucks1093 merged 1 commit into
Conversation
The two staking flows maintain separate aggregates: stake_keys_locked and friends maintain StakingRewardsState::total_staked next to the rewards pool, while stake_keys/unstake_keys maintain DataKey::TotalStaked. The view read only the former, so a creator whose keys were staked through the simple flow reported a total of 0. Sum both aggregates so the view matches what the contract actually tracks. Neither writer changes, so the locked flow and the rewards math that shares StakingRewardsState are unaffected. Co-Authored-By: Codebuff <noreply@codebuff.com>
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.
Description
This PR adds on-chain protocol revenue distribution, allowing accumulated treasury fees to be distributed pro-rata among stakers based on their staked key value.
Changes
• Added distribute_protocol_revenue(snapshot_id: u32).
• Restricted revenue distribution to the protocol admin.
• Added validation for the supplied holder snapshot.
• Calculates each staker’s share based on:
staked_quantity × current_price / total_staked_value.
• Transfers each staker’s share from the treasury to their wallet.
• Retains any division dust in the treasury.
• Emits a protocol_revenue_distributed event containing:
• total_distributed
• staker_count
• snapshot_id
• Handles SnapshotNotFound for unknown snapshots.
• Handles Unauthorized for non-admin callers.
Issue
Closes #832