Snapshot System

Deep dive into the multi-period snapshot system for fair yield distribution in YRT tokens.


The Problem: Distribution Bypass

Without snapshots, users could manipulate yield distribution through strategic token transfers.

Attack Scenario (Without Snapshots)

Problem: Last-minute token transfers can bypass fair distribution!


The Solution: Snapshot Holders

The snapshot system records both balances AND holder addresses at maturity date, preventing manipulation.

Fair Distribution (With Snapshots)

Solution: Distribution uses frozen snapshot, not current balances!


Implementation Architecture

Key Innovation: Holder List

The periodSnapshotHolders mapping stores the list of addresses that held tokens at snapshot time.

Why this matters:

  • Distribution can iterate through snapshot holders only

  • No need to check entire blockchain for past holders

  • Prevents distribution bypass via post-snapshot transfers


Snapshot Lifecycle

1. Holder Tracking (Continuous)

Holders are tracked automatically on every transfer:

Example:

2. Snapshot Trigger (At Maturity)

Snapshot is triggered automatically by Chainlink Automation when maturity date is reached

What gets frozen:

  1. Total supply at snapshot time

  2. Balance of each holder

  3. List of holder addresses ← Critical for fair distribution

  4. Timestamp of snapshot

3. Distribution (Post-Snapshot)

Distribution uses snapshot holders list, not current holders


Multi-Period Independence

Each period maintains completely independent snapshots.

Example: 3 Periods

Key Point: Each period's snapshot is frozen independently. P2 snapshot doesn't affect P1 distribution.


Yield Calculation Formula

Formula

Example Calculation

Period 1 Data:

Distribution Calculation:

Holder
Snapshot Balance
Share
Yield Received

Alice

250 YRT

25%

25,000 USDC

Bob

200 YRT

20%

20,000 USDC

Charlie

150 YRT

15%

15,000 USDC

Owner

400 YRT

40%

40,000 USDC

Total

1000 YRT

100%

100,000 USDC


Edge Cases Handled

1. Post-Snapshot Transfers

Scenario: Alice sells tokens after snapshot but before distribution.

Why it works: Distribution uses periodSnapshotHolders[periodId] which is frozen.

2. Pre-Snapshot Trading

Scenario: Alice buys YRT 1 day before snapshot.

Design Choice: Snapshot captures ownership at specific timestamp. All holders at that moment receive yield proportionally.

3. Zero Balance Holders

Scenario: Bob had tokens but sold them all before snapshot.

Result: Bob is not included in snapshot holders list, saves gas during distribution.

4. Multiple Periods Same Holder

Scenario: Alice holds through P1, P2, P3.

Each period is independent. Alice's P1 distribution doesn't affect P2 or P3.


Gas Optimization

Efficient Holder Tracking

Instead of scanning all addresses, we maintain allHolders array:

Benefit: Snapshot only loops through current holders (e.g., 100 iterations), not all historical addresses (e.g., 10,000).

Batch Distribution

For large holder counts, distribution can be batched:


Security Considerations

Attack Vector: Front-Running Distribution

Attempted Attack:

  1. Attacker sees distribution transaction in mempool

  2. Attacker front-runs with token purchase

  3. Hopes to receive yield

Mitigation:

Attacker's address is not in snapshot, so they receive nothing. ✅

Attack Vector: Snapshot Manipulation

Attempted Attack:

  1. Attacker accumulates large position

  2. Attacker front-runs snapshot trigger

  3. Sells immediately after snapshot

Reality: This is not an attack - it's expected behavior! Snapshot captures ownership at specific moment. If attacker held tokens at snapshot time, they deserve proportional yield.

Why it's fair:

  • Attacker took price risk during holding period

  • Attacker paid for tokens at market price

  • Other holders can do the same

  • Market efficiency ensures fair pricing


Comparison: With vs. Without Snapshot Holders

Scenario
Without Snapshot Holders
With Snapshot Holders

Alice holds 90 days, sells before distribution

Alice gets 0 yield ❌

Alice gets yield ✅

Bob buys after snapshot

Bob gets yield ❌

Bob gets 0 yield ✅

Gas cost

High (check all addresses)

Low (only snapshot holders)

Manipulation risk

High

None

Fairness

Unfair

Fair


API Reference

Query Snapshot Data

Trigger Snapshot (Admin Only)



Key Takeaways:

  1. Snapshot captures BOTH balances AND holder addresses

  2. Each period has independent snapshot

  3. Distribution uses snapshot holders, not current holders

  4. Prevents manipulation through post-snapshot transfers

  5. Gas-efficient through active holder tracking


Last Updated: october 2025

Last updated