Validator 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 Validator Staking ADO in your Andromeda Applications to achieve very usefull and cool use cases.

Ado-type: validator-staking

Version: 1.0.0

InstantiateMsg

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

default_validator

Addr

The address of the validator to delegate the tokens to by default. This means when you call a Stake message without specifying the validator field, then the tokens will be staked with the default validator.

kernel_address

String

Contract address of the kernel contract to be used for AMP messaging. Kernel contract address can be found in our deployed contracts.

owner

Option<String>

Optional address to specify as the owner of the ADO being created. Defaults to the sender if not specified.

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>,
    },
}
NameTypeDescription

validator

Option<Addr>

The address of the validator to delegate the tokens to.

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>,
    }
}
NameTypeDescription

validator

Option<Addr>

The address of the validator to undelegate the tokens from.

amount

Option<Uint128>

The amount of tokens to unstake. Defaults to the maximum amount if not specified.

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>,
    },
  }
NameTypeDescription

validator

Option<Addr>

The address of the validator to claim the rewards for.

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 {
        denom: Option<String>,
        recipient: Option<AndrAddr>,
    },
 }
NameTypeDescription

denom

Option<String>

The denom of the previously staked funds to withdraw. If not specified, all available funds are withdrawn

recipient

Option<AndrAddr>

An optional address to receive the withdrawn funds. Will default to the sender if not specified.

UpdateDefaultValidator

Update the set default validator.

Only available to the contract owner.

pub enum ExecuteMsg {
  UpdateDefaultValidator {
        validator: Addr,
    },
}
NameTypeDescription

validator

Addr

The new validator address to be used by default.

Redelegate

Moves the specified amount of staked tokens from one validator to another.

Only available to the contract owner.

 pub enum ExecuteMsg {
   Redelegate {
        src_validator: Option<Addr>,
        dst_validator: Addr,
        amount: Option<Uint128>,
    },
  }
NameTypeDescription

src_validator

Option<Addr>

The address of the validator to move tokens from.

dst_validator

Addr

The address of the validator to move tokens to.

amount

Option<Uint128>

The amount of tokens to redelegate. Takes the maximum amount if not specified.

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> },
    }
NameTypeDescription

validator

Option<Addr>

The validator to check the staked tokens for.

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>,
}
NameTypeDescription

delegator

Addr

The address of the delegator. Will be the address of the staking ADO in our case.

validator

String

The validator that the tokens are delegated to.

amount

The amount of funds locked in the delegation.

can_redelegate

can_redelegate captures how much can be immediately redelegated. 0 is no redelegation and can_redelegate == amount is redelegate all.

accumulated_rewards

Vec<Coin>

The amount of rewards accruied from the staking that can be currently withdrawn.

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,
}
NameTypeDescription

fund

The denom and amount of the token being unstaked.

payout_at

The time these tokens can be claimed which is the time the unbonding period is over.

DefaultValidator

Queries the default validator address set at instantiation.

pub enum QueryMsg {
   #[returns(GetDefaultValidatorResponse)]
    DefaultValidator {},
  }

Returns the address as a string.

Base Queries

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

Last updated

Additional Resources

GithubWebsite