Skip to main content

Operator

Olympus Range Operator

Olympus Range Operator (Policy) Contract

The Olympus Range Operator performs market operations to enforce OlympusDAO's OHM price range guidance policies against a specific reserve asset. The Operator is maintained by a keeper-triggered function on the Olympus Heart contract, which orchestrates state updates in the correct order to ensure market operations use up to date information. When the price of OHM against the reserve asset exceeds the cushion spread, the Operator deploys bond markets to support the price. The Operator also offers zero slippage swaps at prices dictated by the wall spread from the moving average. These market operations are performed up to a specific capacity before the market must stabilize to regenerate the capacity.

Methods

ONE_HUNDRED_PERCENT

function ONE_HUNDRED_PERCENT() external view returns (uint32)

Returns

NameTypeDescription
_0uint32undefined

ONE_PERCENT

function ONE_PERCENT() external view returns (uint32)

Returns

NameTypeDescription
_0uint32undefined

ROLES

function ROLES() external view returns (contract ROLESv1)

Returns

NameTypeDescription
_0contract ROLESv1undefined

activate

function activate() external nonpayable

Activate the OperatorAccess restricted

Restart function for the Operator after a pause.

active

function active() external view returns (bool)

Whether the Operator is active

Returns

NameTypeDescription
_0boolundefined

auctioneer

function auctioneer() external view returns (contract IBondSDA)

Auctioneer contract used for cushion bond market deployments

Returns

NameTypeDescription
_0contract IBondSDAundefined

bondPurchase

function bondPurchase(uint256 id_, uint256 amountOut_) external nonpayable

Records a bond purchase and updates capacity correctlyAccess restricted (BondCallback)

Parameters

NameTypeDescription
id_uint256ID of the bond market
amountOut_uint256Amount of capacity expended

callback

function callback() external view returns (contract IBondCallback)

Callback contract used for cushion bond market payouts

Returns

NameTypeDescription
_0contract IBondCallbackundefined

changeKernel

function changeKernel(contract Kernel newKernel_) external nonpayable

Function used by kernel when migrating to a new kernel.

Parameters

NameTypeDescription
newKernel_contract Kernelundefined

config

function config() external view returns (struct IOperator.Config)

Returns the config variable of the Operator as a Config struct

Returns

NameTypeDescription
_0IOperator.Configundefined

configureDependencies

function configureDependencies() external nonpayable returns (Keycode[] dependencies)

Define module dependencies for this policy.

Returns

NameTypeDescription
dependenciesKeycode[]- Keycode array of module dependencies.

deactivate

function deactivate() external nonpayable

Deactivate the OperatorAccess restricted

Emergency pause function for the Operator. Prevents market operations from occurring.

deactivateCushion

function deactivateCushion(bool high_) external nonpayable

Manually close a cushion bond marketAccess restricted

Emergency shutdown function for Cushions

Parameters

NameTypeDescription
high_boolWhether to deactivate the high or low side cushion (true = high, false = low)

fullCapacity

function fullCapacity(bool high_) external view returns (uint256)

Returns the full capacity of the specified wall (if it was regenerated now)

Calculates the capacity to deploy for a wall based on the amount of reserves owned by the treasury and the reserve factor.

Parameters

NameTypeDescription
high_bool- Whether to return the full capacity for the high or low wall

Returns

NameTypeDescription
_0uint256undefined

getAmountOut

function getAmountOut(contract ERC20 tokenIn_, uint256 amountIn_) external view returns (uint256)

Returns the amount to be received from a swap

Parameters

NameTypeDescription
tokenIn_contract ERC20- Token to swap into the wall - If OHM: swap at the low wall price for Reserve - If Reserve: swap at the high wall price for OHM
amountIn_uint256- Amount of tokenIn to swap

Returns

NameTypeDescription
_0uint256Amount of opposite token received

initialize

function initialize() external nonpayable

Initialize the Operator to begin market operationsAccess restrictedCan only be called once

This function executes actions required to start operations that cannot be done prior to the Operator policy being approved by the Kernel.

initialized

function initialized() external view returns (bool)

Whether the Operator has been initialized

Returns

NameTypeDescription
_0boolundefined

isActive

function isActive() external view returns (bool)

Easily accessible indicator for if a policy is activated or not.

Returns

NameTypeDescription
_0boolundefined

kernel

function kernel() external view returns (contract Kernel)

Returns

NameTypeDescription
_0contract Kernelundefined

ohm

function ohm() external view returns (contract ERC20)

OHM token contract

Returns

NameTypeDescription
_0contract ERC20undefined

ohmDecimals

function ohmDecimals() external view returns (uint8)

Returns

NameTypeDescription
_0uint8undefined

operate

function operate() external nonpayable

Executes market operations logic.Access restricted

This function is triggered by a keeper on the Heart contract.

regenerate

function regenerate(bool high_) external nonpayable

Regenerate the wall for a sideAccess restricted

This function is an escape hatch to trigger out of cycle regenerations and may be useful when doing migrations of Treasury funds

Parameters

NameTypeDescription
high_boolWhether to regenerate the high side or low side (true = high, false = low)

requestPermissions

function requestPermissions() external view returns (struct Permissions[] requests)

Function called by kernel to set module function permissions.

Returns

NameTypeDescription
requestsPermissions[]- Array of keycodes and function selectors for requested permissions.

reserve

function reserve() external view returns (contract ERC20)

Reserve token contract

Returns

NameTypeDescription
_0contract ERC20undefined

reserveDecimals

function reserveDecimals() external view returns (uint8)

Returns

NameTypeDescription
_0uint8undefined

setBondContracts

function setBondContracts(contract IBondSDA auctioneer_, contract IBondCallback callback_) external nonpayable

