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