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.

State Variables​

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

_oracleDecimals​

uint8 internal _oracleDecimals

TRSRY​

TRSRYv1 public TRSRY

PRICE​

PRICEv1 public PRICE

CHREG​

CHREGv1 public CHREG

teller​

address public immutable teller

auctioneer​

IBondSDA public immutable auctioneer

epoch​

uint48 public epoch

nextYield​

uint256 public nextYield

lastReserveBalance​

uint256 public lastReserveBalance

lastConversionRate​

uint256 public lastConversionRate

isShutdown​

bool public isShutdown

epochLength​

uint48 public constant epochLength = 21

backingPerToken​

uint256 public constant backingPerToken = 1133 * 1e7

Functions​

constructor​

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

initialize​

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

configureDependencies​

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

requestPermissions​

function requestPermissions() external view override returns (Permissions[] memory 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);

getNextYield​

compute yield for the next week

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

getOhmBalanceAndBacking​

compute backing for ohm balance

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

Events​

RepoMarket​

event RepoMarket(uint256 marketId, uint256 bidAmount);

NextYieldSet​

event NextYieldSet(uint256 nextYield);

Shutdown​

event Shutdown();