Skip to main content

Distributor

Git Source

Inherits: IDistributor, Policy, RolesConsumer

Import External Dependencies Import Local Dependencies Import external interfaces

State Variables

TRSRY

Modules

TRSRYv1 public TRSRY;

MINTR

MINTRv1 public MINTR;

ohm

Olympus contract dependencies

ERC20 private immutable ohm;

staking

IStaking public immutable staking;

pools

Policy state

address[] public pools;

rewardRate

uint256 public rewardRate;

bounty

uint256 public bounty;

unlockRebase

bool private unlockRebase;

DENOMINATOR

Constants

uint256 private constant DENOMINATOR = 1e9;

Functions

constructor

constructor(Kernel kernel_, address ohm_, address staking_, uint256 initialRate_) Policy(kernel_);

configureDependencies

Define module dependencies for this policy.

function configureDependencies() external override returns (Keycode[] memory dependencies);

Returns

NameTypeDescription
dependenciesKeycode[]- Keycode array of module dependencies.

requestPermissions

Function called by kernel to set module function permissions.

function requestPermissions() external view override returns (Permissions[] memory permissions);

Returns

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

triggerRebase

Trigger rebases via distributor. There is an error in Staking's stake function which pulls forward part of the rebase for the next epoch. This path triggers a rebase by calling unstake (which does not have the issue). The patch also restricts distribute to only be able to be called from a tx originating in this function.

function triggerRebase() external;

distribute

Send the epoch's reward to the staking contract, and mint rewards to Uniswap V2 pools. This removes opportunity cost for liquidity providers by sending rebase rewards directly into the liquidity pool. NOTE: This does not add additional emissions (user could be staked instead and get the same tokens).

function distribute() external;

retrieveBounty

Mints the bounty (if > 0) to the staking contract for distribution.

function retrieveBounty() external returns (uint256);

Returns

NameTypeDescription
<none>uint256uint256 The amount of OHM minted as a bounty.

nextRewardFor

Returns the next reward for the given address based on their OHM balance.

function nextRewardFor(address who_) public view returns (uint256);

Parameters

NameTypeDescription
who_addressThe address to get the next reward for.

Returns

NameTypeDescription
<none>uint256uint256 The next reward for the given address.

setBounty

Adjusts the bounty

This function is only available to an authorized user.

function setBounty(uint256 bounty_) external onlyRole("distributor_admin");

Parameters

NameTypeDescription
bounty_uint256The new bounty amount in OHM (9 decimals).

setPools

Sets the Uniswap V2 pools to be minted into

This function is only available to an authorized user.

function setPools(address[] calldata pools_) external onlyRole("distributor_admin");

Parameters

NameTypeDescription
pools_address[]The array of Uniswap V2 pools.

removePool

Removes a liquidity pool from the list of pools to be minted into

This function is only available to an authorized user.

function removePool(uint256 index_, address pool_) external onlyRole("distributor_admin");

Parameters

NameTypeDescription
index_uint256The index in the pools array of the liquidity pool to remove.
pool_addressThe address of the liquidity pool to remove.

addPool

Adds a liquidity pool to the list of pools to be minted into

function addPool(uint256 index_, address pool_) external onlyRole("distributor_admin");

Parameters

NameTypeDescription
index_uint256The index in the pools array to add the liquidity pool to.
pool_addressThe address of the liquidity pool to add.

setRewardRate

Sets the new OHM reward rate to mint and distribute per epoch

function setRewardRate(uint256 newRewardRate_) external onlyRole("distributor_admin");

Parameters

NameTypeDescription
newRewardRate_uint256The new rate to set (9 decimals, i.e. 10_000_000 / 1_000_000_000 = 1%)

Errors

Distributor_InvalidConstruction

error Distributor_InvalidConstruction();

Distributor_SanityCheck

error Distributor_SanityCheck();

Distributor_AdjustmentLimit

error Distributor_AdjustmentLimit();

Distributor_AdjustmentUnderflow

error Distributor_AdjustmentUnderflow();

Distributor_NotPermissioned

error Distributor_NotPermissioned();