> 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
