> For the complete documentation index, see [llms.txt](https://docs.ipor.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ipor.io/dao-governance/tokenomics/usdipor-token-legacy/math-behind-the-rewards-contract.md).

# Math behind the rewards contract

**LR** - Block number when the last rebalancing took place. Certain variables would be rebalanced when the state change is necessary. Those events would include:

* adding or modifying staked tokens balance by the user
* changing parameters used to calculate boost, such as rewards per block&#x20;

***ULR*** - Time of rebalancing that occurrs when the user modifies his position (ipToken, pwToken delegation). It is saved under individual staking position.&#x20;

### User power-up

User power-up is calculated for each user whose position changes. That includes staking or unstaking ipTokens or modifying the delegated balance of pwIPOR.&#x20;

The user's power-up is governed by the below function: &#x20;

$$
UPU = \begin{cases}

10\cdot \left(\frac{pwIpor}{ipToken} \right) +0.2 & \frac{pwIpor}{ipToken} < 0.01 \\

4\cdot \left(\frac{pwIpor}{ipToken} \right) +0.26 & \frac{pwIpor}{ipToken} < 0.02 \\

3\cdot \left(\frac{pwIpor}{ipToken} \right) +0.28 & \frac{pwIpor}{ipToken} < 0.03 \\

2\cdot \left(\frac{pwIpor}{ipToken} \right) +0.31 & \frac{pwIpor}{ipToken} < 0.04 \\

1\cdot \left(\frac{pwIpor}{ipToken} \right) +0.35 & \frac{pwIpor}{ipToken} < 0.05 \\

VS + \log\_2\left(HS +\frac{pwIpor}{ipToken}\right) & \frac{pwIpor}{ipToken} \ge 0.05 \\

\end{cases}
$$

***VS*** - Vertical Shift \
***HS*** - Horizontal Shift\
***pwIpor*** - User's pwIPOR balance delegated to a particular asset\
***ipToken*** - User's staked ipToken balance

The curve can be swapped by the DAO for a different one at a later stage in time, affecting all future rebalancings. The user's power-up value is fixed and can only be changed if the rebalancing is triggered.&#x20;

### Aggregate Power-up

Aggregate Power-up is a synthetic summary of all power-ups across all users. It's used to calculate individual rewards in relation to the rest of the pool.&#x20;

$$
APU = \sum\_{# \text{all users whitch stake }ipTokens \geq 1} (ipTokens \cdot UPU)
$$

***APU*** - Aggregate Power-up\
***UPU*** - User Power-up

### Accrued rewards

Accrued rewards are tracked over time to allow for the calculation of users' rewards between events of rebalancing.

$$
\operatorname{accruedRewards} = \operatorname{accruedRewards}*{LR} +  \operatorname{rewardsPerBlock} ~~\cdot~~ \left(\text{blockNumber} - \operatorname{blockNumber}*{LR}\right)
$$

### Composite Multiplier

$$
CM = \frac{blockRewards}{APU}
$$

The composite multiplier (CM) accounts for the rewards per "boosted unit of liquidity staked" per block.&#x20;

$$
CMC = \sum\_{# blocks}CM\_{Block}
$$

Composite Multiplier Cummulative (CMC) is a sum of Composite multipliers for every block until now.&#x20;

### Account Mining Rewards

User rewards at block *n* can be calculated using the below formula. Block *ULR* is the block with the state of compositeMultiplierCumulative (CMC) at the time of the last rebalancing of user rewards.&#x20;

$$
userRewards\_{n}​=ipToken \* UPU\~\*\~\left(\operatorname{CMC}*{\operatorname{n-1}}​−CMC*{ULR-1}​\right)
$$

The $$CMC\_{ULR-1}$$ is saved when the user modifies his position. It is calculated to reflect the state without accounting for the current block.

​

$$
CMC\_{ULR-1} = CMC\_{LR-1} + \left(URL-LR \right) \cdot CM\_{LR}
$$

When the user modifies their position, the most recent CMC is saved per the user's record.

### Basic assumptions

VerticalShift ⇒ VS ⇒$$10^{-4}$$ $$\leq$$ VS $$\leq$$ 3

HorizontalShift ⇒ HS ⇒ 1 $$\leq$$ HS $$\leq$$ $$10^{3}$$

ipToken ⇒ 1 $$\leq$$ ipToken

pwIpor ⇒ 0 $$\leq$$ pwIpor $$\leq$$ 25 $$\cdot$$ $$10^{6}$$

$blockRewards $$\leq$$ 100

$totalRewards = 25 $$\cdot$$ $$10^{6}$$
