Skip to main content

RANGEv1

Methods

INIT

function INIT() external nonpayable

Initialization function for the module

This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.

KEYCODE

function KEYCODE() external pure returns (Keycode)

5 byte identifier for a module.

Returns

NameTypeDescription
_0Keycodeundefined

VERSION

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

Returns which semantic version of a module is being implemented.

Returns

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

active

function active(bool high_) external view returns (bool)

Get the status of a side of the range (whether it is active or not).

Parameters

NameTypeDescription
high_bool- Specifies the side of the range to get status for (true = high side, false = low side).

Returns

NameTypeDescription
_0boolundefined

capacity

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

Get the capacity for a side of the range.

Parameters

NameTypeDescription
high_bool- Specifies the side of the range to get capacity for (true = high side, false = low side).

Returns

NameTypeDescription
_0uint256undefined

changeKernel

function changeKernel(contract Kernel newKernel_) external nonpayable

Function used by kernel when migrating to a new kernel.

Parameters

NameTypeDescription
newKernel_contract Kernelundefined

kernel

function kernel() external view returns (contract Kernel)

Returns

NameTypeDescription
_0contract Kernelundefined

lastActive

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

Get the timestamp when the range was last active.

Parameters

NameTypeDescription
high_bool- Specifies the side of the range to get timestamp for (true = high side, false = low side).

Returns

NameTypeDescription
_0uint256undefined

market

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

Get the market ID for a side of the range.

Parameters

NameTypeDescription
high_bool- Specifies the side of the range to get market for (true = high side, false = low side).

Returns

NameTypeDescription
_0uint256undefined

ohm

function ohm() external view returns (contract ERC20)

OHM token contract address

Returns

NameTypeDescription
_0contract ERC20undefined

price

function price(bool wall_, bool high_) external view returns (uint256)

Get the price for the wall or cushion for a side of the range.

Parameters

NameTypeDescription
wall_bool- Specifies the band to get the price for (true = wall, false = cushion).
high_bool- Specifies the side of the range to get the price for (true = high side, false = low side).

Returns

NameTypeDescription
_0uint256undefined

range

function range() external view returns (struct RANGEv1.Range)

Get the full Range data in a struct.

Returns

NameTypeDescription
_0RANGEv1.Rangeundefined

regenerate

function regenerate(bool high_, uint256 capacity_) external nonpayable

Regenerate a side of the range to a specific capacity.Access restricted to activated policies.

Parameters

NameTypeDescription
high_bool- Specifies the side of the range to regenerate (true = high side, false = low side).
capacity_uint256- Amount to set the capacity to (OHM tokens for high side, Reserve tokens for low side).

reserve

function reserve() external view returns (contract ERC20)

Reserve token contract address

Returns

NameTypeDescription
_0contract ERC20undefined

setSpreads

function setSpreads(uint256 cushionSpread_, uint256 wallSpread_) external nonpayable

Set the wall and cushion spreads.Access restricted to activated policies.

The new spreads will not go into effect until the next time updatePrices() is called.

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 to activated policies.

The new threshold factor will not go into effect until the next time regenerate() is called for each side of the wall.

Parameters

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

spread

function spread(bool wall_) external view returns (uint256)

Get the spread for the wall or cushion band.

Parameters

NameTypeDescription
wall_bool- Specifies the band to get the spread for (true = wall, false = cushion).

Returns

NameTypeDescription
_0uint256undefined

thresholdFactor

function thresholdFactor() external view returns (uint256)

Threshold factor for the change, a percent in 2 decimals (i.e. 1000 = 10%). Determines how much of the capacity must be spent before the side is taken down.

A threshold is required so that a wall is not "active" with a capacity near zero, but unable to be depleted practically (dust).

Returns

NameTypeDescription
_0uint256undefined

updateCapacity

function updateCapacity(bool high_, uint256 capacity_) external nonpayable

Update the capacity for a side of the range.Access restricted to activated policies.

Parameters

NameTypeDescription
high_bool- Specifies the side of the range to update capacity for (true = high side, false = low side).
capacity_uint256- Amount to set the capacity to (OHM tokens for high side, Reserve tokens for low side).

updateMarket

function updateMarket(bool high_, uint256 market_, uint256 marketCapacity_) external nonpayable

Update the market ID (cushion) for a side of the range.Access restricted to activated policies.

Parameters

NameTypeDescription
high_bool- Specifies the side of the range to update market for (true = high side, false = low side).
market_uint256- Market ID to set for the side.
marketCapacity_uint256- Amount to set the last market capacity to (OHM tokens for high side, Reserve tokens for low side).

updatePrices

function updatePrices(uint256 movingAverage_) external nonpayable

Update the prices for the low and high sides.Access restricted to activated policies.

Parameters

NameTypeDescription
movingAverage_uint256- Current moving average price to set range prices from.

Events

CushionDown

event CushionDown(bool high_, uint256 timestamp_)

Parameters

NameTypeDescription
high_boolundefined
timestamp_uint256undefined

CushionUp

event CushionUp(bool high_, uint256 timestamp_, uint256 capacity_)

Parameters

NameTypeDescription
high_boolundefined
timestamp_uint256undefined
capacity_uint256undefined

PricesChanged

event PricesChanged(uint256 wallLowPrice_, uint256 cushionLowPrice_, uint256 cushionHighPrice_, uint256 wallHighPrice_)

Parameters

NameTypeDescription
wallLowPrice_uint256undefined
cushionLowPrice_uint256undefined
cushionHighPrice_uint256undefined
wallHighPrice_uint256undefined

SpreadsChanged

event SpreadsChanged(uint256 cushionSpread_, uint256 wallSpread_)

Parameters

NameTypeDescription
cushionSpread_uint256undefined
wallSpread_uint256undefined

ThresholdFactorChanged

event ThresholdFactorChanged(uint256 thresholdFactor_)

Parameters

NameTypeDescription
thresholdFactor_uint256undefined

WallDown

event WallDown(bool high_, uint256 timestamp_, uint256 capacity_)

Parameters

NameTypeDescription
high_boolundefined
timestamp_uint256undefined
capacity_uint256undefined

WallUp

event WallUp(bool high_, uint256 timestamp_, uint256 capacity_)

Parameters

NameTypeDescription
high_boolundefined
timestamp_uint256undefined
capacity_uint256undefined

Errors

KernelAdapter_OnlyKernel

error KernelAdapter_OnlyKernel(address caller_)

Parameters

NameTypeDescription
caller_addressundefined

Module_PolicyNotPermitted

error Module_PolicyNotPermitted(address policy_)

Parameters

NameTypeDescription
policy_addressundefined

RANGE_InvalidParams

error RANGE_InvalidParams()