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.

InitMsg

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InitMsg {
    pub owner: HumanAddr,
    pub mirror_token: HumanAddr,
    pub mint_contract: HumanAddr,
    pub oracle_contract: HumanAddr,
    pub terraswap_factory: HumanAddr,
    pub base_denom: String,
    pub premium_min_update_interval: u64,
}
KeyTypeDescription

owner

HumanAddr

Owner address of Staking contract

mirror_token

HumanAddr

Contract address of the Mirror Token (MIR)

mint_contract

HumanAddr

Contract address of Mirror Mint

oracle_contract

HumanAddr

Contract address of Mirror Oracle

terraswap_factory

HumanAddr

Contract address of Terraswap Factory

base_denom

String

Native token denom for Terraswap pairs (TerraUSD)

premium_min_update_interval

u64

Interval of time denominated in number of blocks which the collateral premium information is updated

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.

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

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.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
    UpdateConfig {
        owner: Option<HumanAddr>,
        premium_min_update_interval: Option<u64>,
    }
NameTypeDescription

owner*

HumanAddr

Owner address of Staking contract

premium_min_update_interval*

u64

Interval of time denominated in number of blocks which the collateral premium information is updated

* = optional

RegisterAsset

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

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

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.

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

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.

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

asset_token*

HumanAddr

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

* = optional

AutoStake

When providing liquidity in Mirror Protocol, asset pair is first sent to Staking contract, and it acts as a relay. When defined assets are sent to the contract, the contract provides liquidity to receive LP tokens and starts AutoStakeHook.

Note: Executor of the transaction should first increase allowance to spend CW20 tokens

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
    AutoStake {
        assets: [Asset; 2],
        slippage_tolerance: Option<Decimal>,
    }    
}
KeyTypeDescription

assets*

Array[Assets]

Information of assets that are provided into liquidity pool

slippage_tolerance*

Decimal

Maximum price slippage allowed to execute this transaction

*= optional

AutoStakeHook

[INTERNAL]

Hook to stake the minted LP tokens from providing liquidity.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
    AutoStakeHook {
        asset_token: HumanAddr,
        staking_token: HumanAddr,
        staker_addr: HumanAddr,
        prev_staking_token_amount: Uint128,
    }    
}
KeyTypeDescription

assets_token

HumanAddr

Contract address of the asset token

staking_token

HumanAddr

Contract address of the LP token to be staked

staker_addr

HumanAddr

Address of the staker

prev_staking_token_amount

Uint128

LP staking balance of the staker before this transaction

AdjustPremium

[Permission-less operation] Changes the price premium rate for a specified mAsset, can be done by anyone. Message can be sent again after a defined premium_min_update_interval.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
    AdjustPremium {
        asset_tokens: Vec<HumanAddr>,
    }
KeyTypeDescription

asset_tokens

Vec<HumanAddr>

Array of token contract addresses to update new price premium rate

IncreaseShortToken

[Mint contract operation] Increases the total staked supply of sLP tokens for a specific staker.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
    IncreaseShortToken {
        asset_token: HumanAddr,
        staker_addr: HumanAddr,
        amount: Uint128,
    }
}
KeyTypeDescription

asset_token

HumanAddr

Token contract address of sLP

staker_addr

HumanAddr

Address of the sLP staker

amount

Uint128

Amount of sLP supply to be increased

DecreaseShortToken

[Mint contract operations] Decreases the total staked supply of sLP tokens for a specific staker.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
    DecreaseShortToken {
        asset_token: HumanAddr,
        staker_addr: HumanAddr,
        amount: Uint128,
    }
KeyTypeDescription

asset_token

HumanAddr

Token contract address of sLP

staker_addr

HumanAddr

Address of the sLP staker

amount

Uint128

Amount of sLP supply to be decreased

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.

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

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.

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

asset_token

HumanAddr

Contract address of asset token (staking pool identifier)

QueryMsg

Config

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

Response

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct ConfigResponse {
    pub owner: HumanAddr,
    pub mirror_token: HumanAddr,
    pub mint_contract: HumanAddr,
    pub oracle_contract: HumanAddr,
    pub terraswap_factory: HumanAddr,
    pub base_denom: String,
    pub premium_min_update_interval: u64,
}
KeyTypeDescription

owner

HumanAddr

Owner address of Staking contract

mirror_token

HumanAddr

Contract address of the Mirror Token (MIR)

mint_contract

HumanAddr

Contract address of Mirror Mint

oracle_contract

HumanAddr

Contract address of Mirror Oracle

terraswap_factory

HumanAddr

Contract address of Terraswap Factory

base_denom

String

Native token denom for Terraswap pairs (TerraUSD)

premium_min_update_interval

u64

Interval of time denominated in number of blocks which the collateral premium information is updated

PoolInfo

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

asset_token

HumanAddr

Asset token to query (staking pool identifier)

Response

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct PoolInfoResponse {
    pub asset_token: HumanAddr,
    pub staking_token: HumanAddr,
    pub total_bond_amount: Uint128,
    pub total_short_amount: Uint128,
    pub reward_index: Decimal,
    pub short_reward_index: Decimal,
    pub pending_reward: Uint128,
    pub short_pending_reward: Uint128,
    pub premium_rate: Decimal,
    pub short_reward_weight: Decimal,
    pub premium_updated_time: u64,
}
KeyTypeDescription

asset_token

HumanAddr

Contract address of mAsset token

staking_token

HumanAddr

Contract address of LP or sLP token

total_bond_amount

Uint128

Amount of total LP staked

total_short_amount

Uint128

Amount of total sLP staked

reward_index

Decimal

Amount of reward distributed per 1 LP token

short_reward_index

Decimal

Amount of reward distributed per 1 sLP token

pending_reward

Uint128

Amount of unclaimed rewards by LP stakers

short_pending_reward

Uint128

Amount of unclaimed rewards by sLP stakers

premium_rate

Decimal

Current price premium of the asset pool

short_reward_weight

Decimal

Current reward weight for sLP staking

premium_updated_time

u64

Block height which the price premium data for this asset is most recently updated

RewardInfo

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

asset_token*

HumanAddr

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

staker

HumanAddr

Address of staker to query

*= optional

Response

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct RewardInfoResponseItem {
    pub asset_token: HumanAddr,
    pub bond_amount: Uint128,
    pub pending_reward: Uint128,
    pub is_short: bool,
}
KeyTypeDescription

asset_token

HumanAddr

Asset token being queried

bond_amount

Uint128

Amount of LP or sLP tokens staked

pending_reward

Uint128

Amount of reward that are not claimed

is_short

bool

Identifies of the pool os LP or sLP pool

Last updated