Staking

Introduction

The Staking ADO is smart contract that allows users to stake native tokens with the validator of their choice.

This ADO is not meant for general use meaning that it should not be open for the public (Have people other than the owner use it for staking). It is designed so the owner of the ADO has full control over the staking which is why most messages are restricted to the owner.

The staking message can still be called by any address. This is to allow the ADO owner to integrate this ADO with Andromeda Apps allowing the allocation of funds gained by the App to be routed to this ADO and staked.

Example

Let us assume a project is looking to start an NFT project having part of the project be that the users will get some funds over time:

This would be just one part of the benefits of buying the project's NFT.

  • Project is looking to launch an NFT collection.

  • The collection will be sold using one of the ADOs like our Marketplace ADO.

  • Using a splitter connection, the funds from the sale are distributed having part of the funds go to the Staking ADO and start staking automatically.

  • The rewards accrued from staking are then sent to another splitter that distributes the rewards back to the NFT buyers.

This gives a small idea of how you can use the Staking ADO in your Andromeda Applications to achieve very usefull and cool use cases.

Ado-type: validator-staking

Version: 0.2.1-beta.1

InstantiateMsg

pub struct InstantiateMsg {
    pub default_validator: Addr,
    pub kernel_address:String,
    pub owner: Option<String>,
}

ExecuteMsg

Stake

Stakes the attached funds with the specified validator.

  • If the validator is not specified, then the default_validator specified at instantiation will be used.

  • Make sure to attach one type of funds only.

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

Unstake

Unstakes the delegated tokens from the specified validator.

  • Only available to the contract owner.

  • If the validator is not specified, then the default_validator specified at instantiation will be used.

  • The tokens will be released back to the ADO after the unbonding period has passed. You will need to call the WithdrawFunds message after that to get the tokens back into your wallet.

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

Claim

Claim the rewards accrued from staking for a specific validator.

  • Only available to the contract owner.

  • If the validator is not specified, then the default_validator specified at instantiation will be used.

pub enum ExecuteMsg {
   Claim {
        validator: Option<Addr>,
        recipient: Option<AndrAddr>,
    },
  }

WithdrawFunds

Withdraw unstaked tokens from the ADO.

  • Only available to the contract owner.

  • Make sure the unbonding period has passed before trying to withdraw funds.

pub enum ExecuteMsg {
    WithdrawFunds {},
    }

Base Executes

The rest of the execute messages can be found in the ADO Base section.

QueryMsg

StakedTokens

Queries the staked tokens with the specified validator.

If the validator is not specified, then the default_validator specified at instantiation will be used.

pub enum QueryMsg {
    #[returns(Option<::cosmwasm_std::FullDelegation>)]
    StakedTokens { validator: Option<Addr> },
    }

FullDelegation

Returns the information of the staked tokens.

pub struct FullDelegation {
    pub delegator: Addr,
    pub validator: String,
    pub amount: Coin,
    pub can_redelegate: Coin,
    pub accumulated_rewards: Vec<Coin>,
}

UnstakedTokens

Queries the tokens that are unstaked and provides the time they can be claimed (Unbonding period is over).

 pub enum QueryMsg {
 #[returns(Option<Vec<UnstakingTokens>>)]
    UnstakedTokens {},
    }

UnstakingTokens

Struct containing information of the unstaked tokens.

pub struct UnstakingTokens {
    pub fund: Coin,
    pub payout_at: Timestamp,
}

Base Queries

The rest of the query messages can be found in the ADO Base section.

Last updated

Additional Resources

GithubWebsite