Contract Overview
Balance:
0 Ether
More Info
My Name Tag:
Not Available
[ Download CSV Export ]
Latest 25 internal transaction
[ Download CSV Export ]
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
FeePool
Compiler Version
v0.5.16+commit.9c3226ce
Optimization Enabled:
Yes with 1500 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity)
/** *Submitted for verification at Etherscan.io on 2022-03-16 */ /* ⚠⚠⚠ WARNING WARNING WARNING ⚠⚠⚠ This is a TARGET contract - DO NOT CONNECT TO IT DIRECTLY IN YOUR CONTRACTS or DAPPS! This contract has an associated PROXY that MUST be used for all integrations - this TARGET will be REPLACED in an upcoming Synthetix release! The proxy for this contract can be found here: https://contracts.synthetix.io/kovan/ProxyFeePool *//* ____ __ __ __ _ / __/__ __ ___ / /_ / / ___ / /_ (_)__ __ _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ / /___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\ /___/ * Synthetix: FeePool.sol * * Latest source (may be newer): https://github.com/Synthetixio/synthetix/blob/master/contracts/FeePool.sol * Docs: https://docs.synthetix.io/contracts/FeePool * * Contract Dependencies: * - EternalStorage * - IAddressResolver * - IFeePool * - LimitedSetup * - MixinResolver * - MixinSystemSettings * - Owned * - Proxyable * - State * Libraries: * - SafeDecimalMath * - SafeMath * - VestingEntries * * MIT License * =========== * * Copyright (c) 2022 Synthetix * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity ^0.5.16; // https://docs.synthetix.io/contracts/source/contracts/owned contract Owned { address public owner; address public nominatedOwner; constructor(address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { _onlyOwner(); _; } function _onlyOwner() private view { require(msg.sender == owner, "Only the contract owner may perform this action"); } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); } // Inheritance // Internal references // https://docs.synthetix.io/contracts/source/contracts/proxy contract Proxy is Owned { Proxyable public target; constructor(address _owner) public Owned(_owner) {} function setTarget(Proxyable _target) external onlyOwner { target = _target; emit TargetUpdated(_target); } function _emit( bytes calldata callData, uint numTopics, bytes32 topic1, bytes32 topic2, bytes32 topic3, bytes32 topic4 ) external onlyTarget { uint size = callData.length; bytes memory _callData = callData; assembly { /* The first 32 bytes of callData contain its length (as specified by the abi). * Length is assumed to be a uint256 and therefore maximum of 32 bytes * in length. It is also leftpadded to be a multiple of 32 bytes. * This means moving call_data across 32 bytes guarantees we correctly access * the data itself. */ switch numTopics case 0 { log0(add(_callData, 32), size) } case 1 { log1(add(_callData, 32), size, topic1) } case 2 { log2(add(_callData, 32), size, topic1, topic2) } case 3 { log3(add(_callData, 32), size, topic1, topic2, topic3) } case 4 { log4(add(_callData, 32), size, topic1, topic2, topic3, topic4) } } } // solhint-disable no-complex-fallback function() external payable { // Mutable call setting Proxyable.messageSender as this is using call not delegatecall target.setMessageSender(msg.sender); assembly { let free_ptr := mload(0x40) calldatacopy(free_ptr, 0, calldatasize) /* We must explicitly forward ether to the underlying contract as well. */ let result := call(gas, sload(target_slot), callvalue, free_ptr, calldatasize, 0, 0) returndatacopy(free_ptr, 0, returndatasize) if iszero(result) { revert(free_ptr, returndatasize) } return(free_ptr, returndatasize) } } modifier onlyTarget { require(Proxyable(msg.sender) == target, "Must be proxy target"); _; } event TargetUpdated(Proxyable newTarget); } // Inheritance // Internal references // https://docs.synthetix.io/contracts/source/contracts/proxyable contract Proxyable is Owned { // This contract should be treated like an abstract contract /* The proxy this contract exists behind. */ Proxy public proxy; /* The caller of the proxy, passed through to this contract. * Note that every function using this member must apply the onlyProxy or * optionalProxy modifiers, otherwise their invocations can use stale values. */ address public messageSender; constructor(address payable _proxy) internal { // This contract is abstract, and thus cannot be instantiated directly require(owner != address(0), "Owner must be set"); proxy = Proxy(_proxy); emit ProxyUpdated(_proxy); } function setProxy(address payable _proxy) external onlyOwner { proxy = Proxy(_proxy); emit ProxyUpdated(_proxy); } function setMessageSender(address sender) external onlyProxy { messageSender = sender; } modifier onlyProxy { _onlyProxy(); _; } function _onlyProxy() private view { require(Proxy(msg.sender) == proxy, "Only the proxy can call"); } modifier optionalProxy { _optionalProxy(); _; } function _optionalProxy() private { if (Proxy(msg.sender) != proxy && messageSender != msg.sender) { messageSender = msg.sender; } } modifier optionalProxy_onlyOwner { _optionalProxy_onlyOwner(); _; } // solhint-disable-next-line func-name-mixedcase function _optionalProxy_onlyOwner() private { if (Proxy(msg.sender) != proxy && messageSender != msg.sender) { messageSender = msg.sender; } require(messageSender == owner, "Owner only function"); } event ProxyUpdated(address proxyAddress); } // https://docs.synthetix.io/contracts/source/contracts/limitedsetup contract LimitedSetup { uint public setupExpiryTime; /** * @dev LimitedSetup Constructor. * @param setupDuration The time the setup period will last for. */ constructor(uint setupDuration) internal { setupExpiryTime = now + setupDuration; } modifier onlyDuringSetup { require(now < setupExpiryTime, "Can only perform this action during setup"); _; } } // https://docs.synthetix.io/contracts/source/interfaces/iaddressresolver interface IAddressResolver { function getAddress(bytes32 name) external view returns (address); function getSynth(bytes32 key) external view returns (address); function requireAndGetAddress(bytes32 name, string calldata reason) external view returns (address); } // https://docs.synthetix.io/contracts/source/interfaces/isynth interface ISynth { // Views function currencyKey() external view returns (bytes32); function transferableSynths(address account) external view returns (uint); // Mutative functions function transferAndSettle(address to, uint value) external returns (bool); function transferFromAndSettle( address from, address to, uint value ) external returns (bool); // Restricted: used internally to Synthetix function burn(address account, uint amount) external; function issue(address account, uint amount) external; } // https://docs.synthetix.io/contracts/source/interfaces/iissuer interface IIssuer { // Views function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid); function availableCurrencyKeys() external view returns (bytes32[] memory); function availableSynthCount() external view returns (uint); function availableSynths(uint index) external view returns (ISynth); function canBurnSynths(address account) external view returns (bool); function collateral(address account) external view returns (uint); function collateralisationRatio(address issuer) external view returns (uint); function collateralisationRatioAndAnyRatesInvalid(address _issuer) external view returns (uint cratio, bool anyRateIsInvalid); function debtBalanceOf(address issuer, bytes32 currencyKey) external view returns (uint debtBalance); function issuanceRatio() external view returns (uint); function lastIssueEvent(address account) external view returns (uint); function maxIssuableSynths(address issuer) external view returns (uint maxIssuable); function minimumStakeTime() external view returns (uint); function remainingIssuableSynths(address issuer) external view returns ( uint maxIssuable, uint alreadyIssued, uint totalSystemDebt ); function synths(bytes32 currencyKey) external view returns (ISynth); function getSynths(bytes32[] calldata currencyKeys) external view returns (ISynth[] memory); function synthsByAddress(address synthAddress) external view returns (bytes32); function totalIssuedSynths(bytes32 currencyKey, bool excludeOtherCollateral) external view returns (uint); function transferableSynthetixAndAnyRateIsInvalid(address account, uint balance) external view returns (uint transferable, bool anyRateIsInvalid); // Restricted: used internally to Synthetix function issueSynths(address from, uint amount) external; function issueSynthsOnBehalf( address issueFor, address from, uint amount ) external; function issueMaxSynths(address from) external; function issueMaxSynthsOnBehalf(address issueFor, address from) external; function burnSynths(address from, uint amount) external; function burnSynthsOnBehalf( address burnForAddress, address from, uint amount ) external; function burnSynthsToTarget(address from) external; function burnSynthsToTargetOnBehalf(address burnForAddress, address from) external; function burnForRedemption( address deprecatedSynthProxy, address account, uint balance ) external; function liquidateDelinquentAccount( address account, uint susdAmount, address liquidator ) external returns (uint totalRedeemed, uint amountToLiquidate); function setCurrentPeriodId(uint128 periodId) external; } // Inheritance // Internal references // https://docs.synthetix.io/contracts/source/contracts/addressresolver contract AddressResolver is Owned, IAddressResolver { mapping(bytes32 => address) public repository; constructor(address _owner) public Owned(_owner) {} /* ========== RESTRICTED FUNCTIONS ========== */ function importAddresses(bytes32[] calldata names, address[] calldata destinations) external onlyOwner { require(names.length == destinations.length, "Input lengths must match"); for (uint i = 0; i < names.length; i++) { bytes32 name = names[i]; address destination = destinations[i]; repository[name] = destination; emit AddressImported(name, destination); } } /* ========= PUBLIC FUNCTIONS ========== */ function rebuildCaches(MixinResolver[] calldata destinations) external { for (uint i = 0; i < destinations.length; i++) { destinations[i].rebuildCache(); } } /* ========== VIEWS ========== */ function areAddressesImported(bytes32[] calldata names, address[] calldata destinations) external view returns (bool) { for (uint i = 0; i < names.length; i++) { if (repository[names[i]] != destinations[i]) { return false; } } return true; } function getAddress(bytes32 name) external view returns (address) { return repository[name]; } function requireAndGetAddress(bytes32 name, string calldata reason) external view returns (address) { address _foundAddress = repository[name]; require(_foundAddress != address(0), reason); return _foundAddress; } function getSynth(bytes32 key) external view returns (address) { IIssuer issuer = IIssuer(repository["Issuer"]); require(address(issuer) != address(0), "Cannot find Issuer address"); return address(issuer.synths(key)); } /* ========== EVENTS ========== */ event AddressImported(bytes32 name, address destination); } // Internal references // https://docs.synthetix.io/contracts/source/contracts/mixinresolver contract MixinResolver { AddressResolver public resolver; mapping(bytes32 => address) private addressCache; constructor(address _resolver) internal { resolver = AddressResolver(_resolver); } /* ========== INTERNAL FUNCTIONS ========== */ function combineArrays(bytes32[] memory first, bytes32[] memory second) internal pure returns (bytes32[] memory combination) { combination = new bytes32[](first.length + second.length); for (uint i = 0; i < first.length; i++) { combination[i] = first[i]; } for (uint j = 0; j < second.length; j++) { combination[first.length + j] = second[j]; } } /* ========== PUBLIC FUNCTIONS ========== */ // Note: this function is public not external in order for it to be overridden and invoked via super in subclasses function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {} function rebuildCache() public { bytes32[] memory requiredAddresses = resolverAddressesRequired(); // The resolver must call this function whenver it updates its state for (uint i = 0; i < requiredAddresses.length; i++) { bytes32 name = requiredAddresses[i]; // Note: can only be invoked once the resolver has all the targets needed added address destination = resolver.requireAndGetAddress(name, string(abi.encodePacked("Resolver missing target: ", name))); addressCache[name] = destination; emit CacheUpdated(name, destination); } } /* ========== VIEWS ========== */ function isResolverCached() external view returns (bool) { bytes32[] memory requiredAddresses = resolverAddressesRequired(); for (uint i = 0; i < requiredAddresses.length; i++) { bytes32 name = requiredAddresses[i]; // false if our cache is invalid or if the resolver doesn't have the required address if (resolver.getAddress(name) != addressCache[name] || addressCache[name] == address(0)) { return false; } } return true; } /* ========== INTERNAL FUNCTIONS ========== */ function requireAndGetAddress(bytes32 name) internal view returns (address) { address _foundAddress = addressCache[name]; require(_foundAddress != address(0), string(abi.encodePacked("Missing address: ", name))); return _foundAddress; } /* ========== EVENTS ========== */ event CacheUpdated(bytes32 name, address destination); } // https://docs.synthetix.io/contracts/source/interfaces/iflexiblestorage interface IFlexibleStorage { // Views function getUIntValue(bytes32 contractName, bytes32 record) external view returns (uint); function getUIntValues(bytes32 contractName, bytes32[] calldata records) external view returns (uint[] memory); function getIntValue(bytes32 contractName, bytes32 record) external view returns (int); function getIntValues(bytes32 contractName, bytes32[] calldata records) external view returns (int[] memory); function getAddressValue(bytes32 contractName, bytes32 record) external view returns (address); function getAddressValues(bytes32 contractName, bytes32[] calldata records) external view returns (address[] memory); function getBoolValue(bytes32 contractName, bytes32 record) external view returns (bool); function getBoolValues(bytes32 contractName, bytes32[] calldata records) external view returns (bool[] memory); function getBytes32Value(bytes32 contractName, bytes32 record) external view returns (bytes32); function getBytes32Values(bytes32 contractName, bytes32[] calldata records) external view returns (bytes32[] memory); // Mutative functions function deleteUIntValue(bytes32 contractName, bytes32 record) external; function deleteIntValue(bytes32 contractName, bytes32 record) external; function deleteAddressValue(bytes32 contractName, bytes32 record) external; function deleteBoolValue(bytes32 contractName, bytes32 record) external; function deleteBytes32Value(bytes32 contractName, bytes32 record) external; function setUIntValue( bytes32 contractName, bytes32 record, uint value ) external; function setUIntValues( bytes32 contractName, bytes32[] calldata records, uint[] calldata values ) external; function setIntValue( bytes32 contractName, bytes32 record, int value ) external; function setIntValues( bytes32 contractName, bytes32[] calldata records, int[] calldata values ) external; function setAddressValue( bytes32 contractName, bytes32 record, address value ) external; function setAddressValues( bytes32 contractName, bytes32[] calldata records, address[] calldata values ) external; function setBoolValue( bytes32 contractName, bytes32 record, bool value ) external; function setBoolValues( bytes32 contractName, bytes32[] calldata records, bool[] calldata values ) external; function setBytes32Value( bytes32 contractName, bytes32 record, bytes32 value ) external; function setBytes32Values( bytes32 contractName, bytes32[] calldata records, bytes32[] calldata values ) external; } // Internal references // https://docs.synthetix.io/contracts/source/contracts/mixinsystemsettings contract MixinSystemSettings is MixinResolver { // must match the one defined SystemSettingsLib, defined in both places due to sol v0.5 limitations bytes32 internal constant SETTING_CONTRACT_NAME = "SystemSettings"; bytes32 internal constant SETTING_WAITING_PERIOD_SECS = "waitingPeriodSecs"; bytes32 internal constant SETTING_PRICE_DEVIATION_THRESHOLD_FACTOR = "priceDeviationThresholdFactor"; bytes32 internal constant SETTING_ISSUANCE_RATIO = "issuanceRatio"; bytes32 internal constant SETTING_FEE_PERIOD_DURATION = "feePeriodDuration"; bytes32 internal constant SETTING_TARGET_THRESHOLD = "targetThreshold"; bytes32 internal constant SETTING_LIQUIDATION_DELAY = "liquidationDelay"; bytes32 internal constant SETTING_LIQUIDATION_RATIO = "liquidationRatio"; bytes32 internal constant SETTING_LIQUIDATION_PENALTY = "liquidationPenalty"; bytes32 internal constant SETTING_RATE_STALE_PERIOD = "rateStalePeriod"; /* ========== Exchange Fees Related ========== */ bytes32 internal constant SETTING_EXCHANGE_FEE_RATE = "exchangeFeeRate"; bytes32 internal constant SETTING_EXCHANGE_DYNAMIC_FEE_THRESHOLD = "exchangeDynamicFeeThreshold"; bytes32 internal constant SETTING_EXCHANGE_DYNAMIC_FEE_WEIGHT_DECAY = "exchangeDynamicFeeWeightDecay"; bytes32 internal constant SETTING_EXCHANGE_DYNAMIC_FEE_ROUNDS = "exchangeDynamicFeeRounds"; bytes32 internal constant SETTING_EXCHANGE_MAX_DYNAMIC_FEE = "exchangeMaxDynamicFee"; /* ========== End Exchange Fees Related ========== */ bytes32 internal constant SETTING_MINIMUM_STAKE_TIME = "minimumStakeTime"; bytes32 internal constant SETTING_AGGREGATOR_WARNING_FLAGS = "aggregatorWarningFlags"; bytes32 internal constant SETTING_TRADING_REWARDS_ENABLED = "tradingRewardsEnabled"; bytes32 internal constant SETTING_DEBT_SNAPSHOT_STALE_TIME = "debtSnapshotStaleTime"; bytes32 internal constant SETTING_CROSS_DOMAIN_DEPOSIT_GAS_LIMIT = "crossDomainDepositGasLimit"; bytes32 internal constant SETTING_CROSS_DOMAIN_ESCROW_GAS_LIMIT = "crossDomainEscrowGasLimit"; bytes32 internal constant SETTING_CROSS_DOMAIN_REWARD_GAS_LIMIT = "crossDomainRewardGasLimit"; bytes32 internal constant SETTING_CROSS_DOMAIN_WITHDRAWAL_GAS_LIMIT = "crossDomainWithdrawalGasLimit"; bytes32 internal constant SETTING_CROSS_DOMAIN_FEE_PERIOD_CLOSE_GAS_LIMIT = "crossDomainCloseGasLimit"; bytes32 internal constant SETTING_CROSS_DOMAIN_RELAY_GAS_LIMIT = "crossDomainRelayGasLimit"; bytes32 internal constant SETTING_ETHER_WRAPPER_MAX_ETH = "etherWrapperMaxETH"; bytes32 internal constant SETTING_ETHER_WRAPPER_MINT_FEE_RATE = "etherWrapperMintFeeRate"; bytes32 internal constant SETTING_ETHER_WRAPPER_BURN_FEE_RATE = "etherWrapperBurnFeeRate"; bytes32 internal constant SETTING_WRAPPER_MAX_TOKEN_AMOUNT = "wrapperMaxTokens"; bytes32 internal constant SETTING_WRAPPER_MINT_FEE_RATE = "wrapperMintFeeRate"; bytes32 internal constant SETTING_WRAPPER_BURN_FEE_RATE = "wrapperBurnFeeRate"; bytes32 internal constant SETTING_INTERACTION_DELAY = "interactionDelay"; bytes32 internal constant SETTING_COLLAPSE_FEE_RATE = "collapseFeeRate"; bytes32 internal constant SETTING_ATOMIC_MAX_VOLUME_PER_BLOCK = "atomicMaxVolumePerBlock"; bytes32 internal constant SETTING_ATOMIC_TWAP_WINDOW = "atomicTwapWindow"; bytes32 internal constant SETTING_ATOMIC_EQUIVALENT_FOR_DEX_PRICING = "atomicEquivalentForDexPricing"; bytes32 internal constant SETTING_ATOMIC_EXCHANGE_FEE_RATE = "atomicExchangeFeeRate"; bytes32 internal constant SETTING_ATOMIC_PRICE_BUFFER = "atomicPriceBuffer"; bytes32 internal constant SETTING_ATOMIC_VOLATILITY_CONSIDERATION_WINDOW = "atomicVolConsiderationWindow"; bytes32 internal constant SETTING_ATOMIC_VOLATILITY_UPDATE_THRESHOLD = "atomicVolUpdateThreshold"; bytes32 internal constant CONTRACT_FLEXIBLESTORAGE = "FlexibleStorage"; enum CrossDomainMessageGasLimits {Deposit, Escrow, Reward, Withdrawal, CloseFeePeriod, Relay} struct DynamicFeeConfig { uint threshold; uint weightDecay; uint rounds; uint maxFee; } constructor(address _resolver) internal MixinResolver(_resolver) {} function resolverAddressesRequired() public view returns (bytes32[] memory addresses) { addresses = new bytes32[](1); addresses[0] = CONTRACT_FLEXIBLESTORAGE; } function flexibleStorage() internal view returns (IFlexibleStorage) { return IFlexibleStorage(requireAndGetAddress(CONTRACT_FLEXIBLESTORAGE)); } function _getGasLimitSetting(CrossDomainMessageGasLimits gasLimitType) internal pure returns (bytes32) { if (gasLimitType == CrossDomainMessageGasLimits.Deposit) { return SETTING_CROSS_DOMAIN_DEPOSIT_GAS_LIMIT; } else if (gasLimitType == CrossDomainMessageGasLimits.Escrow) { return SETTING_CROSS_DOMAIN_ESCROW_GAS_LIMIT; } else if (gasLimitType == CrossDomainMessageGasLimits.Reward) { return SETTING_CROSS_DOMAIN_REWARD_GAS_LIMIT; } else if (gasLimitType == CrossDomainMessageGasLimits.Withdrawal) { return SETTING_CROSS_DOMAIN_WITHDRAWAL_GAS_LIMIT; } else if (gasLimitType == CrossDomainMessageGasLimits.Relay) { return SETTING_CROSS_DOMAIN_RELAY_GAS_LIMIT; } else if (gasLimitType == CrossDomainMessageGasLimits.CloseFeePeriod) { return SETTING_CROSS_DOMAIN_FEE_PERIOD_CLOSE_GAS_LIMIT; } else { revert("Unknown gas limit type"); } } function getCrossDomainMessageGasLimit(CrossDomainMessageGasLimits gasLimitType) internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, _getGasLimitSetting(gasLimitType)); } function getTradingRewardsEnabled() internal view returns (bool) { return flexibleStorage().getBoolValue(SETTING_CONTRACT_NAME, SETTING_TRADING_REWARDS_ENABLED); } function getWaitingPeriodSecs() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_WAITING_PERIOD_SECS); } function getPriceDeviationThresholdFactor() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_PRICE_DEVIATION_THRESHOLD_FACTOR); } function getIssuanceRatio() internal view returns (uint) { // lookup on flexible storage directly for gas savings (rather than via SystemSettings) return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ISSUANCE_RATIO); } function getFeePeriodDuration() internal view returns (uint) { // lookup on flexible storage directly for gas savings (rather than via SystemSettings) return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_FEE_PERIOD_DURATION); } function getTargetThreshold() internal view returns (uint) { // lookup on flexible storage directly for gas savings (rather than via SystemSettings) return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_TARGET_THRESHOLD); } function getLiquidationDelay() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATION_DELAY); } function getLiquidationRatio() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATION_RATIO); } function getLiquidationPenalty() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATION_PENALTY); } function getRateStalePeriod() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_RATE_STALE_PERIOD); } /* ========== Exchange Related Fees ========== */ function getExchangeFeeRate(bytes32 currencyKey) internal view returns (uint) { return flexibleStorage().getUIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_EXCHANGE_FEE_RATE, currencyKey)) ); } /// @notice Get exchange dynamic fee related keys /// @return threshold, weight decay, rounds, and max fee function getExchangeDynamicFeeConfig() internal view returns (DynamicFeeConfig memory) { bytes32[] memory keys = new bytes32[](4); keys[0] = SETTING_EXCHANGE_DYNAMIC_FEE_THRESHOLD; keys[1] = SETTING_EXCHANGE_DYNAMIC_FEE_WEIGHT_DECAY; keys[2] = SETTING_EXCHANGE_DYNAMIC_FEE_ROUNDS; keys[3] = SETTING_EXCHANGE_MAX_DYNAMIC_FEE; uint[] memory values = flexibleStorage().getUIntValues(SETTING_CONTRACT_NAME, keys); return DynamicFeeConfig({threshold: values[0], weightDecay: values[1], rounds: values[2], maxFee: values[3]}); } /* ========== End Exchange Related Fees ========== */ function getMinimumStakeTime() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_MINIMUM_STAKE_TIME); } function getAggregatorWarningFlags() internal view returns (address) { return flexibleStorage().getAddressValue(SETTING_CONTRACT_NAME, SETTING_AGGREGATOR_WARNING_FLAGS); } function getDebtSnapshotStaleTime() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_DEBT_SNAPSHOT_STALE_TIME); } function getEtherWrapperMaxETH() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ETHER_WRAPPER_MAX_ETH); } function getEtherWrapperMintFeeRate() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ETHER_WRAPPER_MINT_FEE_RATE); } function getEtherWrapperBurnFeeRate() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ETHER_WRAPPER_BURN_FEE_RATE); } function getWrapperMaxTokenAmount(address wrapper) internal view returns (uint) { return flexibleStorage().getUIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_WRAPPER_MAX_TOKEN_AMOUNT, wrapper)) ); } function getWrapperMintFeeRate(address wrapper) internal view returns (int) { return flexibleStorage().getIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_WRAPPER_MINT_FEE_RATE, wrapper)) ); } function getWrapperBurnFeeRate(address wrapper) internal view returns (int) { return flexibleStorage().getIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_WRAPPER_BURN_FEE_RATE, wrapper)) ); } function getInteractionDelay(address collateral) internal view returns (uint) { return flexibleStorage().getUIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_INTERACTION_DELAY, collateral)) ); } function getCollapseFeeRate(address collateral) internal view returns (uint) { return flexibleStorage().getUIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_COLLAPSE_FEE_RATE, collateral)) ); } function getAtomicMaxVolumePerBlock() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ATOMIC_MAX_VOLUME_PER_BLOCK); } function getAtomicTwapWindow() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_ATOMIC_TWAP_WINDOW); } function getAtomicEquivalentForDexPricing(bytes32 currencyKey) internal view returns (address) { return flexibleStorage().getAddressValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_ATOMIC_EQUIVALENT_FOR_DEX_PRICING, currencyKey)) ); } function getAtomicExchangeFeeRate(bytes32 currencyKey) internal view returns (uint) { return flexibleStorage().getUIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_ATOMIC_EXCHANGE_FEE_RATE, currencyKey)) ); } function getAtomicPriceBuffer(bytes32 currencyKey) internal view returns (uint) { return flexibleStorage().getUIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_ATOMIC_PRICE_BUFFER, currencyKey)) ); } function getAtomicVolatilityConsiderationWindow(bytes32 currencyKey) internal view returns (uint) { return flexibleStorage().getUIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_ATOMIC_VOLATILITY_CONSIDERATION_WINDOW, currencyKey)) ); } function getAtomicVolatilityUpdateThreshold(bytes32 currencyKey) internal view returns (uint) { return flexibleStorage().getUIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_ATOMIC_VOLATILITY_UPDATE_THRESHOLD, currencyKey)) ); } } // https://docs.synthetix.io/contracts/source/interfaces/ifeepool interface IFeePool { // Views // solhint-disable-next-line func-name-mixedcase function FEE_ADDRESS() external view returns (address); function feesAvailable(address account) external view returns (uint, uint); function feePeriodDuration() external view returns (uint); function isFeesClaimable(address account) external view returns (bool); function targetThreshold() external view returns (uint); function totalFeesAvailable() external view returns (uint); function totalRewardsAvailable() external view returns (uint); // Mutative Functions function claimFees() external returns (bool); function claimOnBehalf(address claimingForAddress) external returns (bool); function closeCurrentFeePeriod() external; function closeSecondary(uint snxBackedDebt, uint debtShareSupply) external; function recordFeePaid(uint sUSDAmount) external; function setRewardsToDistribute(uint amount) external; } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } // Libraries // https://docs.synthetix.io/contracts/source/libraries/safedecimalmath library SafeDecimalMath { using SafeMath for uint; /* Number of decimal places in the representations. */ uint8 public constant decimals = 18; uint8 public constant highPrecisionDecimals = 27; /* The number representing 1.0. */ uint public constant UNIT = 10**uint(decimals); /* The number representing 1.0 for higher fidelity numbers. */ uint public constant PRECISE_UNIT = 10**uint(highPrecisionDecimals); uint private constant UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR = 10**uint(highPrecisionDecimals - decimals); /** * @return Provides an interface to UNIT. */ function unit() external pure returns (uint) { return UNIT; } /** * @return Provides an interface to PRECISE_UNIT. */ function preciseUnit() external pure returns (uint) { return PRECISE_UNIT; } /** * @return The result of multiplying x and y, interpreting the operands as fixed-point * decimals. * * @dev A unit factor is divided out after the product of x and y is evaluated, * so that product must be less than 2**256. As this is an integer division, * the internal division always rounds down. This helps save on gas. Rounding * is more expensive on gas. */ function multiplyDecimal(uint x, uint y) internal pure returns (uint) { /* Divide by UNIT to remove the extra factor introduced by the product. */ return x.mul(y) / UNIT; } /** * @return The result of safely multiplying x and y, interpreting the operands * as fixed-point decimals of the specified precision unit. * * @dev The operands should be in the form of a the specified unit factor which will be * divided out after the product of x and y is evaluated, so that product must be * less than 2**256. * * Unlike multiplyDecimal, this function rounds the result to the nearest increment. * Rounding is useful when you need to retain fidelity for small decimal numbers * (eg. small fractions or percentages). */ function _multiplyDecimalRound( uint x, uint y, uint precisionUnit ) private pure returns (uint) { /* Divide by UNIT to remove the extra factor introduced by the product. */ uint quotientTimesTen = x.mul(y) / (precisionUnit / 10); if (quotientTimesTen % 10 >= 5) { quotientTimesTen += 10; } return quotientTimesTen / 10; } /** * @return The result of safely multiplying x and y, interpreting the operands * as fixed-point decimals of a precise unit. * * @dev The operands should be in the precise unit factor which will be * divided out after the product of x and y is evaluated, so that product must be * less than 2**256. * * Unlike multiplyDecimal, this function rounds the result to the nearest increment. * Rounding is useful when you need to retain fidelity for small decimal numbers * (eg. small fractions or percentages). */ function multiplyDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) { return _multiplyDecimalRound(x, y, PRECISE_UNIT); } /** * @return The result of safely multiplying x and y, interpreting the operands * as fixed-point decimals of a standard unit. * * @dev The operands should be in the standard unit factor which will be * divided out after the product of x and y is evaluated, so that product must be * less than 2**256. * * Unlike multiplyDecimal, this function rounds the result to the nearest increment. * Rounding is useful when you need to retain fidelity for small decimal numbers * (eg. small fractions or percentages). */ function multiplyDecimalRound(uint x, uint y) internal pure returns (uint) { return _multiplyDecimalRound(x, y, UNIT); } /** * @return The result of safely dividing x and y. The return value is a high * precision decimal. * * @dev y is divided after the product of x and the standard precision unit * is evaluated, so the product of x and UNIT must be less than 2**256. As * this is an integer division, the result is always rounded down. * This helps save on gas. Rounding is more expensive on gas. */ function divideDecimal(uint x, uint y) internal pure returns (uint) { /* Reintroduce the UNIT factor that will be divided out by y. */ return x.mul(UNIT).div(y); } /** * @return The result of safely dividing x and y. The return value is as a rounded * decimal in the precision unit specified in the parameter. * * @dev y is divided after the product of x and the specified precision unit * is evaluated, so the product of x and the specified precision unit must * be less than 2**256. The result is rounded to the nearest increment. */ function _divideDecimalRound( uint x, uint y, uint precisionUnit ) private pure returns (uint) { uint resultTimesTen = x.mul(precisionUnit * 10).div(y); if (resultTimesTen % 10 >= 5) { resultTimesTen += 10; } return resultTimesTen / 10; } /** * @return The result of safely dividing x and y. The return value is as a rounded * standard precision decimal. * * @dev y is divided after the product of x and the standard precision unit * is evaluated, so the product of x and the standard precision unit must * be less than 2**256. The result is rounded to the nearest increment. */ function divideDecimalRound(uint x, uint y) internal pure returns (uint) { return _divideDecimalRound(x, y, UNIT); } /** * @return The result of safely dividing x and y. The return value is as a rounded * high precision decimal. * * @dev y is divided after the product of x and the high precision unit * is evaluated, so the product of x and the high precision unit must * be less than 2**256. The result is rounded to the nearest increment. */ function divideDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) { return _divideDecimalRound(x, y, PRECISE_UNIT); } /** * @dev Convert a standard decimal representation to a high precision one. */ function decimalToPreciseDecimal(uint i) internal pure returns (uint) { return i.mul(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR); } /** * @dev Convert a high precision decimal to a standard decimal representation. */ function preciseDecimalToDecimal(uint i) internal pure returns (uint) { uint quotientTimesTen = i / (UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR / 10); if (quotientTimesTen % 10 >= 5) { quotientTimesTen += 10; } return quotientTimesTen / 10; } // Computes `a - b`, setting the value to 0 if b > a. function floorsub(uint a, uint b) internal pure returns (uint) { return b >= a ? 0 : a - b; } /* ---------- Utilities ---------- */ /* * Absolute value of the input, returned as a signed number. */ function signedAbs(int x) internal pure returns (int) { return x < 0 ? -x : x; } /* * Absolute value of the input, returned as an unsigned number. */ function abs(int x) internal pure returns (uint) { return uint(signedAbs(x)); } } interface AggregatorInterface { function latestAnswer() external view returns (int256); function latestTimestamp() external view returns (uint256); function latestRound() external view returns (uint256); function getAnswer(uint256 roundId) external view returns (int256); function getTimestamp(uint256 roundId) external view returns (uint256); event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 timestamp); event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt); } interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); } /** * @title The V2 & V3 Aggregator Interface * @notice Solidity V0.5 does not allow interfaces to inherit from other * interfaces so this contract is a combination of v0.5 AggregatorInterface.sol * and v0.5 AggregatorV3Interface.sol. */ interface AggregatorV2V3Interface { // // V2 Interface: // function latestAnswer() external view returns (int256); function latestTimestamp() external view returns (uint256); function latestRound() external view returns (uint256); function getAnswer(uint256 roundId) external view returns (int256); function getTimestamp(uint256 roundId) external view returns (uint256); event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 timestamp); event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt); // // V3 Interface: // function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); } // https://docs.synthetix.io/contracts/source/interfaces/ierc20 interface IERC20 { // ERC20 Optional Views function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); // Views function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); // Mutative functions function transfer(address to, uint value) external returns (bool); function approve(address spender, uint value) external returns (bool); function transferFrom( address from, address to, uint value ) external returns (bool); // Events event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } // https://docs.synthetix.io/contracts/source/interfaces/isystemstatus interface ISystemStatus { struct Status { bool canSuspend; bool canResume; } struct Suspension { bool suspended; // reason is an integer code, // 0 => no reason, 1 => upgrading, 2+ => defined by system usage uint248 reason; } // Views function accessControl(bytes32 section, address account) external view returns (bool canSuspend, bool canResume); function requireSystemActive() external view; function systemSuspended() external view returns (bool); function requireIssuanceActive() external view; function requireExchangeActive() external view; function requireFuturesActive() external view; function requireFuturesMarketActive(bytes32 marketKey) external view; function requireExchangeBetweenSynthsAllowed(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view; function requireSynthActive(bytes32 currencyKey) external view; function synthSuspended(bytes32 currencyKey) external view returns (bool); function requireSynthsActive(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view; function systemSuspension() external view returns (bool suspended, uint248 reason); function issuanceSuspension() external view returns (bool suspended, uint248 reason); function exchangeSuspension() external view returns (bool suspended, uint248 reason); function futuresSuspension() external view returns (bool suspended, uint248 reason); function synthExchangeSuspension(bytes32 currencyKey) external view returns (bool suspended, uint248 reason); function synthSuspension(bytes32 currencyKey) external view returns (bool suspended, uint248 reason); function futuresMarketSuspension(bytes32 marketKey) external view returns (bool suspended, uint248 reason); function getSynthExchangeSuspensions(bytes32[] calldata synths) external view returns (bool[] memory exchangeSuspensions, uint256[] memory reasons); function getSynthSuspensions(bytes32[] calldata synths) external view returns (bool[] memory suspensions, uint256[] memory reasons); function getFuturesMarketSuspensions(bytes32[] calldata marketKeys) external view returns (bool[] memory suspensions, uint256[] memory reasons); // Restricted functions function suspendIssuance(uint256 reason) external; function suspendSynth(bytes32 currencyKey, uint256 reason) external; function suspendFuturesMarket(bytes32 marketKey, uint256 reason) external; function updateAccessControl( bytes32 section, address account, bool canSuspend, bool canResume ) external; } interface IVirtualSynth { // Views function balanceOfUnderlying(address account) external view returns (uint); function rate() external view returns (uint); function readyToSettle() external view returns (bool); function secsLeftInWaitingPeriod() external view returns (uint); function settled() external view returns (bool); function synth() external view returns (ISynth); // Mutative functions function settle(address account) external; } // https://docs.synthetix.io/contracts/source/interfaces/isynthetix interface ISynthetix { // Views function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid); function availableCurrencyKeys() external view returns (bytes32[] memory); function availableSynthCount() external view returns (uint); function availableSynths(uint index) external view returns (ISynth); function collateral(address account) external view returns (uint); function collateralisationRatio(address issuer) external view returns (uint); function debtBalanceOf(address issuer, bytes32 currencyKey) external view returns (uint); function isWaitingPeriod(bytes32 currencyKey) external view returns (bool); function maxIssuableSynths(address issuer) external view returns (uint maxIssuable); function remainingIssuableSynths(address issuer) external view returns ( uint maxIssuable, uint alreadyIssued, uint totalSystemDebt ); function synths(bytes32 currencyKey) external view returns (ISynth); function synthsByAddress(address synthAddress) external view returns (bytes32); function totalIssuedSynths(bytes32 currencyKey) external view returns (uint); function totalIssuedSynthsExcludeOtherCollateral(bytes32 currencyKey) external view returns (uint); function transferableSynthetix(address account) external view returns (uint transferable); // Mutative Functions function burnSynths(uint amount) external; function burnSynthsOnBehalf(address burnForAddress, uint amount) external; function burnSynthsToTarget() external; function burnSynthsToTargetOnBehalf(address burnForAddress) external; function exchange( bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey ) external returns (uint amountReceived); function exchangeOnBehalf( address exchangeForAddress, bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey ) external returns (uint amountReceived); function exchangeWithTracking( bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, address rewardAddress, bytes32 trackingCode ) external returns (uint amountReceived); function exchangeWithTrackingForInitiator( bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, address rewardAddress, bytes32 trackingCode ) external returns (uint amountReceived); function exchangeOnBehalfWithTracking( address exchangeForAddress, bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, address rewardAddress, bytes32 trackingCode ) external returns (uint amountReceived); function exchangeWithVirtual( bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, bytes32 trackingCode ) external returns (uint amountReceived, IVirtualSynth vSynth); function exchangeAtomically( bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, bytes32 trackingCode ) external returns (uint amountReceived); function issueMaxSynths() external; function issueMaxSynthsOnBehalf(address issueForAddress) external; function issueSynths(uint amount) external; function issueSynthsOnBehalf(address issueForAddress, uint amount) external; function mint() external returns (bool); function settle(bytes32 currencyKey) external returns ( uint reclaimed, uint refunded, uint numEntries ); // Liquidations function liquidateDelinquentAccount(address account, uint susdAmount) external returns (bool); // Restricted Functions function mintSecondary(address account, uint amount) external; function mintSecondaryRewards(uint amount) external; function burnSecondary(address account, uint amount) external; } // https://docs.synthetix.io/contracts/source/interfaces/isynthetixdebtshare interface ISynthetixDebtShare { // Views function currentPeriodId() external view returns (uint128); function allowance(address account, address spender) external view returns (uint); function balanceOf(address account) external view returns (uint); function balanceOfOnPeriod(address account, uint periodId) external view returns (uint); function totalSupply() external view returns (uint); function sharePercent(address account) external view returns (uint); function sharePercentOnPeriod(address account, uint periodId) external view returns (uint); // Mutative functions function takeSnapshot(uint128 id) external; function mintShare(address account, uint256 amount) external; function burnShare(address account, uint256 amount) external; function approve(address, uint256) external pure returns (bool); function transfer(address to, uint256 amount) external pure returns (bool); function transferFrom( address from, address to, uint256 amount ) external returns (bool); function addAuthorizedBroker(address target) external; function removeAuthorizedBroker(address target) external; function addAuthorizedToSnapshot(address target) external; function removeAuthorizedToSnapshot(address target) external; } // Inheritance // https://docs.synthetix.io/contracts/source/contracts/state contract State is Owned { // the address of the contract that can modify variables // this can only be changed by the owner of this contract address public associatedContract; constructor(address _associatedContract) internal { // This contract is abstract, and thus cannot be instantiated directly require(owner != address(0), "Owner must be set"); associatedContract = _associatedContract; emit AssociatedContractUpdated(_associatedContract); } /* ========== SETTERS ========== */ // Change the associated contract to a new address function setAssociatedContract(address _associatedContract) external onlyOwner { associatedContract = _associatedContract; emit AssociatedContractUpdated(_associatedContract); } /* ========== MODIFIERS ========== */ modifier onlyAssociatedContract { require(msg.sender == associatedContract, "Only the associated contract can perform this action"); _; } /* ========== EVENTS ========== */ event AssociatedContractUpdated(address associatedContract); } // Inheritance // https://docs.synthetix.io/contracts/source/contracts/eternalstorage /** * @notice This contract is based on the code available from this blog * https://blog.colony.io/writing-upgradeable-contracts-in-solidity-6743f0eecc88/ * Implements support for storing a keccak256 key and value pairs. It is the more flexible * and extensible option. This ensures data schema changes can be implemented without * requiring upgrades to the storage contract. */ contract EternalStorage is Owned, State { constructor(address _owner, address _associatedContract) public Owned(_owner) State(_associatedContract) {} /* ========== DATA TYPES ========== */ mapping(bytes32 => uint) internal UIntStorage; mapping(bytes32 => string) internal StringStorage; mapping(bytes32 => address) internal AddressStorage; mapping(bytes32 => bytes) internal BytesStorage; mapping(bytes32 => bytes32) internal Bytes32Storage; mapping(bytes32 => bool) internal BooleanStorage; mapping(bytes32 => int) internal IntStorage; // UIntStorage; function getUIntValue(bytes32 record) external view returns (uint) { return UIntStorage[record]; } function setUIntValue(bytes32 record, uint value) external onlyAssociatedContract { UIntStorage[record] = value; } function deleteUIntValue(bytes32 record) external onlyAssociatedContract { delete UIntStorage[record]; } // StringStorage function getStringValue(bytes32 record) external view returns (string memory) { return StringStorage[record]; } function setStringValue(bytes32 record, string calldata value) external onlyAssociatedContract { StringStorage[record] = value; } function deleteStringValue(bytes32 record) external onlyAssociatedContract { delete StringStorage[record]; } // AddressStorage function getAddressValue(bytes32 record) external view returns (address) { return AddressStorage[record]; } function setAddressValue(bytes32 record, address value) external onlyAssociatedContract { AddressStorage[record] = value; } function deleteAddressValue(bytes32 record) external onlyAssociatedContract { delete AddressStorage[record]; } // BytesStorage function getBytesValue(bytes32 record) external view returns (bytes memory) { return BytesStorage[record]; } function setBytesValue(bytes32 record, bytes calldata value) external onlyAssociatedContract { BytesStorage[record] = value; } function deleteBytesValue(bytes32 record) external onlyAssociatedContract { delete BytesStorage[record]; } // Bytes32Storage function getBytes32Value(bytes32 record) external view returns (bytes32) { return Bytes32Storage[record]; } function setBytes32Value(bytes32 record, bytes32 value) external onlyAssociatedContract { Bytes32Storage[record] = value; } function deleteBytes32Value(bytes32 record) external onlyAssociatedContract { delete Bytes32Storage[record]; } // BooleanStorage function getBooleanValue(bytes32 record) external view returns (bool) { return BooleanStorage[record]; } function setBooleanValue(bytes32 record, bool value) external onlyAssociatedContract { BooleanStorage[record] = value; } function deleteBooleanValue(bytes32 record) external onlyAssociatedContract { delete BooleanStorage[record]; } // IntStorage function getIntValue(bytes32 record) external view returns (int) { return IntStorage[record]; } function setIntValue(bytes32 record, int value) external onlyAssociatedContract { IntStorage[record] = value; } function deleteIntValue(bytes32 record) external onlyAssociatedContract { delete IntStorage[record]; } } // Inheritance // https://docs.synthetix.io/contracts/source/contracts/feepooleternalstorage contract FeePoolEternalStorage is EternalStorage, LimitedSetup { bytes32 internal constant LAST_FEE_WITHDRAWAL = "last_fee_withdrawal"; constructor(address _owner, address _feePool) public EternalStorage(_owner, _feePool) LimitedSetup(6 weeks) {} function importFeeWithdrawalData(address[] calldata accounts, uint[] calldata feePeriodIDs) external onlyOwner onlyDuringSetup { require(accounts.length == feePeriodIDs.length, "Length mismatch"); for (uint8 i = 0; i < accounts.length; i++) { this.setUIntValue(keccak256(abi.encodePacked(LAST_FEE_WITHDRAWAL, accounts[i])), feePeriodIDs[i]); } } } // https://docs.synthetix.io/contracts/source/interfaces/iexchanger interface IExchanger { struct ExchangeEntrySettlement { bytes32 src; uint amount; bytes32 dest; uint reclaim; uint rebate; uint srcRoundIdAtPeriodEnd; uint destRoundIdAtPeriodEnd; uint timestamp; } struct ExchangeEntry { uint sourceRate; uint destinationRate; uint destinationAmount; uint exchangeFeeRate; uint exchangeDynamicFeeRate; uint roundIdForSrc; uint roundIdForDest; } // Views function calculateAmountAfterSettlement( address from, bytes32 currencyKey, uint amount, uint refunded ) external view returns (uint amountAfterSettlement); function isSynthRateInvalid(bytes32 currencyKey) external view returns (bool); function maxSecsLeftInWaitingPeriod(address account, bytes32 currencyKey) external view returns (uint); function settlementOwing(address account, bytes32 currencyKey) external view returns ( uint reclaimAmount, uint rebateAmount, uint numEntries ); function hasWaitingPeriodOrSettlementOwing(address account, bytes32 currencyKey) external view returns (bool); function feeRateForExchange(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view returns (uint); function dynamicFeeRateForExchange(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view returns (uint feeRate, bool tooVolatile); function getAmountsForExchange( uint sourceAmount, bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey ) external view returns ( uint amountReceived, uint fee, uint exchangeFeeRate ); function priceDeviationThresholdFactor() external view returns (uint); function waitingPeriodSecs() external view returns (uint); function lastExchangeRate(bytes32 currencyKey) external view returns (uint); // Mutative functions function exchange( address exchangeForAddress, address from, bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, address destinationAddress, bool virtualSynth, address rewardAddress, bytes32 trackingCode ) external returns (uint amountReceived, IVirtualSynth vSynth); function exchangeAtomically( address from, bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, address destinationAddress, bytes32 trackingCode ) external returns (uint amountReceived); function settle(address from, bytes32 currencyKey) external returns ( uint reclaimed, uint refunded, uint numEntries ); function suspendSynthWithInvalidRate(bytes32 currencyKey) external; } pragma experimental ABIEncoderV2; library VestingEntries { struct VestingEntry { uint64 endTime; uint256 escrowAmount; } struct VestingEntryWithID { uint64 endTime; uint256 escrowAmount; uint256 entryID; } } interface IRewardEscrowV2 { // Views function balanceOf(address account) external view returns (uint); function numVestingEntries(address account) external view returns (uint); function totalEscrowedAccountBalance(address account) external view returns (uint); function totalVestedAccountBalance(address account) external view returns (uint); function getVestingQuantity(address account, uint256[] calldata entryIDs) external view returns (uint); function getVestingSchedules( address account, uint256 index, uint256 pageSize ) external view returns (VestingEntries.VestingEntryWithID[] memory); function getAccountVestingEntryIDs( address account, uint256 index, uint256 pageSize ) external view returns (uint256[] memory); function getVestingEntryClaimable(address account, uint256 entryID) external view returns (uint); function getVestingEntry(address account, uint256 entryID) external view returns (uint64, uint256); // Mutative functions function vest(uint256[] calldata entryIDs) external; function createEscrowEntry( address beneficiary, uint256 deposit, uint256 duration ) external; function appendVestingEntry( address account, uint256 quantity, uint256 duration ) external; function migrateVestingSchedule(address _addressToMigrate) external; function migrateAccountEscrowBalances( address[] calldata accounts, uint256[] calldata escrowBalances, uint256[] calldata vestedBalances ) external; // Account Merging function startMergingWindow() external; function mergeAccount(address accountToMerge, uint256[] calldata entryIDs) external; function nominateAccountToMerge(address account) external; function accountMergingIsOpen() external view returns (bool); // L2 Migration function importVestingEntries( address account, uint256 escrowedAmount, VestingEntries.VestingEntry[] calldata vestingEntries ) external; // Return amount of SNX transfered to SynthetixBridgeToOptimism deposit contract function burnForMigration(address account, uint256[] calldata entryIDs) external returns (uint256 escrowedAccountBalance, VestingEntries.VestingEntry[] memory vestingEntries); } // https://docs.synthetix.io/contracts/source/interfaces/idelegateapprovals interface IDelegateApprovals { // Views function canBurnFor(address authoriser, address delegate) external view returns (bool); function canIssueFor(address authoriser, address delegate) external view returns (bool); function canClaimFor(address authoriser, address delegate) external view returns (bool); function canExchangeFor(address authoriser, address delegate) external view returns (bool); // Mutative function approveAllDelegatePowers(address delegate) external; function removeAllDelegatePowers(address delegate) external; function approveBurnOnBehalf(address delegate) external; function removeBurnOnBehalf(address delegate) external; function approveIssueOnBehalf(address delegate) external; function removeIssueOnBehalf(address delegate) external; function approveClaimOnBehalf(address delegate) external; function removeClaimOnBehalf(address delegate) external; function approveExchangeOnBehalf(address delegate) external; function removeExchangeOnBehalf(address delegate) external; } // https://docs.synthetix.io/contracts/source/interfaces/irewardsdistribution interface IRewardsDistribution { // Structs struct DistributionData { address destination; uint amount; } // Views function authority() external view returns (address); function distributions(uint index) external view returns (address destination, uint amount); // DistributionData function distributionsLength() external view returns (uint); // Mutative Functions function distributeRewards(uint amount) external returns (bool); } interface ICollateralManager { // Manager information function hasCollateral(address collateral) external view returns (bool); function isSynthManaged(bytes32 currencyKey) external view returns (bool); // State information function long(bytes32 synth) external view returns (uint amount); function short(bytes32 synth) external view returns (uint amount); function totalLong() external view returns (uint susdValue, bool anyRateIsInvalid); function totalShort() external view returns (uint susdValue, bool anyRateIsInvalid); function getBorrowRate() external view returns (uint borrowRate, bool anyRateIsInvalid); function getShortRate(bytes32 synth) external view returns (uint shortRate, bool rateIsInvalid); function getRatesAndTime(uint index) external view returns ( uint entryRate, uint lastRate, uint lastUpdated, uint newIndex ); function getShortRatesAndTime(bytes32 currency, uint index) external view returns ( uint entryRate, uint lastRate, uint lastUpdated, uint newIndex ); function exceedsDebtLimit(uint amount, bytes32 currency) external view returns (bool canIssue, bool anyRateIsInvalid); function areSynthsAndCurrenciesSet(bytes32[] calldata requiredSynthNamesInResolver, bytes32[] calldata synthKeys) external view returns (bool); function areShortableSynthsSet(bytes32[] calldata requiredSynthNamesInResolver, bytes32[] calldata synthKeys) external view returns (bool); // Loans function getNewLoanId() external returns (uint id); // Manager mutative function addCollaterals(address[] calldata collaterals) external; function removeCollaterals(address[] calldata collaterals) external; function addSynths(bytes32[] calldata synthNamesInResolver, bytes32[] calldata synthKeys) external; function removeSynths(bytes32[] calldata synths, bytes32[] calldata synthKeys) external; function addShortableSynths(bytes32[] calldata requiredSynthNamesInResolver, bytes32[] calldata synthKeys) external; function removeShortableSynths(bytes32[] calldata synths) external; // State mutative function incrementLongs(bytes32 synth, uint amount) external; function decrementLongs(bytes32 synth, uint amount) external; function incrementShorts(bytes32 synth, uint amount) external; function decrementShorts(bytes32 synth, uint amount) external; function accrueInterest( uint interestIndex, bytes32 currency, bool isShort ) external returns (uint difference, uint index); function updateBorrowRatesCollateral(uint rate) external; function updateShortRatesCollateral(bytes32 currency, uint rate) external; } interface IWETH { // ERC20 Optional Views function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); // Views function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); // Mutative functions function transfer(address to, uint value) external returns (bool); function approve(address spender, uint value) external returns (bool); function transferFrom( address from, address to, uint value ) external returns (bool); // WETH-specific functions. function deposit() external payable; function withdraw(uint amount) external; // Events event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); event Deposit(address indexed to, uint amount); event Withdrawal(address indexed to, uint amount); } // https://docs.synthetix.io/contracts/source/interfaces/ietherwrapper contract IEtherWrapper { function mint(uint amount) external; function burn(uint amount) external; function distributeFees() external; function capacity() external view returns (uint); function getReserves() external view returns (uint); function totalIssuedSynths() external view returns (uint); function calculateMintFee(uint amount) public view returns (uint); function calculateBurnFee(uint amount) public view returns (uint); function maxETH() public view returns (uint256); function mintFeeRate() public view returns (uint256); function burnFeeRate() public view returns (uint256); function weth() public view returns (IWETH); } interface IFuturesMarketManager { function markets(uint index, uint pageSize) external view returns (address[] memory); function numMarkets() external view returns (uint); function allMarkets() external view returns (address[] memory); function marketForKey(bytes32 marketKey) external view returns (address); function marketsForKeys(bytes32[] calldata marketKeys) external view returns (address[] memory); function totalDebt() external view returns (uint debt, bool isInvalid); } // https://docs.synthetix.io/contracts/source/interfaces/iwrapperfactory interface IWrapperFactory { function isWrapper(address possibleWrapper) external view returns (bool); function createWrapper( IERC20 token, bytes32 currencyKey, bytes32 synthContractName ) external returns (address); function distributeFees() external; } interface ISynthetixBridgeToOptimism { function closeFeePeriod(uint snxBackedDebt, uint debtSharesSupply) external; function migrateEscrow(uint256[][] calldata entryIDs) external; function depositReward(uint amount) external; function depositAndMigrateEscrow(uint256 depositAmount, uint256[][] calldata entryIDs) external; } // Inheritance // Libraries // Internal references // https://docs.synthetix.io/contracts/source/contracts/feepool contract FeePool is Owned, Proxyable, LimitedSetup, MixinSystemSettings, IFeePool { using SafeMath for uint; using SafeDecimalMath for uint; bytes32 public constant CONTRACT_NAME = "FeePool"; // Where fees are pooled in sUSD. address public constant FEE_ADDRESS = 0xfeEFEEfeefEeFeefEEFEEfEeFeefEEFeeFEEFEeF; // sUSD currencyKey. Fees stored and paid in sUSD bytes32 private sUSD = "sUSD"; // This struct represents the issuance activity that's happened in a fee period. struct FeePeriod { uint64 feePeriodId; uint64 startTime; uint allNetworksSnxBackedDebt; uint allNetworksDebtSharesSupply; uint feesToDistribute; uint feesClaimed; uint rewardsToDistribute; uint rewardsClaimed; } // A staker(mintr) can claim from the previous fee period (7 days) only. // Fee Periods stored and managed from [0], such that [0] is always // the current active fee period which is not claimable until the // public function closeCurrentFeePeriod() is called closing the // current weeks collected fees. [1] is last weeks feeperiod uint8 public constant FEE_PERIOD_LENGTH = 2; FeePeriod[FEE_PERIOD_LENGTH] private _recentFeePeriods; uint256 private _currentFeePeriod; /* ========== ADDRESS RESOLVER CONFIGURATION ========== */ bytes32 private constant CONTRACT_SYSTEMSTATUS = "SystemStatus"; bytes32 private constant CONTRACT_SYNTHETIXDEBTSHARE = "SynthetixDebtShare"; bytes32 private constant CONTRACT_FEEPOOLETERNALSTORAGE = "FeePoolEternalStorage"; bytes32 private constant CONTRACT_EXCHANGER = "Exchanger"; bytes32 private constant CONTRACT_ISSUER = "Issuer"; bytes32 private constant CONTRACT_REWARDESCROW_V2 = "RewardEscrowV2"; bytes32 private constant CONTRACT_DELEGATEAPPROVALS = "DelegateApprovals"; bytes32 private constant CONTRACT_COLLATERALMANAGER = "CollateralManager"; bytes32 private constant CONTRACT_REWARDSDISTRIBUTION = "RewardsDistribution"; bytes32 private constant CONTRACT_ETHER_WRAPPER = "EtherWrapper"; bytes32 private constant CONTRACT_FUTURES_MARKET_MANAGER = "FuturesMarketManager"; bytes32 private constant CONTRACT_WRAPPER_FACTORY = "WrapperFactory"; bytes32 private constant CONTRACT_SYNTHETIX_BRIDGE_TO_OPTIMISM = "SynthetixBridgeToOptimism"; bytes32 private constant CONTRACT_SYNTHETIX_BRIDGE_TO_BASE = "SynthetixBridgeToBase"; bytes32 private constant CONTRACT_EXT_AGGREGATOR_ISSUED_SYNTHS = "ext:AggregatorIssuedSynths"; bytes32 private constant CONTRACT_EXT_AGGREGATOR_DEBT_RATIO = "ext:AggregatorDebtRatio"; /* ========== ETERNAL STORAGE CONSTANTS ========== */ bytes32 private constant LAST_FEE_WITHDRAWAL = "last_fee_withdrawal"; constructor( address payable _proxy, address _owner, address _resolver ) public Owned(_owner) Proxyable(_proxy) LimitedSetup(3 weeks) MixinSystemSettings(_resolver) { // Set our initial fee period _recentFeePeriodsStorage(0).feePeriodId = 1; _recentFeePeriodsStorage(0).startTime = uint64(block.timestamp); } /* ========== VIEWS ========== */ function resolverAddressesRequired() public view returns (bytes32[] memory addresses) { bytes32[] memory existingAddresses = MixinSystemSettings.resolverAddressesRequired(); bytes32[] memory newAddresses = new bytes32[](14); newAddresses[0] = CONTRACT_SYSTEMSTATUS; newAddresses[1] = CONTRACT_SYNTHETIXDEBTSHARE; newAddresses[2] = CONTRACT_FEEPOOLETERNALSTORAGE; newAddresses[3] = CONTRACT_EXCHANGER; newAddresses[4] = CONTRACT_ISSUER; newAddresses[5] = CONTRACT_REWARDESCROW_V2; newAddresses[6] = CONTRACT_DELEGATEAPPROVALS; newAddresses[7] = CONTRACT_REWARDSDISTRIBUTION; newAddresses[8] = CONTRACT_COLLATERALMANAGER; newAddresses[9] = CONTRACT_WRAPPER_FACTORY; newAddresses[10] = CONTRACT_ETHER_WRAPPER; newAddresses[11] = CONTRACT_EXT_AGGREGATOR_ISSUED_SYNTHS; newAddresses[12] = CONTRACT_EXT_AGGREGATOR_DEBT_RATIO; newAddresses[13] = CONTRACT_FUTURES_MARKET_MANAGER; addresses = combineArrays(existingAddresses, newAddresses); } function systemStatus() internal view returns (ISystemStatus) { return ISystemStatus(requireAndGetAddress(CONTRACT_SYSTEMSTATUS)); } function synthetixDebtShare() internal view returns (ISynthetixDebtShare) { return ISynthetixDebtShare(requireAndGetAddress(CONTRACT_SYNTHETIXDEBTSHARE)); } function feePoolEternalStorage() internal view returns (FeePoolEternalStorage) { return FeePoolEternalStorage(requireAndGetAddress(CONTRACT_FEEPOOLETERNALSTORAGE)); } function exchanger() internal view returns (IExchanger) { return IExchanger(requireAndGetAddress(CONTRACT_EXCHANGER)); } function collateralManager() internal view returns (ICollateralManager) { return ICollateralManager(requireAndGetAddress(CONTRACT_COLLATERALMANAGER)); } function issuer() internal view returns (IIssuer) { return IIssuer(requireAndGetAddress(CONTRACT_ISSUER)); } function rewardEscrowV2() internal view returns (IRewardEscrowV2) { return IRewardEscrowV2(requireAndGetAddress(CONTRACT_REWARDESCROW_V2)); } function delegateApprovals() internal view returns (IDelegateApprovals) { return IDelegateApprovals(requireAndGetAddress(CONTRACT_DELEGATEAPPROVALS)); } function rewardsDistribution() internal view returns (IRewardsDistribution) { return IRewardsDistribution(requireAndGetAddress(CONTRACT_REWARDSDISTRIBUTION)); } function etherWrapper() internal view returns (IEtherWrapper) { return IEtherWrapper(requireAndGetAddress(CONTRACT_ETHER_WRAPPER)); } function futuresMarketManager() internal view returns (IFuturesMarketManager) { return IFuturesMarketManager(requireAndGetAddress(CONTRACT_FUTURES_MARKET_MANAGER)); } function wrapperFactory() internal view returns (IWrapperFactory) { return IWrapperFactory(requireAndGetAddress(CONTRACT_WRAPPER_FACTORY)); } function issuanceRatio() external view returns (uint) { return getIssuanceRatio(); } function feePeriodDuration() external view returns (uint) { return getFeePeriodDuration(); } function targetThreshold() external view returns (uint) { return getTargetThreshold(); } function allNetworksSnxBackedDebt() public view returns (uint256 debt, uint256 updatedAt) { (, int256 rawData, , uint timestamp, ) = AggregatorV2V3Interface(requireAndGetAddress(CONTRACT_EXT_AGGREGATOR_ISSUED_SYNTHS)).latestRoundData(); debt = uint(rawData); updatedAt = timestamp; } function allNetworksDebtSharesSupply() public view returns (uint256 sharesSupply, uint256 updatedAt) { (, int256 rawIssuedSynths, , uint issuedSynthsUpdatedAt, ) = AggregatorV2V3Interface(requireAndGetAddress(CONTRACT_EXT_AGGREGATOR_ISSUED_SYNTHS)).latestRoundData(); (, int256 rawRatio, , uint ratioUpdatedAt, ) = AggregatorV2V3Interface(requireAndGetAddress(CONTRACT_EXT_AGGREGATOR_DEBT_RATIO)).latestRoundData(); uint debt = uint(rawIssuedSynths); sharesSupply = rawRatio == 0 ? 0 : debt.divideDecimalRoundPrecise(uint(rawRatio)); updatedAt = issuedSynthsUpdatedAt < ratioUpdatedAt ? issuedSynthsUpdatedAt : ratioUpdatedAt; } function recentFeePeriods(uint index) external view returns ( uint64 feePeriodId, uint64 unused, // required post 185 for api compatibility uint64 startTime, uint feesToDistribute, uint feesClaimed, uint rewardsToDistribute, uint rewardsClaimed ) { FeePeriod memory feePeriod = _recentFeePeriodsStorage(index); return ( feePeriod.feePeriodId, 0, feePeriod.startTime, feePeriod.feesToDistribute, feePeriod.feesClaimed, feePeriod.rewardsToDistribute, feePeriod.rewardsClaimed ); } function _recentFeePeriodsStorage(uint index) internal view returns (FeePeriod storage) { return _recentFeePeriods[(_currentFeePeriod + index) % FEE_PERIOD_LENGTH]; } /** * @notice The Exchanger contract informs us when fees are paid. * @param amount susd amount in fees being paid. */ function recordFeePaid(uint amount) external onlyInternalContracts { // Keep track off fees in sUSD in the open fee pool period. _recentFeePeriodsStorage(0).feesToDistribute = _recentFeePeriodsStorage(0).feesToDistribute.add(amount); } /** * @notice The RewardsDistribution contract informs us how many SNX rewards are sent to RewardEscrow to be claimed. */ function setRewardsToDistribute(uint amount) external optionalProxy { require(messageSender == address(rewardsDistribution()), "RewardsDistribution only"); // Add the amount of SNX rewards to distribute on top of any rolling unclaimed amount _recentFeePeriodsStorage(0).rewardsToDistribute = _recentFeePeriodsStorage(0).rewardsToDistribute.add(amount); } /** * @notice Close the current fee period and start a new one. */ function closeCurrentFeePeriod() external issuanceActive { require(getFeePeriodDuration() > 0, "Fee Period Duration not set"); require(_recentFeePeriodsStorage(0).startTime <= (now - getFeePeriodDuration()), "Too early to close fee period"); // get current oracle values (uint snxBackedDebt, ) = allNetworksSnxBackedDebt(); (uint debtSharesSupply, ) = allNetworksDebtSharesSupply(); // close on this chain _closeSecondary(snxBackedDebt, debtSharesSupply); // inform other chain of the chosen values ISynthetixBridgeToOptimism( resolver.requireAndGetAddress( CONTRACT_SYNTHETIX_BRIDGE_TO_OPTIMISM, "Missing contract: SynthetixBridgeToOptimism" ) ) .closeFeePeriod(snxBackedDebt, debtSharesSupply); } function closeSecondary(uint allNetworksSnxBackedDebt, uint allNetworksDebtSharesSupply) external onlyRelayer { _closeSecondary(allNetworksSnxBackedDebt, allNetworksDebtSharesSupply); } /** * @notice Close the current fee period and start a new one. */ function _closeSecondary(uint allNetworksSnxBackedDebt, uint allNetworksDebtSharesSupply) internal { etherWrapper().distributeFees(); wrapperFactory().distributeFees(); // before closing the current fee period, set the recorded snxBackedDebt and debtSharesSupply _recentFeePeriodsStorage(0).allNetworksDebtSharesSupply = allNetworksDebtSharesSupply; _recentFeePeriodsStorage(0).allNetworksSnxBackedDebt = allNetworksSnxBackedDebt; // Note: when FEE_PERIOD_LENGTH = 2, periodClosing is the current period & periodToRollover is the last open claimable period FeePeriod storage periodClosing = _recentFeePeriodsStorage(FEE_PERIOD_LENGTH - 2); FeePeriod storage periodToRollover = _recentFeePeriodsStorage(FEE_PERIOD_LENGTH - 1); // Any unclaimed fees from the last period in the array roll back one period. // Because of the subtraction here, they're effectively proportionally redistributed to those who // have already claimed from the old period, available in the new period. // The subtraction is important so we don't create a ticking time bomb of an ever growing // number of fees that can never decrease and will eventually overflow at the end of the fee pool. _recentFeePeriodsStorage(FEE_PERIOD_LENGTH - 2).feesToDistribute = periodToRollover .feesToDistribute .sub(periodToRollover.feesClaimed) .add(periodClosing.feesToDistribute); _recentFeePeriodsStorage(FEE_PERIOD_LENGTH - 2).rewardsToDistribute = periodToRollover .rewardsToDistribute .sub(periodToRollover.rewardsClaimed) .add(periodClosing.rewardsToDistribute); // Shift the previous fee periods across to make room for the new one. _currentFeePeriod = _currentFeePeriod.add(FEE_PERIOD_LENGTH).sub(1).mod(FEE_PERIOD_LENGTH); // Clear the first element of the array to make sure we don't have any stale values. delete _recentFeePeriods[_currentFeePeriod]; // Open up the new fee period. // periodID is set to the current timestamp for compatibility with other systems taking snapshots on the debt shares uint newFeePeriodId = block.timestamp; _recentFeePeriodsStorage(0).feePeriodId = uint64(newFeePeriodId); _recentFeePeriodsStorage(0).startTime = uint64(block.timestamp); // Inform Issuer to start recording for the new fee period issuer().setCurrentPeriodId(uint128(newFeePeriodId)); emitFeePeriodClosed(_recentFeePeriodsStorage(1).feePeriodId); } /** * @notice Claim fees for last period when available or not already withdrawn. */ function claimFees() external issuanceActive optionalProxy returns (bool) { return _claimFees(messageSender); } /** * @notice Delegated claimFees(). Call from the deletegated address * and the fees will be sent to the claimingForAddress. * approveClaimOnBehalf() must be called first to approve the deletage address * @param claimingForAddress The account you are claiming fees for */ function claimOnBehalf(address claimingForAddress) external issuanceActive optionalProxy returns (bool) { require(delegateApprovals().canClaimFor(claimingForAddress, messageSender), "Not approved to claim on behalf"); return _claimFees(claimingForAddress); } function _claimFees(address claimingAddress) internal returns (bool) { uint rewardsPaid = 0; uint feesPaid = 0; uint availableFees; uint availableRewards; // Address won't be able to claim fees if it is too far below the target c-ratio. // It will need to burn synths then try claiming again. (bool feesClaimable, bool anyRateIsInvalid) = _isFeesClaimableAndAnyRatesInvalid(claimingAddress); require(feesClaimable, "C-Ratio below penalty threshold"); require(!anyRateIsInvalid, "A synth or SNX rate is invalid"); // Get the claimingAddress available fees and rewards (availableFees, availableRewards) = feesAvailable(claimingAddress); require( availableFees > 0 || availableRewards > 0, "No fees or rewards available for period, or fees already claimed" ); // Record the address has claimed for this period _setLastFeeWithdrawal(claimingAddress, _recentFeePeriodsStorage(1).feePeriodId); if (availableFees > 0) { // Record the fee payment in our recentFeePeriods feesPaid = _recordFeePayment(availableFees); // Send them their fees _payFees(claimingAddress, feesPaid); } if (availableRewards > 0) { // Record the reward payment in our recentFeePeriods rewardsPaid = _recordRewardPayment(availableRewards); // Send them their rewards _payRewards(claimingAddress, rewardsPaid); } emitFeesClaimed(claimingAddress, feesPaid, rewardsPaid); return true; } /** * @notice Admin function to import the FeePeriod data from the previous contract */ function importFeePeriod( uint feePeriodIndex, uint feePeriodId, uint startTime, uint feesToDistribute, uint feesClaimed, uint rewardsToDistribute, uint rewardsClaimed ) external optionalProxy_onlyOwner onlyDuringSetup { require(feePeriodIndex < FEE_PERIOD_LENGTH, "invalid fee period index"); _recentFeePeriods[feePeriodIndex] = FeePeriod({ feePeriodId: uint64(feePeriodId), startTime: uint64(startTime), feesToDistribute: feesToDistribute, feesClaimed: feesClaimed, rewardsToDistribute: rewardsToDistribute, rewardsClaimed: rewardsClaimed, allNetworksSnxBackedDebt: 0, allNetworksDebtSharesSupply: 0 }); // make sure recording is aware of the actual period id if (feePeriodIndex == 0) { issuer().setCurrentPeriodId(uint128(feePeriodId)); } } /** * @notice Record the fee payment in our recentFeePeriods. * @param sUSDAmount The amount of fees priced in sUSD. */ function _recordFeePayment(uint sUSDAmount) internal returns (uint) { // Don't assign to the parameter uint remainingToAllocate = sUSDAmount; uint feesPaid; // Start at the oldest period and record the amount, moving to newer periods // until we've exhausted the amount. // The condition checks for overflow because we're going to 0 with an unsigned int. for (uint i = FEE_PERIOD_LENGTH - 1; i < FEE_PERIOD_LENGTH; i--) { uint feesAlreadyClaimed = _recentFeePeriodsStorage(i).feesClaimed; uint delta = _recentFeePeriodsStorage(i).feesToDistribute.sub(feesAlreadyClaimed); if (delta > 0) { // Take the smaller of the amount left to claim in the period and the amount we need to allocate uint amountInPeriod = delta < remainingToAllocate ? delta : remainingToAllocate; _recentFeePeriodsStorage(i).feesClaimed = feesAlreadyClaimed.add(amountInPeriod); remainingToAllocate = remainingToAllocate.sub(amountInPeriod); feesPaid = feesPaid.add(amountInPeriod); // No need to continue iterating if we've recorded the whole amount; if (remainingToAllocate == 0) return feesPaid; } } return feesPaid; } /** * @notice Record the reward payment in our recentFeePeriods. * @param snxAmount The amount of SNX tokens. */ function _recordRewardPayment(uint snxAmount) internal returns (uint) { // Don't assign to the parameter uint remainingToAllocate = snxAmount; uint rewardPaid; // Start at the oldest period and record the amount, moving to newer periods // until we've exhausted the amount. // The condition checks for overflow because we're going to 0 with an unsigned int. for (uint i = FEE_PERIOD_LENGTH - 1; i < FEE_PERIOD_LENGTH; i--) { uint toDistribute = _recentFeePeriodsStorage(i).rewardsToDistribute.sub(_recentFeePeriodsStorage(i).rewardsClaimed); if (toDistribute > 0) { // Take the smaller of the amount left to claim in the period and the amount we need to allocate uint amountInPeriod = toDistribute < remainingToAllocate ? toDistribute : remainingToAllocate; _recentFeePeriodsStorage(i).rewardsClaimed = _recentFeePeriodsStorage(i).rewardsClaimed.add(amountInPeriod); remainingToAllocate = remainingToAllocate.sub(amountInPeriod); rewardPaid = rewardPaid.add(amountInPeriod); // No need to continue iterating if we've recorded the whole amount; if (remainingToAllocate == 0) return rewardPaid; } } return rewardPaid; } /** * @notice Send the fees to claiming address. * @param account The address to send the fees to. * @param sUSDAmount The amount of fees priced in sUSD. */ function _payFees(address account, uint sUSDAmount) internal notFeeAddress(account) { // Grab the sUSD Synth ISynth sUSDSynth = issuer().synths(sUSD); // NOTE: we do not control the FEE_ADDRESS so it is not possible to do an // ERC20.approve() transaction to allow this feePool to call ERC20.transferFrom // to the accounts address // Burn the source amount sUSDSynth.burn(FEE_ADDRESS, sUSDAmount); // Mint their new synths sUSDSynth.issue(account, sUSDAmount); } /** * @notice Send the rewards to claiming address - will be locked in rewardEscrow. * @param account The address to send the fees to. * @param snxAmount The amount of SNX. */ function _payRewards(address account, uint snxAmount) internal notFeeAddress(account) { /* Escrow the tokens for 1 year. */ uint escrowDuration = 52 weeks; // Record vesting entry for claiming address and amount // SNX already minted to rewardEscrow balance rewardEscrowV2().appendVestingEntry(account, snxAmount, escrowDuration); } /** * @notice The total fees available in the system to be withdrawnn in sUSD */ function totalFeesAvailable() external view returns (uint) { uint totalFees = 0; // Fees in fee period [0] are not yet available for withdrawal for (uint i = 1; i < FEE_PERIOD_LENGTH; i++) { totalFees = totalFees.add(_recentFeePeriodsStorage(i).feesToDistribute); totalFees = totalFees.sub(_recentFeePeriodsStorage(i).feesClaimed); } return totalFees; } /** * @notice The total SNX rewards available in the system to be withdrawn */ function totalRewardsAvailable() external view returns (uint) { uint totalRewards = 0; // Rewards in fee period [0] are not yet available for withdrawal for (uint i = 1; i < FEE_PERIOD_LENGTH; i++) { totalRewards = totalRewards.add(_recentFeePeriodsStorage(i).rewardsToDistribute); totalRewards = totalRewards.sub(_recentFeePeriodsStorage(i).rewardsClaimed); } return totalRewards; } /** * @notice The fees available to be withdrawn by a specific account, priced in sUSD * @dev Returns two amounts, one for fees and one for SNX rewards */ function feesAvailable(address account) public view returns (uint, uint) { // Add up the fees uint[2][FEE_PERIOD_LENGTH] memory userFees = feesByPeriod(account); uint totalFees = 0; uint totalRewards = 0; // Fees & Rewards in fee period [0] are not yet available for withdrawal for (uint i = 1; i < FEE_PERIOD_LENGTH; i++) { totalFees = totalFees.add(userFees[i][0]); totalRewards = totalRewards.add(userFees[i][1]); } // And convert totalFees to sUSD // Return totalRewards as is in SNX amount return (totalFees, totalRewards); } function _isFeesClaimableAndAnyRatesInvalid(address account) internal view returns (bool, bool) { // Threshold is calculated from ratio % above the target ratio (issuanceRatio). // 0 < 10%: Claimable // 10% > above: Unable to claim (uint ratio, bool anyRateIsInvalid) = issuer().collateralisationRatioAndAnyRatesInvalid(account); uint targetRatio = getIssuanceRatio(); // Claimable if collateral ratio below target ratio if (ratio < targetRatio) { return (true, anyRateIsInvalid); } // Calculate the threshold for collateral ratio before fees can't be claimed. uint ratio_threshold = targetRatio.multiplyDecimal(SafeDecimalMath.unit().add(getTargetThreshold())); // Not claimable if collateral ratio above threshold if (ratio > ratio_threshold) { return (false, anyRateIsInvalid); } return (true, anyRateIsInvalid); } function isFeesClaimable(address account) external view returns (bool feesClaimable) { (feesClaimable, ) = _isFeesClaimableAndAnyRatesInvalid(account); } /** * @notice Calculates fees by period for an account, priced in sUSD * @param account The address you want to query the fees for */ function feesByPeriod(address account) public view returns (uint[2][FEE_PERIOD_LENGTH] memory results) { // What's the user's debt entry index and the debt they owe to the system at current feePeriod uint userOwnershipPercentage; ISynthetixDebtShare sds = synthetixDebtShare(); userOwnershipPercentage = sds.sharePercent(account); // The [0] fee period is not yet ready to claim, but it is a fee period that they can have // fees owing for, so we need to report on it anyway. uint feesFromPeriod; uint rewardsFromPeriod; (feesFromPeriod, rewardsFromPeriod) = _feesAndRewardsFromPeriod(0, userOwnershipPercentage); results[0][0] = feesFromPeriod; results[0][1] = rewardsFromPeriod; // Retrieve user's last fee claim by periodId uint lastFeeWithdrawal = getLastFeeWithdrawal(account); // Go through our fee periods from the oldest feePeriod[FEE_PERIOD_LENGTH - 1] and figure out what we owe them. // Condition checks for periods > 0 for (uint i = FEE_PERIOD_LENGTH - 1; i > 0; i--) { uint64 periodId = _recentFeePeriodsStorage(i).feePeriodId; if (lastFeeWithdrawal < periodId) { userOwnershipPercentage = sds.sharePercentOnPeriod(account, uint(periodId)); (feesFromPeriod, rewardsFromPeriod) = _feesAndRewardsFromPeriod(i, userOwnershipPercentage); results[i][0] = feesFromPeriod; results[i][1] = rewardsFromPeriod; } } } /** * @notice ownershipPercentage is a high precision decimals uint based on * wallet's debtPercentage. Gives a precise amount of the feesToDistribute * for fees in the period. Precision factor is removed before results are * returned. * @dev The reported fees owing for the current period [0] are just a * running balance until the fee period closes */ function _feesAndRewardsFromPeriod(uint period, uint ownershipPercentage) internal view returns (uint, uint) { // If it's zero, they haven't issued, and they have no fees OR rewards. if (ownershipPercentage == 0) return (0, 0); FeePeriod storage fp = _recentFeePeriodsStorage(period); // Calculate their percentage of the fees / rewards in this period // This is a high precision integer. uint feesFromPeriod = fp.feesToDistribute.multiplyDecimal(ownershipPercentage); uint rewardsFromPeriod = fp.rewardsToDistribute.multiplyDecimal(ownershipPercentage); return (feesFromPeriod, rewardsFromPeriod); } function effectiveDebtRatioForPeriod(address account, uint period) external view returns (uint) { // if period is not closed yet, or outside of the fee period range, return 0 instead of reverting if (period == 0 || period >= FEE_PERIOD_LENGTH) { return 0; } // If the period being checked is uninitialised then return 0. This is only at the start of the system. if (_recentFeePeriodsStorage(period - 1).startTime == 0) return 0; return synthetixDebtShare().sharePercentOnPeriod(account, uint(_recentFeePeriods[period].feePeriodId)); } /** * @notice Get the feePeriodID of the last claim this account made * @param _claimingAddress account to check the last fee period ID claim for * @return uint of the feePeriodID this account last claimed */ function getLastFeeWithdrawal(address _claimingAddress) public view returns (uint) { return feePoolEternalStorage().getUIntValue(keccak256(abi.encodePacked(LAST_FEE_WITHDRAWAL, _claimingAddress))); } /** * @notice Calculate the collateral ratio before user is blocked from claiming. */ function getPenaltyThresholdRatio() public view returns (uint) { return getIssuanceRatio().multiplyDecimal(SafeDecimalMath.unit().add(getTargetThreshold())); } /** * @notice Set the feePeriodID of the last claim this account made * @param _claimingAddress account to set the last feePeriodID claim for * @param _feePeriodID the feePeriodID this account claimed fees for */ function _setLastFeeWithdrawal(address _claimingAddress, uint _feePeriodID) internal { feePoolEternalStorage().setUIntValue( keccak256(abi.encodePacked(LAST_FEE_WITHDRAWAL, _claimingAddress)), _feePeriodID ); } /* ========== Modifiers ========== */ function _isInternalContract(address account) internal view returns (bool) { return account == address(exchanger()) || issuer().synthsByAddress(account) != bytes32(0) || collateralManager().hasCollateral(account) || account == address(futuresMarketManager()) || account == address(wrapperFactory()) || account == address(etherWrapper()); } modifier onlyInternalContracts { require(_isInternalContract(msg.sender), "Only Internal Contracts"); _; } modifier onlyRelayer { require( msg.sender == address(this) || msg.sender == resolver.getAddress(CONTRACT_SYNTHETIX_BRIDGE_TO_BASE), "Only valid relayer can call" ); _; } modifier notFeeAddress(address account) { require(account != FEE_ADDRESS, "Fee address not allowed"); _; } modifier issuanceActive() { systemStatus().requireIssuanceActive(); _; } /* ========== Proxy Events ========== */ event FeePeriodClosed(uint feePeriodId); bytes32 private constant FEEPERIODCLOSED_SIG = keccak256("FeePeriodClosed(uint256)"); function emitFeePeriodClosed(uint feePeriodId) internal { proxy._emit(abi.encode(feePeriodId), 1, FEEPERIODCLOSED_SIG, 0, 0, 0); } event FeesClaimed(address account, uint sUSDAmount, uint snxRewards); bytes32 private constant FEESCLAIMED_SIG = keccak256("FeesClaimed(address,uint256,uint256)"); function emitFeesClaimed( address account, uint sUSDAmount, uint snxRewards ) internal { proxy._emit(abi.encode(account, sUSDAmount, snxRewards), 1, FEESCLAIMED_SIG, 0, 0, 0); } }
[{"inputs":[{"internalType":"address payable","name":"_proxy","type":"address"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_resolver","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"name","type":"bytes32"},{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"CacheUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"feePeriodId","type":"uint256"}],"name":"FeePeriodClosed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"sUSDAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"snxRewards","type":"uint256"}],"name":"FeesClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"proxyAddress","type":"address"}],"name":"ProxyUpdated","type":"event"},{"constant":true,"inputs":[],"name":"CONTRACT_NAME","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"FEE_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"FEE_PERIOD_LENGTH","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"allNetworksDebtSharesSupply","outputs":[{"internalType":"uint256","name":"sharesSupply","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"allNetworksSnxBackedDebt","outputs":[{"internalType":"uint256","name":"debt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"claimFees","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"claimingForAddress","type":"address"}],"name":"claimOnBehalf","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"closeCurrentFeePeriod","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"allNetworksSnxBackedDebt","type":"uint256"},{"internalType":"uint256","name":"allNetworksDebtSharesSupply","type":"uint256"}],"name":"closeSecondary","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"period","type":"uint256"}],"name":"effectiveDebtRatioForPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"feePeriodDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"feesAvailable","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"feesByPeriod","outputs":[{"internalType":"uint256[2][2]","name":"results","type":"uint256[2][2]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_claimingAddress","type":"address"}],"name":"getLastFeeWithdrawal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getPenaltyThresholdRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"feePeriodIndex","type":"uint256"},{"internalType":"uint256","name":"feePeriodId","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"feesToDistribute","type":"uint256"},{"internalType":"uint256","name":"feesClaimed","type":"uint256"},{"internalType":"uint256","name":"rewardsToDistribute","type":"uint256"},{"internalType":"uint256","name":"rewardsClaimed","type":"uint256"}],"name":"importFeePeriod","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isFeesClaimable","outputs":[{"internalType":"bool","name":"feesClaimable","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isResolverCached","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"issuanceRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"messageSender","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"proxy","outputs":[{"internalType":"contract Proxy","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"rebuildCache","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"recentFeePeriods","outputs":[{"internalType":"uint64","name":"feePeriodId","type":"uint64"},{"internalType":"uint64","name":"unused","type":"uint64"},{"internalType":"uint64","name":"startTime","type":"uint64"},{"internalType":"uint256","name":"feesToDistribute","type":"uint256"},{"internalType":"uint256","name":"feesClaimed","type":"uint256"},{"internalType":"uint256","name":"rewardsToDistribute","type":"uint256"},{"internalType":"uint256","name":"rewardsClaimed","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"recordFeePaid","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"resolver","outputs":[{"internalType":"contract AddressResolver","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"resolverAddressesRequired","outputs":[{"internalType":"bytes32[]","name":"addresses","type":"bytes32[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"setMessageSender","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address payable","name":"_proxy","type":"address"}],"name":"setProxy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setRewardsToDistribute","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"setupExpiryTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"targetThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalFeesAvailable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalRewardsAvailable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]
Contract Creation Code
6080604052631cd554d160e21b6007553480156200001c57600080fd5b50604051620045c2380380620045c28339810160408190526200003f9162000226565b8080621baf8085856001600160a01b038116620000795760405162461bcd60e51b8152600401620000709062000348565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0383161781556040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91620000c691849062000310565b60405180910390a1506000546001600160a01b0316620000fa5760405162461bcd60e51b8152600401620000709062000336565b600280546001600160a01b0319166001600160a01b0383161790556040517ffc80377ca9c49cc11ae6982f390a42db976d5530af7c43889264b13fbbd7c57e906200014790839062000300565b60405180910390a1504201600455600580546001600160a01b0319166001600160a01b0392909216919091179055506001620001846000620001e7565b80546001600160401b0319166001600160401b039290921691909117905542620001af6000620001e7565b80546001600160401b03929092166801000000000000000002600160401b600160801b031990921691909117905550620003a3915050565b60006008600260ff16836016540181620001fd57fe5b06600281106200020957fe5b6007020192915050565b8051620002208162000389565b92915050565b6000806000606084860312156200023c57600080fd5b60006200024a868662000213565b93505060206200025d8682870162000213565b9250506040620002708682870162000213565b9150509250925092565b620002858162000375565b82525050565b620002858162000363565b6000620002a56011836200035a565b7013dddb995c881b5d5cdd081899481cd95d607a1b815260200192915050565b6000620002d46019836200035a565b7f4f776e657220616464726573732063616e6e6f74206265203000000000000000815260200192915050565b602081016200022082846200027a565b604081016200032082856200027a565b6200032f60208301846200028b565b9392505050565b60208082528101620002208162000296565b602080825281016200022081620002c5565b90815260200190565b60006001600160a01b03821662000220565b600062000220826000620002208262000363565b620003948162000363565b8114620003a057600080fd5b50565b61420f80620003b36000396000f3fe608060405234801561001057600080fd5b50600436106102775760003560e01c80636466f45e11610160578063b410a034116100d8578063e0e6393d1161008c578063ec55688911610071578063ec55688914610497578063f43d41611461049f578063fd1f498d146104b257610277565b8063e0e6393d14610487578063eb1edd611461048f57610277565b8063cff2ddad116100bd578063cff2ddad14610462578063d294f09314610477578063d67bdd251461047f57610277565b8063b410a03414610447578063bc67f8321461044f57610277565b806379ba50971161012f5780638da5cb5b116101145780638da5cb5b1461042457806397107d6d1461042c578063ac8341931461043f57610277565b806379ba509714610407578063899ffef41461040f57610277565b80636466f45e146103d15780636de813f1146103e457806373941b96146103ec57806374185360146103ff57610277565b806333140016116101f357806346ba2d90116101c2578063569249d0116101a7578063569249d0146103ae57806359a2f19f146103b6578063614d08f8146103c957610277565b806346ba2d901461039157806353a47bb71461039957610277565b8063331400161461033b5780633ebc457a1461035b5780633fcd22401461036357806341c178c31461038957610277565b80631627540c1161024a57806322bf55ef1161022f57806322bf55ef1461030b5780632af64bd31461031e5780632e227eeb1461033357610277565b80631627540c146102ee57806322425fa41461030357610277565b806304f3bcec1461027c57806307ea50cd1461029a5780630813071c146102ba5780630de58615146102cd575b600080fd5b6102846104c5565b6040516102919190613eb2565b60405180910390f35b6102ad6102a83660046131df565b6104d4565b6040516102919190613dea565b6102ad6102c8366004613223565b6105a9565b6102e06102db3660046131df565b6106bb565b604051610291929190613e06565b6103016102fc3660046131df565b61073d565b005b6102ad61079b565b6103016103193660046132b7565b6107ab565b610326610808565b6040516102919190613ddc565b6102e061091f565b61034e6103493660046131df565b610aa6565b6040516102919190613dbd565b610301610c9d565b6103766103713660046132b7565b610ea5565b604051610291979695949392919061402f565b6102e0610f53565b6102ad611001565b6103a1611007565b6040516102919190613d43565b6102ad611016565b6103266103c43660046131df565b611071565b6102ad611083565b6103266103df3660046131df565b6110a7565b6102ad6111d3565b6103016103fa366004613305565b611228565b610301611310565b610301611462565b6104176114fe565b6040516102919190613dcb565b6103a1611858565b61030161043a3660046131df565b611867565b6102ad6118ba565b6102ad611966565b61030161045d3660046131df565b611970565b61046a61199a565b6040516102919190614097565b61032661199f565b6103a1611a16565b6102ad611a25565b6103a1611a2f565b610284611a47565b6103016104ad366004613324565b611a56565b6103016104c03660046132b7565b611c06565b6005546001600160a01b031681565b60006104de611c72565b6001600160a01b031663bdc963d87f6c6173745f6665655f7769746864726177616c000000000000000000000000008460405160200161051f929190613cdc565b604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004016105519190613dea565b60206040518083038186803b15801561056957600080fd5b505afa15801561057d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506105a1919081019061327b565b90505b919050565b60008115806105b9575060028210155b156105c6575060006106b5565b6105d260018303611c9d565b5468010000000000000000900467ffffffffffffffff166105f5575060006106b5565b6105fd611cc7565b6001600160a01b0316638ced14df846008856002811061061957fe5b60070201546040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b168152610662929167ffffffffffffffff1690600401613d7a565b60206040518083038186803b15801561067a57600080fd5b505afa15801561068e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506106b2919081019061327b565b90505b92915050565b6000806106c66130ee565b6106cf84610aa6565b905060008060015b6002811015610730576106fc8482600281106106ef57fe5b6020020151518490611cf2565b925061072684826002811061070d57fe5b602002015160016020020151839063ffffffff611cf216565b91506001016106d7565b509093509150505b915091565b610745611d17565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290610790908390613d43565b60405180910390a150565b60006107a5611d43565b90505b90565b6107b433611e0a565b6107d95760405162461bcd60e51b81526004016107d090613ed1565b60405180910390fd5b6107f7816107e76000611c9d565b600301549063ffffffff611cf216565b6108016000611c9d565b6003015550565b600060606108146114fe565b905060005b815181101561091657600082828151811061083057fe5b602090810291909101810151600081815260069092526040918290205460055492516321f8a72160e01b81529193506001600160a01b039081169216906321f8a72190610881908590600401613dea565b60206040518083038186803b15801561089957600080fd5b505afa1580156108ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506108d19190810190613205565b6001600160a01b03161415806108fc57506000818152600660205260409020546001600160a01b0316155b1561090d57600093505050506107a8565b50600101610819565b50600191505090565b60008060008061094e7f6578743a41676772656761746f7249737375656453796e746873000000000000611fae565b6001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561098657600080fd5b505afa15801561099a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506109be91908101906133c0565b509350509250506000806109f17f6578743a41676772656761746f7244656274526174696f000000000000000000611fae565b6001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015610a2957600080fd5b505afa158015610a3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610a6191908101906133c0565b50919450909250859150508215610a8757610a82818463ffffffff61200b16565b610a8a565b60005b9650818410610a995781610a9b565b835b955050505050509091565b610aae6130ee565b600080610ab9611cc7565b6040517fe6d24bbd0000000000000000000000000000000000000000000000000000000081529091506001600160a01b0382169063e6d24bbd90610b01908790600401613d43565b60206040518083038186803b158015610b1957600080fd5b505afa158015610b2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610b51919081019061327b565b9150600080610b61600085612024565b8651829052865160200181905290925090506000610b7e876104d4565b905060015b8015610c92576000610b9482611c9d565b5467ffffffffffffffff16905080831015610c88576040517f8ced14df0000000000000000000000000000000000000000000000000000000081526001600160a01b03871690638ced14df90610bfa908c9067ffffffffffffffff861690600401613d7a565b60206040518083038186803b158015610c1257600080fd5b505afa158015610c26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610c4a919081019061327b565b9650610c568288612024565b909550935084888360028110610c6857fe5b60200201515283888360028110610c7b57fe5b6020020151600160200201525b5060001901610b83565b505050505050919050565b610ca5612088565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b158015610cdd57600080fd5b505afa158015610cf1573d6000803e3d6000fd5b505050506000610cff611d43565b11610d1c5760405162461bcd60e51b81526004016107d090614011565b610d24611d43565b4203610d306000611c9d565b5468010000000000000000900467ffffffffffffffff161115610d655760405162461bcd60e51b81526004016107d090613ef1565b6000610d6f610f53565b5090506000610d7c61091f565b509050610d8982826120b3565b6005546040517fdacb2d010000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063dacb2d0190610df2907f53796e746865746978427269646765546f4f7074696d69736d0000000000000090600401613e34565b60206040518083038186803b158015610e0a57600080fd5b505afa158015610e1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610e429190810190613205565b6001600160a01b031663b9958ab883836040518363ffffffff1660e01b8152600401610e6f929190613e06565b600060405180830381600087803b158015610e8957600080fd5b505af1158015610e9d573d6000803e3d6000fd5b505050505050565b6000806000806000806000610eb861311b565b610ec189611c9d565b6040805161010081018252825467ffffffffffffffff80821680845268010000000000000000909204166020830181905260018501549383019390935260028401546060830152600384015460808301819052600485015460a08401819052600586015460c0850181905260069096015460e0909401849052919e60009e50939c509a50985091965090945092505050565b600080600080610f827f6578743a41676772656761746f7249737375656453796e746873000000000000611fae565b6001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015610fba57600080fd5b505afa158015610fce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610ff291908101906133c0565b50919791965090945050505050565b60045481565b6001546001600160a01b031681565b60008060015b600281101561106b5761104261103182611c9d565b60030154839063ffffffff611cf216565b915061106161105082611c9d565b60040154839063ffffffff61239a16565b915060010161101c565b50905090565b600061107c826123c2565b5092915050565b7f466565506f6f6c0000000000000000000000000000000000000000000000000081565b60006110b1612088565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b1580156110e957600080fd5b505afa1580156110fd573d6000803e3d6000fd5b505050506111096124b6565b6111116124f5565b6003546040517f21f4ae570000000000000000000000000000000000000000000000000000000081526001600160a01b03928316926321f4ae579261115e92879290911690600401613d5f565b60206040518083038186803b15801561117657600080fd5b505afa15801561118a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506111ae919081019061325d565b6111ca5760405162461bcd60e51b81526004016107d090613f81565b6105a182612520565b60008060015b600281101561106b576111ff6111ee82611c9d565b60050154839063ffffffff611cf216565b915061121e61120d82611c9d565b60060154839063ffffffff61239a16565b91506001016111d9565b333014806112e657506005546040516321f8a72160e01b81526001600160a01b03909116906321f8a72190611281907f53796e746865746978427269646765546f42617365000000000000000000000090600401613dea565b60206040518083038186803b15801561129957600080fd5b505afa1580156112ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506112d19190810190613205565b6001600160a01b0316336001600160a01b0316145b6113025760405162461bcd60e51b81526004016107d090613fc1565b61130c82826120b3565b5050565b606061131a6114fe565b905060005b815181101561130c57600082828151811061133657fe5b602002602001015190506000600560009054906101000a90046001600160a01b03166001600160a01b031663dacb2d0183846040516020016113789190613d2d565b6040516020818303038152906040526040518363ffffffff1660e01b81526004016113a4929190613e14565b60206040518083038186803b1580156113bc57600080fd5b505afa1580156113d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506113f49190810190613205565b6000838152600660205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa68906114509084908490613df8565b60405180910390a1505060010161131f565b6001546001600160a01b0316331461148c5760405162461bcd60e51b81526004016107d090613ee1565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c926114cf926001600160a01b0391821692911690613d5f565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b606080611509612615565b60408051600e8082526101e0820190925291925060609190602082016101c0803883390190505090507f53797374656d53746174757300000000000000000000000000000000000000008160008151811061156057fe5b6020026020010181815250507f53796e74686574697844656274536861726500000000000000000000000000008160018151811061159a57fe5b6020026020010181815250507f466565506f6f6c457465726e616c53746f726167650000000000000000000000816002815181106115d457fe5b6020026020010181815250507f45786368616e67657200000000000000000000000000000000000000000000008160038151811061160e57fe5b6020026020010181815250506524b9b9bab2b960d11b8160048151811061163157fe5b6020026020010181815250507f526577617264457363726f7756320000000000000000000000000000000000008160058151811061166b57fe5b6020026020010181815250507f44656c6567617465417070726f76616c73000000000000000000000000000000816006815181106116a557fe5b6020026020010181815250507f52657761726473446973747269627574696f6e00000000000000000000000000816007815181106116df57fe5b6020026020010181815250507f436f6c6c61746572616c4d616e616765720000000000000000000000000000008160088151811061171957fe5b6020026020010181815250507f57726170706572466163746f72790000000000000000000000000000000000008160098151811061175357fe5b6020026020010181815250507f457468657257726170706572000000000000000000000000000000000000000081600a8151811061178d57fe5b6020026020010181815250507f6578743a41676772656761746f7249737375656453796e74687300000000000081600b815181106117c757fe5b6020026020010181815250507f6578743a41676772656761746f7244656274526174696f00000000000000000081600c8151811061180157fe5b6020026020010181815250507f467574757265734d61726b65744d616e6167657200000000000000000000000081600d8151811061183b57fe5b6020026020010181815250506118518282612674565b9250505090565b6000546001600160a01b031681565b61186f611d17565b600280546001600160a01b0319166001600160a01b0383161790556040517ffc80377ca9c49cc11ae6982f390a42db976d5530af7c43889264b13fbbd7c57e90610790908390613d51565b60006107a56119526118ca612729565b731a60e2e2a8be0bc2b6381dd31fd3fd5f9a28de4c63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b15801561190e57600080fd5b505af4158015611922573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611946919081019061327b565b9063ffffffff611cf216565b61195a6127a0565b9063ffffffff61281716565b60006107a56127a0565b611978612841565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b600281565b60006119a9612088565b6001600160a01b0316637c3125416040518163ffffffff1660e01b815260040160006040518083038186803b1580156119e157600080fd5b505afa1580156119f5573d6000803e3d6000fd5b50505050611a016124b6565b6003546107a5906001600160a01b0316612520565b6003546001600160a01b031681565b60006107a5612729565b73feefeefeefeefeefeefeefeefeefeefeefeefeef81565b6002546001600160a01b031681565b611a5e61286b565b6004544210611a7f5760405162461bcd60e51b81526004016107d090613fd1565b60028710611a9f5760405162461bcd60e51b81526004016107d090613ff1565b6040518061010001604052808767ffffffffffffffff1681526020018667ffffffffffffffff16815260200160008152602001600081526020018581526020018481526020018381526020018281525060088860028110611afc57fe5b8251600791909102919091018054602084015167ffffffffffffffff90811668010000000000000000026fffffffffffffffff0000000000000000199190941667ffffffffffffffff19909216919091171691909117815560408201516001820155606082015160028201556080820151600382015560a0820151600482015560c0820151600582015560e09091015160069091015586611bfd57611b9f6128d9565b6001600160a01b03166331e6da5a876040518263ffffffff1660e01b8152600401611bca9190614021565b600060405180830381600087803b158015611be457600080fd5b505af1158015611bf8573d6000803e3d6000fd5b505050505b50505050505050565b611c0e6124b6565b611c166128ed565b6003546001600160a01b03908116911614611c435760405162461bcd60e51b81526004016107d090613f51565b611c6181611c516000611c9d565b600501549063ffffffff611cf216565b611c6b6000611c9d565b6005015550565b60006107a57f466565506f6f6c457465726e616c53746f726167650000000000000000000000611fae565b60006008600260ff16836016540181611cb257fe5b0660028110611cbd57fe5b6007020192915050565b60006107a57f53796e7468657469784465627453686172650000000000000000000000000000611fae565b6000828201838110156106b25760405162461bcd60e51b81526004016107d090613f11565b6000546001600160a01b03163314611d415760405162461bcd60e51b81526004016107d090613f91565b565b6000611d4d612918565b6001600160a01b03166323257c2b7f53797374656d53657474696e67730000000000000000000000000000000000007f666565506572696f644475726174696f6e0000000000000000000000000000006040518363ffffffff1660e01b8152600401611dba929190613e06565b60206040518083038186803b158015611dd257600080fd5b505afa158015611de6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107a5919081019061327b565b6000611e14612943565b6001600160a01b0316826001600160a01b03161480611eb657506000611e386128d9565b6001600160a01b03166316b2213f846040518263ffffffff1660e01b8152600401611e639190613d43565b60206040518083038186803b158015611e7b57600080fd5b505afa158015611e8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611eb3919081019061327b565b14155b80611f3f5750611ec461296e565b6001600160a01b031663b38988f7836040518263ffffffff1660e01b8152600401611eef9190613d43565b60206040518083038186803b158015611f0757600080fd5b505afa158015611f1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611f3f919081019061325d565b80611f625750611f4d612999565b6001600160a01b0316826001600160a01b0316145b80611f855750611f706129c4565b6001600160a01b0316826001600160a01b0316145b806105a15750611f936129ef565b6001600160a01b0316826001600160a01b0316149050919050565b60008181526006602090815260408083205490516001600160a01b039091169182151591611fde91869101613d0d565b6040516020818303038152906040529061107c5760405162461bcd60e51b81526004016107d09190613ec0565b60006106b283836b033b2e3c9fd0803ce8000000612a1a565b6000808261203757506000905080612081565b600061204285611c9d565b9050600061205d85836003015461281790919063ffffffff16565b9050600061207886846005015461281790919063ffffffff16565b91945090925050505b9250929050565b60006107a57f53797374656d5374617475730000000000000000000000000000000000000000611fae565b6120bb6129ef565b6001600160a01b031663bb57ad206040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156120f557600080fd5b505af1158015612109573d6000803e3d6000fd5b505050506121156129c4565b6001600160a01b031663bb57ad206040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561214f57600080fd5b505af1158015612163573d6000803e3d6000fd5b50505050806121726000611c9d565b60020155816121816000611c9d565b60010155600061219081611c9d565b9050600061219e6001611c9d565b90506121c382600301546119468360040154846003015461239a90919063ffffffff16565b6121cd6000611c9d565b600301556005808301546006830154918301546121f492611946919063ffffffff61239a16565b6121fe6000611c9d565b6005015560165461223b9060029061222f90600190612223908463ffffffff611cf216565b9063ffffffff61239a16565b9063ffffffff612a5f16565b60168190556008906002811061224d57fe5b6007020180547fffffffffffffffffffffffffffffffff00000000000000000000000000000000168155600060018201819055600282018190556003820181905560048201819055600582018190556006909101819055429081906122b190611c9d565b805467ffffffffffffffff191667ffffffffffffffff92909216919091179055426122dc6000611c9d565b805467ffffffffffffffff9290921668010000000000000000026fffffffffffffffff0000000000000000199092169190911790556123196128d9565b6001600160a01b03166331e6da5a826040518263ffffffff1660e01b81526004016123449190614021565b600060405180830381600087803b15801561235e57600080fd5b505af1158015612372573d6000803e3d6000fd5b505050506123936123836001611c9d565b5467ffffffffffffffff16612a8f565b5050505050565b6000828211156123bc5760405162461bcd60e51b81526004016107d090613f21565b50900390565b6000806000806123d06128d9565b6001600160a01b031663ae3bbbbb866040518263ffffffff1660e01b81526004016123fb9190613d43565b604080518083038186803b15801561241257600080fd5b505afa158015612426573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061244a91908101906132d5565b9150915060006124586127a0565b90508083101561247057506001935091506107389050565b600061248d6124806118ca612729565b839063ffffffff61281716565b9050808411156124a7576000839550955050505050610738565b50600194509092505050915091565b6002546001600160a01b031633148015906124dc57506003546001600160a01b03163314155b15611d4157600380546001600160a01b03191633179055565b60006107a57f44656c6567617465417070726f76616c73000000000000000000000000000000611fae565b6000808080808080612531886123c2565b91509150816125525760405162461bcd60e51b81526004016107d090613fa1565b80156125705760405162461bcd60e51b81526004016107d090613f61565b612579886106bb565b90945092508315158061258c5750600083115b6125a85760405162461bcd60e51b81526004016107d090613f41565b6125c6886125b66001611c9d565b5467ffffffffffffffff16612b47565b83156125e1576125d584612bc4565b94506125e18886612c88565b82156125fc576125f083612e5c565b95506125fc8887612f1e565b612607888688612f98565b506001979650505050505050565b604080516001808252818301909252606091602080830190803883390190505090507f466c657869626c6553746f7261676500000000000000000000000000000000008160008151811061266557fe5b60200260200101818152505090565b606081518351016040519080825280602002602001820160405280156126a4578160200160208202803883390190505b50905060005b83518110156126e6578381815181106126bf57fe5b60200260200101518282815181106126d357fe5b60209081029190910101526001016126aa565b5060005b825181101561107c578281815181106126ff57fe5b602002602001015182828651018151811061271657fe5b60209081029190910101526001016126ea565b6000612733612918565b6001600160a01b03166323257c2b7f53797374656d53657474696e67730000000000000000000000000000000000007f7461726765745468726573686f6c6400000000000000000000000000000000006040518363ffffffff1660e01b8152600401611dba929190613e06565b60006127aa612918565b6001600160a01b03166323257c2b7f53797374656d53657474696e67730000000000000000000000000000000000007f69737375616e6365526174696f000000000000000000000000000000000000006040518363ffffffff1660e01b8152600401611dba929190613e06565b6000670de0b6b3a7640000612832848463ffffffff61305416565b8161283957fe5b049392505050565b6002546001600160a01b03163314611d415760405162461bcd60e51b81526004016107d090614001565b6002546001600160a01b0316331480159061289157506003546001600160a01b03163314155b156128a957600380546001600160a01b031916331790555b6000546003546001600160a01b03908116911614611d415760405162461bcd60e51b81526004016107d090613f01565b60006107a56524b9b9bab2b960d11b611fae565b60006107a57f52657761726473446973747269627574696f6e00000000000000000000000000611fae565b60006107a57f466c657869626c6553746f726167650000000000000000000000000000000000611fae565b60006107a57f45786368616e6765720000000000000000000000000000000000000000000000611fae565b60006107a57f436f6c6c61746572616c4d616e61676572000000000000000000000000000000611fae565b60006107a57f467574757265734d61726b65744d616e61676572000000000000000000000000611fae565b60006107a57f57726170706572466163746f7279000000000000000000000000000000000000611fae565b60006107a57f4574686572577261707065720000000000000000000000000000000000000000611fae565b600080612a4084612a3487600a870263ffffffff61305416565b9063ffffffff61308e16565b90506005600a820610612a5157600a015b600a900490505b9392505050565b600081612a7e5760405162461bcd60e51b81526004016107d090613f71565b818381612a8757fe5b069392505050565b6002546040516001600160a01b039091169063907dff9790612ab5908490602001613dea565b6040516020818303038152906040526001604051612ad290613d38565b6040519081900381207fffffffff0000000000000000000000000000000000000000000000000000000060e086901b168252612b1993929160009081908190600401613e53565b600060405180830381600087803b158015612b3357600080fd5b505af1158015612393573d6000803e3d6000fd5b612b4f611c72565b6001600160a01b0316633562fd207f6c6173745f6665655f7769746864726177616c0000000000000000000000000084604051602001612b90929190613cdc565b60405160208183030381529060405280519060200120836040518363ffffffff1660e01b8152600401610e6f929190613e06565b6000818160015b6002811015612c80576000612bdf82611c9d565b6004015490506000612c0482612bf485611c9d565b600301549063ffffffff61239a16565b90508015612c75576000858210612c1b5785612c1d565b815b9050612c2f838263ffffffff611cf216565b612c3885611c9d565b60040155612c4c868263ffffffff61239a16565b9550612c5e858263ffffffff611cf216565b945085612c73578496505050505050506105a4565b505b505060001901612bcb565b509392505050565b816001600160a01b03811673feefeefeefeefeefeefeefeefeefeefeefeefeef1415612cc65760405162461bcd60e51b81526004016107d090613fe1565b6000612cd06128d9565b6001600160a01b031663326080396007546040518263ffffffff1660e01b8152600401612cfd9190613dea565b60206040518083038186803b158015612d1557600080fd5b505afa158015612d29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612d4d9190810190613299565b6040517f9dc29fac0000000000000000000000000000000000000000000000000000000081529091506001600160a01b03821690639dc29fac90612dab9073feefeefeefeefeefeefeefeefeefeefeefeefeef908790600401613d7a565b600060405180830381600087803b158015612dc557600080fd5b505af1158015612dd9573d6000803e3d6000fd5b50506040517f867904b40000000000000000000000000000000000000000000000000000000081526001600160a01b038416925063867904b49150612e249087908790600401613d7a565b600060405180830381600087803b158015612e3e57600080fd5b505af1158015612e52573d6000803e3d6000fd5b5050505050505050565b6000818160015b6002811015612c80576000612e97612e7a83611c9d565b60060154612e8784611c9d565b600501549063ffffffff61239a16565b90508015612f14576000848210612eae5784612eb0565b815b9050612ecf81612ebf85611c9d565b600601549063ffffffff611cf216565b612ed884611c9d565b60060155612eec858263ffffffff61239a16565b9450612efe848263ffffffff611cf216565b935084612f125783955050505050506105a4565b505b5060001901612e63565b816001600160a01b03811673feefeefeefeefeefeefeefeefeefeefeefeefeef1415612f5c5760405162461bcd60e51b81526004016107d090613fe1565b6301dfe200612f696130c3565b6001600160a01b0316631bb47b448585846040518463ffffffff1660e01b8152600401612e2493929190613d95565b6002546040516001600160a01b039091169063907dff9790612fc290869086908690602001613d95565b6040516020818303038152906040526001604051612fdf90613d02565b6040519081900381207fffffffff0000000000000000000000000000000000000000000000000000000060e086901b16825261302693929160009081908190600401613e53565b600060405180830381600087803b15801561304057600080fd5b505af1158015611bfd573d6000803e3d6000fd5b600082613063575060006106b5565b8282028284828161307057fe5b04146106b25760405162461bcd60e51b81526004016107d090613fb1565b60008082116130af5760405162461bcd60e51b81526004016107d090613f31565b60008284816130ba57fe5b04949350505050565b60006107a57f526577617264457363726f775632000000000000000000000000000000000000611fae565b60405180604001604052806002905b613105613174565b8152602001906001900390816130fd5790505090565b604051806101000160405280600067ffffffffffffffff168152602001600067ffffffffffffffff1681526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60405180604001604052806002906020820280388339509192915050565b80356106b581614191565b80516106b581614191565b80516106b5816141a8565b80516106b5816141b1565b80516106b5816141ba565b80356106b5816141b1565b80516106b5816141c3565b6000602082840312156131f157600080fd5b60006131fd8484613192565b949350505050565b60006020828403121561321757600080fd5b60006131fd848461319d565b6000806040838503121561323657600080fd5b60006132428585613192565b9250506020613253858286016131c9565b9150509250929050565b60006020828403121561326f57600080fd5b60006131fd84846131a8565b60006020828403121561328d57600080fd5b60006131fd84846131b3565b6000602082840312156132ab57600080fd5b60006131fd84846131be565b6000602082840312156132c957600080fd5b60006131fd84846131c9565b600080604083850312156132e857600080fd5b60006132f485856131b3565b9250506020613253858286016131a8565b6000806040838503121561331857600080fd5b600061324285856131c9565b600080600080600080600060e0888a03121561333f57600080fd5b600061334b8a8a6131c9565b975050602061335c8a828b016131c9565b965050604061336d8a828b016131c9565b955050606061337e8a828b016131c9565b945050608061338f8a828b016131c9565b93505060a06133a08a828b016131c9565b92505060c06133b18a828b016131c9565b91505092959891949750929550565b600080600080600060a086880312156133d857600080fd5b60006133e488886131d4565b95505060206133f5888289016131b3565b9450506040613406888289016131b3565b9350506060613417888289016131b3565b9250506080613428888289016131d4565b9150509295509295909350565b6000613441838361352b565b505060400190565b60006134558383613580565b505060200190565b6134668161411c565b82525050565b613466816140be565b613466613481826140be565b614170565b61348f816140ab565b61349981846105a4565b92506134a4826107a8565b8060005b83811015610e9d5781516134bc8782613435565b96506134c7836140a5565b9250506001016134a8565b60006134dd826140b1565b6134e781856140b5565b93506134f2836140a5565b8060005b8381101561352057815161350a8882613449565b9750613515836140a5565b9250506001016134f6565b509495945050505050565b613534816140ab565b61353e81846105a4565b9250613549826107a8565b8060005b83811015610e9d5781516135618782613449565b965061356c836140a5565b92505060010161354d565b613466816140c9565b613466816107a8565b613466613595826107a8565b6107a8565b60006135a5826140b1565b6135af81856140b5565b93506135bf818560208601614140565b6135c881614181565b9093019392505050565b613466816140ce565b61346681614127565b61346681614135565b60006135fa6017836140b5565b7f4f6e6c7920496e7465726e616c20436f6e747261637473000000000000000000815260200192915050565b60006136336035836140b5565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527f2063616e20616363657074206f776e6572736869700000000000000000000000602082015260400192915050565b6000613692601d836140b5565b7f546f6f206561726c7920746f20636c6f73652066656520706572696f64000000815260200192915050565b60006136cb6013836140b5565b7f4f776e6572206f6e6c792066756e6374696f6e00000000000000000000000000815260200192915050565b60006137046024836105a4565b7f46656573436c61696d656428616464726573732c75696e743235362c75696e7481527f3235362900000000000000000000000000000000000000000000000000000000602082015260240192915050565b6000613763601b836140b5565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b600061379c601e836140b5565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815260200192915050565b60006137d5601a836140b5565b7f536166654d6174683a206469766973696f6e206279207a65726f000000000000815260200192915050565b600061380e6040836140b5565b7f4e6f2066656573206f72207265776172647320617661696c61626c6520666f7281527f20706572696f642c206f72206665657320616c726561647920636c61696d6564602082015260400192915050565b600061386d602b836140b5565b7f4d697373696e6720636f6e74726163743a2053796e746865746978427269646781527f65546f4f7074696d69736d000000000000000000000000000000000000000000602082015260400192915050565b60006138cc6011836105a4565b7f4d697373696e6720616464726573733a20000000000000000000000000000000815260110192915050565b60006139056018836140b5565b7f52657761726473446973747269627574696f6e206f6e6c790000000000000000815260200192915050565b600061393e601e836140b5565b7f412073796e7468206f7220534e58207261746520697320696e76616c69640000815260200192915050565b60006139776018836140b5565b7f536166654d6174683a206d6f64756c6f206279207a65726f0000000000000000815260200192915050565b60006139b0601f836140b5565b7f4e6f7420617070726f76656420746f20636c61696d206f6e20626568616c6600815260200192915050565b60006139e9602f836140b5565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681527f6f726d207468697320616374696f6e0000000000000000000000000000000000602082015260400192915050565b6000613a48601f836140b5565b7f432d526174696f2062656c6f772070656e616c7479207468726573686f6c6400815260200192915050565b6000613a816021836140b5565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f81527f7700000000000000000000000000000000000000000000000000000000000000602082015260400192915050565b6000613ae0601b836140b5565b7f4f6e6c792076616c69642072656c617965722063616e2063616c6c0000000000815260200192915050565b6000613b196029836140b5565b7f43616e206f6e6c7920706572666f726d207468697320616374696f6e2064757281527f696e672073657475700000000000000000000000000000000000000000000000602082015260400192915050565b6000613b786019836105a4565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b6000613bb16017836140b5565b7f4665652061646472657373206e6f7420616c6c6f776564000000000000000000815260200192915050565b6000613bea6018836140b5565b7f696e76616c69642066656520706572696f6420696e6465780000000000000000815260200192915050565b6000613c236018836105a4565b7f466565506572696f64436c6f7365642875696e74323536290000000000000000815260180192915050565b6000613c5c6017836140b5565b7f4f6e6c79207468652070726f78792063616e2063616c6c000000000000000000815260200192915050565b6000613c95601b836140b5565b7f46656520506572696f64204475726174696f6e206e6f74207365740000000000815260200192915050565b613466816140d9565b613466816140fa565b61346681614107565b6000613ce88285613589565b602082019150613cf88284613475565b5060140192915050565b60006106b5826136f7565b6000613d18826138bf565b9150613d248284613589565b50602001919050565b6000613d1882613b6b565b60006106b582613c16565b602081016106b5828461346c565b602081016106b5828461345d565b60408101613d6d828561346c565b612a58602083018461346c565b60408101613d88828561346c565b612a586020830184613580565b60608101613da3828661346c565b613db06020830185613580565b6131fd6040830184613580565b608081016106b58284613486565b602080825281016106b281846134d2565b602081016106b58284613577565b602081016106b58284613580565b60408101613d6d8285613580565b60408101613d888285613580565b60408101613e228285613580565b81810360208301526131fd818461359a565b60408101613e428284613580565b81810360208301526106b281613860565b60c08082528101613e64818961359a565b9050613e7360208301886135e4565b613e806040830187613580565b613e8d60608301866135db565b613e9a60808301856135db565b613ea760a08301846135db565b979650505050505050565b602081016106b582846135d2565b602080825281016106b2818461359a565b602080825281016105a1816135ed565b602080825281016105a181613626565b602080825281016105a181613685565b602080825281016105a1816136be565b602080825281016105a181613756565b602080825281016105a18161378f565b602080825281016105a1816137c8565b602080825281016105a181613801565b602080825281016105a1816138f8565b602080825281016105a181613931565b602080825281016105a18161396a565b602080825281016105a1816139a3565b602080825281016105a1816139dc565b602080825281016105a181613a3b565b602080825281016105a181613a74565b602080825281016105a181613ad3565b602080825281016105a181613b0c565b602080825281016105a181613ba4565b602080825281016105a181613bdd565b602080825281016105a181613c4f565b602080825281016105a181613c88565b602081016106b58284613cc1565b60e0810161403d828a613cca565b61404a6020830189613cca565b6140576040830188613cca565b6140646060830187613580565b6140716080830186613580565b61407e60a0830185613580565b61408b60c0830184613580565b98975050505050505050565b602081016106b58284613cd3565b60200190565b50600290565b5190565b90815260200190565b60006105a1826140ee565b151590565b60006105a1826140be565b6fffffffffffffffffffffffffffffffff1690565b6001600160a01b031690565b67ffffffffffffffff1690565b60ff1690565b69ffffffffffffffffffff1690565b60006105a1826140ce565b60006105a1613595836107a8565b60006105a1826107a8565b60005b8381101561415b578181015183820152602001614143565b8381111561416a576000848401525b50505050565b60006105a18260006105a18261418b565b601f01601f191690565b60601b90565b61419a816140be565b81146141a557600080fd5b50565b61419a816140c9565b61419a816107a8565b61419a816140ce565b61419a8161410d56fea365627a7a72315820220520b39512e28275c7a4b3a7705149a66773c9db921b235fce506c078fa5d76c6578706572696d656e74616cf564736f6c63430005100040000000000000000000000000c43b833f93c3896472ded3eff73311f571e3874200000000000000000000000073570075092502472e4b61a7058df1a4a1db12f2000000000000000000000000242a3df52c375bee81b1c668741d7c63af68fdd2
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c43b833f93c3896472ded3eff73311f571e3874200000000000000000000000073570075092502472e4b61a7058df1a4a1db12f2000000000000000000000000242a3df52c375bee81b1c668741d7c63af68fdd2
-----Decoded View---------------
Arg [0] : _proxy (address): 0xc43b833f93c3896472ded3eff73311f571e38742
Arg [1] : _owner (address): 0x73570075092502472e4b61a7058df1a4a1db12f2
Arg [2] : _resolver (address): 0x242a3df52c375bee81b1c668741d7c63af68fdd2
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000c43b833f93c3896472ded3eff73311f571e38742
Arg [1] : 00000000000000000000000073570075092502472e4b61a7058df1a4a1db12f2
Arg [2] : 000000000000000000000000242a3df52c375bee81b1c668741d7c63af68fdd2
Libraries Used
SafeDecimalMath : 0x1a60e2e2a8be0bc2b6381dd31fd3fd5f9a28de4cSystemSettingsLib : 0x34305b62550e0c652e697736e0bc93e67ab9b67bSignedSafeDecimalMath : 0xcefd89a03bd594287316da4b4f060104c8b271e0
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.