Set the contracts that the Operator deploys bond markets with.Access restricted

Parameters

NameTypeDescription
auctioneer_contract IBondSDA- Address of the bond auctioneer to use.
callback_contract IBondCallback- Address of the callback to use.

setCushionFactor

function setCushionFactor(uint32 cushionFactor_) external nonpayable

Set the cushion factorAccess restricted

Parameters

NameTypeDescription
cushionFactor_uint32- Percent of wall capacity that the operator will deploy in the cushion, assumes 2 decimals (i.e. 1000 = 10%)

setCushionParams

function setCushionParams(uint32 duration_, uint32 debtBuffer_, uint32 depositInterval_) external nonpayable

Set the parameters used to deploy cushion bond marketsAccess restricted

Parameters

NameTypeDescription
duration_uint32- Duration of cushion bond markets in seconds
debtBuffer_uint32- Percentage over the initial debt to allow the market to accumulate at any one time. Percent with 3 decimals, e.g. 1_000 = 1 %. See IBondSDA for more info.
depositInterval_uint32- Target frequency of deposits in seconds. Determines max payout of the bond market. See IBondSDA for more info.

setRegenParams

function setRegenParams(uint32 wait_, uint32 threshold_, uint32 observe_) external nonpayable

Set the wall regeneration parametersAccess restricted

We must see Threshold number of price points that meet our criteria within the last Observe number of price points to regenerate a wall.

Parameters

NameTypeDescription
wait_uint32- Minimum duration to wait to reinstate a wall in seconds
threshold_uint32- Number of price points on other side of moving average to reinstate a wall
observe_uint32- Number of price points to observe to determine regeneration

setReserveFactor

function setReserveFactor(uint32 reserveFactor_) external nonpayable

Set the reserve factorAccess restricted

Parameters

NameTypeDescription
reserveFactor_uint32- Percent of treasury reserves to deploy as capacity for market operations, assumes 2 decimals (i.e. 1000 = 10%)

setSpreads

function setSpreads(uint256 cushionSpread_, uint256 wallSpread_) external nonpayable

Set the wall and cushion spreadsAccess restricted

Interface for externally setting these values on the RANGE module

Parameters

NameTypeDescription
cushionSpread_uint256- Percent spread to set the cushions at above/below the moving average, assumes 2 decimals (i.e. 1000 = 10%)
wallSpread_uint256- Percent spread to set the walls at above/below the moving average, assumes 2 decimals (i.e. 1000 = 10%)

setThresholdFactor

function setThresholdFactor(uint256 thresholdFactor_) external nonpayable

Set the threshold factor for when a wall is considered "down"Access restricted

Interface for externally setting this value on the RANGE module

Parameters

NameTypeDescription
thresholdFactor_uint256- Percent of capacity that the wall should close below, assumes 2 decimals (i.e. 1000 = 10%)

status

function status() external view returns (struct IOperator.Status)

Returns the status variable of the Operator as a Status struct

Returns

NameTypeDescription
_0IOperator.Statusundefined

swap

function swap(contract ERC20 tokenIn_, uint256 amountIn_, uint256 minAmountOut_) external nonpayable returns (uint256 amountOut)

Swap at the current wall prices

Parameters

NameTypeDescription
tokenIn_contract ERC20- Token to swap into the wall - OHM: swap at the low wall price for Reserve - Reserve: swap at the high wall price for OHM
amountIn_uint256- Amount of tokenIn to swap
minAmountOut_uint256- Minimum amount of opposite token to receive

Returns

NameTypeDescription
amountOutuint256- Amount of opposite token received

Events

CushionFactorChanged

event CushionFactorChanged(uint32 cushionFactor_)

Parameters

NameTypeDescription
cushionFactor_uint32undefined

CushionParamsChanged

event CushionParamsChanged(uint32 duration_, uint32 debtBuffer_, uint32 depositInterval_)

Parameters

NameTypeDescription
duration_uint32undefined
debtBuffer_uint32undefined
depositInterval_uint32undefined

RegenParamsChanged

event RegenParamsChanged(uint32 wait_, uint32 threshold_, uint32 observe_)

Parameters

NameTypeDescription
wait_uint32undefined
threshold_uint32undefined
observe_uint32undefined

ReserveFactorChanged

event ReserveFactorChanged(uint32 reserveFactor_)

Parameters

NameTypeDescription
reserveFactor_uint32undefined

Swap

event Swap(contract ERC20 indexed tokenIn_, contract ERC20 indexed tokenOut_, uint256 amountIn_, uint256 amountOut_)

Parameters

NameTypeDescription
tokenIn_ indexedcontract ERC20undefined
tokenOut_ indexedcontract ERC20undefined
amountIn_uint256undefined
amountOut_uint256undefined

Errors

KernelAdapter_OnlyKernel

error KernelAdapter_OnlyKernel(address caller_)

Parameters

NameTypeDescription
caller_addressundefined

Operator_AlreadyInitialized

error Operator_AlreadyInitialized()

Operator_AmountLessThanMinimum

error Operator_AmountLessThanMinimum(uint256 amountOut, uint256 minAmountOut)

Parameters

NameTypeDescription
amountOutuint256undefined
minAmountOutuint256undefined

Operator_Inactive

error Operator_Inactive()

Operator_InsufficientCapacity

error Operator_InsufficientCapacity()

Operator_InvalidParams

error Operator_InvalidParams()

Operator_NotInitialized

error Operator_NotInitialized()

Operator_WallDown

error Operator_WallDown()

Policy_ModuleDoesNotExist

error Policy_ModuleDoesNotExist(Keycode keycode_)

Parameters

NameTypeDescription
keycode_Keycodeundefined