> For the complete documentation index, see [llms.txt](https://gitbook.mor.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.mor.org/smart-contracts/documentation/distribution-protocol/v7-protocol/guides/mor-emission-logic.md).

# MOR emission logic

The `LinearDistributionIntervalDecrease` library implements a reward calculation strategy designed for protocols that emit a fixed token amount per interval, with a predictable linear decrease in the emission rate over time. This pattern is used for long-term token emission schemes (e.g., MOR) that reward staking participants based on when they joined and how long they stayed.

## Overview

The key concept is *linear emission with interval-based reduction*. Instead of updating user rewards every second, the protocol defines a base reward amount that decreases linearly every fixed time interval (e.g., s). This model balances emission precision and computational efficiency, making it ideal for large-scale staking systems.

## **Emission scheme params**

* `initialAmount` — the starting reward amount per interval (e.g., 1000 tokens per day).
* `decreaseAmount` — how much the reward decreases *per interval* (e.g., 10 tokens less per day).
* `interval` — time in seconds (e.g., 86400 for daily).
* `payoutStart` — timestamp when emissions start.
* `startTime` / `endTime` — the specific time window to compute rewards for.

Internally, reward calculation over a range (e.g., user staking from day 4 to day 10) is split into three parts:

1. **Partial First Interval**

   If the time window begins *within* an interval (not at its start), a proportional reward is computed based on how much of that interval is included.
2. **Full Intervals in the Middle**

   If the period spans multiple full intervals, the total reward for these is computed efficiently using an arithmetic sum of decreasing values:

```
        initialReward * ip_ - (decreaseAmount_ * (ip_ * (ip_ - 1))) / 2
```

&#x20;       This handles the geometric drop without looping over each interval.

3. **Partial Last Interval**

   If the time window ends *within* an interval, a proportional reward for the trailing part is added, similar to the first part.

If the input `endTime_` exceeds this cutoff, it’s clamped to avoid negative rewards.<br>

## Emission cutoff

The system prevents reward underflow by computing a maximum emission end time. This is the timestamp when the emissions would naturally reduce to zero:

```
maxIntervals = ceil(initialAmount / decreaseAmount)
maxEndTime = payoutStart + maxIntervals * interval
```


---

# 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://gitbook.mor.org/smart-contracts/documentation/distribution-protocol/v7-protocol/guides/mor-emission-logic.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.
