# Staking

Lock LP tokens to obtain veSEILOR tokens. The total amount of rewards is determined based on the configuration of this contract and the boost locking time. LP tokens can be withdrawn in advance, but the rewards cannot be withdrawn until they expire according to the lock.

## Config

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct StakingConfig {
    pub gov: Addr,
    // Immutable variables for staking and rewards tokens
    pub staking_token: Addr,
    pub rewards_token: Addr,
    pub boost: Addr,
    pub fund: Addr,
    pub reward_controller_addr: Addr,
    pub new_gov: Option<Addr>,
}

```

<table><thead><tr><th width="237">Key</th><th width="89">Type</th><th>Description</th></tr></thead><tbody><tr><td>gov</td><td>Addr</td><td>The address of the governance contract</td></tr><tr><td>staking_token</td><td>Addr</td><td>The address of the token contract to be staked</td></tr><tr><td>rewards_token</td><td>Addr</td><td>The address of the token contract to be rewarded</td></tr><tr><td>boost</td><td>Addr</td><td>The address of contract <a href="/pages/Lda4TL0MXzjH3zJwS5X2">boost</a></td></tr><tr><td>fund</td><td>Addr</td><td>The address of contract <a href="/pages/Cee0W0Awot4wWTDzaYb7">fund</a></td></tr><tr><td>reward_controller_addr</td><td>Addr</td><td>The address controlling the amount of SEILOR token rewards for each mining.</td></tr><tr><td>new_gov*</td><td>Addr</td><td>The address of the new governance contract</td></tr></tbody></table>

\* = optional

## InitMsg

```rust
#[cw_serde]
pub struct InstantiateMsg {
    pub gov: Option<Addr>,
    pub staking_token: Addr,
    pub rewards_token: Addr,
    pub boost: Addr,
    pub fund: Addr,
    pub reward_controller_addr: Addr,
    pub duration: Uint128,
}
```

```json
{
  "gov": "sei1...",
  "staking_token": "sei1...",
  "rewards_token": "sei1...",
  "boost": "sei1...",
  "fund": "sei1...",
  "reward_controller_addr": "sei1...",
  "duration": "2592000"
}
```

<table><thead><tr><th width="227">Key</th><th width="164">Type</th><th>Description</th></tr></thead><tbody><tr><td>gov</td><td>Addr</td><td>The address of the governance contract</td></tr><tr><td>staking_token</td><td>Addr</td><td>The address of the token contract to be staked</td></tr><tr><td>rewards_token</td><td>Addr</td><td>The address of the token contract to be rewarded</td></tr><tr><td>boost</td><td>Addr</td><td>The address of contract <a href="/pages/Lda4TL0MXzjH3zJwS5X2">boost</a></td></tr><tr><td>fund</td><td>Addr</td><td>The address of contract <a href="/pages/Cee0W0Awot4wWTDzaYb7">fund</a></td></tr><tr><td>reward_controller_addr</td><td>Addr</td><td>The address controlling the amount of SEILOR token rewards for each mining</td></tr><tr><td>duration</td><td>Uint128</td><td>The duration of this batch mining reward</td></tr></tbody></table>

## ExecuteMsg

### Receive

```rust
#[cw_serde]
pub enum ExecuteMsg {
    /// Receives a message of type [`Cw20ReceiveMsg`]
    Receive(Cw20ReceiveMsg),
}
#[cw_serde]
pub struct Cw20ReceiveMsg {
    pub sender: String,
    pub amount: Uint128,
    pub msg: Binary,
}
```

<pre class="language-json"><code class="lang-json">{
  "receive": {
    "cw20_receive_msg": {
        "sender": "sei1...",
        "amount": "1000000",
        "msg": "eyJ0eXBlIjoiY3cyMCIsImFtb3VudCI6IjEwMDAwMCJ9"
<strong>      }
</strong>  }
}
</code></pre>

<table><thead><tr><th width="181">Key</th><th width="196">Type</th><th>Description</th></tr></thead><tbody><tr><td>sender</td><td>String</td><td>The sender's address</td></tr><tr><td>amount</td><td>Uint128</td><td>Amount to be sent</td></tr><tr><td>msg</td><td>Binary</td><td>Message to be sent</td></tr></tbody></table>

### UpdateStakingConfig&#x20;

```rust
#[cw_serde]
pub enum ExecuteMsg {
    UpdateStakingConfig {
        config_msg: UpdateStakingConfigStruct,
    },
}
#[cw_serde]
pub struct UpdateStakingConfigStruct {
    pub gov: Option<Addr>,
    pub staking_token: Option<Addr>,
    pub rewards_token: Option<Addr>,
    pub boost: Option<Addr>,
    pub fund: Option<Addr>,
    pub reward_controller_addr: Option<Addr>,
}
```

<pre class="language-json"><code class="lang-json">{
  "update_staking_config": {
    "config_msg": {
          "gov": "sei1...",
          "staking_token": "sei1...",
          "rewards_token": "sei1...",
          "boost": "sei1...",
          "fund": "sei1...",
          "reward_controller_addr": "sei1..."
<strong>      }
</strong>  }
}
</code></pre>

<table><thead><tr><th width="227">Key</th><th width="164">Type</th><th>Description</th></tr></thead><tbody><tr><td>gov</td><td>Addr</td><td>The address of the governance contract</td></tr><tr><td>staking_token</td><td>Addr</td><td>The address of the token contract to be staked</td></tr><tr><td>rewards_token</td><td>Addr</td><td>The address of the token contract to be rewarded</td></tr><tr><td>boost</td><td>Addr</td><td>The address of contract <a href="/pages/Lda4TL0MXzjH3zJwS5X2">boost</a></td></tr><tr><td>fund</td><td>Addr</td><td>The address of contract <a href="/pages/Cee0W0Awot4wWTDzaYb7">fund</a></td></tr><tr><td>reward_controller_addr</td><td>Addr</td><td>The address controlling the amount of SEILOR token rewards for each mining</td></tr></tbody></table>

### UpdateStakingState&#x20;

```rust
#[cw_serde]
pub enum ExecuteMsg {
    UpdateStakingState {
        duration: Uint128,
    },
}
```

```json
{
  "update_staking_state": {
    "duration": "2592000"
  }
}
```

<table><thead><tr><th width="164">Key</th><th width="191">Type</th><th>Description</th></tr></thead><tbody><tr><td>duration</td><td>Uint128</td><td>The duration of this batch mining reward</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### GetReward&#x20;

```rust
#[cw_serde]
pub enum ExecuteMsg {
    GetReward {},
}
```

```json
{
  "get_reward": {}
}
```

### Withdraw&#x20;

```rust
#[cw_serde]
pub enum ExecuteMsg {
    Withdraw {
        amount: Uint128,
    },
}
```

```json
{
  "withdraw": {
    "amount": "1000000"
  }
}
```

<table><thead><tr><th width="207">Key</th><th width="183">Type</th><th>Description</th></tr></thead><tbody><tr><td>amount</td><td>Uint128</td><td>Amount to be withdrew</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### NotifyRewardAmount&#x20;

```rust
#[cw_serde]
pub enum ExecuteMsg {
    NotifyRewardAmount {
        amount: Uint128,
    },
}
```

```json
{
  "notify_reward_amount": {
    "amount": "1000000"
  }
}
```

<table><thead><tr><th width="180">Key</th><th width="152">Type</th><th>Description</th></tr></thead><tbody><tr><td>amount</td><td>Uint128</td><td>The total allocation of mining rewards for this batch</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

## QueryMsg

```rust
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(RewardPerTokenResponse)]
    RewardPerToken {},
}
```

```json
{
  "reward_per_token": {}
}
```

### RewardPerTokenResponse

```rust
#[cw_serde]
pub struct RewardPerTokenResponse {
    pub reward_per_token: Uint128,
}
```

```
{
  "reward_per_token": "1000000"
}
```

<table><thead><tr><th width="213">Key</th><th width="175">Type</th><th>Description</th></tr></thead><tbody><tr><td>reward_per_token</td><td>Uint128</td><td>The rate of reward for each token</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### LastTimeRewardApplicable&#x20;

```rust
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(LastTimeRewardApplicableResponse)]
    LastTimeRewardApplicable {},
}
```

```json
{
  "last_time_reward_applicable": {}
}
```

### LastTimeRewardApplicableResponse&#x20;

```rust
#[cw_serde]
pub struct LastTimeRewardApplicableResponse {
    pub last_time_reward_applicable: Uint128,
}
```

```json
{
  "last_time_reward_applicable": "1000000"
}
```

<table><thead><tr><th width="266">Key</th><th width="127">Type</th><th>Description</th></tr></thead><tbody><tr><td>last_time_reward_applicable</td><td>Uint128</td><td>Last time reward applicable</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### GetBoost

```rust
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(GetBoostResponse)]
    GetBoost { account: Addr },
}
```

```
{
  "get_boost": {
    "account": "sei1..."
  }
}
```

### GetBoostResponse&#x20;

```rust
#[cw_serde]
pub struct GetBoostResponse {
    pub boost: Uint128,
}
```

```
{
  "boost": "1000000"
}
```

<table><thead><tr><th width="137">Key</th><th width="170">Type</th><th>Description</th></tr></thead><tbody><tr><td>boost</td><td>Uint128</td><td>boost value</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### Earned&#x20;

```rust
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(EarnedResponse)]
    Earned { account: Addr },
}
```

```json
{
  "earned": {
    "account": "sei1..."
  }
}
```

<table><thead><tr><th width="180">Key</th><th width="183">Type</th><th>Description</th></tr></thead><tbody><tr><td>account</td><td>Addr</td><td>The user's address</td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### EarnedResponse

```rust
#[cw_serde]
pub struct EarnedResponse {
    pub earned: Uint128,
}
```

```
{
  "earned": "1000000"
}
```

<table><thead><tr><th width="143">Key</th><th width="123">Type</th><th>Description</th></tr></thead><tbody><tr><td>earned</td><td>Uint128</td><td>The amount of rewards that the user has already received.</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### QueryStakingConfig&#x20;

```rust
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(StakingConfigResponse)]
    QueryStakingConfig {},
}
```

```
{
  "query_staking_config": {}
}
```

### StakingConfigResponse

```rust
#[cw_serde]
pub struct StakingConfigResponse {
    pub gov: Addr,
    pub staking_token: Addr,
    pub rewards_token: Addr,
    pub boost: Addr,
    pub fund: Addr,
    pub reward_controller_addr: Addr,
}
```

```
{
  "gov": "sei1...",
  "staking_token": "sei1...",
  "rewards_token": "sei1...",
  "boost": "sei1...",
  "fund": "sei1...",
  "reward_controller_addr": "sei1..."
}
```

<table><thead><tr><th width="237">Key</th><th width="89">Type</th><th>Description</th></tr></thead><tbody><tr><td>gov</td><td>Addr</td><td>The address of the governance contract</td></tr><tr><td>staking_token</td><td>Addr</td><td>The address of the token contract to be staked</td></tr><tr><td>rewards_token</td><td>Addr</td><td>The address of the token contract to be rewarded</td></tr><tr><td>boost</td><td>Addr</td><td>The address of contract <a href="/pages/Lda4TL0MXzjH3zJwS5X2">boost</a></td></tr><tr><td>fund</td><td>Addr</td><td>The address of contract <a href="/pages/Cee0W0Awot4wWTDzaYb7">fund</a></td></tr><tr><td>reward_controller_addr</td><td>Addr</td><td>The address controlling the amount of SEILOR token rewards for each mining.</td></tr><tr><td>new_gov*</td><td>Addr</td><td>The address of the new governance contract</td></tr></tbody></table>

\* = optional

### QueryStakingState

```rust
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(StakingStateResponse)]
    QueryStakingState {},
}
```

```
{
  "query_staking_state": {}
}
```

### StakingStateResponse

```rust
#[cw_serde]
pub struct StakingStateResponse {
    pub duration: Uint128,
    pub finish_at: Uint128,
    pub updated_at: Uint128,
    pub reward_rate: Uint256,
    pub reward_per_token_stored: Uint128,
    pub total_supply: Uint128,
}
```

```json
{
  "duration": "1000000",
  "finish_at": "1000000",
  "updated_at": "1000000",
  "reward_rate": "1000000",
  "reward_per_token_stored": "1000000",
  "total_supply": "1000000"
}
```

<table><thead><tr><th width="266">Key</th><th width="118">Type</th><th>Description</th></tr></thead><tbody><tr><td>duration</td><td>Uint128</td><td>Duration of rewards to be paid out (in seconds) 2_592_000 = 30 days</td></tr><tr><td>finish_at</td><td>Uint128</td><td>Timestamp of when the rewards finish</td></tr><tr><td>update_at</td><td>Uint128</td><td>last updated time</td></tr><tr><td>reward_rate</td><td>Uint256</td><td>Reward to be paid out per second</td></tr><tr><td>reward_per_token_stored</td><td>Uint128</td><td>Sum of (reward rate * dt * 1e6 / total supply)</td></tr><tr><td>total_supply</td><td>Uint128</td><td>The total amount of staked tokens.</td></tr></tbody></table>

### GetUserUpdatedAt&#x20;

```rust
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(GetUserUpdatedAtResponse)]
    GetUserUpdatedAt { account: Addr },
}
```

```
{
  "get_user_updated_at": {
    "account": "sei1..."
  }
}
```

<table><thead><tr><th width="147">Key</th><th width="153">Type</th><th>Decription</th></tr></thead><tbody><tr><td>account</td><td>Addr</td><td>The user's address</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### GetUserUpdatedAtResponse&#x20;

```rust
#[cw_serde]
pub struct GetUserUpdatedAtResponse {
    pub updated_at: Uint128,
}
```

```
{
  "updated_at": "1000000"
}
```

<table><thead><tr><th width="192">Key</th><th width="188">Type</th><th>Description</th></tr></thead><tbody><tr><td>updated_at</td><td>Uint128</td><td>last updated time for user</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### GetUserRewardPerTokenPaid&#x20;

```rust
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(GetUserRewardPerTokenPaidResponse)]
    GetUserRewardPerTokenPaid { account: Addr },
}
```

```
{
  "get_user_reward_per_token_paid": {
    "account": "sei1..."
  }
}
```

<table><thead><tr><th width="193">Key</th><th width="193">Type</th><th>Description</th></tr></thead><tbody><tr><td>account</td><td>Addr</td><td>the user's address</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### GetUserRewardPerTokenPaidResponse&#x20;

```rust
#[cw_serde]
pub struct GetUserRewardPerTokenPaidResponse {
    pub reward_per_token_paid: Uint128,
}
```

```
{
  "reward_per_token_paid": "1000000"
}
```

<table><thead><tr><th width="221">Key</th><th width="101">Type</th><th>Description</th></tr></thead><tbody><tr><td>reward_per_token_paid</td><td>Uint128</td><td>Calculating the reward rate per Staking token for a specific user after applying the boost</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### BalanceOf&#x20;

```rust
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(BalanceOfResponse)]
    BalanceOf { account: Addr },
}
```

```json
{
  "balance_of": {
    "account": "sei1..."
  }
}
```

<table><thead><tr><th width="185">Key</th><th width="179">Type</th><th>Description</th></tr></thead><tbody><tr><td>account</td><td>Addr</td><td>the user's address</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### BalanceOfResponse&#x20;

```rust
#[cw_serde]
pub struct BalanceOfResponse {
    pub balance_of: Uint128,
}
```

```json
{
  "balance_of": "1000000"
}
```

<table><thead><tr><th width="191">Key</th><th width="169">Type</th><th>Description</th></tr></thead><tbody><tr><td>balance_of</td><td>Uint128</td><td>the balance of the user's address</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kryptonite.finance/developer/seilor-token/staking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
