IIFtsoManager
#
Source | Inherits from IFtsoManager, IFlareDaemonize
Internal interface for the FtsoManager
contract.
Events#
AccruingUnearnedRewardsFailed
#
event AccruingUnearnedRewardsFailed(
uint256 epochId
)
Unexpected failure while accruing unearned rewards. This should be a rare occurrence.
Parameters | Type | Description |
---|---|---|
epochId |
uint256 |
Epoch ID of the failure. |
ChillingNonrevealingDataProvidersFailed
#
event ChillingNonrevealingDataProvidersFailed(
)
Unexpected failure. This should be a rare occurrence.
CleanupBlockNumberManagerFailedForBlock
#
event CleanupBlockNumberManagerFailedForBlock(
uint256 blockNumber
)
Unexpected failure. This should be a rare occurrence.
ClosingExpiredRewardEpochFailed
#
event ClosingExpiredRewardEpochFailed(
uint256 rewardEpoch
)
Unexpected failure. This should be a rare occurrence.
DistributingRewardsFailed
#
event DistributingRewardsFailed(
address ftso,
uint256 epochId
)
Unexpected failure while distributing rewards. This should be a rare occurrence.
Parameters | Type | Description |
---|---|---|
ftso |
address |
Contract address of the FTSO where the failure happened. |
epochId |
uint256 |
Epoch ID of the failure. |
FallbackMode
#
event FallbackMode(
bool fallbackMode
)
Emitted when the fallback mode of the FTSO manager changes its state. Fallback mode is a recovery mode, where only data from a trusted subset of FTSO data providers is used to calculate the final price.
The FTSO Manager enters the fallback mode when ALL FTSOs are in fallback mode.
Parameters | Type | Description |
---|---|---|
fallbackMode |
bool |
New state of the FTSO Manager fallback mode. |
FinalizingPriceEpochFailed
#
event FinalizingPriceEpochFailed(
contract IIFtso ftso,
uint256 epochId,
enum IFtso.PriceFinalizationType failingType
)
Unexpected failure while finalizing a price epoch. This should be a rare occurrence.
Parameters | Type | Description |
---|---|---|
ftso |
contract IIFtso |
Contract address of the FTSO where the failure happened. |
epochId |
uint256 |
Epoch ID of the failure. |
failingType |
enum IFtso.PriceFinalizationType |
How was the epoch finalized. |
FtsoAdded
#
event FtsoAdded(
contract IIFtso ftso,
bool add
)
Emitted when a new FTSO has been added or an existing one has been removed.
Parameters | Type | Description |
---|---|---|
ftso |
contract IIFtso |
Contract address of the FTSO. |
add |
bool |
True if added, removed otherwise. |
FtsoDeactivationFailed
#
event FtsoDeactivationFailed(
contract IIFtso ftso
)
Unexpected failure. This should be a rare occurrence.
FtsoFallbackMode
#
event FtsoFallbackMode(
contract IIFtso ftso,
bool fallbackMode
)
Emitted when the fallback mode of an FTSO changes its state.
Parameters | Type | Description |
---|---|---|
ftso |
contract IIFtso |
Contract address of the FTSO. |
fallbackMode |
bool |
New state of its fallback mode. |
InitializingCurrentEpochStateForRevealFailed
#
event InitializingCurrentEpochStateForRevealFailed(
contract IIFtso ftso,
uint256 epochId
)
Unexpected failure while initializing a price epoch. This should be a rare occurrence.
Parameters | Type | Description |
---|---|---|
ftso |
contract IIFtso |
Contract address of the FTSO where the failure happened. |
epochId |
uint256 |
Epoch ID that failed initialization. |
PriceEpochFinalized
#
event PriceEpochFinalized(
address chosenFtso,
uint256 rewardEpochId
)
Emitted when a price epoch ends, this is, after the reveal phase, when final prices are calculated.
Parameters | Type | Description |
---|---|---|
chosenFtso |
address |
Contract address of the FTSO asset that was randomly chosen to be the basis for reward calculation. On this price epoch, rewards will be calculated based on how close each data provider was to the median of all submitted prices FOR THIS FTSO. |
rewardEpochId |
uint256 |
Reward epoch ID this price epoch belongs to. |
RewardEpochFinalized
#
event RewardEpochFinalized(
uint256 votepowerBlock,
uint256 startBlock
)
Emitted when a reward epoch ends and rewards are available.
Parameters | Type | Description |
---|---|---|
votepowerBlock |
uint256 |
The vote power block of the epoch. |
startBlock |
uint256 |
The first block of the epoch. |
UpdatingActiveValidatorsTriggerFailed
#
event UpdatingActiveValidatorsTriggerFailed(
uint256 rewardEpoch
)
Unexpected failure. This should be a rare occurrence.
UseGoodRandomSet
#
event UseGoodRandomSet(
bool useGoodRandom,
uint256 maxWaitForGoodRandomSeconds
)
Emitted when the requirement to provide good random numbers has changed.
As part of the FTSO protocol, data providers must submit a random number along with their price reveals. When good random numbers are enforced, all providers that submit a hash must then submit a reveal with a random number or they will be punished. This is a measure against random number manipulation.
Parameters | Type | Description |
---|---|---|
useGoodRandom |
bool |
Whether good random numbers are now enforced or not. |
maxWaitForGoodRandomSeconds |
uint256 |
Max number of seconds to wait for a good random number to be submitted. |
Functions#
active
#
function active(
) external view returns (
bool);
Returns whether the FTSO Manager is active
or not.
Returns | Type | Description |
---|---|---|
[0] | bool |
bool Active status. |
addFtso
#
function addFtso(
contract IIFtso _ftso
) external;
Adds FTSO to the list of managed FTSOs, to support a new price pair. All FTSOs in a multi-asset FTSO must be managed by the same FTSO manager.
Parameters | Type | Description |
---|---|---|
_ftso |
contract IIFtso |
FTSO contract address to add. |
addFtsosBulk
#
function addFtsosBulk(
contract IIFtso[] _ftsos
) external;
Adds a list of FTSOs to the list of managed FTSOs, to support new price pairs. All FTSOs in a multi-asset FTSO must be managed by the same FTSO manager.
Parameters | Type | Description |
---|---|---|
_ftsos |
contract IIFtso[] |
Array of FTSO contract addresses to add. |
currentRewardEpochEnds
#
function currentRewardEpochEnds(
) external view returns (
uint256);
Returns when the current reward epoch finishes.
Returns | Type | Description |
---|---|---|
[0] | uint256 |
uint256 Time in seconds since the UNIX epoch when the current reward epoch will finish. |
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. |
getContractName
#
function getContractName(
) external view returns (
string);
Implement this function to allow updating daemonized contracts through the AddressUpdater
.
Returns | Type | Description |
---|---|---|
[0] | string |
string Contract name. |
getCurrentPriceEpochData
#
function getCurrentPriceEpochData(
) external view returns (
uint256 _priceEpochId,
uint256 _priceEpochStartTimestamp,
uint256 _priceEpochEndTimestamp,
uint256 _priceEpochRevealEndTimestamp,
uint256 _currentTimestamp);
Returns timing information for the current price epoch. All intervals are half-closed: end time is not included. All timestamps are in seconds since UNIX epoch.
See the FTSO page for information about the different submission phases.
Returns | Type | Description |
---|---|---|
_priceEpochId |
uint256 |
Price epoch ID. |
_priceEpochStartTimestamp |
uint256 |
Beginning of the commit phase. |
_priceEpochEndTimestamp |
uint256 |
End of the commit phase. |
_priceEpochRevealEndTimestamp |
uint256 |
End of the reveal phase. |
_currentTimestamp |
uint256 |
Current time. |
getCurrentPriceEpochId
#
function getCurrentPriceEpochId(
) external view returns (
uint256 _priceEpochId);
Returns current price epoch ID.
Returns | Type | Description |
---|---|---|
_priceEpochId |
uint256 |
Currently running epoch ID. IDs are consecutive numbers starting from zero. |
getCurrentRewardEpoch
#
function getCurrentRewardEpoch(
) external view returns (
uint256);
Returns current reward epoch ID (the one currently running).
Returns | Type | Description |
---|---|---|
[0] | uint256 |
Reward epoch ID. A monotonically increasing integer. |
getElasticBandWidthPPMFtso
#
function getElasticBandWidthPPMFtso(
contract IIFtso _ftso
) external view returns (
uint256);
Returns the secondary band's width in PPM (parts-per-million) of the median value, for a given FTSO.
Parameters | Type | Description |
---|---|---|
_ftso |
contract IIFtso |
The queried FTSO contract address. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
uint256 Secondary band width in PPM. To obtain the actual band width, divide this number by 10^6 and multiply by the price median value. |
getFallbackMode
#
function getFallbackMode(
) external view returns (
bool _fallbackMode,
contract IIFtso[] _ftsos,
bool[] _ftsoInFallbackMode);
Returns whether the FTSO Manager is currently in fallback mode.
In this mode only submissions from trusted providers are used.
Returns | Type | Description |
---|---|---|
_fallbackMode |
bool |
True if fallback mode is enabled for the manager. |
_ftsos |
contract IIFtso[] |
Array of all currently active FTSO assets. |
_ftsoInFallbackMode |
bool[] |
Boolean array indicating which FTSO assets are in fallback mode. If the FTSO Manager is in fallback mode then ALL FTSOs are in fallback mode. |
getFtsos
#
function getFtsos(
) external view returns (
contract IIFtso[] _ftsos);
Returns the list of currently active
FTSOs.
Returns | Type | Description |
---|---|---|
_ftsos |
contract IIFtso[] |
Array of contract addresses for the FTSOs. |
getLastUnprocessedPriceEpochData
#
function getLastUnprocessedPriceEpochData(
) external view returns (
uint256 _lastUnprocessedPriceEpoch,
uint256 _lastUnprocessedPriceEpochRevealEnds,
bool _lastUnprocessedPriceEpochInitialized);
Returns information regarding the currently unprocessed price epoch. This epoch is not necessarily the last one, in case the network halts for some time due to validator node problems, for example.
Returns | Type | Description |
---|---|---|
_lastUnprocessedPriceEpoch |
uint256 |
ID of the price epoch that is currently waiting finalization. |
_lastUnprocessedPriceEpochRevealEnds |
uint256 |
When that price epoch can be finalized, in seconds since UNIX epoch. |
_lastUnprocessedPriceEpochInitialized |
bool |
Whether this price epoch has been already initialized and therefore it must be finalized before the corresponding reward epoch can be finalized. |
getPriceEpochConfiguration
#
function getPriceEpochConfiguration(
) external view returns (
uint256 _firstPriceEpochStartTs,
uint256 _priceEpochDurationSeconds,
uint256 _revealEpochDurationSeconds);
Returns the current values for price epoch timing configuration.
See the FTSO page for information about the different submission phases.
Returns | Type | Description |
---|---|---|
_firstPriceEpochStartTs |
uint256 |
Timestamp, in seconds since UNIX epoch, of the first price epoch. |
_priceEpochDurationSeconds |
uint256 |
Duration in seconds of the commit phase. |
_revealEpochDurationSeconds |
uint256 |
Duration in seconds of the reveal phase. |
getRewardEpochConfiguration
#
function getRewardEpochConfiguration(
) external view returns (
uint256 _firstRewardEpochStartTs,
uint256 _rewardEpochDurationSeconds);
Returns the current values for reward epoch timing configuration.
See the Reward epochs box.
Returns | Type | Description |
---|---|---|
_firstRewardEpochStartTs |
uint256 |
Timestamp, in seconds since UNIX epoch, of the first reward epoch. |
_rewardEpochDurationSeconds |
uint256 |
Duration in seconds of the reward epochs. |
getRewardEpochData
#
function getRewardEpochData(
uint256 _rewardEpochId
) external view returns (
struct IIFtsoManager.RewardEpochData);
Returns data regarding a specific reward epoch ID.
Parameters | Type | Description |
---|---|---|
_rewardEpochId |
uint256 |
Epoch ID. |
Returns | Type | Description |
---|---|---|
[0] | struct IIFtsoManager.RewardEpochData |
RewardEpochData Its associated data. |
getRewardEpochToExpireNext
#
function getRewardEpochToExpireNext(
) external view returns (
uint256);
Return reward epoch that will expire next, when a new reward epoch is initialized.
Reward epochs older than 90 days expire, and any unclaimed rewards in them become inaccessible.
Returns | Type | Description |
---|---|---|
[0] | uint256 |
uint256 Reward epoch ID. |
getRewardEpochVotePowerBlock
#
function getRewardEpochVotePowerBlock(
uint256 _rewardEpoch
) external view returns (
uint256);
Returns the vote power block that was used for a past reward epoch.
Parameters | Type | Description |
---|---|---|
_rewardEpoch |
uint256 |
The queried reward epoch ID. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
uint256 The block number of that reward epoch's vote power block. |
getRewardExpiryOffsetSeconds
#
function getRewardExpiryOffsetSeconds(
) external view returns (
uint256);
Returns the currently configured reward expiration time.
Returns | Type | Description |
---|---|---|
[0] | uint256 |
uint256 Unclaimed rewards accrued in reward epochs more than this amount of seconds in the past expire and become inaccessible. |
notInitializedFtsos
#
function notInitializedFtsos(
contract IIFtso
) external view returns (
bool);
Returns whether an FTSO has been initialized.
Returns | Type | Description |
---|---|---|
[0] | bool |
bool Initialization state. |
removeFtso
#
function removeFtso(
contract IIFtso _ftso
) external;
Removes an FTSO from the list of managed FTSOs.
Reverts if FTSO is used in a multi-asset FTSO.
Deactivates the _ftso
.
Parameters | Type | Description |
---|---|---|
_ftso |
contract IIFtso |
FTSO contract address to remove. |
replaceFtso
#
function replaceFtso(
contract IIFtso _ftsoToAdd,
bool copyCurrentPrice,
bool copyAssetOrAssetFtsos
) external;
Replaces one FTSO with another with the same symbol. All FTSOs in a multi-asset FTSO must be managed by the same FTSO manager. Deactivates the old FTSO.
Parameters | Type | Description |
---|---|---|
_ftsoToAdd |
contract IIFtso |
FTSO contract address to add. An existing FTSO with the same symbol will be removed. |
copyCurrentPrice |
bool |
When true, initializes the new FTSO with the current price of the previous FTSO. |
copyAssetOrAssetFtsos |
bool |
When true, initializes the new FTSO with the current asset or asset FTSOs of the previous FTSO. |
replaceFtsosBulk
#
function replaceFtsosBulk(
contract IIFtso[] _ftsosToAdd,
bool copyCurrentPrice,
bool copyAssetOrAssetFtsos
) external;
Replaces a list of FTSOs with other FTSOs with the same symbol. All FTSOs in a multi-asset FTSO must be managed by the same FTSO manager. Deactivates the old FTSOs.
Parameters | Type | Description |
---|---|---|
_ftsosToAdd |
contract IIFtso[] |
Array of FTSO contract addresses to add. Every existing FTSO with the same symbols will be removed. |
copyCurrentPrice |
bool |
When true, initializes the new FTSOs with the current price of the previous FTSOs. |
copyAssetOrAssetFtsos |
bool |
When true, initializes the new FTSOs with the current asset or asset FTSOs of the previous FTSOs. |
rewardEpochDurationSeconds
#
function rewardEpochDurationSeconds(
) external view returns (
uint256);
Currently configured reward epoch duration.
Returns | Type | Description |
---|---|---|
[0] | uint256 |
uint256 Reward epoch duration, in seconds. |
rewardEpochs
#
function rewardEpochs(
uint256 _rewardEpochId
) external view returns (
uint256 _votepowerBlock,
uint256 _startBlock,
uint256 _startTimestamp);
Returns information about a reward epoch.
Parameters | Type | Description |
---|---|---|
_rewardEpochId |
uint256 |
The epoch ID to query. |
Returns | Type | Description |
---|---|---|
_votepowerBlock |
uint256 |
The vote power block of the epoch. |
_startBlock |
uint256 |
The first block of the epoch. |
_startTimestamp |
uint256 |
Timestamp of the epoch start, in seconds since UNIX epoch. |
rewardEpochsStartTs
#
function rewardEpochsStartTs(
) external view returns (
uint256);
Time when the current reward epoch started.
Returns | Type | Description |
---|---|---|
[0] | uint256 |
uint256 Timestamp, in seconds since UNIX epoch. |
setFallbackMode
#
function setFallbackMode(
bool _fallbackMode
) external;
Sets whether the FTSO Manager is currently in fallback mode. In this mode only submissions from trusted providers are used.
Parameters | Type | Description |
---|---|---|
_fallbackMode |
bool |
True if fallback mode is enabled. |
setFtsoAsset
#
function setFtsoAsset(
contract IIFtso _ftso,
contract IIVPToken _asset
) external;
Sets the asset tracked by an FTSO.
Parameters | Type | Description |
---|---|---|
_ftso |
contract IIFtso |
The FTSO contract address. |
_asset |
contract IIVPToken |
The VPToken contract address of the asset to track. |
setFtsoAssetFtsos
#
function setFtsoAssetFtsos(
contract IIFtso _ftso,
contract IIFtso[] _assetFtsos
) external;
Sets an array of FTSOs to be tracked by a multi-asset FTSO. FTSOs implicitly determine the FTSO assets.
Parameters | Type | Description |
---|---|---|
_ftso |
contract IIFtso |
The multi-asset FTSO contract address. |
_assetFtsos |
contract IIFtso[] |
Array of FTSOs to be tracked. |
setFtsoFallbackMode
#
function setFtsoFallbackMode(
contract IIFtso _ftso,
bool _fallbackMode
) external;
Sets whether an FTSO is currently in fallback mode. In this mode only submissions from trusted providers are used.
Parameters | Type | Description |
---|---|---|
_ftso |
contract IIFtso |
The FTSO contract address. |
_fallbackMode |
bool |
Fallback mode. |
setGovernanceParameters
#
function setGovernanceParameters(
uint256 _updateTs,
uint256 _maxVotePowerNatThresholdFraction,
uint256 _maxVotePowerAssetThresholdFraction,
uint256 _lowAssetUSDThreshold,
uint256 _highAssetUSDThreshold,
uint256 _highAssetTurnoutThresholdBIPS,
uint256 _lowNatTurnoutThresholdBIPS,
uint256 _elasticBandRewardBIPS,
uint256 _rewardExpiryOffsetSeconds,
address[] _trustedAddresses
) external;
Sets governance parameters for FTSOs
Parameters | Type | Description |
---|---|---|
_updateTs |
uint256 |
Time, in seconds since UNIX epoch, when updated settings should be pushed to FTSOs. |
_maxVotePowerNatThresholdFraction |
uint256 |
High threshold for native token vote power per voter. |
_maxVotePowerAssetThresholdFraction |
uint256 |
High threshold for asset vote power per voter |
_lowAssetUSDThreshold |
uint256 |
Threshold for low asset vote power (in scaled USD). |
_highAssetUSDThreshold |
uint256 |
Threshold for high asset vote power (in scaled USD). |
_highAssetTurnoutThresholdBIPS |
uint256 |
Threshold for high asset turnout (in BIPS). |
_lowNatTurnoutThresholdBIPS |
uint256 |
Threshold for low nat turnout (in BIPS). |
_elasticBandRewardBIPS |
uint256 |
Secondary reward band, where _elasticBandRewardBIPS goes to the secondary band and 10000 - _elasticBandRewardBIPS to the primary (IQR) band. |
_rewardExpiryOffsetSeconds |
uint256 |
Reward epochs closed earlier than block.timestamp - _rewardExpiryOffsetSeconds expire. |
_trustedAddresses |
address[] |
Trusted addresses will be used as a fallback mechanism for setting the price. |
setInitialRewardData
#
function setInitialRewardData(
uint256 _nextRewardEpochToExpire,
uint256 _rewardEpochsLength,
uint256 _currentRewardEpochEnds
) external;
Set reward data to values from old ftso manager. Can only be called before activation.
Parameters | Type | Description |
---|---|---|
_nextRewardEpochToExpire |
uint256 |
See getRewardEpochToExpireNext . |
_rewardEpochsLength |
uint256 |
See getRewardEpochConfiguration . |
_currentRewardEpochEnds |
uint256 |
See getCurrentRewardEpoch . |
switchToFallbackMode
#
function switchToFallbackMode(
) external 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. |