Staking

The Staking Contract contains the logic for LP Token staking and reward distribution. Staking rewards for LP stakers come from the new MIR tokens generated at each block by the Factory Contract and are split between all combined staking pools. The new MIR tokens are distributed in proportion to size of staked LP tokens multiplied by the weight of that asset's staking pool.

Config

Name

Type

Description

owner

HumanAddr

Address of owner of staking contract

mirror_token

HumanAddr

Contract address of the Mirror Token (MIR)

InitMsg

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InitMsg {
pub owner: HumanAddr,
pub mirror_token: HumanAddr,
}

Key

Type

Description

owner

HumanAddr

Address of staking contract owner

mirror_token

HumanAddr

Contract address of the Mirror Token (MIR)

HandleMsg

Receive

Can be called during a CW20 token transfer when the Mint contract is the recipient. Allows the token transfer to execute a Receive Hook as a subsequent action within the same transaction.

Rust
JSON
Rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
Receive {
amount: Uint128,
sender: HumanAddr,
msg: Option<Binary>,
}
}
JSON
{
"receive": {
"amount": "10000000",
"sender": "terra1...",
"msg": "eyAiZXhlY3V0ZV9tc2ciOiAiYmxhaCBibGFoIiB9"
}
}

Key

Type

Description

amount

Uint128

Token amount received

sender

HumanAddr

Sender of token transaction

msg*

Binary

Base64-encoded JSON of Receive Hook message

* = optional

UpdateConfig

Updates the Staking contract's configuration. Can only be issued by the staking contract's owner.

Rust
JSON
Rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct enum HandleMsg {
UpdateConfig {
owner: Option<HumanAddr>,
}
}
JSON
{
"update_config": {
"owner": "terra1..."
}
}

Key

Type

Description

owner*

HumanAddr

Address of new owner of staking contract

* = optional

RegisterAsset

Registers a new staking pool for an asset token and associates the LP token with the staking pool.

Rust
JSON
Rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
RegisterAsset {
asset_token: HumanAddr,
staking_token: HumanAddr,
}
}
JSON
{
"register_asset": {
"asset_token": "terra1...",
"staking_token": "terra1..."
}
}

Key

Type

Description

asset_token

HumanAddr

Contract address of mAsset/MIR token (staking pool identifier)

staking_token

HumanAddr

Contract address of asset's corresponding LP Token

Unbond

Users can issue the unbond message at any time to remove their staked LP tokens from a staking position.

Rust
JSON
Rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
Unbond {
amount: Uint128,
asset_token: HumanAddr,
}
}
JSON
{
"unbond": {
"amount": "10000000",
"asset_token": "terra1..."
}
}

Key

Type

Description

amount

Uint128

Amount of LP tokens to unbond

asset_token

HumanAddr

Contract address of mAsset/MIR token (staking pool identifier)

Withdraw

Withdraws a user's rewards for a specific staking position.

Rust
JSON
Rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
Withdraw {
asset_token: Option<HumanAddr>,
}
}
JSON
{
"withdraw": {
"asset_token": "terra1..."
}
}

Key

Type

Description

asset_token*

HumanAddr

Contract address of asset token (staking pool identifier). If empty, withdraws all rewards from all staking pools involved.

* = optional

Receive Hooks

Bond

WARNING

If you send LP Tokens to the Staking contract without issuing this hook, they will not be staked and will BE LOST FOREVER.

Can be issued when the user sends LP Tokens to the Staking contract. The LP token must be recognized by the staking pool of the specified asset token.

Rust
JSON
Rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20HookMsg {
Bond {
asset_token: HumanAddr,
}
}
JSON
{
"bond": {
"asset_token": "terra1..."
}
}

Key

Type

Description

asset_token

HumanAddr

Contract address of asset token (staking pool identifier).

DepositReward

[INTERNAL]

Can be issued when the user sends MIR tokens to the Staking contract, which will be used as rewards for the specified asset's staking pool. Used by Factory Contract to deposit newly minted MIR tokens.

Rust
JSON
Rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20HookMsg {
DepositReward {
asset_token: HumanAddr,
}
}
JSON
{
"deposit_reward": {
"asset_token": "terra1..."
}
}

Key

Type

Description

asset_token

HumanAddr

Contract address of asset token (staking pool identifier)

QueryMsg

Config

Rust
JSON
Rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
Config {}
}
JSON
{
"config": {}
}

Key

Type

Description

PoolInfo

Rust
JSON
Rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
PoolInfo {
asset_token: HumanAddr,
}
}
JSON
{
"pool_info": {
"asset_token": "terra1..."
}
}

Key

Type

Description

asset_token

HumanAddr

Asset token to query (staking pool identifier)

RewardInfo

Rust
JSON
Rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
RewardInfo {
asset_token: Option<HumanAddr>,
staker: HumanAddr,
}
}
JSON
{
"reward_info": {
"asset_token": "terra1...",
"staker": "terra1..."
}
}

Key

Type

Description

asset_token*

HumanAddr

Asset token to query. If empty, returns info for all staking pools.

staker

HumanAddr

Address of staker to query

* = optional