Skip to content

Add partial_position_freeze() locking only a portion of a staking position #337

Description

@Rickyy1017

Summary

Currently freeze (Issue #71) applies to an entire position. Add a partial freeze mechanism where the admin can freeze a specific token amount within a position — the frozen portion cannot be unstaked while the unfrozen portion remains freely accessible.

Acceptance Criteria

  • FrozenAmount(Address) persistent storage: i128 amount frozen within user's position
  • partial_freeze(admin, user: Address, amount: i128) — freezes amount of user's position
  • partial_unfreeze(admin, user: Address, amount: i128) — releases frozen amount
  • get_frozen_amount(user: Address) -> i128 read-only query
  • get_available_amount(user: Address) -> i128 = position.amount - frozen_amount
  • unstake only allows withdrawal up to available_amount — revert with AmountFrozen if exceeding available
  • partial_frozen event: (user, frozen_amount, total_position, ledger)
  • Cannot freeze more than current position.amount — revert with FreezeExceedsPosition
  • Tests: partial freeze limits unstake, unfreeze restores access, freeze more than position rejected, rewards still accrue on frozen amount

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions