Expand description

Voting Escrow Snapshots: Historical snapshots of previous voting escrow balances.

Motivation

There are several instances in which one may want to use an instantaneous snapshot of all vote escrow balances, for example:

  • Fee distribution. One may want to send protocol revenue to veToken holders.
  • Airdrops. One may want to send tokens to holders of a veToken.

Mechanism

veToken balances are recorded for every period. A period is recorded for every 3 days.

There are two accounts that are used to compute historical balances:

  • LockerHistory, which stores the total number of veTokens for each period, and
  • EscrowHistory, which stores the veTokens in each Escrow per period.

Any time someone refreshes and/or modifies their vote escrow, they should refresh their EscrowHistory accounts.

Program Addresses

License

The snapshots program is licensed under the Affero General Public License version 3.

Modules

An Anchor generated module, providing a set of structs mirroring the structs deriving Accounts, where each field is a Pubkey. This is useful for specifying accounts for a client.

An Anchor generated module containing the program’s set of instructions, where each method handler in the #[program] mod is associated with a struct defining the input arguments to the method. These should be used directly, when one wants to serialize Anchor instruction data, for example, when speciying instructions on a client.

Module representing the program.

The snapshots program.

Structs

Stores the total veToken balance of an locked_voter::Escrow for the given epochs.

Stores the total number of veTokens in circulation for each period.

Enums

Errors.

Constants

The Unix timestamp of the start of the first era.

Number of periods in an era.

Number of seconds in a period.

Number of seconds in an era.

Statics

The static program ID

Functions

Calculates the era and period of the given Unix timestamp.

Calculates the start timestamp of an era.

Calculates the next era and period of the given period.

Calculates the next era and period of the given Unix timestamp.

Calculates the start timestamp of a period of an era.

Confirms that a given pubkey is equivalent to the program ID

The Anchor codegen exposes a programming model where a user defines a set of methods inside of a #[program] module in a way similar to writing RPC request handlers. The macro then generates a bunch of code wrapping these user defined methods into something that can be executed on Solana.

A period is elapsed if its start time has passed.

Returns the program ID