Skip to main content

OlympusPrice

Git Source

Inherits: PRICEv1

Price oracle data storage contract.

Constants​

_scaleFactor​

uint256 internal immutable _scaleFactor;

Functions​

constructor​

constructor(
Kernel kernel_,
AggregatorV2V3Interface ohmEthPriceFeed_,
uint48 ohmEthUpdateThreshold_,
AggregatorV2V3Interface reserveEthPriceFeed_,
uint48 reserveEthUpdateThreshold_,
uint48 observationFrequency_,
uint48 movingAverageDuration_,
uint256 minimumTargetPrice_
) Module(kernel_);

Parameters

NameTypeDescription
kernel_Kernel
ohmEthPriceFeed_AggregatorV2V3Interface
ohmEthUpdateThreshold_uint48
reserveEthPriceFeed_AggregatorV2V3Interface
reserveEthUpdateThreshold_uint48
observationFrequency_uint48
movingAverageDuration_uint48
minimumTargetPrice_uint256

KEYCODE​

5 byte identifier for a module.

function KEYCODE() public pure override returns (Keycode);

Returns

NameTypeDescription
<none>Keycode

VERSION​

Returns which semantic version of a module is being implemented.

function VERSION() external pure override returns (uint8 major, uint8 minor);

Returns

NameTypeDescription
majoruint8- Major version upgrade indicates breaking change to the interface.
minoruint8- Minor version change retains backward-compatible interface.

updateMovingAverage​

Trigger an update of the moving average. Permissioned.

This function does not have a time-gating on the observationFrequency on this contract. It is set on the Heart policy contract. The Heart beat frequency should be set to the same value as the observationFrequency.

function updateMovingAverage() external override permissioned;

initialize​

Initialize the price module

Access restricted to activated policies

This function must be called after the Price module is deployed to activate it and after updating the observationFrequency or movingAverageDuration (in certain cases) in order for the Price module to function properly.

function initialize(
uint256[] memory startObservations_,
uint48 lastObservationTime_
) external override permissioned;

Parameters

NameTypeDescription
startObservations_uint256[]- Array of observations to initialize the moving average with. Must be of length numObservations.
lastObservationTime_uint48- Unix timestamp of last observation being provided (in seconds).

changeMovingAverageDuration​

Change the moving average window (duration)

Changing the moving average duration will erase the current observations array and require the initialize function to be called again. Ensure that you have saved the existing data and can re-populate before calling this function.

function changeMovingAverageDuration(
uint48 movingAverageDuration_
) external override permissioned;

Parameters

NameTypeDescription
movingAverageDuration_uint48- Moving average duration in seconds, must be a multiple of observation frequency

changeObservationFrequency​

Change the observation frequency of the moving average (i.e. how often a new observation is taken)

Changing the observation frequency clears existing observation data since it will not be taken at the right time intervals. Ensure that you have saved the existing data and/or can re-populate before calling this function.

function changeObservationFrequency(
uint48 observationFrequency_
) external override permissioned;

Parameters

NameTypeDescription
observationFrequency_uint48- Observation frequency in seconds, must be a divisor of the moving average duration

changeUpdateThresholds​

Change the update thresholds for the price feeds

The update thresholds should be set based on the update threshold of the chainlink oracles.

function changeUpdateThresholds(
uint48 ohmEthUpdateThreshold_,
uint48 reserveEthUpdateThreshold_
) external override permissioned;

Parameters

NameTypeDescription
ohmEthUpdateThreshold_uint48- Maximum allowed time between OHM/ETH price feed updates
reserveEthUpdateThreshold_uint48- Maximum allowed time between Reserve/ETH price feed updates

changeMinimumTargetPrice​

Change the minimum target price

The minimum target price should be set based on the liquid backing of OHM.

function changeMinimumTargetPrice(uint256 minimumTargetPrice_) external override permissioned;

Parameters

NameTypeDescription
minimumTargetPrice_uint256- Minimum target price for RBS system with 18 decimals, expressed as number of Reserve per OHM

getCurrentPrice​

Get the current price of OHM in the Reserve asset from the price feeds

function getCurrentPrice() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256

getLastPrice​

Get the last stored price observation of OHM in the Reserve asset

function getLastPrice() external view override returns (uint256);

Returns

NameTypeDescription
<none>uint256

getMovingAverage​

Get the moving average of OHM in the Reserve asset over the defined window (see movingAverageDuration and observationFrequency).

function getMovingAverage() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256

getTargetPrice​

Get target price of OHM in the Reserve asset for the RBS system

Returns the maximum of the moving average and the minimum target price

function getTargetPrice() external view override returns (uint256);

Returns

NameTypeDescription
<none>uint256