> For the complete documentation index, see [llms.txt](https://cenit-finance-1.gitbook.io/generic-simulation-tool-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cenit-finance-1.gitbook.io/generic-simulation-tool-docs/others/stuff-to-be-aware-of/staker-behavior.md).

# Staker behavior

One of the most recurrent utilities in the token economy is staking. Stakers will purchase tokens and stake them as long as the yield offered by the protocol is higher than the expected APY of the market. To model this, we need to implement several lines of Simulation Equations.

Imagine an example where the rewards for stakers are:

1. Fees from the protocol, determined by the variable *VA\_fees\_to\_stakers*.
2. Extra incentives to stakers, determined by *VA\_emissions\_to\_stakers\_value\_eavg*.

The equations would be:

<table data-header-hidden><thead><tr><th width="282"></th><th></th></tr></thead><tbody><tr><td>VA_staking_equilibrium_tokens</td><td>(VA_fees_to_stakers + VA_emissions_to_stakers_value_eavg) / (VA_eavg_token_price * time_step.years * SP_competitive_market_apy_percent/100)</td></tr></tbody></table>

This first equation establishes how many tokens are required to stake at each time to reach equilibrium with the expected APY. Based on the currently staked tokens and the ones that should be staked, we calculate the total amount of tokens that will be purchased or sold in the market to achieve equilibrium. Lastly, we create some stability constraints on *VA\_staked\_tokens\_traded*.

<table data-header-hidden><thead><tr><th width="321"></th><th></th></tr></thead><tbody><tr><td>VA_desired_staked_tokens_variation</td><td><p>MAX(VA_staking_equilibrium_tokens - A_stakers.total_tokens, VA_locked_staked_tokens - A_stakers.total_tokens)</p><p><br><br></p></td></tr><tr><td>VA_staked_tokens_traded</td><td>MAX(MIN(VA_desired_staked_tokens_variation.previous, market_tokens.previous * (1-EXP(-time_step.days/SP_liquidity_time_constant))), - market_tokens.previous * (1-EXP(-time_step.days/SP_liquidity_time_constant/30)))</td></tr></tbody></table>

We then have a mechanism to ensure some token staking lock-up in the following rows:

<table data-header-hidden><thead><tr><th width="310"></th><th></th></tr></thead><tbody><tr><td>VA_locked_staked_tokens_array</td><td>store_amount(VA_locked_staked_tokens_array.previous, MAX(0, VA_staked_tokens_traded), SP_staking_max_timelock, time.months)</td></tr><tr><td>VA_locked_staked_tokens</td><td>stored_total(VA_locked_staked_tokens_array.previous)</td></tr></tbody></table>

To add another stream of revenue directed to the stakers, we should adapt the *VA\_staking\_equilibrium\_tokens* formula to include those revenues. Ensure that the currencies are in USD per timestep for each of them.

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://cenit-finance-1.gitbook.io/generic-simulation-tool-docs/others/stuff-to-be-aware-of/staker-behavior.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
