Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- FtsoRegistry
- Optimization enabled
- true
- Compiler version
- v0.7.6+commit.7338295f
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2021-09-17T13:56:02.137929Z
Constructor Arguments
000000000000000000000000493044fbbaa7f9f78379864fa88accaff6a7586e
Arg [0] (address) : 0x493044fbbaa7f9f78379864fa88accaff6a7586e
Contract source code
// Sources flattened with hardhat v2.3.0 https://hardhat.org pragma abicoder v2; // File contracts/genesis/interface/IFtsoGenesis.sol // SPDX-License-Identifier: MIT pragma solidity 0.7.6; interface IFtsoGenesis { /** * @notice Submits price hash for current epoch - only price submitter * @param _sender Sender address * @param _epochId Target epoch id to which hashes are submitted * @param _hash Hashed price and random number * @notice Emits PriceHashSubmitted event. */ function submitPriceHashSubmitter(address _sender, uint256 _epochId, bytes32 _hash) external; /** * @notice Reveals submitted price during epoch reveal period - only price submitter * @param _voter Voter address * @param _epochId Id of the epoch in which the price hash was submitted * @param _price Submitted price in USD * @param _random Submitted random number * @notice The hash of _price and _random must be equal to the submitted hash * @notice Emits PriceRevealed event */ function revealPriceSubmitter( address _voter, uint256 _epochId, uint256 _price, uint256 _random, uint256 _wNatVP ) external; /** * @notice Get (and cache) wNat vote power for specified voter and given epoch id * @param _voter Voter address * @param _epochId Id of the epoch in which the price hash was submitted * @return wNat vote power */ function wNatVotePowerCached(address _voter, uint256 _epochId) external returns (uint256); } // File contracts/userInterfaces/IFtso.sol // pragma solidity 0.7.6; interface IFtso { enum PriceFinalizationType { // initial state NOT_FINALIZED, // median calculation used to decide price WEIGHTED_MEDIAN, // low turnout - price decided from average of trusted addresses TRUSTED_ADDRESSES, // low turnout + no votes from trusted addresses - price copied from previous epoch PREVIOUS_PRICE_COPIED, // price decided from average of trusted addresses - triggered due to an exception TRUSTED_ADDRESSES_EXCEPTION, // previous price copied - triggered due to an exception PREVIOUS_PRICE_COPIED_EXCEPTION } // events event PriceHashSubmitted( address indexed submitter, uint256 indexed epochId, bytes32 hash, uint256 timestamp ); event PriceRevealed( address indexed voter, uint256 indexed epochId, uint256 price, uint256 random, uint256 timestamp, uint256 votePowerNat, uint256 votePowerAsset ); event PriceFinalized( uint256 indexed epochId, uint256 price, bool rewardedFtso, uint256 lowRewardPrice, uint256 highRewardPrice, PriceFinalizationType finalizationType, uint256 timestamp ); event PriceEpochInitializedOnFtso( uint256 indexed epochId, uint256 endTime, uint256 timestamp ); event LowTurnout( uint256 indexed epochId, uint256 natTurnout, uint256 lowNatTurnoutThresholdBIPS, uint256 timestamp ); /** * @notice Returns if FTSO is active */ function active() external view returns (bool); /** * @notice Returns the FTSO symbol */ function symbol() external view returns (string memory); /** * @notice Returns current epoch id */ function getCurrentEpochId() external view returns (uint256); /** * @notice Returns id of the epoch which was opened for price submission at the specified timestamp * @param _timestamp Timestamp as seconds from unix epoch */ function getEpochId(uint256 _timestamp) external view returns (uint256); /** * @notice Returns random number of the specified epoch * @param _epochId Id of the epoch */ function getRandom(uint256 _epochId) external view returns (uint256); /** * @notice Returns asset price consented in specific epoch * @param _epochId Id of the epoch * @return Price in USD multiplied by ASSET_PRICE_USD_DECIMALS */ function getEpochPrice(uint256 _epochId) external view returns (uint256); /** * @notice Returns current epoch data * @return _epochId Current epoch id * @return _epochSubmitEndTime End time of the current epoch price submission as seconds from unix epoch * @return _epochRevealEndTime End time of the current epoch price reveal as seconds from unix epoch * @return _votePowerBlock Vote power block for the current epoch * @return _fallbackMode Current epoch in fallback mode - only votes from trusted addresses will be used * @dev half-closed intervals - end time not included */ function getPriceEpochData() external view returns ( uint256 _epochId, uint256 _epochSubmitEndTime, uint256 _epochRevealEndTime, uint256 _votePowerBlock, bool _fallbackMode ); /** * @notice Returns current epoch data * @return _firstEpochStartTime First epoch start time * @return _submitPeriod Submit period in seconds * @return _revealPeriod Reveal period in seconds */ function getPriceEpochConfiguration() external view returns ( uint256 _firstEpochStartTime, uint256 _submitPeriod, uint256 _revealPeriod ); /** * @notice Returns asset price submitted by voter in specific epoch * @param _epochId Id of the epoch * @param _voter Address of the voter * @return Price in USD multiplied by ASSET_PRICE_USD_DECIMALS */ function getEpochPriceForVoter(uint256 _epochId, address _voter) external view returns (uint256); /** * @notice Returns current asset price * @return _price Price in USD multiplied by ASSET_PRICE_USD_DECIMALS * @return _timestamp Time when price was updated for the last time */ function getCurrentPrice() external view returns (uint256 _price, uint256 _timestamp); /** * @notice Returns current random number */ function getCurrentRandom() external view returns (uint256); } // File @openzeppelin/contracts/token/ERC20/[email protected] // pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File contracts/userInterfaces/IGovernanceVotePower.sol // pragma solidity 0.7.6; interface IGovernanceVotePower { /** * @notice Delegate all governance vote power of `msg.sender` to `_to`. * @param _to The address of the recipient **/ function delegate(address _to) external; /** * @notice Undelegate all governance vote power that `msg.sender` has delegated. **/ function undelegate() external; /** * @notice Get the governance vote power of `_who` at block `_blockNumber` * @param _who The address to get voting power. * @param _blockNumber The block number at which to fetch. * @return Governance vote power of `_who` at `_blockNumber`. */ function votePowerOfAt(address _who, uint256 _blockNumber) external view returns(uint256); } // File contracts/userInterfaces/IVPContractEvents.sol // pragma solidity 0.7.6; interface IVPContractEvents { /** * Event triggered when an account delegates or undelegates another account. * Definition: `votePowerFromTo(from, to)` is `changed` from `priorVotePower` to `newVotePower`. * For undelegation, `newVotePower` is 0. * * Note: the event is always emitted from VPToken's `writeVotePowerContract`. */ event Delegate(address indexed from, address indexed to, uint256 priorVotePower, uint256 newVotePower); /** * Event triggered only when account `delegator` revokes delegation to `delegatee` * for a single block in the past (typically the current vote block). * * Note: the event is always emitted from VPToken's `writeVotePowerContract` and/or `readVotePowerContract`. */ event Revoke(address indexed delegator, address indexed delegatee, uint256 votePower, uint256 blockNumber); } // File contracts/userInterfaces/IVPToken.sol // pragma solidity 0.7.6; interface IVPToken is IERC20 { /** * @notice Delegate by percentage `_bips` of voting power to `_to` from `msg.sender`. * @param _to The address of the recipient * @param _bips The percentage of voting power to be delegated expressed in basis points (1/100 of one percent). * Not cummulative - every call resets the delegation value (and value of 0 undelegates `to`). **/ function delegate(address _to, uint256 _bips) external; /** * @notice Explicitly delegate `_amount` of voting power to `_to` from `msg.sender`. * @param _to The address of the recipient * @param _amount An explicit vote power amount to be delegated. * Not cummulative - every call resets the delegation value (and value of 0 undelegates `to`). **/ function delegateExplicit(address _to, uint _amount) external; /** * @notice Revoke all delegation from sender to `_who` at given block. * Only affects the reads via `votePowerOfAtCached()` in the block `_blockNumber`. * Block `_blockNumber` must be in the past. * This method should be used only to prevent rogue delegate voting in the current voting block. * To stop delegating use delegate/delegateExplicit with value of 0 or undelegateAll/undelegateAllExplicit. * @param _who Address of the delegatee * @param _blockNumber The block number at which to revoke delegation. */ function revokeDelegationAt(address _who, uint _blockNumber) external; /** * @notice Undelegate all voting power for delegates of `msg.sender` * Can only be used with percentage delegation. * Does not reset delegation mode back to NOTSET. **/ function undelegateAll() external; /** * @notice Undelegate all explicit vote power by amount delegates for `msg.sender`. * Can only be used with explicit delegation. * Does not reset delegation mode back to NOTSET. * @param _delegateAddresses Explicit delegation does not store delegatees' addresses, * so the caller must supply them. * @return The amount still delegated (in case the list of delegates was incomplete). */ function undelegateAllExplicit(address[] memory _delegateAddresses) external returns (uint256); /** * @dev Should be compatible with ERC20 method */ function name() external view returns (string memory); /** * @dev Should be compatible with ERC20 method */ function symbol() external view returns (string memory); /** * @dev Should be compatible with ERC20 method */ function decimals() external view returns (uint8); /** * @notice Total amount of tokens at a specific `_blockNumber`. * @param _blockNumber The block number when the totalSupply is queried * @return The total amount of tokens at `_blockNumber` **/ function totalSupplyAt(uint _blockNumber) external view returns(uint256); /** * @dev Queries the token balance of `_owner` at a specific `_blockNumber`. * @param _owner The address from which the balance will be retrieved. * @param _blockNumber The block number when the balance is queried. * @return The balance at `_blockNumber`. **/ function balanceOfAt(address _owner, uint _blockNumber) external view returns (uint256); /** * @notice Get the current total vote power. * @return The current total vote power (sum of all accounts' vote powers). */ function totalVotePower() external view returns(uint256); /** * @notice Get the total vote power at block `_blockNumber` * @param _blockNumber The block number at which to fetch. * @return The total vote power at the block (sum of all accounts' vote powers). */ function totalVotePowerAt(uint _blockNumber) external view returns(uint256); /** * @notice Get the current vote power of `_owner`. * @param _owner The address to get voting power. * @return Current vote power of `_owner`. */ function votePowerOf(address _owner) external view returns(uint256); /** * @notice Get the vote power of `_owner` at block `_blockNumber` * @param _owner The address to get voting power. * @param _blockNumber The block number at which to fetch. * @return Vote power of `_owner` at `_blockNumber`. */ function votePowerOfAt(address _owner, uint256 _blockNumber) external view returns(uint256); /** * @notice Get the delegation mode for '_who'. This mode determines whether vote power is * allocated by percentage or by explicit value. Once the delegation mode is set, * it never changes, even if all delegations are removed. * @param _who The address to get delegation mode. * @return delegation mode: 0 = NOTSET, 1 = PERCENTAGE, 2 = AMOUNT (i.e. explicit) */ function delegationModeOf(address _who) external view returns(uint256); /** * @notice Get current delegated vote power `_from` delegator delegated `_to` delegatee. * @param _from Address of delegator * @param _to Address of delegatee * @return The delegated vote power. */ function votePowerFromTo(address _from, address _to) external view returns(uint256); /** * @notice Get delegated the vote power `_from` delegator delegated `_to` delegatee at `_blockNumber`. * @param _from Address of delegator * @param _to Address of delegatee * @param _blockNumber The block number at which to fetch. * @return The delegated vote power. */ function votePowerFromToAt(address _from, address _to, uint _blockNumber) external view returns(uint256); /** * @notice Compute the current undelegated vote power of `_owner` * @param _owner The address to get undelegated voting power. * @return The unallocated vote power of `_owner` */ function undelegatedVotePowerOf(address _owner) external view returns(uint256); /** * @notice Get the undelegated vote power of `_owner` at given block. * @param _owner The address to get undelegated voting power. * @param _blockNumber The block number at which to fetch. * @return The undelegated vote power of `_owner` (= owner's own balance minus all delegations from owner) */ function undelegatedVotePowerOfAt(address _owner, uint256 _blockNumber) external view returns(uint256); /** * @notice Get the vote power delegation `delegationAddresses` * and `_bips` of `_who`. Returned in two separate positional arrays. * @param _who The address to get delegations. * @return _delegateAddresses Positional array of delegation addresses. * @return _bips Positional array of delegation percents specified in basis points (1/100 or 1 percent) * @return _count The number of delegates. * @return _delegationMode The mode of the delegation (NOTSET=0, PERCENTAGE=1, AMOUNT=2). */ function delegatesOf(address _who) external view returns ( address[] memory _delegateAddresses, uint256[] memory _bips, uint256 _count, uint256 _delegationMode ); /** * @notice Get the vote power delegation `delegationAddresses` * and `pcts` of `_who`. Returned in two separate positional arrays. * @param _who The address to get delegations. * @param _blockNumber The block for which we want to know the delegations. * @return _delegateAddresses Positional array of delegation addresses. * @return _bips Positional array of delegation percents specified in basis points (1/100 or 1 percent) * @return _count The number of delegates. * @return _delegationMode The mode of the delegation (NOTSET=0, PERCENTAGE=1, AMOUNT=2). */ function delegatesOfAt(address _who, uint256 _blockNumber) external view returns ( address[] memory _delegateAddresses, uint256[] memory _bips, uint256 _count, uint256 _delegationMode ); /** * Returns VPContract used for readonly operations (view methods). * The only non-view method that might be called on it is `revokeDelegationAt`. * * @notice `readVotePowerContract` is almost always equal to `writeVotePowerContract` * except during upgrade from one VPContract to a new version (which should happen * rarely or never and will be anounced before). * * @notice You shouldn't call any methods on VPContract directly, all are exposed * via VPToken (and state changing methods are forbidden from direct calls). * This is the reason why this method returns `IVPContractEvents` - it should only be used * for listening to events (`Revoke` only). */ function readVotePowerContract() external view returns (IVPContractEvents); /** * Returns VPContract used for state changing operations (non-view methods). * The only non-view method that might be called on it is `revokeDelegationAt`. * * @notice `writeVotePowerContract` is almost always equal to `readVotePowerContract` * except during upgrade from one VPContract to a new version (which should happen * rarely or never and will be anounced before). In the case of upgrade, * `writeVotePowerContract` will be replaced first to establish delegations, and * after some perio (e.g. after a reward epoch ends) `readVotePowerContract` will be set equal to it. * * @notice You shouldn't call any methods on VPContract directly, all are exposed * via VPToken (and state changing methods are forbidden from direct calls). * This is the reason why this method returns `IVPContractEvents` - it should only be used * for listening to events (`Delegate` and `Revoke` only). */ function writeVotePowerContract() external view returns (IVPContractEvents); /** * When set, allows token owners to participate in governance voting * and delegate governance vote power. */ function governanceVotePower() external view returns (IGovernanceVotePower); } // File contracts/token/interface/IICleanable.sol // pragma solidity 0.7.6; interface IICleanable { /** * Set the contract that is allowed to call history cleaning methods. */ function setCleanerContract(address _cleanerContract) external; /** * Set the cleanup block number. * Historic data for the blocks before `cleanupBlockNumber` can be erased, * history before that block should never be used since it can be inconsistent. * In particular, cleanup block number must be before current vote power block. * @param _blockNumber The new cleanup block number. */ function setCleanupBlockNumber(uint256 _blockNumber) external; /** * Set the contract that is allowed to set cleanupBlockNumber. * Usually this will be an instance of CleanupBlockNumberManager. */ function setCleanupBlockNumberManager(address _cleanupBlockNumberManager) external; /** * Get the current cleanup block number. */ function cleanupBlockNumber() external view returns (uint256); } // File contracts/token/interface/IIVPContract.sol // pragma solidity 0.7.6; interface IIVPContract is IICleanable, IVPContractEvents { /** * Update vote powers when tokens are transfered. * Also update delegated vote powers for percentage delegation * and check for enough funds for explicit delegations. **/ function updateAtTokenTransfer( address _from, address _to, uint256 _fromBalance, uint256 _toBalance, uint256 _amount ) external; /** * @notice Delegate `_bips` percentage of voting power to `_to` from `_from` * @param _from The address of the delegator * @param _to The address of the recipient * @param _balance The delegator's current balance * @param _bips The percentage of voting power to be delegated expressed in basis points (1/100 of one percent). * Not cummulative - every call resets the delegation value (and value of 0 revokes delegation). **/ function delegate( address _from, address _to, uint256 _balance, uint256 _bips ) external; /** * @notice Explicitly delegate `_amount` of voting power to `_to` from `msg.sender`. * @param _from The address of the delegator * @param _to The address of the recipient * @param _balance The delegator's current balance * @param _amount An explicit vote power amount to be delegated. * Not cummulative - every call resets the delegation value (and value of 0 undelegates `to`). **/ function delegateExplicit( address _from, address _to, uint256 _balance, uint _amount ) external; /** * @notice Revoke all delegation from sender to `_who` at given block. * Only affects the reads via `votePowerOfAtCached()` in the block `_blockNumber`. * Block `_blockNumber` must be in the past. * This method should be used only to prevent rogue delegate voting in the current voting block. * To stop delegating use delegate/delegateExplicit with value of 0 or undelegateAll/undelegateAllExplicit. * @param _from The address of the delegator * @param _who Address of the delegatee * @param _balance The delegator's current balance * @param _blockNumber The block number at which to revoke delegation. **/ function revokeDelegationAt( address _from, address _who, uint256 _balance, uint _blockNumber ) external; /** * @notice Undelegate all voting power for delegates of `msg.sender` * Can only be used with percentage delegation. * Does not reset delegation mode back to NOTSET. * @param _from The address of the delegator **/ function undelegateAll( address _from, uint256 _balance ) external; /** * @notice Undelegate all explicit vote power by amount delegates for `msg.sender`. * Can only be used with explicit delegation. * Does not reset delegation mode back to NOTSET. * @param _from The address of the delegator * @param _delegateAddresses Explicit delegation does not store delegatees' addresses, * so the caller must supply them. * @return The amount still delegated (in case the list of delegates was incomplete). */ function undelegateAllExplicit( address _from, address[] memory _delegateAddresses ) external returns (uint256); /** * @notice Get the vote power of `_who` at block `_blockNumber` * Reads/updates cache and upholds revocations. * @param _who The address to get voting power. * @param _blockNumber The block number at which to fetch. * @return Vote power of `_who` at `_blockNumber`. */ function votePowerOfAtCached(address _who, uint256 _blockNumber) external returns(uint256); /** * @notice Get the current vote power of `_who`. * @param _who The address to get voting power. * @return Current vote power of `_who`. */ function votePowerOf(address _who) external view returns(uint256); /** * @notice Get the vote power of `_who` at block `_blockNumber` * @param _who The address to get voting power. * @param _blockNumber The block number at which to fetch. * @return Vote power of `_who` at `_blockNumber`. */ function votePowerOfAt(address _who, uint256 _blockNumber) external view returns(uint256); /** * Return vote powers for several addresses in a batch. * @param _owners The list of addresses to fetch vote power of. * @param _blockNumber The block number at which to fetch. * @return A list of vote powers. */ function batchVotePowerOfAt( address[] memory _owners, uint256 _blockNumber ) external view returns(uint256[] memory); /** * @notice Get current delegated vote power `_from` delegator delegated `_to` delegatee. * @param _from Address of delegator * @param _to Address of delegatee * @param _balance The delegator's current balance * @return The delegated vote power. */ function votePowerFromTo( address _from, address _to, uint256 _balance ) external view returns(uint256); /** * @notice Get delegated the vote power `_from` delegator delegated `_to` delegatee at `_blockNumber`. * @param _from Address of delegator * @param _to Address of delegatee * @param _balance The delegator's current balance * @param _blockNumber The block number at which to fetch. * @return The delegated vote power. */ function votePowerFromToAt( address _from, address _to, uint256 _balance, uint _blockNumber ) external view returns(uint256); /** * @notice Compute the current undelegated vote power of `_owner` * @param _owner The address to get undelegated voting power. * @param _balance Owner's current balance * @return The unallocated vote power of `_owner` */ function undelegatedVotePowerOf( address _owner, uint256 _balance ) external view returns(uint256); /** * @notice Get the undelegated vote power of `_owner` at given block. * @param _owner The address to get undelegated voting power. * @param _blockNumber The block number at which to fetch. * @return The undelegated vote power of `_owner` (= owner's own balance minus all delegations from owner) */ function undelegatedVotePowerOfAt( address _owner, uint256 _balance, uint256 _blockNumber ) external view returns(uint256); /** * @notice Get the delegation mode for '_who'. This mode determines whether vote power is * allocated by percentage or by explicit value. * @param _who The address to get delegation mode. * @return Delegation mode (NOTSET=0, PERCENTAGE=1, AMOUNT=2)) */ function delegationModeOf(address _who) external view returns (uint256); /** * @notice Get the vote power delegation `_delegateAddresses` * and `pcts` of an `_owner`. Returned in two separate positional arrays. * @param _owner The address to get delegations. * @return _delegateAddresses Positional array of delegation addresses. * @return _bips Positional array of delegation percents specified in basis points (1/100 or 1 percent) * @return _count The number of delegates. * @return _delegationMode The mode of the delegation (NOTSET=0, PERCENTAGE=1, AMOUNT=2). */ function delegatesOf( address _owner ) external view returns ( address[] memory _delegateAddresses, uint256[] memory _bips, uint256 _count, uint256 _delegationMode ); /** * @notice Get the vote power delegation `delegationAddresses` * and `pcts` of an `_owner`. Returned in two separate positional arrays. * @param _owner The address to get delegations. * @param _blockNumber The block for which we want to know the delegations. * @return _delegateAddresses Positional array of delegation addresses. * @return _bips Positional array of delegation percents specified in basis points (1/100 or 1 percent) * @return _count The number of delegates. * @return _delegationMode The mode of the delegation (NOTSET=0, PERCENTAGE=1, AMOUNT=2). */ function delegatesOfAt( address _owner, uint256 _blockNumber ) external view returns ( address[] memory _delegateAddresses, uint256[] memory _bips, uint256 _count, uint256 _delegationMode ); /** * The VPToken (or some other contract) that owns this VPContract. * All state changing methods may be called only from this address. * This is because original msg.sender is sent in `_from` parameter * and we must be sure that it cannot be faked by directly calling VPContract. * Owner token is also used in case of replacement to recover vote powers from balances. */ function ownerToken() external view returns (IVPToken); /** * Return true if this IIVPContract is configured to be used as a replacement for other contract. * It means that vote powers are not necessarily correct at the initialization, therefore * every method that reads vote power must check whether it is initialized for that address and block. */ function isReplacement() external view returns (bool); } // File contracts/token/interface/IIGovernanceVotePower.sol // pragma solidity 0.7.6; interface IIGovernanceVotePower is IGovernanceVotePower { /** * Update vote powers when tokens are transfered. **/ function updateAtTokenTransfer( address _from, address _to, uint256 _fromBalance, uint256 _toBalance, uint256 _amount ) external; /** * Set the cleanup block number. * Historic data for the blocks before `cleanupBlockNumber` can be erased, * history before that block should never be used since it can be inconsistent. * In particular, cleanup block number must be before current vote power block. * @param _blockNumber The new cleanup block number. */ function setCleanupBlockNumber(uint256 _blockNumber) external; /** * Set the contract that is allowed to call history cleaning methods. */ function setCleanerContract(address _cleanerContract) external; /** * @notice Get the token that this governance vote power contract belongs to. */ function ownerToken() external view returns(IVPToken); } // File contracts/token/interface/IIVPToken.sol // pragma solidity 0.7.6; interface IIVPToken is IVPToken, IICleanable { /** * Sets new governance vote power contract that allows token owners to participate in governance voting * and delegate governance vote power. */ function setGovernanceVotePower(IIGovernanceVotePower _governanceVotePower) external; /** * @notice Get the total vote power at block `_blockNumber` using cache. * It tries to read the cached value and if not found, reads the actual value and stores it in cache. * Can only be used if `_blockNumber` is in the past, otherwise reverts. * @param _blockNumber The block number at which to fetch. * @return The total vote power at the block (sum of all accounts' vote powers). */ function totalVotePowerAtCached(uint256 _blockNumber) external returns(uint256); /** * @notice Get the vote power of `_owner` at block `_blockNumber` using cache. * It tries to read the cached value and if not found, reads the actual value and stores it in cache. * Can only be used if _blockNumber is in the past, otherwise reverts. * @param _owner The address to get voting power. * @param _blockNumber The block number at which to fetch. * @return Vote power of `_owner` at `_blockNumber`. */ function votePowerOfAtCached(address _owner, uint256 _blockNumber) external returns(uint256); /** * Return vote powers for several addresses in a batch. * @param _owners The list of addresses to fetch vote power of. * @param _blockNumber The block number at which to fetch. * @return A list of vote powers. */ function batchVotePowerOfAt( address[] memory _owners, uint256 _blockNumber ) external view returns(uint256[] memory); } // File contracts/ftso/interface/IIFtso.sol // pragma solidity 0.7.6; interface IIFtso is IFtso, IFtsoGenesis { /// function finalizePriceReveal /// called by reward manager only on correct timing. /// if price reveal period for epoch x ended. finalize. /// iterate list of price submissions /// find weighted median /// find adjucant 50% of price submissions. /// Allocate reward for any price submission which is same as a "winning" submission function finalizePriceEpoch(uint256 _epochId, bool _returnRewardData) external returns( address[] memory _eligibleAddresses, uint256[] memory _natWeights, uint256 _totalNatWeight ); function averageFinalizePriceEpoch(uint256 _epochId) external; function forceFinalizePriceEpoch(uint256 _epochId) external; // activateFtso will be called by ftso manager once ftso is added // before this is done, FTSO can't run function activateFtso( uint256 _firstEpochStartTs, uint256 _epochPeriod, uint256 _revealPeriod ) external; function deactivateFtso() external; // update initial price and timestamp - only if not active function updateInitialPrice(uint256 _initialPriceUSD, uint256 _initialPriceTimestamp) external; function configureEpochs( uint256 _maxVotePowerNatThresholdFraction, uint256 _maxVotePowerAssetThresholdFraction, uint256 _lowAssetUSDThreshold, uint256 _highAssetUSDThreshold, uint256 _highAssetTurnoutThresholdBIPS, uint256 _lowNatTurnoutThresholdBIPS, address[] memory _trustedAddresses ) external; function setAsset(IIVPToken _asset) external; function setAssetFtsos(IIFtso[] memory _assetFtsos) external; // current vote power block will update per reward epoch. // the FTSO doesn't have notion of reward epochs. // reward manager only can set this data. function setVotePowerBlock(uint256 _blockNumber) external; function initializeCurrentEpochStateForReveal(uint256 _circulatingSupplyNat, bool _fallbackMode) external; /** * @notice Returns the FTSO asset * @dev Asset is null in case of multi-asset FTSO */ function getAsset() external view returns (IIVPToken); /** * @notice Returns the Asset FTSOs * @dev AssetFtsos is not null only in case of multi-asset FTSO */ function getAssetFtsos() external view returns (IIFtso[] memory); /** * @notice Returns current configuration of epoch state * @return _maxVotePowerNatThresholdFraction High threshold for native token vote power per voter * @return _maxVotePowerAssetThresholdFraction High threshold for asset vote power per voter * @return _lowAssetUSDThreshold Threshold for low asset vote power * @return _highAssetUSDThreshold Threshold for high asset vote power * @return _highAssetTurnoutThresholdBIPS Threshold for high asset turnout * @return _lowNatTurnoutThresholdBIPS Threshold for low nat turnout * @return _trustedAddresses Trusted addresses - use their prices if low nat turnout is not achieved */ function epochsConfiguration() external view returns ( uint256 _maxVotePowerNatThresholdFraction, uint256 _maxVotePowerAssetThresholdFraction, uint256 _lowAssetUSDThreshold, uint256 _highAssetUSDThreshold, uint256 _highAssetTurnoutThresholdBIPS, uint256 _lowNatTurnoutThresholdBIPS, address[] memory _trustedAddresses ); /** * @notice Returns parameters necessary for approximately replicating vote weighting. * @return _assets the list of Assets that are accounted in vote * @return _assetMultipliers weight of each asset in (multiasset) ftso, mutiplied by TERA * @return _totalVotePowerNat total native token vote power at block * @return _totalVotePowerAsset total combined asset vote power at block * @return _assetWeightRatio ratio of combined asset vp vs. native token vp (in BIPS) * @return _votePowerBlock vote powewr block for given epoch */ function getVoteWeightingParameters() external view returns ( IIVPToken[] memory _assets, uint256[] memory _assetMultipliers, uint256 _totalVotePowerNat, uint256 _totalVotePowerAsset, uint256 _assetWeightRatio, uint256 _votePowerBlock ); function wNat() external view returns (IIVPToken); } // File contracts/genesis/interface/IFtsoRegistryGenesis.sol // pragma solidity 0.7.6; interface IFtsoRegistryGenesis { function getFtsos(uint256[] memory _indices) external view returns(IFtsoGenesis[] memory _ftsos); } // File contracts/userInterfaces/IPriceSubmitter.sol // pragma solidity 0.7.6; interface IPriceSubmitter { /** * Event emitted when price hashes were submitted through PriceSubmitter. * @param submitter the address of the sender * @param epochId current price epoch id * @param ftsos array of ftsos that correspond to the indexes in call * @param hashes the submitted hashes * @param timestamp current block timestamp */ event PriceHashesSubmitted( address indexed submitter, uint256 indexed epochId, IFtsoGenesis[] ftsos, bytes32[] hashes, uint256 timestamp ); /** * Event emitted when prices were revealed through PriceSubmitter. * @param voter the address of the sender * @param epochId id of the epoch in which the price hash was submitted * @param ftsos array of ftsos that correspond to the indexes in the call * @param prices the submitted prices * @param timestamp current block timestamp */ event PricesRevealed( address indexed voter, uint256 indexed epochId, IFtsoGenesis[] ftsos, uint256[] prices, uint256[] randoms, uint256 timestamp ); /** * @notice Submits price hashes for current epoch * @param _epochId Target epoch id to which hashes are submitted * @param _ftsoIndices List of ftso indices * @param _hashes List of hashed price and random number * @notice Emits PriceHashesSubmitted event */ function submitPriceHashes( uint256 _epochId, uint256[] memory _ftsoIndices, bytes32[] memory _hashes ) external; /** * @notice Reveals submitted prices during epoch reveal period * @param _epochId Id of the epoch in which the price hashes was submitted * @param _ftsoIndices List of ftso indices * @param _prices List of submitted prices in USD * @param _randoms List of submitted random numbers * @notice The hash of _price and _random must be equal to the submitted hash * @notice Emits PricesRevealed event */ function revealPrices( uint256 _epochId, uint256[] memory _ftsoIndices, uint256[] memory _prices, uint256[] memory _randoms ) external; /** * Returns bitmap of all ftso's for which `_voter` is allowed to submit prices/hashes. * If voter is allowed to vote for ftso at index (see *_FTSO_INDEX), the corrsponding * bit in the result will be 1. */ function voterWhitelistBitmap(address _voter) external view returns (uint256); function getVoterWhitelister() external view returns (address); function getFtsoRegistry() external view returns (IFtsoRegistryGenesis); function getFtsoManager() external view returns (address); } // File contracts/userInterfaces/IFtsoManager.sol // pragma solidity 0.7.6; interface IFtsoManager { event FtsoAdded(IIFtso ftso, bool add); event FallbackMode(bool fallbackMode); event FtsoFallbackMode(IIFtso ftso, bool fallbackMode); event RewardEpochFinalized(uint256 votepowerBlock, uint256 startBlock); event PriceEpochFinalized(address chosenFtso, uint256 rewardEpochId); event InitializingCurrentEpochStateForRevealFailed(IIFtso ftso, uint256 epochId); event FinalizingPriceEpochFailed(IIFtso ftso, uint256 epochId, IFtso.PriceFinalizationType failingType); event DistributingRewardsFailed(address ftso, uint256 epochId); function active() external view returns (bool); function getPriceSubmitter() external view returns (IPriceSubmitter); function getCurrentRewardEpoch() external view returns (uint256); function getRewardEpochVotePowerBlock(uint256 _rewardEpoch) external view returns (uint256); function getCurrentPriceEpochData() external view returns ( uint256 _priceEpochId, uint256 _priceEpochStartTimestamp, uint256 _priceEpochEndTimestamp, uint256 _priceEpochRevealEndTimestamp, uint256 _currentTimestamp ); function getFtsos() external view returns (IIFtso[] memory _ftsos); function getPriceEpochConfiguration() external view returns ( uint256 _firstPriceEpochStartTs, uint256 _priceEpochDurationSeconds, uint256 _revealEpochDurationSeconds ); function getFallbackMode() external view returns ( bool _fallbackMode, IIFtso[] memory _ftsos, bool[] memory _ftsoInFallbackMode ); } // File contracts/ftso/interface/IIFtsoManager.sol // pragma solidity 0.7.6; interface IIFtsoManager is IFtsoManager { event ClosingExpiredRewardEpochFailed(uint256 _rewardEpoch); event CleanupBlockNumberManagerUnset(); event CleanupBlockNumberManagerFailedForBlock(uint256 blockNumber); function activate() external; function setGovernanceParameters( uint256 _maxVotePowerNatThresholdFraction, uint256 _maxVotePowerAssetThresholdFraction, uint256 _lowAssetUSDThreshold, uint256 _highAssetUSDThreshold, uint256 _highAssetTurnoutThresholdBIPS, uint256 _lowNatTurnoutThresholdBIPS, uint256 _rewardExpiryOffsetSeconds, address[] memory _trustedAddresses ) external; function addFtso(IIFtso _ftso) external; function removeFtso(IIFtso _ftso) external; function replaceFtso( IIFtso _ftsoToRemove, IIFtso _ftsoToAdd, bool copyCurrentPrice, bool copyAssetOrAssetFtsos ) external; function setFtsoAsset(IIFtso _ftso, IIVPToken _asset) external; function setFtsoAssetFtsos(IIFtso _ftso, IIFtso[] memory _assetFtsos) external; function setFallbackMode(bool _fallbackMode) external; function setFtsoFallbackMode(IIFtso _ftso, bool _fallbackMode) external; } // File contracts/userInterfaces/IFtsoRegistry.sol // pragma solidity 0.7.6; interface IFtsoRegistry is IFtsoRegistryGenesis { function getFtso(uint256 _ftsoIndex) external view returns(IIFtso _activeFtsoAddress); function getFtsoBySymbol(string memory _symbol) external view returns(IIFtso _activeFtsoAddress); function getSupportedIndices() external view returns(uint256[] memory _supportedIndices); function getSupportedSymbols() external view returns(string[] memory _supportedSymbols); function getSupportedFtsos() external view returns(IIFtso[] memory _ftsos); function getFtsoIndex(string memory _symbol) external view returns (uint256 _assetIndex); function getFtsoSymbol(uint256 _ftsoIndex) external view returns (string memory _symbol); function getCurrentPrice(uint256 _ftsoIndex) external view returns(uint256 _price, uint256 _timestamp); function getCurrentPrice(string memory _symbol) external view returns(uint256 _price, uint256 _timestamp); function getSupportedIndicesAndFtsos() external view returns(uint256[] memory _supportedIndices, IIFtso[] memory _ftsos); function getSupportedSymbolsAndFtsos() external view returns(string[] memory _supportedSymbols, IIFtso[] memory _ftsos); function getSupportedIndicesAndSymbols() external view returns(uint256[] memory _supportedIndices, string[] memory _supportedSymbols); function getSupportedIndicesSymbolsAndFtsos() external view returns(uint256[] memory _supportedIndices, string[] memory _supportedSymbols, IIFtso[] memory _ftsos); } // File contracts/utils/interface/IIFtsoRegistry.sol // pragma solidity 0.7.6; interface IIFtsoRegistry is IFtsoRegistry { function setFtsoManagerAddress(IIFtsoManager _ftsoManager) external; // returns ftso index function addFtso(IIFtso _ftsoContract) external returns(uint256); function removeFtso(IIFtso _ftso) external; } // File contracts/governance/implementation/GovernedBase.sol // pragma solidity 0.7.6; /** * @title Governed Base * @notice This abstract base class defines behaviors for a governed contract. * @dev This class is abstract so that specific behaviors can be defined for the constructor. * Contracts should not be left ungoverned, but not all contract will have a constructor * (for example those pre-defined in genesis). **/ abstract contract GovernedBase { address public governance; address public proposedGovernance; bool private initialised; event GovernanceProposed(address proposedGovernance); event GovernanceUpdated (address oldGovernance, address newGoveranance); modifier onlyGovernance () { require (msg.sender == governance, "only governance"); _; } constructor(address _governance) { if (_governance != address(0)) { initialise(_governance); } } /** * @notice First of a two step process for turning over governance to another address. * @param _governance The address to propose to receive governance role. * @dev Must hold governance to propose another address. */ function proposeGovernance(address _governance) external onlyGovernance { proposedGovernance = _governance; emit GovernanceProposed(_governance); } /** * @notice Once proposed, claimant can claim the governance role as the second of a two-step process. */ function claimGovernance() external { require(msg.sender == proposedGovernance, "not claimaint"); emit GovernanceUpdated(governance, proposedGovernance); governance = proposedGovernance; proposedGovernance = address(0); } /** * @notice In a one-step process, turn over governance to another address. * @dev Must hold governance to transfer. */ function transferGovernance(address _governance) external onlyGovernance { emit GovernanceUpdated(governance, _governance); governance = _governance; proposedGovernance = address(0); } /** * @notice Initialize the governance address if not first initialized. */ function initialise(address _governance) public virtual { require(initialised == false, "initialised != false"); initialised = true; emit GovernanceUpdated(governance, _governance); governance = _governance; proposedGovernance = address(0); } } // File contracts/governance/implementation/Governed.sol // pragma solidity 0.7.6; /** * @title Governed * @dev For deployed, governed contracts, enforce a non-zero address at create time. **/ contract Governed is GovernedBase { constructor(address _governance) GovernedBase(_governance) { require(_governance != address(0), "_governance zero"); } } // File contracts/utils/implementation/FtsoRegistry.sol // pragma solidity 0.7.6; /** * @title A contract for FTSO registry */ contract FtsoRegistry is Governed, IIFtsoRegistry { // constants uint256 internal constant MAX_HISTORY_LENGTH = 5; // errors string internal constant ERR_TOKEN_NOT_SUPPORTED = "FTSO index not supported"; string internal constant ERR_FTSO_MANAGER_ONLY = "FTSO manager only"; // storage IIFtso[MAX_HISTORY_LENGTH][] private ftsoHistory; // addresses // This address has to be set in deploy phase IIFtsoManager public ftsoManager; modifier onlyFtsoManager () { require (msg.sender == address(ftsoManager), ERR_FTSO_MANAGER_ONLY); _; } constructor(address _governance) Governed(_governance) { } function setFtsoManagerAddress(IIFtsoManager _ftsoManager) external override onlyGovernance { ftsoManager = _ftsoManager; } /** * @notice Update current active FTSO contracts mapping * @param _ftsoContract new target FTSO contract */ function addFtso(IIFtso _ftsoContract) external override onlyFtsoManager returns(uint256 _ftsoIndex) { uint256 len = ftsoHistory.length; string memory _symbol = _ftsoContract.symbol(); bytes32 _encodedSymbol = keccak256(abi.encode(_symbol)); _ftsoIndex = 0; // Iterate over supported symbol array for ( ; _ftsoIndex < len; _ftsoIndex++) { // Deletion of symbols leaves an empty address "hole", so the address might be zero IIFtso current = ftsoHistory[_ftsoIndex][0]; if (address(current) == address(0)) { continue; } if (_encodedSymbol == keccak256(abi.encode(current.symbol()))) { break; } } // ftso with the same symbol is not yet in history array, add it if (_ftsoIndex == len) { ftsoHistory.push(); } else { // Shift history _shiftHistory(_ftsoIndex); } ftsoHistory[_ftsoIndex][0] = _ftsoContract; } /** * Removes the ftso at specified index and keeps part of the history * @dev Reverts if the provided index is unsupported * @param _ftso ftso to remove */ function removeFtso(IIFtso _ftso) external override onlyFtsoManager { bytes32 _encodedSymbol = keccak256(abi.encode(_ftso.symbol())); uint256 len = ftsoHistory.length; for (uint256 i = 0; i < len; ++i) { IIFtso current = ftsoHistory[i][0]; if (address(current) == address(0)) { continue; } // Removal behaves the same as setting null value as current if (_encodedSymbol == keccak256(abi.encode(current.symbol()))) { _shiftHistory(i); ftsoHistory[i][0] = IIFtso(address(0)); return; } } revert(ERR_TOKEN_NOT_SUPPORTED); } /** * @dev Reverts if unsupported index is passed * @return _activeFtso FTSO contract for provided index */ function getFtso(uint256 _assetIndex) external view override returns(IIFtso _activeFtso) { return _getFtso(_assetIndex); } /** * @dev Reverts if unsupported symbol is passed * @return _activeFtso FTSO contract for provided symbol */ function getFtsoBySymbol(string memory _symbol) external view override returns(IIFtso _activeFtso) { return _getFtso(_getFtsoIndex(_symbol)); } /** * @notice Public view function to get the price of active FTSO for given asset index * @dev Reverts if unsupported index is passed * @return _price current price of asset in USD * @return _timestamp timestamp for when this price was updated */ function getCurrentPrice(uint256 _assetIndex) external view override returns(uint256 _price, uint256 _timestamp) { return _getFtso(_assetIndex).getCurrentPrice(); } function getCurrentPrice(string memory _symbol) external view override returns(uint256 _price, uint256 _timestamp) { return _getFtso(_getFtsoIndex(_symbol)).getCurrentPrice(); } /** * @return _supportedIndices the array of all active FTSO indices in increasing order. * Active FTSOs are ones that currently receive price feeds. */ function getSupportedIndices() external view override returns(uint256[] memory _supportedIndices) { return _getSupportedIndices(); } /** * @return _supportedSymbols the array of all active FTSO symbols in increasing order. * Active FTSOs are ones that currently receive price feeds. */ function getSupportedSymbols() external view override returns(string[] memory _supportedSymbols) { uint256[] memory _supportedIndices = _getSupportedIndices(); uint256 len = _supportedIndices.length; _supportedSymbols = new string[](len); while (len > 0) { --len; IIFtso ftso = ftsoHistory[_supportedIndices[len]][0]; _supportedSymbols[len] = ftso.symbol(); } } /** * @notice Get array of all supported indices and corresponding FTSOs * @return _supportedIndices the array of all supported indices * @return _ftsos the array of all supported ftsos */ function getSupportedIndicesAndFtsos() external view override returns(uint256[] memory _supportedIndices, IIFtso[] memory _ftsos) { _supportedIndices = _getSupportedIndices(); uint256 len = _supportedIndices.length; _ftsos = new IIFtso[](len); while (len > 0) { --len; _ftsos[len] = ftsoHistory[_supportedIndices[len]][0]; } } /** * @notice Get array of all supported symbols and corresponding FTSOs * @return _supportedSymbols the array of all supported symbols * @return _ftsos the array of all supported ftsos */ function getSupportedSymbolsAndFtsos() external view override returns(string[] memory _supportedSymbols, IIFtso[] memory _ftsos) { uint256[] memory _supportedIndices = _getSupportedIndices(); uint256 len = _supportedIndices.length; _ftsos = new IIFtso[](len); _supportedSymbols = new string[](len); while (len > 0) { --len; _ftsos[len] = ftsoHistory[_supportedIndices[len]][0]; _supportedSymbols[len] = _ftsos[len].symbol(); } } /** * @notice Get array of all supported indices and corresponding symbols * @return _supportedIndices the array of all supported indices * @return _supportedSymbols the array of all supported symbols */ function getSupportedIndicesAndSymbols() external view override returns(uint256[] memory _supportedIndices, string[] memory _supportedSymbols) { _supportedIndices = _getSupportedIndices(); uint256 len = _supportedIndices.length; _supportedSymbols = new string[](len); while (len > 0) { --len; IIFtso ftso = ftsoHistory[_supportedIndices[len]][0]; _supportedSymbols[len] = ftso.symbol(); } } /** * @notice Get array of all supported indices, corresponding symbols and FTSOs * @return _supportedIndices the array of all supported indices * @return _supportedSymbols the array of all supported symbols * @return _ftsos the array of all supported ftsos */ function getSupportedIndicesSymbolsAndFtsos() external view override returns(uint256[] memory _supportedIndices, string[] memory _supportedSymbols, IIFtso[] memory _ftsos) { _supportedIndices = _getSupportedIndices(); uint256 len = _supportedIndices.length; _ftsos = new IIFtso[](len); _supportedSymbols = new string[](len); while (len > 0) { --len; _ftsos[len] = ftsoHistory[_supportedIndices[len]][0]; _supportedSymbols[len] = _ftsos[len].symbol(); } } /** * @notice Get array of all FTSO contracts for all supported asset indices. * The index of FTSO in returned array does not necessarily correspond to _assetIndex * Due to deletion, some indices might be unsupported. * @dev See `getSupportedIndicesAndFtsos` for pair of correct indices and `getAllFtsos` * for FTSOs at valid indices but with possible "null" holes. * @return _ftsos the array of all supported FTSOs */ function getSupportedFtsos() external view override returns(IIFtso[] memory _ftsos) { uint256[] memory supportedIndices = _getSupportedIndices(); uint256 len = supportedIndices.length; _ftsos = new IIFtso[](len); while (len > 0) { --len; _ftsos[len] = ftsoHistory[supportedIndices[len]][0]; } } /** * @notice Get the active FTSOs for given indices * @return _ftsos the array of FTSOs */ function getFtsos(uint256[] memory _assetIndices) external view override returns(IFtsoGenesis[] memory _ftsos) { uint256 ftsoLength = ftsoHistory.length; uint256 len = _assetIndices.length; _ftsos = new IFtsoGenesis[](len); while (len > 0) { --len; uint256 assetIndex = _assetIndices[len]; require(assetIndex < ftsoLength, ERR_TOKEN_NOT_SUPPORTED); _ftsos[len] = ftsoHistory[assetIndex][0]; if (address(_ftsos[len]) == address(0)) { // Invalid index, revert if address is zero address revert(ERR_TOKEN_NOT_SUPPORTED); } } } /** * @notice Get array of all FTSO contracts for all supported asset indices * @return _ftsos the array of all FTSOs * @dev Return value might contain uninitialized FTSOS at zero address. */ function getAllFtsos() external view returns(IIFtso[] memory _ftsos) { uint256 len = ftsoHistory.length; IIFtso[] memory ftsos = new IIFtso[](len); while (len > 0) { --len; ftsos[len] = ftsoHistory[len][0]; } return ftsos; } /** * @notice Get the history of FTSOs for given index * @dev If there are less then MAX_HISTORY_LENGTH the remaining addresses will be 0 addresses * @param _assetIndex asset index * @return _ftsoAddressHistory the history of FTSOs contract for provided index */ function getFtsoHistory(uint256 _assetIndex) external view returns(IIFtso[MAX_HISTORY_LENGTH] memory _ftsoAddressHistory) { require(_assetIndex < ftsoHistory.length && address(ftsoHistory[_assetIndex][0]) != address(0), ERR_TOKEN_NOT_SUPPORTED); return ftsoHistory[_assetIndex]; } function getFtsoIndex(string memory _symbol) external view override returns (uint256 _assetIndex) { return _getFtsoIndex(_symbol); } function getFtsoSymbol(uint256 _assetIndex) external view override returns (string memory _symbol) { return _getFtso(_assetIndex).symbol(); } /** * @notice Shift the FTSOs history by one so the FTSO at index 0 can be overwritten * @dev Internal helper function */ function _shiftHistory(uint256 _assetIndex) internal { for (uint256 i = MAX_HISTORY_LENGTH-1; i > 0; i--) { ftsoHistory[_assetIndex][i] = ftsoHistory[_assetIndex][i-1]; } } function _getFtsoIndex(string memory _symbol) private view returns (uint256 _assetIndex) { bytes32 _encodedSymbol = keccak256(abi.encode(_symbol)); uint256 len = ftsoHistory.length; for (uint256 i = 0; i < len; ++i) { IIFtso current = ftsoHistory[i][0]; if (address(current) == address(0)) { continue; } if (_encodedSymbol == keccak256(abi.encode(current.symbol()))) { return i; } } revert(ERR_TOKEN_NOT_SUPPORTED); } /** * @notice Get the active FTSO for given index * @dev Internal get ftso function so it can be used within other methods */ function _getFtso(uint256 _assetIndex) private view returns(IIFtso _activeFtso) { require(_assetIndex < ftsoHistory.length, ERR_TOKEN_NOT_SUPPORTED); IIFtso ftso = ftsoHistory[_assetIndex][0]; if (address(ftso) == address(0)) { // Invalid index, revert if address is zero address revert(ERR_TOKEN_NOT_SUPPORTED); } _activeFtso = ftso; } function _getSupportedIndices() private view returns(uint256[] memory _supportedIndices) { uint256 len = ftsoHistory.length; uint256[] memory supportedIndices = new uint256[](len); address zeroAddress = address(0); uint256 taken = 0; for (uint256 i = 0; i < len; ++i) { if (address(ftsoHistory[i][0]) != zeroAddress) { supportedIndices[taken] = i; ++taken; } } _supportedIndices = new uint256[](taken); while (taken > 0) { --taken; _supportedIndices[taken] = supportedIndices[taken]; } return _supportedIndices; } }
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_governance","internalType":"address"}]},{"type":"event","name":"GovernanceProposed","inputs":[{"type":"address","name":"proposedGovernance","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"GovernanceUpdated","inputs":[{"type":"address","name":"oldGovernance","internalType":"address","indexed":false},{"type":"address","name":"newGoveranance","internalType":"address","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"_ftsoIndex","internalType":"uint256"}],"name":"addFtso","inputs":[{"type":"address","name":"_ftsoContract","internalType":"contract IIFtso"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimGovernance","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IIFtsoManager"}],"name":"ftsoManager","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"_ftsos","internalType":"contract IIFtso[]"}],"name":"getAllFtsos","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_price","internalType":"uint256"},{"type":"uint256","name":"_timestamp","internalType":"uint256"}],"name":"getCurrentPrice","inputs":[{"type":"string","name":"_symbol","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_price","internalType":"uint256"},{"type":"uint256","name":"_timestamp","internalType":"uint256"}],"name":"getCurrentPrice","inputs":[{"type":"uint256","name":"_assetIndex","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"_activeFtso","internalType":"contract IIFtso"}],"name":"getFtso","inputs":[{"type":"uint256","name":"_assetIndex","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"_activeFtso","internalType":"contract IIFtso"}],"name":"getFtsoBySymbol","inputs":[{"type":"string","name":"_symbol","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[5]","name":"_ftsoAddressHistory","internalType":"contract IIFtso[5]"}],"name":"getFtsoHistory","inputs":[{"type":"uint256","name":"_assetIndex","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_assetIndex","internalType":"uint256"}],"name":"getFtsoIndex","inputs":[{"type":"string","name":"_symbol","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"_symbol","internalType":"string"}],"name":"getFtsoSymbol","inputs":[{"type":"uint256","name":"_assetIndex","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"_ftsos","internalType":"contract IFtsoGenesis[]"}],"name":"getFtsos","inputs":[{"type":"uint256[]","name":"_assetIndices","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"_ftsos","internalType":"contract IIFtso[]"}],"name":"getSupportedFtsos","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"_supportedIndices","internalType":"uint256[]"}],"name":"getSupportedIndices","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"_supportedIndices","internalType":"uint256[]"},{"type":"address[]","name":"_ftsos","internalType":"contract IIFtso[]"}],"name":"getSupportedIndicesAndFtsos","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"_supportedIndices","internalType":"uint256[]"},{"type":"string[]","name":"_supportedSymbols","internalType":"string[]"}],"name":"getSupportedIndicesAndSymbols","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"_supportedIndices","internalType":"uint256[]"},{"type":"string[]","name":"_supportedSymbols","internalType":"string[]"},{"type":"address[]","name":"_ftsos","internalType":"contract IIFtso[]"}],"name":"getSupportedIndicesSymbolsAndFtsos","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string[]","name":"_supportedSymbols","internalType":"string[]"}],"name":"getSupportedSymbols","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string[]","name":"_supportedSymbols","internalType":"string[]"},{"type":"address[]","name":"_ftsos","internalType":"contract IIFtso[]"}],"name":"getSupportedSymbolsAndFtsos","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"governance","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialise","inputs":[{"type":"address","name":"_governance","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"proposeGovernance","inputs":[{"type":"address","name":"_governance","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"proposedGovernance","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeFtso","inputs":[{"type":"address","name":"_ftso","internalType":"contract IIFtso"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setFtsoManagerAddress","inputs":[{"type":"address","name":"_ftsoManager","internalType":"contract IIFtsoManager"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferGovernance","inputs":[{"type":"address","name":"_governance","internalType":"address"}]}]
Contract Creation Code
0x60806040523480156200001157600080fd5b506040516200234d3803806200234d83398101604081905262000034916200018d565b80806001600160a01b0381161562000051576200005181620000a9565b506001600160a01b038116620000a1576040805162461bcd60e51b815260206004820152601060248201526f5f676f7665726e616e6365207a65726f60801b604482015290519081900360640190fd5b5050620001bd565b600154600160a01b900460ff161562000109576040805162461bcd60e51b815260206004820152601460248201527f696e697469616c6973656420213d2066616c7365000000000000000000000000604482015290519081900360640190fd5b6001805460ff60a01b1916600160a01b179055600054604080516001600160a01b039283168152918316602083015280517f434a2db650703b36c824e745330d6397cdaa9ee2cc891a4938ae853e1c50b68d9281900390910190a1600080546001600160a01b039092166001600160a01b0319928316179055600180549091169055565b6000602082840312156200019f578081fd5b81516001600160a01b0381168114620001b6578182fd5b9392505050565b61218080620001cd6000396000f3fe608060405234801561001057600080fd5b506004361061018e5760003560e01c80639cb47538116100de578063c55d0f5611610097578063d38bfff411610071578063d38bfff414610368578063d75f6d811461037b578063e68f283b1461038e578063e848da30146103a45761018e565b8063c55d0f5614610320578063c71a1b2014610333578063ce1c0e4d146103535761018e565b80639cb47538146102ac5780639d6a890f146102cc578063a40060ba146102df578063a670ff87146102e7578063adf71fd8146102fa578063c373a08e1461030d5761018e565b806342a0f2431161014b57806360f7ac971161012557806360f7ac97146102655780637687542c1461026d578063798aac5b1461028457806397da6af4146102995761018e565b806342a0f243146102325780635aa6e675146102535780635d36b1901461025b5761018e565b806306a2ba29146101935780630cf48497146101b257806311a7aaaa146101c8578063136d3f64146101dd5780632663f1b4146101fd5780632bcdd6ab1461021d575b600080fd5b61019b6103b7565b6040516101a9929190611ffc565b60405180910390f35b6101ba61048d565b6040516101a9929190611fc4565b6101d0610652565b6040516101a99190611f03565b6101f06101eb366004611dd7565b610661565b6040516101a99190612077565b61021061020b366004611c2a565b6106e8565b6040516101a9919061208a565b610225610955565b6040516101a99190611f9e565b610245610240366004611ced565b610a11565b6040516101a9929190612093565b6101d0610a9d565b610263610aac565b005b6101d0610b6e565b610275610b7d565b6040516101a993929190612034565b61028c610d42565b6040516101a99190611fe9565b6101d06102a7366004611ced565b610d51565b6102bf6102ba366004611c4d565b610d5f565b6040516101a99190611f17565b6102636102da366004611c2a565b610ee3565b610225610fbd565b6102636102f5366004611c2a565b611094565b610263610308366004611c2a565b611308565b61026361031b366004611c2a565b61137b565b61024561032e366004611dd7565b611420565b610346610341366004611dd7565b61142c565b6040516101a99190611f64565b61035b611512565b6040516101a99190611fb1565b610263610376366004611c2a565b611649565b6101d0610389366004611dd7565b61170b565b610396611716565b6040516101a992919061200f565b6102106103b2366004611ced565b61184c565b6060806103c2611857565b8051909250806001600160401b03811180156103dd57600080fd5b50604051908082528060200260200182016040528015610407578160200160208202803683370190505b5091505b80156104885780600190039050600283828151811061042657fe5b60200260200101518154811061043857fe5b600091825260208220600590910201015482516001600160a01b039091169083908390811061046357fe5b60200260200101906001600160a01b031690816001600160a01b03168152505061040b565b509091565b606080600061049a611857565b8051909150806001600160401b03811180156104b557600080fd5b506040519080825280602002602001820160405280156104df578160200160208202803683370190505b509250806001600160401b03811180156104f857600080fd5b5060405190808252806020026020018201604052801561052c57816020015b60608152602001906001900390816105175790505b5093505b801561064c5780600190039050600282828151811061054b57fe5b60200260200101518154811061055d57fe5b600091825260208220600590910201015483516001600160a01b039091169084908390811061058857fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508281815181106105b457fe5b60200260200101516001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b1580156105f457600080fd5b505afa158015610608573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106309190810190611d65565b84828151811061063c57fe5b6020026020010181905250610530565b50509091565b6003546001600160a01b031681565b606061066c82611998565b6001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b1580156106a457600080fd5b505afa1580156106b8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106e09190810190611d65565b90505b919050565b6003546040805180820190915260118152704654534f206d616e61676572206f6e6c7960781b60208201526000916001600160a01b031633146107475760405162461bcd60e51b815260040161073e9190612077565b60405180910390fd5b50600060028054905090506000836001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561078d57600080fd5b505afa1580156107a1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526107c99190810190611d65565b90506000816040516020016107de9190612077565b604051602081830303815290604052805190602001209050600093505b828410156108ee5760006002858154811061081257fe5b60009182526020822060059091020101546001600160a01b031690508061083957506108e3565b806001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561087257600080fd5b505afa158015610886573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108ae9190810190611d65565b6040516020016108be9190612077565b604051602081830303815290604052805190602001208214156108e157506108ee565b505b6001909301926107fb565b8284141561090757600280546001018155600052610910565b61091084611a4f565b846002858154811061091e57fe5b6000918252602082206005909102010180546001600160a01b0319166001600160a01b039290921691909117905550919392505050565b6002546060906000816001600160401b038111801561097357600080fd5b5060405190808252806020026020018201604052801561099d578160200160208202803683370190505b5090505b8115610a0b5781600190039150600282815481106109bb57fe5b600091825260208220600590910201015481516001600160a01b03909116908290849081106109e657fe5b60200260200101906001600160a01b031690816001600160a01b0316815250506109a1565b91505090565b600080610a25610a2084611ae2565b611998565b6001600160a01b031663eb91d37e6040518163ffffffff1660e01b8152600401604080518083038186803b158015610a5c57600080fd5b505afa158015610a70573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a949190611def565b91509150915091565b6000546001600160a01b031681565b6001546001600160a01b03163314610afb576040805162461bcd60e51b815260206004820152600d60248201526c1b9bdd0818db185a5b585a5b9d609a1b604482015290519081900360640190fd5b600054600154604080516001600160a01b03938416815292909116602083015280517f434a2db650703b36c824e745330d6397cdaa9ee2cc891a4938ae853e1c50b68d9281900390910190a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6001546001600160a01b031681565b6060806060610b8a611857565b8051909350806001600160401b0381118015610ba557600080fd5b50604051908082528060200260200182016040528015610bcf578160200160208202803683370190505b509150806001600160401b0381118015610be857600080fd5b50604051908082528060200260200182016040528015610c1c57816020015b6060815260200190600190039081610c075790505b5092505b8015610d3c57806001900390506002848281518110610c3b57fe5b602002602001015181548110610c4d57fe5b600091825260208220600590910201015482516001600160a01b0390911690839083908110610c7857fe5b60200260200101906001600160a01b031690816001600160a01b031681525050818181518110610ca457fe5b60200260200101516001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b158015610ce457600080fd5b505afa158015610cf8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d209190810190611d65565b838281518110610d2c57fe5b6020026020010181905250610c20565b50909192565b6060610d4c611857565b905090565b60006106e0610a2083611ae2565b600254815160609190806001600160401b0381118015610d7e57600080fd5b50604051908082528060200260200182016040528015610da8578160200160208202803683370190505b5092505b8015610edc57806001900390506000848281518110610dc757fe5b6020026020010151905082811060405180604001604052806018815260200160008051602061212b83398151915281525090610e165760405162461bcd60e51b815260040161073e9190612077565b5060028181548110610e2457fe5b600091825260208220600590910201015484516001600160a01b0390911690859084908110610e4f57fe5b60200260200101906001600160a01b031690816001600160a01b03168152505060006001600160a01b0316848381518110610e8657fe5b60200260200101516001600160a01b03161415610ed6576040805180820182526018815260008051602061212b8339815191526020820152905162461bcd60e51b815261073e9190600401612077565b50610dac565b5050919050565b600154600160a01b900460ff1615610f39576040805162461bcd60e51b8152602060048201526014602482015273696e697469616c6973656420213d2066616c736560601b604482015290519081900360640190fd5b6001805460ff60a01b1916600160a01b179055600054604080516001600160a01b039283168152918316602083015280517f434a2db650703b36c824e745330d6397cdaa9ee2cc891a4938ae853e1c50b68d9281900390910190a1600080546001600160a01b039092166001600160a01b0319928316179055600180549091169055565b60606000610fc9611857565b8051909150806001600160401b0381118015610fe457600080fd5b5060405190808252806020026020018201604052801561100e578160200160208202803683370190505b5092505b801561108f5780600190039050600282828151811061102d57fe5b60200260200101518154811061103f57fe5b600091825260208220600590910201015483516001600160a01b039091169084908390811061106a57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050611012565b505090565b6003546040805180820190915260118152704654534f206d616e61676572206f6e6c7960781b6020820152906001600160a01b031633146110e85760405162461bcd60e51b815260040161073e9190612077565b506000816001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561112457600080fd5b505afa158015611138573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111609190810190611d65565b6040516020016111709190612077565b60408051601f19818403018152919052805160209091012060025490915060005b818110156112cb576000600282815481106111a857fe5b60009182526020822060059091020101546001600160a01b03169050806111cf57506112c3565b806001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561120857600080fd5b505afa15801561121c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526112449190810190611d65565b6040516020016112549190612077565b604051602081830303815290604052805190602001208414156112c15761127a82611a4f565b60006002838154811061128957fe5b6000918252602082206005909102010180546001600160a01b0319166001600160a01b03929092169190911790555061130592505050565b505b600101611191565b506040805180820182526018815260008051602061212b8339815191526020820152905162461bcd60e51b815261073e9190600401612077565b50565b6000546001600160a01b03163314611359576040805162461bcd60e51b815260206004820152600f60248201526e6f6e6c7920676f7665726e616e636560881b604482015290519081900360640190fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146113cc576040805162461bcd60e51b815260206004820152600f60248201526e6f6e6c7920676f7665726e616e636560881b604482015290519081900360640190fd5b600180546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f1f95fb40be3a947982072902a887b521248d1d8931a39eb38f84f4d6fd758b699181900360200190a150565b600080610a2583611998565b611434611c0c565b60025482108015611475575060006001600160a01b03166002838154811061145857fe5b60009182526020822060059091020101546001600160a01b031614155b60405180604001604052806018815260200160008051602061212b833981519152815250906114b75760405162461bcd60e51b815260040161073e9190612077565b50600282815481106114c557fe5b600091825260209091206040805160a0810191829052926005908102909201919082845b81546001600160a01b031681526001909101906020018083116114e95750505050509050919050565b6060600061151e611857565b8051909150806001600160401b038111801561153957600080fd5b5060405190808252806020026020018201604052801561156d57816020015b60608152602001906001900390816115585790505b5092505b801561108f57806001900390506000600283838151811061158e57fe5b6020026020010151815481106115a057fe5b6000918252602082206005919091020154604080516395d89b4160e01b815290516001600160a01b03909216935083926395d89b4192600480840193829003018186803b1580156115f057600080fd5b505afa158015611604573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261162c9190810190611d65565b84838151811061163857fe5b602002602001018190525050611571565b6000546001600160a01b0316331461169a576040805162461bcd60e51b815260206004820152600f60248201526e6f6e6c7920676f7665726e616e636560881b604482015290519081900360640190fd5b600054604080516001600160a01b039283168152918316602083015280517f434a2db650703b36c824e745330d6397cdaa9ee2cc891a4938ae853e1c50b68d9281900390910190a1600080546001600160a01b039092166001600160a01b0319928316179055600180549091169055565b60006106e082611998565b606080611721611857565b8051909250806001600160401b038111801561173c57600080fd5b5060405190808252806020026020018201604052801561177057816020015b606081526020019060019003908161175b5790505b5091505b801561048857806001900390506000600284838151811061179157fe5b6020026020010151815481106117a357fe5b6000918252602082206005919091020154604080516395d89b4160e01b815290516001600160a01b03909216935083926395d89b4192600480840193829003018186803b1580156117f357600080fd5b505afa158015611807573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261182f9190810190611d65565b83838151811061183b57fe5b602002602001018190525050611774565b60006106e082611ae2565b6002546060906000816001600160401b038111801561187557600080fd5b5060405190808252806020026020018201604052801561189f578160200160208202803683370190505b50905060008060005b8481101561190e57826001600160a01b0316600282815481106118c757fe5b60009182526020822060059091020101546001600160a01b03161461190657808483815181106118f357fe5b6020026020010181815250508160010191505b6001016118a8565b50806001600160401b038111801561192557600080fd5b5060405190808252806020026020018201604052801561194f578160200160208202803683370190505b5094505b8015611991578060019003905082818151811061196c57fe5b602002602001015185828151811061198057fe5b602002602001018181525050611953565b5050505090565b600254604080518082019091526018815260008051602061212b833981519152602082015260009183106119df5760405162461bcd60e51b815260040161073e9190612077565b506000600283815481106119ef57fe5b60009182526020822060059091020101546001600160a01b0316905080611a49576040805180820182526018815260008051602061212b8339815191526020820152905162461bcd60e51b815261073e9190600401612077565b92915050565b60045b8015611ade5760028281548110611a6557fe5b90600052602060002090600502016001820360058110611a8157fe5b0154600280546001600160a01b039092169184908110611a9d57fe5b90600052602060002090600502018260058110611ab657fe5b0180546001600160a01b0319166001600160a01b039290921691909117905560001901611a52565b5050565b60008082604051602001611af69190612077565b60408051601f19818403018152919052805160209091012060025490915060005b818110156112cb57600060028281548110611b2e57fe5b60009182526020822060059091020101546001600160a01b0316905080611b555750611c04565b806001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b158015611b8e57600080fd5b505afa158015611ba2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611bca9190810190611d65565b604051602001611bda9190612077565b60405160208183030381529060405280519060200120841415611c02575092506106e3915050565b505b600101611b17565b6040518060a001604052806005906020820280368337509192915050565b600060208284031215611c3b578081fd5b8135611c4681612115565b9392505050565b60006020808385031215611c5f578182fd5b82356001600160401b0380821115611c75578384fd5b818501915085601f830112611c88578384fd5b813581811115611c9457fe5b8381029150611ca48483016120a1565b8181528481019084860184860187018a1015611cbe578788fd5b8795505b83861015611ce0578035835260019590950194918601918601611cc2565b5098975050505050505050565b600060208284031215611cfe578081fd5b81356001600160401b03811115611d13578182fd5b8201601f81018413611d23578182fd5b8035611d36611d31826120c4565b6120a1565b818152856020838501011115611d4a578384fd5b81602084016020830137908101602001929092525092915050565b600060208284031215611d76578081fd5b81516001600160401b03811115611d8b578182fd5b8201601f81018413611d9b578182fd5b8051611da9611d31826120c4565b818152856020838501011115611dbd578384fd5b611dce8260208301602086016120e5565b95945050505050565b600060208284031215611de8578081fd5b5035919050565b60008060408385031215611e01578081fd5b505080516020909101519092909150565b6000815180845260208085019450808401835b83811015611e4a5781516001600160a01b031687529582019590820190600101611e25565b509495945050505050565b6000815180845260208085018081965082840281019150828601855b85811015611e9b578284038952611e89848351611ed7565b98850198935090840190600101611e71565b5091979650505050505050565b6000815180845260208085019450808401835b83811015611e4a57815187529582019590820190600101611ebb565b60008151808452611eef8160208601602086016120e5565b601f01601f19169290920160200192915050565b6001600160a01b0391909116815260200190565b6020808252825182820181905260009190848201906040850190845b81811015611f585783516001600160a01b031683529284019291840191600101611f33565b50909695505050505050565b60a08101818360005b6005811015611f955781516001600160a01b0316835260209283019290910190600101611f6d565b50505092915050565b600060208252611c466020830184611e12565b600060208252611c466020830184611e55565b600060408252611fd76040830185611e55565b8281036020840152611dce8185611e12565b600060208252611c466020830184611ea8565b600060408252611fd76040830185611ea8565b6000604082526120226040830185611ea8565b8281036020840152611dce8185611e55565b6000606082526120476060830186611ea8565b82810360208401526120598186611e55565b9050828103604084015261206d8185611e12565b9695505050505050565b600060208252611c466020830184611ed7565b90815260200190565b918252602082015260400190565b6040518181016001600160401b03811182821017156120bc57fe5b604052919050565b60006001600160401b038211156120d757fe5b50601f01601f191660200190565b60005b838110156121005781810151838201526020016120e8565b8381111561210f576000848401525b50505050565b6001600160a01b038116811461130557600080fdfe4654534f20696e646578206e6f7420737570706f727465640000000000000000a2646970667358221220d1f812e478a3bd4375203d7ef0778d5866fb6960f756f24788d30613a03dcdb264736f6c63430007060033000000000000000000000000493044fbbaa7f9f78379864fa88accaff6a7586e
Deployed ByteCode
0x608060405234801561001057600080fd5b506004361061018e5760003560e01c80639cb47538116100de578063c55d0f5611610097578063d38bfff411610071578063d38bfff414610368578063d75f6d811461037b578063e68f283b1461038e578063e848da30146103a45761018e565b8063c55d0f5614610320578063c71a1b2014610333578063ce1c0e4d146103535761018e565b80639cb47538146102ac5780639d6a890f146102cc578063a40060ba146102df578063a670ff87146102e7578063adf71fd8146102fa578063c373a08e1461030d5761018e565b806342a0f2431161014b57806360f7ac971161012557806360f7ac97146102655780637687542c1461026d578063798aac5b1461028457806397da6af4146102995761018e565b806342a0f243146102325780635aa6e675146102535780635d36b1901461025b5761018e565b806306a2ba29146101935780630cf48497146101b257806311a7aaaa146101c8578063136d3f64146101dd5780632663f1b4146101fd5780632bcdd6ab1461021d575b600080fd5b61019b6103b7565b6040516101a9929190611ffc565b60405180910390f35b6101ba61048d565b6040516101a9929190611fc4565b6101d0610652565b6040516101a99190611f03565b6101f06101eb366004611dd7565b610661565b6040516101a99190612077565b61021061020b366004611c2a565b6106e8565b6040516101a9919061208a565b610225610955565b6040516101a99190611f9e565b610245610240366004611ced565b610a11565b6040516101a9929190612093565b6101d0610a9d565b610263610aac565b005b6101d0610b6e565b610275610b7d565b6040516101a993929190612034565b61028c610d42565b6040516101a99190611fe9565b6101d06102a7366004611ced565b610d51565b6102bf6102ba366004611c4d565b610d5f565b6040516101a99190611f17565b6102636102da366004611c2a565b610ee3565b610225610fbd565b6102636102f5366004611c2a565b611094565b610263610308366004611c2a565b611308565b61026361031b366004611c2a565b61137b565b61024561032e366004611dd7565b611420565b610346610341366004611dd7565b61142c565b6040516101a99190611f64565b61035b611512565b6040516101a99190611fb1565b610263610376366004611c2a565b611649565b6101d0610389366004611dd7565b61170b565b610396611716565b6040516101a992919061200f565b6102106103b2366004611ced565b61184c565b6060806103c2611857565b8051909250806001600160401b03811180156103dd57600080fd5b50604051908082528060200260200182016040528015610407578160200160208202803683370190505b5091505b80156104885780600190039050600283828151811061042657fe5b60200260200101518154811061043857fe5b600091825260208220600590910201015482516001600160a01b039091169083908390811061046357fe5b60200260200101906001600160a01b031690816001600160a01b03168152505061040b565b509091565b606080600061049a611857565b8051909150806001600160401b03811180156104b557600080fd5b506040519080825280602002602001820160405280156104df578160200160208202803683370190505b509250806001600160401b03811180156104f857600080fd5b5060405190808252806020026020018201604052801561052c57816020015b60608152602001906001900390816105175790505b5093505b801561064c5780600190039050600282828151811061054b57fe5b60200260200101518154811061055d57fe5b600091825260208220600590910201015483516001600160a01b039091169084908390811061058857fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508281815181106105b457fe5b60200260200101516001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b1580156105f457600080fd5b505afa158015610608573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106309190810190611d65565b84828151811061063c57fe5b6020026020010181905250610530565b50509091565b6003546001600160a01b031681565b606061066c82611998565b6001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b1580156106a457600080fd5b505afa1580156106b8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106e09190810190611d65565b90505b919050565b6003546040805180820190915260118152704654534f206d616e61676572206f6e6c7960781b60208201526000916001600160a01b031633146107475760405162461bcd60e51b815260040161073e9190612077565b60405180910390fd5b50600060028054905090506000836001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561078d57600080fd5b505afa1580156107a1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526107c99190810190611d65565b90506000816040516020016107de9190612077565b604051602081830303815290604052805190602001209050600093505b828410156108ee5760006002858154811061081257fe5b60009182526020822060059091020101546001600160a01b031690508061083957506108e3565b806001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561087257600080fd5b505afa158015610886573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108ae9190810190611d65565b6040516020016108be9190612077565b604051602081830303815290604052805190602001208214156108e157506108ee565b505b6001909301926107fb565b8284141561090757600280546001018155600052610910565b61091084611a4f565b846002858154811061091e57fe5b6000918252602082206005909102010180546001600160a01b0319166001600160a01b039290921691909117905550919392505050565b6002546060906000816001600160401b038111801561097357600080fd5b5060405190808252806020026020018201604052801561099d578160200160208202803683370190505b5090505b8115610a0b5781600190039150600282815481106109bb57fe5b600091825260208220600590910201015481516001600160a01b03909116908290849081106109e657fe5b60200260200101906001600160a01b031690816001600160a01b0316815250506109a1565b91505090565b600080610a25610a2084611ae2565b611998565b6001600160a01b031663eb91d37e6040518163ffffffff1660e01b8152600401604080518083038186803b158015610a5c57600080fd5b505afa158015610a70573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a949190611def565b91509150915091565b6000546001600160a01b031681565b6001546001600160a01b03163314610afb576040805162461bcd60e51b815260206004820152600d60248201526c1b9bdd0818db185a5b585a5b9d609a1b604482015290519081900360640190fd5b600054600154604080516001600160a01b03938416815292909116602083015280517f434a2db650703b36c824e745330d6397cdaa9ee2cc891a4938ae853e1c50b68d9281900390910190a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6001546001600160a01b031681565b6060806060610b8a611857565b8051909350806001600160401b0381118015610ba557600080fd5b50604051908082528060200260200182016040528015610bcf578160200160208202803683370190505b509150806001600160401b0381118015610be857600080fd5b50604051908082528060200260200182016040528015610c1c57816020015b6060815260200190600190039081610c075790505b5092505b8015610d3c57806001900390506002848281518110610c3b57fe5b602002602001015181548110610c4d57fe5b600091825260208220600590910201015482516001600160a01b0390911690839083908110610c7857fe5b60200260200101906001600160a01b031690816001600160a01b031681525050818181518110610ca457fe5b60200260200101516001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b158015610ce457600080fd5b505afa158015610cf8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d209190810190611d65565b838281518110610d2c57fe5b6020026020010181905250610c20565b50909192565b6060610d4c611857565b905090565b60006106e0610a2083611ae2565b600254815160609190806001600160401b0381118015610d7e57600080fd5b50604051908082528060200260200182016040528015610da8578160200160208202803683370190505b5092505b8015610edc57806001900390506000848281518110610dc757fe5b6020026020010151905082811060405180604001604052806018815260200160008051602061212b83398151915281525090610e165760405162461bcd60e51b815260040161073e9190612077565b5060028181548110610e2457fe5b600091825260208220600590910201015484516001600160a01b0390911690859084908110610e4f57fe5b60200260200101906001600160a01b031690816001600160a01b03168152505060006001600160a01b0316848381518110610e8657fe5b60200260200101516001600160a01b03161415610ed6576040805180820182526018815260008051602061212b8339815191526020820152905162461bcd60e51b815261073e9190600401612077565b50610dac565b5050919050565b600154600160a01b900460ff1615610f39576040805162461bcd60e51b8152602060048201526014602482015273696e697469616c6973656420213d2066616c736560601b604482015290519081900360640190fd5b6001805460ff60a01b1916600160a01b179055600054604080516001600160a01b039283168152918316602083015280517f434a2db650703b36c824e745330d6397cdaa9ee2cc891a4938ae853e1c50b68d9281900390910190a1600080546001600160a01b039092166001600160a01b0319928316179055600180549091169055565b60606000610fc9611857565b8051909150806001600160401b0381118015610fe457600080fd5b5060405190808252806020026020018201604052801561100e578160200160208202803683370190505b5092505b801561108f5780600190039050600282828151811061102d57fe5b60200260200101518154811061103f57fe5b600091825260208220600590910201015483516001600160a01b039091169084908390811061106a57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050611012565b505090565b6003546040805180820190915260118152704654534f206d616e61676572206f6e6c7960781b6020820152906001600160a01b031633146110e85760405162461bcd60e51b815260040161073e9190612077565b506000816001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561112457600080fd5b505afa158015611138573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111609190810190611d65565b6040516020016111709190612077565b60408051601f19818403018152919052805160209091012060025490915060005b818110156112cb576000600282815481106111a857fe5b60009182526020822060059091020101546001600160a01b03169050806111cf57506112c3565b806001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561120857600080fd5b505afa15801561121c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526112449190810190611d65565b6040516020016112549190612077565b604051602081830303815290604052805190602001208414156112c15761127a82611a4f565b60006002838154811061128957fe5b6000918252602082206005909102010180546001600160a01b0319166001600160a01b03929092169190911790555061130592505050565b505b600101611191565b506040805180820182526018815260008051602061212b8339815191526020820152905162461bcd60e51b815261073e9190600401612077565b50565b6000546001600160a01b03163314611359576040805162461bcd60e51b815260206004820152600f60248201526e6f6e6c7920676f7665726e616e636560881b604482015290519081900360640190fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146113cc576040805162461bcd60e51b815260206004820152600f60248201526e6f6e6c7920676f7665726e616e636560881b604482015290519081900360640190fd5b600180546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f1f95fb40be3a947982072902a887b521248d1d8931a39eb38f84f4d6fd758b699181900360200190a150565b600080610a2583611998565b611434611c0c565b60025482108015611475575060006001600160a01b03166002838154811061145857fe5b60009182526020822060059091020101546001600160a01b031614155b60405180604001604052806018815260200160008051602061212b833981519152815250906114b75760405162461bcd60e51b815260040161073e9190612077565b50600282815481106114c557fe5b600091825260209091206040805160a0810191829052926005908102909201919082845b81546001600160a01b031681526001909101906020018083116114e95750505050509050919050565b6060600061151e611857565b8051909150806001600160401b038111801561153957600080fd5b5060405190808252806020026020018201604052801561156d57816020015b60608152602001906001900390816115585790505b5092505b801561108f57806001900390506000600283838151811061158e57fe5b6020026020010151815481106115a057fe5b6000918252602082206005919091020154604080516395d89b4160e01b815290516001600160a01b03909216935083926395d89b4192600480840193829003018186803b1580156115f057600080fd5b505afa158015611604573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261162c9190810190611d65565b84838151811061163857fe5b602002602001018190525050611571565b6000546001600160a01b0316331461169a576040805162461bcd60e51b815260206004820152600f60248201526e6f6e6c7920676f7665726e616e636560881b604482015290519081900360640190fd5b600054604080516001600160a01b039283168152918316602083015280517f434a2db650703b36c824e745330d6397cdaa9ee2cc891a4938ae853e1c50b68d9281900390910190a1600080546001600160a01b039092166001600160a01b0319928316179055600180549091169055565b60006106e082611998565b606080611721611857565b8051909250806001600160401b038111801561173c57600080fd5b5060405190808252806020026020018201604052801561177057816020015b606081526020019060019003908161175b5790505b5091505b801561048857806001900390506000600284838151811061179157fe5b6020026020010151815481106117a357fe5b6000918252602082206005919091020154604080516395d89b4160e01b815290516001600160a01b03909216935083926395d89b4192600480840193829003018186803b1580156117f357600080fd5b505afa158015611807573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261182f9190810190611d65565b83838151811061183b57fe5b602002602001018190525050611774565b60006106e082611ae2565b6002546060906000816001600160401b038111801561187557600080fd5b5060405190808252806020026020018201604052801561189f578160200160208202803683370190505b50905060008060005b8481101561190e57826001600160a01b0316600282815481106118c757fe5b60009182526020822060059091020101546001600160a01b03161461190657808483815181106118f357fe5b6020026020010181815250508160010191505b6001016118a8565b50806001600160401b038111801561192557600080fd5b5060405190808252806020026020018201604052801561194f578160200160208202803683370190505b5094505b8015611991578060019003905082818151811061196c57fe5b602002602001015185828151811061198057fe5b602002602001018181525050611953565b5050505090565b600254604080518082019091526018815260008051602061212b833981519152602082015260009183106119df5760405162461bcd60e51b815260040161073e9190612077565b506000600283815481106119ef57fe5b60009182526020822060059091020101546001600160a01b0316905080611a49576040805180820182526018815260008051602061212b8339815191526020820152905162461bcd60e51b815261073e9190600401612077565b92915050565b60045b8015611ade5760028281548110611a6557fe5b90600052602060002090600502016001820360058110611a8157fe5b0154600280546001600160a01b039092169184908110611a9d57fe5b90600052602060002090600502018260058110611ab657fe5b0180546001600160a01b0319166001600160a01b039290921691909117905560001901611a52565b5050565b60008082604051602001611af69190612077565b60408051601f19818403018152919052805160209091012060025490915060005b818110156112cb57600060028281548110611b2e57fe5b60009182526020822060059091020101546001600160a01b0316905080611b555750611c04565b806001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b158015611b8e57600080fd5b505afa158015611ba2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611bca9190810190611d65565b604051602001611bda9190612077565b60405160208183030381529060405280519060200120841415611c02575092506106e3915050565b505b600101611b17565b6040518060a001604052806005906020820280368337509192915050565b600060208284031215611c3b578081fd5b8135611c4681612115565b9392505050565b60006020808385031215611c5f578182fd5b82356001600160401b0380821115611c75578384fd5b818501915085601f830112611c88578384fd5b813581811115611c9457fe5b8381029150611ca48483016120a1565b8181528481019084860184860187018a1015611cbe578788fd5b8795505b83861015611ce0578035835260019590950194918601918601611cc2565b5098975050505050505050565b600060208284031215611cfe578081fd5b81356001600160401b03811115611d13578182fd5b8201601f81018413611d23578182fd5b8035611d36611d31826120c4565b6120a1565b818152856020838501011115611d4a578384fd5b81602084016020830137908101602001929092525092915050565b600060208284031215611d76578081fd5b81516001600160401b03811115611d8b578182fd5b8201601f81018413611d9b578182fd5b8051611da9611d31826120c4565b818152856020838501011115611dbd578384fd5b611dce8260208301602086016120e5565b95945050505050565b600060208284031215611de8578081fd5b5035919050565b60008060408385031215611e01578081fd5b505080516020909101519092909150565b6000815180845260208085019450808401835b83811015611e4a5781516001600160a01b031687529582019590820190600101611e25565b509495945050505050565b6000815180845260208085018081965082840281019150828601855b85811015611e9b578284038952611e89848351611ed7565b98850198935090840190600101611e71565b5091979650505050505050565b6000815180845260208085019450808401835b83811015611e4a57815187529582019590820190600101611ebb565b60008151808452611eef8160208601602086016120e5565b601f01601f19169290920160200192915050565b6001600160a01b0391909116815260200190565b6020808252825182820181905260009190848201906040850190845b81811015611f585783516001600160a01b031683529284019291840191600101611f33565b50909695505050505050565b60a08101818360005b6005811015611f955781516001600160a01b0316835260209283019290910190600101611f6d565b50505092915050565b600060208252611c466020830184611e12565b600060208252611c466020830184611e55565b600060408252611fd76040830185611e55565b8281036020840152611dce8185611e12565b600060208252611c466020830184611ea8565b600060408252611fd76040830185611ea8565b6000604082526120226040830185611ea8565b8281036020840152611dce8185611e55565b6000606082526120476060830186611ea8565b82810360208401526120598186611e55565b9050828103604084015261206d8185611e12565b9695505050505050565b600060208252611c466020830184611ed7565b90815260200190565b918252602082015260400190565b6040518181016001600160401b03811182821017156120bc57fe5b604052919050565b60006001600160401b038211156120d757fe5b50601f01601f191660200190565b60005b838110156121005781810151838201526020016120e8565b8381111561210f576000848401525b50505050565b6001600160a01b038116811461130557600080fdfe4654534f20696e646578206e6f7420737570706f727465640000000000000000a2646970667358221220d1f812e478a3bd4375203d7ef0778d5866fb6960f756f24788d30613a03dcdb264736f6c63430007060033