Skip to main content

OlympusHeart

Git Source

Inherits: IHeart, Policy, RolesConsumer, ReentrancyGuard

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;

active

Status of the Heart, false = stopped, true = beating

bool public active;

PRICE

PRICEv1 internal PRICE;

MINTR

MINTRv1 internal MINTR;

operator

IOperator public operator;

distributor

IDistributor public distributor;

yieldRepo

IYieldRepo public yieldRepo;

reserveMigrator

IReserveMigrator public reserveMigrator;

emissionManager

IEmissionManager public emissionManager;

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_,
IOperator operator_,
IDistributor distributor_,
IYieldRepo yieldRepo_,
IReserveMigrator reserveMigrator_,
IEmissionManager emissionManager_,
uint256 maxReward_,
uint48 auctionDuration_
) Policy(kernel_);

configureDependencies

Define module dependencies for this policy.

function configureDependencies() external override returns (Keycode[] memory dependencies);

Returns

NameTypeDescription
dependenciesKeycode[]- 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

NameTypeDescription
permissionsPermissions[]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

NameTypeDescription
majoruint8The major version of the policy.
minoruint8The 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

function resetBeat() external onlyRole("heart_admin");

activate

Turns the heart on and resets the beat

This function is used to restart the heart after a pause

function activate() external onlyRole("heart_admin");

deactivate

Turns the heart off

Emergency stop function for the heart

function deactivate() external onlyRole("heart_admin");

setOperator

Updates the Operator contract address that the Heart calls on a beat

function setOperator(address operator_) external onlyRole("heart_admin");

Parameters

NameTypeDescription
operator_addressThe address of the new Operator contract

setDistributor

Updates the Distributor contract address that the Heart calls on a beat

function setDistributor(address distributor_) external onlyRole("heart_admin");

Parameters

NameTypeDescription
distributor_addressThe address of the new Distributor contract

setYieldRepo

Updates the YieldRepo contract address that the Heart calls on a beat

function setYieldRepo(address yieldRepo_) external onlyRole("heart_admin");

Parameters

NameTypeDescription
yieldRepo_addressThe address of the new YieldRepo contract

setReserveMigrator

Updates the ReserveMigrator contract address that the Heart calls on a beat

function setReserveMigrator(address reserveMigrator_) external onlyRole("heart_admin");

Parameters

NameTypeDescription
reserveMigrator_addressThe address of the new ReserveMigrator contract

setEmissionManager

Updates the EmissionManager contract address that the Heart calls on a beat

function setEmissionManager(address emissionManager_) external onlyRole("heart_admin");

Parameters

NameTypeDescription
emissionManager_addressThe address of the new EmissionManager contract

notWhileBeatAvailable

modifier notWhileBeatAvailable();

setRewardAuctionParams

Sets the max reward amount, and auction duration for the beat function

function setRewardAuctionParams(uint256 maxReward_, uint48 auctionDuration_)
external
onlyRole("heart_admin")
notWhileBeatAvailable;

Parameters

NameTypeDescription
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);