andromedaprotocol/andromeda-core

[Staking ADO] Allow user to unstake tokens with a given validator

Closed this issue · 3 comments

Description

Along with allowing a user to stake tokens they should also be allowed to un-stake tokens. This is essentially a reversal of the Stake method.

Implementation

Similar to the Stake method we should provide an execute message with an optional validator field:

pub enum ExecuteMsg {
  Unstake {
    pub validator: Option<Addr>,
  }
}

The handler for this message should first check that the provided address is a validator and that the user has tokens delegated with them before sending an Undelegate message.

Acceptance Criteria

  • An Unstake message to undelegate tokens from a validator
  • Unit testing

@cowboy0015

We could possibly use this message in order to set the owner as the withdraw address?

We would need to consider what happens when ownership is transferred.

Claiming rewards can happen before unstaking process. Undelegate makes the fund inaccessible for unbounding period. Determining withdraw address should be done in the reward claim and withdraw process.

Created issue #305 for withdrawing unstaked tokens