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
Name | Type | Description |
---|---|---|
_0 | uint32 | undefined |
ONE_PERCENT
function ONE_PERCENT() external view returns (uint32)
Returns
Name | Type | Description |
---|---|---|
_0 | uint32 | undefined |
ROLES
function ROLES() external view returns (contract ROLESv1)
Returns
Name | Type | Description |
---|---|---|
_0 | contract ROLESv1 | undefined |
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
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
auctioneer
function auctioneer() external view returns (contract IBondSDA)
Auctioneer contract used for cushion bond market deployments
Returns
Name | Type | Description |
---|---|---|
_0 | contract IBondSDA | undefined |
bondPurchase
function bondPurchase(uint256 id_, uint256 amountOut_) external nonpayable
Records a bond purchase and updates capacity correctlyAccess restricted (BondCallback)
Parameters
Name | Type | Description |
---|---|---|
id_ | uint256 | ID of the bond market |
amountOut_ | uint256 | Amount of capacity expended |
callback
function callback() external view returns (contract IBondCallback)
Callback contract used for cushion bond market payouts
Returns
Name | Type | Description |
---|---|---|
_0 | contract IBondCallback | undefined |
changeKernel
function changeKernel(contract Kernel newKernel_) external nonpayable
Function used by kernel when migrating to a new kernel.
Parameters
Name | Type | Description |
---|---|---|
newKernel_ | contract Kernel | undefined |
config
function config() external view returns (struct IOperator.Config)
Returns the config variable of the Operator as a Config struct
Returns
Name | Type | Description |
---|---|---|
_0 | IOperator.Config | undefined |
configureDependencies
function configureDependencies() external nonpayable returns (Keycode[] dependencies)
Define module dependencies for this policy.
Returns
Name | Type | Description |
---|---|---|
dependencies | Keycode[] | - 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
Name | Type | Description |
---|---|---|
high_ | bool | Whether 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
Name | Type | Description |
---|---|---|
high_ | bool | - Whether to return the full capacity for the high or low wall |
Returns
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
getAmountOut
function getAmountOut(contract ERC20 tokenIn_, uint256 amountIn_) external view returns (uint256)
Returns the amount to be received from a swap
Parameters
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
_0 | uint256 | Amount 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
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
isActive
function isActive() external view returns (bool)
Easily accessible indicator for if a policy is activated or not.
Returns
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
kernel
function kernel() external view returns (contract Kernel)
Returns
Name | Type | Description |
---|---|---|
_0 | contract Kernel | undefined |
ohm
function ohm() external view returns (contract ERC20)
OHM token contract
Returns
Name | Type | Description |
---|---|---|
_0 | contract ERC20 | undefined |
ohmDecimals
function ohmDecimals() external view returns (uint8)
Returns
Name | Type | Description |
---|---|---|
_0 | uint8 | undefined |
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
Name | Type | Description |
---|---|---|
high_ | bool | Whether 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
Name | Type | Description |
---|---|---|
requests | Permissions[] | - Array of keycodes and function selectors for requested permissions. |
reserve
function reserve() external view returns (contract ERC20)
Reserve token contract
Returns
Name | Type | Description |
---|---|---|
_0 | contract ERC20 | undefined |
reserveDecimals
function reserveDecimals() external view returns (uint8)
Returns
Name | Type | Description |
---|---|---|
_0 | uint8 | undefined |
setBondContracts
function setBondContracts(contract IBondSDA auctioneer_, contract IBondCallback callback_) external nonpayable
Set the contracts that the Operator deploys bond markets with.Access restricted
Parameters
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
_0 | IOperator.Status | undefined |
swap
function swap(contract ERC20 tokenIn_, uint256 amountIn_, uint256 minAmountOut_) external nonpayable returns (uint256 amountOut)
Swap at the current wall prices
Parameters
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
amountOut | uint256 | - Amount of opposite token received |
Events
CushionFactorChanged
event CushionFactorChanged(uint32 cushionFactor_)
Parameters
Name | Type | Description |
---|---|---|
cushionFactor_ | uint32 | undefined |
CushionParamsChanged
event CushionParamsChanged(uint32 duration_, uint32 debtBuffer_, uint32 depositInterval_)
Parameters
Name | Type | Description |
---|---|---|
duration_ | uint32 | undefined |
debtBuffer_ | uint32 | undefined |
depositInterval_ | uint32 | undefined |
RegenParamsChanged
event RegenParamsChanged(uint32 wait_, uint32 threshold_, uint32 observe_)
Parameters
Name | Type | Description |
---|---|---|
wait_ | uint32 | undefined |
threshold_ | uint32 | undefined |
observe_ | uint32 | undefined |
ReserveFactorChanged
event ReserveFactorChanged(uint32 reserveFactor_)
Parameters
Name | Type | Description |
---|---|---|
reserveFactor_ | uint32 | undefined |
Swap
event Swap(contract ERC20 indexed tokenIn_, contract ERC20 indexed tokenOut_, uint256 amountIn_, uint256 amountOut_)
Parameters
Name | Type | Description |
---|---|---|
tokenIn_ indexed | contract ERC20 | undefined |
tokenOut_ indexed | contract ERC20 | undefined |
amountIn_ | uint256 | undefined |
amountOut_ | uint256 | undefined |
Errors
KernelAdapter_OnlyKernel
error KernelAdapter_OnlyKernel(address caller_)
Parameters
Name | Type | Description |
---|---|---|
caller_ | address | undefined |
Operator_AlreadyInitialized
error Operator_AlreadyInitialized()
Operator_AmountLessThanMinimum
error Operator_AmountLessThanMinimum(uint256 amountOut, uint256 minAmountOut)
Parameters
Name | Type | Description |
---|---|---|
amountOut | uint256 | undefined |
minAmountOut | uint256 | undefined |
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
Name | Type | Description |
---|---|---|
keycode_ | Keycode | undefined |