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
Rust JSON
Copy #[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 ,
}
Copy {
"owner" : "terra1..." ,
"mirror_token" : "terra1..." ,
"mint_contract" : "terra1..." ,
"oracle_contract" : "terra1..." ,
"terraswap_factory" : "terra1..." ,
"base_denom" : "uusd" ,
"premium_min_update_interval" : 8
}
Key Type Description Owner address of Staking contract
Contract address of the Mirror Token (MIR)
Contract address of Mirror Mint
Contract address of Mirror Oracle
Contract address of Terraswap Factory
Native token denom for Terraswap pairs (TerraUSD)
premium_min_update_interval
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.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum HandleMsg {
Receive {
amount : Uint128 ,
sender : HumanAddr ,
msg : Option < Binary >,
}
}
Copy {
"receive" : {
"amount" : "10000000" ,
"sender" : "terra1..." ,
"msg" : "eyAiZXhlY3V0ZV9tc2ciOiAiYmxhaCBibGFoIiB9"
}
}
Key Type Description Sender of token transaction
* = optional
UpdateConfig
Updates the Staking contract's configuration. Can only be issued by the staking contract's owner.
Rust JSON
Copy #[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 >,
}
Copy {
"update_config" : {
"owner" : "terra1..." ,
"premium_min_update_interval" : 8
}
}
Name Type Description Owner address of Staking contract
premium_min_update_interval
*
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.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum HandleMsg {
RegisterAsset {
asset_token : HumanAddr ,
staking_token : HumanAddr ,
}
}
Copy {
"register_asset" : {
"asset_token" : "terra1..." ,
"staking_token" : "terra1..."
}
}
Key Type Description Contract address of mAsset/MIR token (staking pool identifier)
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
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum HandleMsg {
Unbond {
amount : Uint128 ,
asset_token : HumanAddr ,
}
}
Copy {
"unbond" : {
"amount" : "10000000" ,
"asset_token" : "terra1..."
}
}
Key Type Description Amount of LP tokens to unbond
Contract address of mAsset/MIR token (staking pool identifier)
Withdraw
Withdraws a user's rewards for a specific staking position.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum HandleMsg {
Withdraw {
asset_token : Option < HumanAddr >,
}
}
Copy {
"withdraw" : {
"asset_token" : "terra1..."
}
}
Key Type Description 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
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum HandleMsg {
AutoStake {
assets : [ Asset ; 2 ],
slippage_tolerance : Option < Decimal >,
}
}
Copy {
"auto_stake" : {
"assets" : [
"info" : {
"native_token" : {
"denom" : "uusd" ,
}
} ,
"amount" : "1000000" ,
"info" : {
"token" : {
"contract_address" : "terra1..."
}
} ,
"amount" : "1000000" ,
] ,
"slippage_tolerance" : "1.234567"
}
}
Key Type Description Information of assets that are provided into liquidity pool
Maximum price slippage allowed to execute this transaction
*= optional
AutoStakeHook
[INTERNAL]
Hook to stake the minted LP tokens from providing liquidity.
Rust JSON
Copy #[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 ,
}
}
Copy {
"auto_stake_hook" : {
"asset_token" : "terra1..." ,
"staking_token" : "terra1..." ,
"staker_addr" : "terra1..." ,
"prev_staking_token_amount: " 1000000 "
},
}
Key Type Description Contract address of the asset token
Contract address of the LP token to be staked
prev_staking_token_amount
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
.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum HandleMsg {
AdjustPremium {
asset_tokens : Vec < HumanAddr >,
}
Copy {
"adjust_premium" : {
"asset_tokens" : [
"terra1..." , "terra1..."
]
}
}
Key Type Description 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.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum HandleMsg {
IncreaseShortToken {
asset_token : HumanAddr ,
staker_addr : HumanAddr ,
amount : Uint128 ,
}
}
Copy {
"increase_short_token" : {
"asset_token" : "terra1..." ,
"staker_addr" : "terra1..." ,
"amount" : "1000000"
}
}
Key Type Description Token contract address of sLP
Address of the sLP
staker
Amount of sLP
supply to be increased
DecreaseShortToken
[Mint contract operations]
Decreases the total staked supply of sLP
tokens for a specific staker.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum HandleMsg {
DecreaseShortToken {
asset_token : HumanAddr ,
staker_addr : HumanAddr ,
amount : Uint128 ,
}
Copy {
"decrease_short_token" : {
"asset_token" : "terra1..." ,
"staker_addr" : "terra1..." ,
"amount" : "1000000"
}
}
Key Type Description Token contract address of sLP
Address of the sLP
staker
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.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum Cw20HookMsg {
Bond {
asset_token : HumanAddr ,
}
}
Copy {
"bond" : {
"asset_token" : "terra1..."
}
}
Key Type Description 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
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum Cw20HookMsg {
DepositReward {
asset_token : HumanAddr ,
}
}
Copy {
"deposit_reward" : {
"asset_token" : "terra1..."
}
}
Key Type Description Contract address of asset token (staking pool identifier)
QueryMsg
Config
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum QueryMsg {
Config {}
}
Response
Copy #[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 ,
}
Key Type Description Owner address of Staking contract
Contract address of the Mirror Token (MIR)
Contract address of Mirror Mint
Contract address of Mirror Oracle
Contract address of Terraswap Factory
Native token denom for Terraswap pairs (TerraUSD)
premium_min_update_interval
Interval of time denominated in number of blocks which the collateral premium information is updated
Response
Copy {
"config_response" : {
"owner" : "terra1..." ,
"mirror_token" : "terra1..." ,
"mint_contract" : "terra1..." ,
"oracle_contract" : "terra1..." ,
"terraswap_factory" : "terra1..." ,
"base_denom" : "uusd" ,
"premium_min_update_interval" : 8
}
}
Name Type Description Owner address of Staking contract
Contract address of the Mirror Token (MIR)
Contract address of Mirror Mint
Contract address of Mirror Oracle
Contract address of Terraswap Factory
Native token denom for Terraswap pairs (TerraUSD)
premium_min_update_interval
Interval of time denominated in number of blocks which the collateral premium information is updated
PoolInfo
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum QueryMsg {
PoolInfo {
asset_token : HumanAddr ,
}
}
Key Type Description Asset token to query (staking pool identifier)
Response
Copy #[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 ,
}
Key Type Description Contract address of mAsset token
Contract address of LP
or sLP
token
Amount of total LP staked
Amount of total sLP staked
Amount of reward distributed per 1 LP token
Amount of reward distributed per 1 sLP token
Amount of unclaimed rewards by LP stakers
Amount of unclaimed rewards by sLP stakers
Current price premium of the asset pool
Current reward weight for sLP staking
Block height which the price premium data for this asset is most recently updated
Copy {
"pool_info" : {
"asset_token" : "terra1..."
Key
Type Description Asset token to query (staking pool identifier)
Response
Copy {
"pool_info_response" : {
"asset_token" : "terra1..." ,
"staking_token" : "terra1..." ,
"total_bond_amount" : "1000000" ,
"total_short_amount" : "1000000" ,
"reward_index" : "123.456789" ,
"short_reward_index" : "123.456789" ,
"pending_reward" : "123.456789" ,
"short_pending_reward" : "123.456789" ,
"premium_rate" : "0.4" ,
"short_reward_weight" : "0.4" ,
"premium_updated_time" : 8
}
}
Key Type Description Contract address of mAsset token
Contract address of LP
or sLP
token
Amount of total LP staked
Amount of total sLP staked
Amount of reward distributed per 1 LP token
Amount of reward distributed per 1 sLP token
Amount of unclaimed rewards by LP stakers
Amount of unclaimed rewards by sLP stakers
Current price premium of the asset pool
Current reward weight for sLP staking
Block height which the price premium data for this asset is most recently updated
RewardInfo
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum QueryMsg {
RewardInfo {
asset_token : Option < HumanAddr >,
staker : HumanAddr ,
}
}
Key Type Description Asset token to query. If empty, returns info for all staking pools.
Address of staker to query
*= optional
Response
Copy #[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 ,
}
Key Type Description Asset token being queried
Amount of LP or sLP tokens staked
Amount of reward that are not claimed
Identifies of the pool os LP or sLP pool
Copy {
"reward_info" : {
"asset_token" : "terra1..." ,
"staker" : "terra1..."
}
}
Key Type Description Asset token to query. If empty, returns info for all staking pools.
Address of staker to query
*= optional
Response
Copy {
"reward_info_response_item" : {
"asset_token" : "terra1..." ,
"bond_amount" : "1000000" ,
"pending_reward" : "1000000" ,
"is_short" : true
}
}
Key Type Description Asset token being queried
Amount of LP or sLP tokens staked
Amount of reward that are not claimed
Identifies of the pool os LP or sLP pool