Staking

The Staking Contract contains the logic for LP Token staking and reward distribution. Staking rewards for LP stakers come from the new VKR tokens generated at each block by the Factory Contract and are split between all combined staking pools.

InstantiateMsg

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InstantiateMsg {
    pub token: String,
    pub pair: String,
    pub lp_token: String,
}

ExecuteMsg

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 ExecuteMsg {
    Receive {
        amount: Uint128,
        sender: Addr,
        msg: Option<Binary>,
    }
}

* = optional

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 ExecuteMsg {
    Unbond {
        amount: Uint128,
    }
}

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 ExecuteMsg {
    Withdraw {}
}

AutoStake

When providing liquidity in Valkyrie 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 ExecuteMsg {
    AutoStake {
        token_amount: Uint128,
        slippage_tolerance: Option<Decimal>,
    }
}

* = 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 ExecuteMsg {
    AutoStakeHook {
        staker_addr: String,
        prev_staking_token_amount: Uint128,
    }
}

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 {}
}

DepositReward

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

QueryMsg

Config

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

State

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

StakerInfo

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

Response

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
pub struct StakerInfoResponse {
    pub staker: String,
    pub bond_amount: Uint128,
    pub pending_reward: Uint128,
}

Last updated