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§
- accounts
- An Anchor generated module, providing a set of structs
mirroring the structs deriving
Accounts
, where each field is aPubkey
. This is useful for specifying accounts for a client. - instruction
- 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. - program
- Module representing the program.
- snapshots
- The snapshots program.
Structs§
- Escrow
History - Stores the total veToken balance of an locked_voter::Escrow for the given epochs.
- Locker
History - Stores the total number of veTokens in circulation for each period.
Enums§
- Error
Code - Errors.
Constants§
- COMMON_
ERA_ UNIX_ TS - The Unix timestamp of the start of the first era.
- ERA_
NUM_ PERIODS - Number of periods in an era.
- PERIOD_
SECONDS - Number of seconds in a period.
- SECONDS_
PER_ ERA - Number of seconds in an era.
Statics§
- ID
- The static program ID
Functions§
- calculate_
era_ and_ period_ of_ ts - Calculates the era and period of the given Unix timestamp.
- calculate_
era_ start_ ts - Calculates the start timestamp of an era.
- calculate_
next_ era_ and_ period - Calculates the next era and period of the given period.
- calculate_
next_ era_ and_ period_ of_ ts - Calculates the next era and period of the given Unix timestamp.
- calculate_
period_ start_ ts - Calculates the start timestamp of a period of an era.
- check_
id - Confirms that a given pubkey is equivalent to the program ID
- entry
- 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. - entrypoint⚠
- Safety
- has_
period_ elapsed - A period is
elapsed
if its start time has passed. - id
- Returns the program ID