Inflation
#
Source | Inherits from IInflationGenesis, GovernedAndFlareDaemonized, IFlareDaemonize, AddressUpdatable
Recognizes, authorizes, mints, and funds native tokens to Flare services that are rewardable through inflation.
See the technical specification.
Events#
GovernanceCallTimelocked
#
event GovernanceCallTimelocked(
bytes4 selector,
uint256 allowedAfterTimestamp,
bytes encodedCall
)
Emitted when a new governance
call has been recorded and is now waiting for the time lock to expire.
GovernanceInitialised
#
event GovernanceInitialised(
address initialGovernance
)
Emitted when the governance
address is initialized.
This address will be used until production mode is entered (see GovernedProductionModeEntered
).
At that point the governance
address is taken from GovernanceSettings
.
GovernedProductionModeEntered
#
event GovernedProductionModeEntered(
address governanceSettings
)
Emitted when governance
is enabled and the governance
address cannot be changed anymore
(only through a network fork).
InflationAllocationSet
#
event InflationAllocationSet(
contract IIInflationAllocation inflationAllocation
)
InflationAuthorized
#
event InflationAuthorized(
uint256 amountWei
)
InflationRewardServiceDailyAuthorizedInflationComputed
#
event InflationRewardServiceDailyAuthorizedInflationComputed(
contract IIInflationReceiver inflationReceiver,
uint256 amountWei
)
InflationRewardServiceTopupComputed
#
event InflationRewardServiceTopupComputed(
contract IIInflationReceiver inflationReceiver,
uint256 amountWei
)
InflationRewardServiceTopupRequestReceived
#
event InflationRewardServiceTopupRequestReceived(
contract IIInflationReceiver inflationReceiver,
uint256 amountWei
)
MintingReceived
#
event MintingReceived(
uint256 amountWei,
uint256 selfDestructAmountWei
)
NewTimeSlotInitialized
#
event NewTimeSlotInitialized(
uint256 startTimeStamp,
uint256 endTimeStamp,
uint256 inflatableSupplyWei,
uint256 recognizedInflationWei
)
SupplySet
#
event SupplySet(
contract IISupply oldSupply,
contract IISupply newSupply
)
TimelockedGovernanceCallCanceled
#
event TimelockedGovernanceCallCanceled(
bytes4 selector,
uint256 timestamp
)
Emitted when a timelocked governance
call is canceled before execution.
TimelockedGovernanceCallExecuted
#
event TimelockedGovernanceCallExecuted(
bytes4 selector,
uint256 timestamp
)
Emitted when a timelocked governance
call is executed.
TopupConfigurationSet
#
event TopupConfigurationSet(
struct TopupConfiguration topupConfiguration
)
Functions#
cancelGovernanceCall
#
function cancelGovernanceCall(
bytes4 _selector
) external;
Cancel a timelocked governance
call before it has been executed.
Only governance
can call this method.
Parameters | Type | Description |
---|---|---|
_selector |
bytes4 |
The method selector. |
constructor
#
constructor(
address _governance,
contract FlareDaemon _flareDaemon,
address _addressUpdater,
uint256 _rewardEpochStartTs
) public;
constructor
#
constructor(
address _governance,
contract FlareDaemon _flareDaemon
) public;
constructor
#
constructor(
address _governance
) public;
Parameters | Type | Description |
---|---|---|
_governance |
address |
Governance contract. Must not be zero. |
daemonize
#
function daemonize(
) external returns (
bool);
Implement this function to receive a trigger from the FlareDaemon
.
The trigger method is called by the validator right at the end of block state transition.
Returns | Type | Description |
---|---|---|
[0] | bool |
bool Whether the contract is still active after the call. Currently unused. |
executeGovernanceCall
#
function executeGovernanceCall(
bytes4 _selector
) external;
Execute the timelocked governance
calls once the timelock period expires.
Only executor can call this method.
Parameters | Type | Description |
---|---|---|
_selector |
bytes4 |
The method selector (only one timelocked call per method is stored). |
getAddressUpdater
#
function getAddressUpdater(
) public view returns (
address _addressUpdater);
Returns the configured address updater.
Returns | Type | Description |
---|---|---|
_addressUpdater |
address |
The AddresUpdater contract that can update our contract address list, as a response to a governance call. |
getContractName
#
function getContractName(
) external pure returns (
string);
Implement this function to allow updating daemonized contracts through the AddressUpdater
.
Returns | Type | Description |
---|---|---|
[0] | string |
string Contract name. |
getCurrentTimeSlot
#
function getCurrentTimeSlot(
) external view returns (
struct InflationTimeSlots.InflationTimeSlot);
Return the current time slot.
Expect library to revert if there is no current time slot.
Returns | Type | Description |
---|---|---|
[0] | struct InflationTimeSlots.InflationTimeSlot |
The inflation time slot state of the current time slot. |
getCurrentTimeSlotId
#
function getCurrentTimeSlotId(
) external view returns (
uint256);
Return current time slot id.
Expect library to revert if there is no current time slot.
Returns | Type | Description |
---|---|---|
[0] | uint256 |
Id of the current time slot. |
getNextExpectedTopupTs
#
function getNextExpectedTopupTs(
) external view returns (
uint256 _nextTopupTs);
Returns next expected inflation topup time stamp which is also inflation authorization time. The returned time from this API is actually the time of the block in which the topup is requested. The Actual topup will take place in the next block. Expected diff is up to a few seconds (max is less then a minute).
getRewardServices
#
function getRewardServices(
) external view returns (
struct InflationRewardServices.RewardService[]);
Return the structure of reward services.
Returns | Type | Description |
---|---|---|
[0] | struct InflationRewardServices.RewardService[] |
Reward services structure. |
getTimeSlot
#
function getTimeSlot(
uint256 _index
) external view returns (
struct InflationTimeSlots.InflationTimeSlot);
Given an index, return the time slot at that index.
Expect library to revert if index not found.
Parameters | Type | Description |
---|---|---|
_index |
uint256 |
The index of the time slot to fetch. |
Returns | Type | Description |
---|---|---|
[0] | struct InflationTimeSlots.InflationTimeSlot |
The inflation time slot state. |
getTopupConfiguration
#
function getTopupConfiguration(
contract IIInflationReceiver _inflationReceiver
) external view returns (
struct TopupConfiguration _topupConfiguration);
Given an inflation receiver, get the topup configuration.
Parameters | Type | Description |
---|---|---|
_inflationReceiver |
contract IIInflationReceiver |
The reward service. |
Returns | Type | Description |
---|---|---|
_topupConfiguration |
struct TopupConfiguration |
The configuration of how the topup requests are calculated for a given reward service. |
getTotals
#
function getTotals(
) external view returns (
uint256 _totalAuthorizedInflationWei,
uint256 _totalInflationTopupRequestedWei,
uint256 _totalInflationTopupDistributedWei,
uint256 _totalRecognizedInflationWei);
Get a tuple of totals across inflation time slots.
Returns | Type | Description |
---|---|---|
_totalAuthorizedInflationWei |
uint256 |
Total inflation authorized to be mintable |
_totalInflationTopupRequestedWei |
uint256 |
Total inflation requested to be topped up for rewarding |
_totalInflationTopupDistributedWei |
uint256 |
Total inflation received for funding reward services |
_totalRecognizedInflationWei |
uint256 |
Total inflation recognized for rewarding |
governance
#
function governance(
) public view returns (
address);
Returns the current effective governance
address.
receiveMinting
#
function receiveMinting(
) external payable;
Receive newly minted native tokens from the FlareDaemon
.
Assume that the received amount will be >= last topup requested across all services. If there is not enough balance sent to cover the topup request, expect the library method to revert. Also assume that any received balance greater than the calculated topup request came from self-destructor sending a balance to this contract.
setInitialData
#
function setInitialData(
contract IIInflationV1 _oldInflation,
uint256 _noOfAnnums
) external;
Used to copy data from old inflation contract.
Only governance
can call.
Parameters | Type | Description |
---|---|---|
_oldInflation |
contract IIInflationV1 |
Address of old inflation. |
_noOfAnnums |
uint256 |
Number of annums in old inflation. |
setPreInflationCalculation
#
function setPreInflationCalculation(
contract IIPreInflationCalculation _preInflationCalculation
) external;
Set contract that should be triggered before new inflation is calculated (it can be address(0))
Only governance
can call.
setTopupConfiguration
#
function setTopupConfiguration(
contract IIInflationReceiver _inflationReceiver,
enum TopupType _topupType,
uint256 _topupFactorX100
) external;
Set the topup configuration for a reward service.
Only governance
can call.
Topup factor, if _topupType == FACTOROFDAILYAUTHORIZED, must be greater than 100.
Parameters | Type | Description |
---|---|---|
_inflationReceiver |
contract IIInflationReceiver |
The reward service to receive the inflation funds for distribution. |
_topupType |
enum TopupType |
The type to signal how the topup amounts are to be calculated. FACTOROFDAILYAUTHORIZED = Use a factor of last daily authorized to set a target balance for a reward service to maintain as a reserve for claiming. ALLAUTHORIZED = Mint enough native tokens to topup reward service contract to hold all authorized but unrequested rewards. |
_topupFactorX100 |
uint256 |
If _topupType == FACTOROFDAILYAUTHORIZED, then this factor (times 100) is multiplied by last daily authorized inflation to obtain the maximum balance that a reward service can hold at any given time. If it holds less, then this max amount is used to compute the mint request topup required to bring the reward service contract native token balance up to that amount. |
switchToFallbackMode
#
function switchToFallbackMode(
) external view returns (
bool);
This function will be called after an error is caught in daemonize
.
It will switch the contract to a simpler fallback mode, which hopefully works when full mode doesn't.
Not every contract needs to support fallback mode (FtsoManager
does), so this method may be empty.
Switching back to normal mode is left to the contract (typically a governed method call).
This function may be called due to low-gas error, so it shouldn't use more than ~30.000 gas.
Returns | Type | Description |
---|---|---|
[0] | bool |
True if switched to fallback mode, false if already in fallback mode or if fallback mode is not supported. |
switchToProductionMode
#
function switchToProductionMode(
) external;
Enter the production mode after all the initial governance
settings have been set.
This enables timelocks and the governance
can be obtained afterward by calling
governanceSettings
.getGovernanceAddress().
Emits GovernedProductionModeEntered
.
updateContractAddresses
#
function updateContractAddresses(
bytes32[] _contractNameHashes,
address[] _contractAddresses
) external;
External method called from AddressUpdater
only.
Modifiers#
onlyAddressUpdater
#
modifier onlyAddressUpdater()
Only the AdressUpdater
contract can call this method.
Its address is set at construction time but it can also update itself.
onlyFlareDaemon
#
modifier onlyFlareDaemon()
Only the flareDaemon
can call this method.
Variables#
flareDaemon
#
contract FlareDaemon flareDaemon
The FlareDaemon
contract, set at construction time.
governanceSettings
#
contract IGovernanceSettings governanceSettings
Governance Settings.
inflationAllocation
#
contract IIInflationAllocation inflationAllocation
lastAuthorizationTs
#
uint256 lastAuthorizationTs
The last time inflation was authorized.
preInflationCalculation
#
contract IIPreInflationCalculation preInflationCalculation
productionMode
#
bool productionMode
When true, governance
is enabled and cannot be disabled. See switchToProductionMode
.
rewardEpochStartTs
#
uint256 rewardEpochStartTs
Do not start inflation time slots before this, in seconds after UNIX epoch.
rewardEpochStartedTs
#
uint256 rewardEpochStartedTs
When the first reward epoch was started, in seconds after UNIX epoch.
timelockedCalls
#
mapping(bytes4 => struct GovernedBase.TimelockedCall) timelockedCalls
List of pending timelocked governance
calls.