OlympusHeart
Inherits: IHeart, Policy, PolicyEnabler, ReentrancyGuard, BasePeriodicTaskManager
Title: Olympus Heart
forge-lint: disable-start(mixed-case-variable)
Olympus Heart (Policy) Contract
The Olympus Heart contract provides keeper rewards to call the heart beat function which fuels Olympus market operations. The Heart orchestrates state updates in the correct order to ensure market operations use up to date information. This version implements an auction style reward system where the reward is linearly increasing up to a max reward. Rewards are issued in OHM.
State Variables
lastBeat
Timestamp of the last beat (UTC, in seconds)
uint48 public lastBeat
auctionDuration
Duration of the reward auction (in seconds)
uint48 public auctionDuration
maxReward
Max reward for beating the Heart (in reward token decimals)
uint256 public maxReward
PRICE
PRICEv1 internal PRICE
MINTR
MINTRv1 internal MINTR
distributor
IDistributor public distributor
Functions
constructor
Auction duration must be less than or equal to frequency, but we cannot validate that in the constructor because PRICE is not yet set. Therefore, manually ensure that the value is valid when deploying the contract.
constructor(Kernel kernel_, IDistributor distributor_, uint256 maxReward_, uint48 auctionDuration_)
Policy(kernel_);
configureDependencies
Define module dependencies for this policy.
function configureDependencies() external override returns (Keycode[] memory dependencies);
Returns
| Name | Type | Description |
|---|---|---|
dependencies | Keycode[] | - Keycode array of module dependencies. |
requestPermissions
Function called by kernel to set module function permissions.
function requestPermissions() external view override returns (Permissions[] memory permissions);
Returns
| Name | Type | Description |
|---|---|---|
permissions | Permissions[] | requests - Array of keycodes and function selectors for requested permissions. |
VERSION
Returns the version of the policy.
function VERSION() external pure returns (uint8 major, uint8 minor);
Returns
| Name | Type | Description |
|---|---|---|
major | uint8 | The major version of the policy. |
minor | uint8 | The minor version of the policy. |
beat
Beats the heart
Triggers price oracle update and market operations
function beat() external nonReentrant;
_syncBeatWithDistributor
function _syncBeatWithDistributor() internal;
_resetBeat
function _resetBeat() internal;
resetBeat
Unlocks the cycle if stuck on one side, eject function
This function is gated to the ADMIN or MANAGER roles
function resetBeat() external onlyManagerOrAdminRole;
_enable
Implementation-specific enable function
This function is called by the enable() function
The implementing contract can override this function and perform the following:
- Validate any parameters (if needed) or revert
- Validate state (if needed) or revert
- Perform any necessary actions, apart from modifying the
isEnabledstate variable
function _enable(bytes calldata) internal override;
Parameters
| Name | Type | Description |
|---|---|---|
<none> | bytes |
setDistributor
Updates the Distributor contract address that the Heart calls on a beat
This function is gated to the ADMIN role
function setDistributor(address distributor_) external onlyAdminRole;
Parameters
| Name | Type | Description |
|---|---|---|
distributor_ | address | The address of the new Distributor contract |
notWhileBeatAvailable
modifier notWhileBeatAvailable() ;
setRewardAuctionParams
Sets the max reward amount, and auction duration for the beat function
This function is gated to the ADMIN role
function setRewardAuctionParams(uint256 maxReward_, uint48 auctionDuration_)
external
onlyAdminRole
notWhileBeatAvailable;
Parameters
| Name | Type | Description |
|---|---|---|
maxReward_ | uint256 | - New max reward amount, in units of the reward token |
auctionDuration_ | uint48 | - New auction duration, in seconds |
frequency
Heart beat frequency, in seconds
function frequency() public view returns (uint48);
currentReward
Current reward amount based on linear auction
function currentReward() public view returns (uint256);