Skip to main content

YieldRepurchaseFacility

Git Source

Inherits: IYieldRepo, Policy, RolesConsumer

the Yield Repurchase Facility (Yield Repo) contract pulls a derived amount of yield from the Olympus treasury each week and uses it, along with the backing of previously purchased OHM, to purchase OHM off the market using a Bond Protocol SDA market.

Constants​

sReserve​

ERC4626 public immutable sReserve;

reserve​

ERC20 public immutable reserve;

_reserveDecimals​

uint8 internal immutable _reserveDecimals;

ohm​

ERC20 public immutable ohm;

_ohmDecimals​

uint8 internal immutable _ohmDecimals;

teller​

address public immutable teller;

auctioneer​

IBondSDA public immutable auctioneer;

epochLength​

uint48 public constant epochLength = 21;

backingPerToken​

uint256 public constant backingPerToken = 1133 * 1e7;

State Variables​

_oracleDecimals​

uint8 internal _oracleDecimals;

TRSRY​

TRSRYv1 public TRSRY;

PRICE​

PRICEv1 public PRICE;

CHREG​

CHREGv1 public CHREG;

epoch​

========== VIEWS ========== //

Returns the current epoch

uint48 public epoch;

Returns

NameTypeDescription
<none>uint48

nextYield​

uint256 public nextYield;

lastReserveBalance​

uint256 public lastReserveBalance;

lastConversionRate​

uint256 public lastConversionRate;

isShutdown​

Returns whether the contract is shutdown

bool public isShutdown;

Returns

NameTypeDescription
<none>bool

Functions​

constructor​

constructor(
Kernel kernel_,
address ohm_,
address sReserve_,
address teller_,
address auctioneer_
) Policy(kernel_);

Parameters

NameTypeDescription
kernel_Kernel
ohm_address
sReserve_address
teller_address
auctioneer_address

initialize​

function initialize(
uint256 initialReserveBalance,
uint256 initialConversionRate,
uint256 initialYield
) external onlyRole("loop_daddy");

Parameters

NameTypeDescription
initialReserveBalanceuint256
initialConversionRateuint256
initialYielduint256

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[]- Array of keycodes and function selectors for requested permissions.

VERSION​

Returns the version of the policy.

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

Returns

NameTypeDescription
majoruint8The major version of the policy.
minoruint8The minor version of the policy.

endEpoch​

create a new bond market at the end of the day with some portion of remaining funds

function endEpoch() public override onlyRole("heart");

adjustNextYield​

allow manager to increase (by maximum 10%) or decrease yield for week if contract is inaccurate

function adjustNextYield(uint256 newNextYield) external onlyRole("loop_daddy");

Parameters

NameTypeDescription
newNextYielduint256to fund

shutdown​

retire contract by burning ohm balance and transferring tokens to treasury

function shutdown(ERC20[] memory tokensToTransfer) external onlyRole("loop_daddy");

Parameters

NameTypeDescription
tokensToTransferERC20[]list of tokens to transfer back to treasury (i.e. reserves)

_createMarket​

create bond protocol market with given budget

function _createMarket(uint256 bidAmount) internal;

Parameters

NameTypeDescription
bidAmountuint256amount of reserve to fund bond market with

_getBackingForPurchased​

internal function to burn ohm and retrieve backing

function _getBackingForPurchased() internal;

_withdraw​

internal function to withdraw sReserve from treasury

note amount given is in reserve, not sReserve

function _withdraw(uint256 amount) internal;

Parameters

NameTypeDescription
amountuint256an amount to withdraw, in reserve

_getPriceDecimals​

Helper function to calculate number of price decimals based on the value returned from the price feed.

function _getPriceDecimals(uint256 price_) internal view returns (int8);

Parameters

NameTypeDescription
price_uint256The price to calculate the number of decimals for

Returns

NameTypeDescription
<none>int8The number of decimals

getReserveBalance​

fetch combined sReserve balance of active clearinghouses and treasury, in reserve

function getReserveBalance() public view override returns (uint256 balance);

Returns

NameTypeDescription
balanceuint256

getNextYield​

compute yield for the next week

function getNextYield() public view override returns (uint256 yield);

Returns

NameTypeDescription
yielduint256

getOhmBalanceAndBacking​

compute backing for ohm balance

function getOhmBalanceAndBacking()
public
view
override
returns (uint256 balance, uint256 backing);

Returns

NameTypeDescription
balanceuint256
backinguint256

Events​

RepoMarket​

event RepoMarket(uint256 marketId, uint256 bidAmount);

Parameters

NameTypeDescription
marketIduint256
bidAmountuint256

NextYieldSet​

event NextYieldSet(uint256 nextYield);

Parameters

NameTypeDescription
nextYielduint256

Shutdown​

event Shutdown();