Skip to main content

RANGEv2

Git Source

Inherits: Module

State Variables

_range

Range internal _range;

thresholdFactor

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).

uint256 public thresholdFactor;

ohm

OHM token contract address

ERC20 public ohm;

reserve

Reserve token contract address

ERC20 public reserve;

Functions

updateCapacity

Update the capacity for a side of the range.

Access restricted to activated policies.

function updateCapacity(bool high_, uint256 capacity_) external virtual;

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).

updatePrices

Update the prices for the low and high sides.

Access restricted to activated policies.

function updatePrices(uint256 target_) external virtual;

Parameters

NameTypeDescription
target_uint256- Target price to set range prices from.

regenerate

Regenerate a side of the range to a specific capacity.

Access restricted to activated policies.

function regenerate(bool high_, uint256 capacity_) external virtual;

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).

updateMarket

Update the market ID (cushion) for a side of the range.

Access restricted to activated policies.

function updateMarket(bool high_, uint256 market_, uint256 marketCapacity_) external virtual;

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).

setSpreads

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.

function setSpreads(bool high_, uint256 cushionSpread_, uint256 wallSpread_) external virtual;

Parameters

NameTypeDescription
high_bool- Specifies the side of the range to set spreads for (true = high side, false = low side).
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

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.

function setThresholdFactor(uint256 thresholdFactor_) external virtual;

Parameters

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

range

Get the full Range data in a struct.

function range() external view virtual returns (Range memory);

capacity

Get the capacity for a side of the range.

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

Parameters

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

active

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

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

Parameters

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

price

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

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

Parameters

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

spread

Get the spread for the wall or cushion band.

function spread(bool high_, bool wall_) external view virtual returns (uint256);

Parameters

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

market

Get the market ID for a side of the range.

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

Parameters

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

lastActive

Get the timestamp when the range was last active.

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

Parameters

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

Events

WallUp

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

WallDown

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

CushionUp

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

CushionDown

event CushionDown(bool high_, uint256 timestamp_);

PricesChanged

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

SpreadsChanged

event SpreadsChanged(bool high_, uint256 cushionSpread_, uint256 wallSpread_);

ThresholdFactorChanged

event ThresholdFactorChanged(uint256 thresholdFactor_);

Errors

RANGE_InvalidParams

error RANGE_InvalidParams();

Structs

Line

struct Line {
uint256 price;
uint256 spread;
}

Side

struct Side {
bool active;
uint48 lastActive;
uint256 capacity;
uint256 threshold;
uint256 market;
Line cushion;
Line wall;
}

Range

struct Range {
Side low;
Side high;
}