> For the complete documentation index, see [llms.txt](https://autopilot-5.gitbook.io/autopilot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://autopilot-5.gitbook.io/autopilot/protocol/markdown/mathematical-security-guarantees.md).

# Mathematical Security Guarantees

Autopilot uses deterministic, on-chain logic to calculate and distribute rewards.\
The system is designed for precision, fairness, and protection against manipulation.

***

#### Reward Calculation

Reward distribution is handled using a **scaled accumulator model** to ensure accuracy across all participants, regardless of epoch size or number of users.

```solidity
solidityCopyEditreward_scaled = (reward_amount * SCALE) / total_tracked_weight;
acc_reward_scaled += reward_scaled;
```

* `SCALE = 1e18` preserves precision in all reward calculations
* `acc_reward_scaled` tracks cumulative rewards and cannot be changed retroactively
* Users can independently verify their reward allocation using only on-chain data

This model is consistent with approaches used in protocols like Aave and Compound and ensures each user receives rewards proportional to their voting weight.

***

#### Dilution Protection

To prevent timing-based manipulation, Autopilot enforces strict reward eligibility rules per epoch.

**1. Per-Epoch Weight Tracking**

* A snapshot of voting power is taken each epoch.
* Any deposit made during the **Special Window** (90 minutes before epoch end to 30 minutes after epoch start) is excluded from that epoch’s rewards.

**2. Snapshot Enforcement**

* Before any user action (deposit, withdrawal, claim), the contract executes:

```solidity
solidityCopyEditemergencySnapshot()
```

* This locks in the current voting weight for reward calculations.

**3. Gap Handling**

If a transaction is missed due to network issues or bot delay, the system:

* Detects the gap
* Advances epoch state
* Applies fallback snapshots to maintain reward consistency


---

# 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:

```
GET https://autopilot-5.gitbook.io/autopilot/protocol/markdown/mathematical-security-guarantees.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.
