Skip to content

Add key staking so holders can lock keys to signal commitment and earn a loyalty tier #519

Description

@Chucks1093

Summary

Holding keys and staking keys are different levels of commitment. A holder who locks their keys for a period signals they are not selling — which is valuable information for creators and other buyers. The contract should track staked vs liquid balances per holder and expose the staking status so the client can display loyalty tiers based on how long and how many keys a wallet has staked.

Scope

  • Add stake_keys(creator_id, amount: u32, lock_ledgers: u32) function
    • Moves amount from the holder's liquid balance to their staked balance
    • Records unlock_ledger = current_ledger + lock_ledgers
    • lock_ledgers must be at least a configurable minimum (e.g. 1000 ledgers ≈ 83 minutes)
    • A holder can have multiple stake positions for the same creator
  • Add unstake_keys(creator_id, stake_id) function
    • Reverts with StillLocked if current ledger is before unlock_ledger
    • Returns keys to liquid balance on success
  • Staked keys cannot be transferred or sold — attempts revert with KeysStaked
  • Add get_stake_positions(creator_id, wallet) -> Vec<StakePosition> view returning each position: { stake_id, amount, unlock_ledger }
  • Add get_liquid_balance(creator_id, wallet) -> u32 view returning only the unstaked balance

Acceptance Criteria

  • Staked keys deducted from liquid balance immediately
  • Unstake before unlock_ledger reverts with StillLocked
  • Unstake after unlock_ledger returns keys to liquid balance
  • Sell of staked keys reverts with KeysStaked
  • Transfer of staked keys reverts with KeysStaked
  • get_stake_positions returns all active positions for a wallet
  • get_liquid_balance returns only unstaked keys

ETA: 24 hours


Coordinate on Telegram

Metadata

Metadata

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions