# Farm Details

## #

Liquidity Tokens (LP Tokens)### #

youves SwapIf a user deposits liquidity into a swap (e.g. uUSD and USDT), he receives liquidity tokens, which represent the deposited assets. For the flat-curve CFMM swaps, the LP tokens are created by this simple formula:

`LP_token_amount = amount_token_A + amount_token_B`

## #

RewardThe weekly reward amount gets distributed to stakers in the farm. Depending on the farm there can be different reward types with different distribution formulas.

### #

Reward Type# | Reward Type | Description |
---|---|---|

1 | Flat incentive | The rewards are allocated over time, proportionally to the user's stake in the farm and the weekly reward. This is how most farms work. |

2 | Long-term inventive | The the weight of a user's stake is are growing over time, up to the maximum at 180 days age of the stake. More details below. The goal is to incentivise long term staking. |

### #

Flat IncentiveFarms have a defined reward distribution per period. this can be weeks, days and for calculation purposes typically seconds.

`rewards_per_week rewards_per_day = rewards_per_week / 7 rewards_per_second = rewards_per_day / (24 * 60 *60) `

At any time a user's `token_fraction`

is equal to

`token_fraction = number_staked_LP_tokens_of_user / number_LP_tokens_total`

The calculation of a user's rewards `reward_payout`

is straightforward for any time period `time_period_in_seconds`

where the `token_fraction`

and `rewards_per_second`

stay constant.

`period_reward_payout[i] = token_fraction[i] * time_period_in_seconds[i] * rewards_per_second[i]`

The `aggregated_reward_payout`

is just the sum of the `reward_payout`

.

`aggregated_reward_payout[i] = aggregated_reward_payout[i-1] + period_reward_payout[i]`

Whenever either of `token_fraction`

and `rewards_per_second`

need to be recalculated, the above formula can be re-applied.

### #

Long-Term IncentiveThe unweighted reward payout `reward_payout`

and `aggregated_reward_payout`

is as in the flat incentive case above.

Both `now`

and timestamp `ts_applied`

have seconds as units. `now`

is expressed as the current Unix Epoch time.

`max_release_days = 180max_release_seconds = max_release_days * 24 * 60 *60 = 15,552,000`

To calculate the age at a given time `age_current`

, the formula is as follows:

`age_current = MIN(max_release_seconds, now - ts_applied)`

The weight at a given time `weight_current`

is

`weight_current = age_current/max_release_seconds`

The number of LP tokens a user has in the pool at a given moment are called `number_LP_tokens_current`

.

Upon adding more LP tokens to the pool, the applied age `age_applied`

and `number_LP_tokens_current`

get updated.

`age_applied = (number_LP_tokens_current * age_current + number_LP_tokens_added * 0) / (number_LP_tokens_current + number_LP_tokens_added)number_LP_tokens_current = number_LP_tokens_current + number_LP_tokens_added`

As a consequence the applied timestamp `ts_applied`

is updated as follows:

`ts_applied = now - age_applied `

If the `number_LP_tokens_current`

previously was 0, then

`age_applied = 0 `

and

`ts_applied = now`

When claiming rewards, the claim which gets paid out is `weighted_aggregate_reward_payout`

. It is calculated as:

`weighted_aggregate_reward_payout = aggregated_reward_payout * weight_current`

Furthermore, the residual of `aggregated_reward_payout - weighted_aggregate_reward_payout`

is distributed to the ongoing participants in the farm, proportional to their `token_fraction`

.

Finally the claiming user's `aggregated_reward_payout`

gets reset.

`aggregated_reward_payout = 0 `

When claiming without withdrawing LP tokens, the applied timestamp `ts_applied`

remains unchanged.

A user's stake of LP tokens can only be withdrawn in full and upon withdrawing, the `aggregated_reward_payout`

is calculated and the rewards are automatically claimed and the residual rewards are distributed to the farm.