The RAI protocol has a number of components that need to be called periodically to maintain the system’s health. In order to be fully autonomous, the aforementioned components reward addresses that call them using the rewards module. Rewards are paid in RAI offered by the Stability Fee Treasury.
Calls to these components need to be profitable (pay for the cost of gas and reward the caller) or else the system can be at risk of not having crucial updates performed. RAI rewards for each component are updated periodically using “reward adjuster” contracts. The reward adjuster contracts take into consideration the latest ETH price, the gas cost of calling each function and a gas price.
Currently, a fixed gas price is used for all reward recalculations due to the absence of a proper gas TWAP feed. This method could/should be replaced in the future once a reliable and inexpensive gas price oracle becomes available on Ethereum L1.
Bad debt (confiscated by liquidations) is pushed into a debt queue and sits there for a predetermined delay to allow for collateral auctions to settle. Debt can be popped from the queue after the delay for each debt block passes.
This function can only be called from GEB_RRFM_SETTER. This function is critical to the system, as it updates the redemption rate.
This function is called by MEDIANIZER_RAI whenever an external call to
This function is called by MEDIANIZER_ETH whenever an external call to
updateResult()is made. It updates the ETH price.
This is a rewards relayer for calls made to FEED_SECURITY_MODULE_ETH, function
Updates the collateral debt ceiling for ETH-A.
onAuctionSystemCoinLimit, based on current global debt amount.
Updates every Safe’s debt floor to ensure liquidations are profitable.
Updates the surplus buffer based on latest global debt.
initialDebtAuctionMintedTokens. The contract adjusts both parameters according to changes in price on both RAI and FLX.
surplusAuctionAmountToSellin the Accounting Engine.
Rewards paying contracts inherit one of several implementations outlined below, or rely on an external contract that pays function callers rewards relayer. All implementations live in this repository. Several different flavors of reimbursement contracts exist, including different setups, that can be inherited or can be deployed separately. Reward contracts can be put in two buckets:
Fixed Rewards: pay a fixed RAI reward to function callers (pre computed cost of call + a margin on top, currently set to +30%). Only used on
- Increasing Rewards: pay an increasing RAI reward to function callers, all are currently set to start at the gas cost of the call, and increase to 200% of the cost.
In order to ensure RAI rewards for calling different functions are adjusted periodically and do not become unprofitable due to ETH price movements or high gas prices, there’s a set of contracts called “reward adjusters” which are meant to adjust those rewards. Adjusters can be called by anyone although they do not give out RAI rewards by themselves.
When a reward adjuster is called, it will also call the Treasury Param Adjuster contract (detailed in a section below).
When adding a reward paying contract in the reward bundlers, it is important to set it up in the Treasury Core Parameter Adjuster as well. Templates for adding new reward paying contracts in a reward bundler and the treasury param adjuster are available in the Dao Governance Actions repository.
There are two rewards adjusters currently in production:
Adjusts rewards for fixed rewards contracts (currently only the Debt Popper Rewards). When called, it will adjust the RAI reward offered by each contract it has whitelisted. It will then adjust each whitelisted contract’s allowance in the Stability Fee Treasury and then call the Treasury Core Param Adjuster.
Has similar logic to the Fixed version but it is used for contracts that offer an increasing RAI reward. It will set a minimum and maximum reward in each of its whitelisted contracts, an allowance to pull RAI from the SF Treasury and it will then call the Treasury Param Adjuster (passing the max reward in the case of each contract as a parameter).
This contract is called by rewards adjusters on every adjustment. It is meant to keep track of the maximum reward offered to each contract.
setNewTreasuryParameters()is public and it can be called by anyone. It sets
pullFundsMinThresholdon the Stability Fee Treasury, ensuring funds are available to pay for all calls that grant a reward to the caller.
treasuryCapacity: maximum amount of RAI that can be kept in the treasury at any time; ensures the treasury doesn’t keep too many funds which can instead be used in the surplus buffer
minimumFundsRequired: minimum amount of RAI that should be kept in the treasury
pullFundsMinThreshold: minimum amount of RAI that must be in the treasury so that someone can call
totalAllowancein the Stability Fee Treasury to
type(uint).max. The only requirement for an address to have its
totalAllowancereset is that it has a non null