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.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InstantiateMsg {
pub token: String,
pub pair: String,
pub lp_token: String,
}
Key | Type | Description |
token | String | Contract address of the Valkyrie Token (VKR) |
pair | String | Terraswap pairs (TerraUSD) |
lp_token | String | Contract address of the LP token to be staked |
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
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
Receive {
amount: Uint128,
sender: Addr,
msg: Option<Binary>,
}
}
{
"receive": {
"amount": "10000000",
"sender": "terra1...",
"msg": "eyAiZXhlY3V0ZV9tc2ciOiAiYmxhaCBibGFoIiB9"
}
}
Key | Type | Description |
amount | Uint128 | Token amount received |
sender | Addr | Sender of token transaction |
msg * | Binary | Base64-encoded JSON of Receive Hook message |
* = optional
Users can issue the unbond message at any time to remove their staked LP tokens from a staking position.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
Unbond {
amount: Uint128,
}
}
{
"unbond": {
"amount": "10000000",
}
}
Key | Type | Description |
amount | Uint128 | Amount of LP tokens to unbond |
Withdraws a user's rewards for a specific staking position.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
Withdraw {}
}
{
"withdraw": { }
}
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
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
AutoStake {
token_amount: Uint128,
slippage_tolerance: Option<Decimal>,
}
}
{
"AutoStake": {
"token_amount": 10000,
"slippage_tolerance": 100,
}
}
Key | Type | Description |
token_amount | Uint128 | Amount of VKR token that are provided into liquidity pool |
slippage_tolerance* | Decimal | Maximum price slippage allowed to execute this transaction |
* = optional
[INTERNAL]
Hook to stake the minted LP tokens from providing liquidity.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
AutoStakeHook {
staker_addr: String,
prev_staking_token_amount: Uint128,
}
}
{
"auto_stake_hook": {
"staker_addr": "terra1...",
"already_staked_amount": 10000,
}
}
Key | Type | Description |
staker_addr | String | Address of the staker |
prev_staking_token_amount | Uint128 | LP staking balance of the staker before this transaction |
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
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20HookMsg {
Bond {}
}
{
"bond": {
}
}
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20HookMsg {
DepositReward {}
}
{
"deposit_reward": {
}
}
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
Config {}
}
{
"config": {}
}
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
State {}
}
{
"state": {}
}
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
StakerInfo {
staker_addr: String
}
}
{
"staker_info": {
"staker_addr" : "terra1..."
}
}
Key | Type | Description |
staker_addr | String | Wallet address of Lp staker |
Rust
JSON
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
pub struct StakerInfoResponse {
pub staker: String,
pub bond_amount: Uint128,
pub pending_reward: Uint128,
}
{
"staker_info_response": {
"staker":"terra1...",
"bond_amount": 1000,
"pending_reward": 1000
}
}
Key | Type | Description |
staker | String | Address of the staker |
bond_amount | Uint128 | Amount of LP or sLP tokens staked |
pending_reward | Uint128 | Amount of reward that are not claimed |
Last modified 1yr ago