Skip to content

Report keys staked via stake_keys in get_total_staked - #1026

Merged
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
shinorh247:fix/get-total-staked-includes-simple-flow-stakes
Oct 2, 2026
Merged

Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
shinorh247:fix/get-total-staked-includes-simple-flow-stakes

Conversation

@shinorh247

Copy link
Copy Markdown
Contributor

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

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>
@Chucks1093
Chucks1093 merged commit 88a953b into accesslayerorg:main Oct 2, 2026
1 check passed
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.

Add a protocol revenue split function distributing accumulated treasury fees to stakers across all keys

2 participants