YieldRepurchaseFacility
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
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| <none> | bool |
Functions
constructor
constructor(
Kernel kernel_,
address ohm_,
address sReserve_,
address teller_,
address auctioneer_
) Policy(kernel_);
Parameters
| Name | Type | Description |
|---|---|---|
| kernel_ | Kernel | |
| ohm_ | address | |
| sReserve_ | address | |
| teller_ | address | |
| auctioneer_ | address |
initialize
function initialize(
uint256 initialReserveBalance,
uint256 initialConversionRate,
uint256 initialYield
) external onlyRole("loop_daddy");
Parameters
| Name | Type | Description |
|---|---|---|
| initialReserveBalance | uint256 | |
| initialConversionRate | uint256 | |
| initialYield | uint256 |
configureDependencies
Define module dependencies for this policy.
function configureDependencies() external override returns (Keycode[] memory dependencies);
Returns
| Name | Type | Description |
|---|---|---|
| dependencies | Keycode[] | - 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
| Name | Type | Description |
|---|---|---|
| permissions | Permissions[] | - 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
| Name | Type | Description |
|---|---|---|
| major | uint8 | The major version of the policy. |
| minor | uint8 | The 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
| Name | Type | Description |
|---|---|---|
| newNextYield | uint256 | to fund |
shutdown
retire contract by burning ohm balance and transferring tokens to treasury
function shutdown(ERC20[] memory tokensToTransfer) external onlyRole("loop_daddy");
Parameters
| Name | Type | Description |
|---|---|---|
| tokensToTransfer | ERC20[] | 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
| Name | Type | Description |
|---|---|---|
| bidAmount | uint256 | amount 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
| Name | Type | Description |
|---|---|---|
| amount | uint256 | an 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
| Name | Type | Description |
|---|---|---|
| price_ | uint256 | The price to calculate the number of decimals for |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | int8 | The number of decimals |
getReserveBalance
fetch combined sReserve balance of active clearinghouses and treasury, in reserve
function getReserveBalance() public view override returns (uint256 balance);
Returns
| Name | Type | Description |
|---|---|---|
| balance | uint256 |
getNextYield
compute yield for the next week
function getNextYield() public view override returns (uint256 yield);
Returns
| Name | Type | Description |
|---|---|---|
| yield | uint256 |
getOhmBalanceAndBacking
compute backing for ohm balance
function getOhmBalanceAndBacking()
public
view
override
returns (uint256 balance, uint256 backing);
Returns
| Name | Type | Description |
|---|---|---|
| balance | uint256 | |
| backing | uint256 |
Events
RepoMarket
event RepoMarket(uint256 marketId, uint256 bidAmount);
Parameters
| Name | Type | Description |
|---|---|---|
| marketId | uint256 | |
| bidAmount | uint256 |
NextYieldSet
event NextYieldSet(uint256 nextYield);
Parameters
| Name | Type | Description |
|---|---|---|
| nextYield | uint256 |
Shutdown
event Shutdown();