Skip to content

Fix Claims handling in cw20-staking #110

@ethanfrey

Description

@ethanfrey

Part of #59 - pulled out for needed UI

Note: should be done on the v0.2.x branch and released as v0.2.3, before merging into master.

We currently just store how many tokens the person has unbonded and allow anyone with claims to grab the money. This is unfair as if I start unbonding 3 weeks ago and forget to check right at time, you may have unbonded yesterday and snap up the claims as soon as my unbonding made it to the contract account, making me wait 3 more weeks for your period.

The solution here is to store information on the native staking unbonding period inside the contract as a Duration - this contact value should equal the actual unbonding period of the chain for best effect.

Further Claims are no longer Uint128, but rather Vec<Claim>

pub struct Claim {
  pub mature Expiration,
  pub amount Uint128
}

These should be stored as one Vec per client. And sorted from first expiration to last expiration. This info must be displayed on a query.

On a handling a claim msg, we remove all mature claims from the list, and take the sum of their totals, releasing these native tokens to the claimee.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions