⌛Epoch Manager
The Epoch Manager is a contract which sole purpose is to create epochs on MANTRA, acting like a clock for the other contracts.
An Epoch
is a period of time that is defined by the duration
parameter on EpochConfig
, and they are used by other contracts to take timely actions. For example, the Farm Manager uses epochs to calculate the farm rewards for its users.
How it works
The epoch configuration is set up when the contract is instantiated. The epoch configuration defines the duration of an epoch and when the genesis epoch is going to take place, i.e. the first epoch.
Once the genesis epoch is created, after the epoch duration has passed, anyone can create a new epoch by calling the CreateEpoch
message. This action will create a new epoch by increasing the epoch id by one, adjust the start time for the new epoch and alert the contracts that have registered for the hook.
Epoch Hook
There are two actions that only the owner of the Epoch Manager can execute: AddHook
and RemoveHook
. These add or remove a contract to the HOOKS
list.
These contracts must implement the EpochChangedHookMsg
interface, which is the signature of the message that will be executed on the hooks when a new epoch is created. The hook contains the current Epoch
, specifying the id and start_time.
Instantiate
Instantiates an instance of the epoch manager contract
ExecuteMsg
CreateEpoch
Creates a new epoch. It's permissionless. A new epoch can only be created after the current one has ended.
AddHook
Adds a new hook to the hook registry, i.e. adds a contract to be notified when a new epoch is created.
RemoveHook
Removes a hook from the hook registry.
UpdateConfig
Updates the contract configuration.
QueryMsg
Config
Returns the configuration of the contract.
CurrentEpoch
Returns the current epoch, which is the last on the EPOCHS map
Epoch
Returns the epoch with the given ID.
Hooks
Returns the hooks in the registry.
Hook
Returns whether a hook has been registered.
QueryMsg
Config
Returns the configuration of the contract.
CurrentEpoch
Returns the current epoch, which is the last on the EPOCHS map.
Epoch
Returns the epoch with the given id.
Hooks
Returns the hooks in the registry.
Hook
Returns whether a hook has been registered.
MigrateMsg
Message to migrate the contract to a new code ID.
Last updated