Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
Latest 5 from a total of 5 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Reset Last Value | 22961734 | 25 days ago | IN | 0 ETH | 0.000001041405 | ||||
Reset Last Value | 22961723 | 25 days ago | IN | 0 ETH | 0.000001021843 | ||||
Reset Last Value | 22961673 | 25 days ago | IN | 0 ETH | 0.000001031813 | ||||
Reset Last Value | 22961664 | 25 days ago | IN | 0 ETH | 0.000000931878 | ||||
Reset Last Value | 22847095 | 27 days ago | IN | 0 ETH | 0.000000058653 |
Loading...
Loading
Contract Name:
CircuitBreaker
Compiler Version
v0.5.16+commit.9c3226ce
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity)
/** *Submitted for verification at sepolia-optimism.etherscan.io on 2023-12-11 */ /* ____ __ __ __ _ / __/__ __ ___ / /_ / / ___ / /_ (_)__ __ _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ / /___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\ /___/ * Synthetix: CircuitBreaker.sol * * Latest source (may be newer): https://github.com/Synthetixio/synthetix/blob/master/contracts/CircuitBreaker.sol * Docs: https://docs.synthetix.io/contracts/CircuitBreaker * * Contract Dependencies: * - IAddressResolver * - ICircuitBreaker * - MixinResolver * - MixinSystemSettings * - Owned * Libraries: * - SafeDecimalMath * - SafeMath * * MIT License * =========== * * Copyright (c) 2023 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); } // 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 allNetworksDebtInfo() external view returns ( uint256 debt, uint256 sharesSupply, bool isStale ); 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); function liquidationAmounts(address account, bool isSelfLiquidation) external view returns ( uint totalRedeemed, uint debtToRemove, uint escrowToLiquidate, uint initialDebtBalance ); // Restricted: used internally to Synthetix function addSynths(ISynth[] calldata synthsToAdd) external; 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 setCurrentPeriodId(uint128 periodId) external; function liquidateAccount(address account, bool isSelfLiquidation) external returns ( uint totalRedeemed, uint debtRemoved, uint escrowToLiquidate ); function issueSynthsWithoutDebt( bytes32 currencyKey, address to, uint amount ) external returns (bool rateInvalid); function burnSynthsWithoutDebt( bytes32 currencyKey, address to, uint amount ) external returns (bool rateInvalid); function modifyDebtSharesForMigration(address account, uint amount) 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_ESCROW_DURATION = "liquidationEscrowDuration"; bytes32 internal constant SETTING_LIQUIDATION_PENALTY = "liquidationPenalty"; bytes32 internal constant SETTING_SNX_LIQUIDATION_PENALTY = "snxLiquidationPenalty"; bytes32 internal constant SETTING_SELF_LIQUIDATION_PENALTY = "selfLiquidationPenalty"; bytes32 internal constant SETTING_FLAG_REWARD = "flagReward"; bytes32 internal constant SETTING_LIQUIDATE_REWARD = "liquidateReward"; 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_VOLATILITY_CONSIDERATION_WINDOW = "atomicVolConsiderationWindow"; bytes32 internal constant SETTING_ATOMIC_VOLATILITY_UPDATE_THRESHOLD = "atomicVolUpdateThreshold"; bytes32 internal constant SETTING_PURE_CHAINLINK_PRICE_FOR_ATOMIC_SWAPS_ENABLED = "pureChainlinkForAtomicsEnabled"; bytes32 internal constant SETTING_CROSS_SYNTH_TRANSFER_ENABLED = "crossChainSynthTransferEnabled"; 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 getLiquidationEscrowDuration() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATION_ESCROW_DURATION); } function getLiquidationPenalty() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATION_PENALTY); } function getSnxLiquidationPenalty() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_SNX_LIQUIDATION_PENALTY); } function getSelfLiquidationPenalty() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_SELF_LIQUIDATION_PENALTY); } function getFlagReward() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_FLAG_REWARD); } function getLiquidateReward() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATE_REWARD); } 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 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)) ); } function getPureChainlinkPriceForAtomicSwapsEnabled(bytes32 currencyKey) internal view returns (bool) { return flexibleStorage().getBoolValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_PURE_CHAINLINK_PRICE_FOR_ATOMIC_SWAPS_ENABLED, currencyKey)) ); } function getCrossChainSynthTransferEnabled(bytes32 currencyKey) internal view returns (uint) { return flexibleStorage().getUIntValue( SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_CROSS_SYNTH_TRANSFER_ENABLED, currencyKey)) ); } function getExchangeMaxDynamicFee() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_EXCHANGE_MAX_DYNAMIC_FEE); } function getExchangeDynamicFeeRounds() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_EXCHANGE_DYNAMIC_FEE_ROUNDS); } function getExchangeDynamicFeeThreshold() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_EXCHANGE_DYNAMIC_FEE_THRESHOLD); } function getExchangeDynamicFeeWeightDecay() internal view returns (uint) { return flexibleStorage().getUIntValue(SETTING_CONTRACT_NAME, SETTING_EXCHANGE_DYNAMIC_FEE_WEIGHT_DECAY); } } // https://docs.synthetix.io/contracts/source/interfaces/ICircuitBreaker interface ICircuitBreaker { // Views function isInvalid(address oracleAddress, uint value) external view returns (bool); function priceDeviationThresholdFactor() external view returns (uint); function isDeviationAboveThreshold(uint base, uint comparison) external view returns (bool); function lastValue(address oracleAddress) external view returns (uint); function circuitBroken(address oracleAddress) external view returns (bool); // Mutative functions function resetLastValue(address[] calldata oracleAddresses, uint[] calldata values) external; function probeCircuitBreaker(address oracleAddress, uint value) external returns (bool circuitBroken); } /** * @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)); } } // 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; } pragma experimental ABIEncoderV2; // https://docs.synthetix.io/contracts/source/interfaces/IDirectIntegration interface IDirectIntegrationManager { struct ParameterIntegrationSettings { bytes32 currencyKey; address dexPriceAggregator; address atomicEquivalentForDexPricing; uint atomicExchangeFeeRate; uint atomicTwapWindow; uint atomicMaxVolumePerBlock; uint atomicVolatilityConsiderationWindow; uint atomicVolatilityUpdateThreshold; uint exchangeFeeRate; uint exchangeMaxDynamicFee; uint exchangeDynamicFeeRounds; uint exchangeDynamicFeeThreshold; uint exchangeDynamicFeeWeightDecay; } function getExchangeParameters(address integration, bytes32 key) external view returns (ParameterIntegrationSettings memory settings); function setExchangeParameters( address integration, bytes32[] calldata currencyKeys, ParameterIntegrationSettings calldata params ) external; } // https://docs.synthetix.io/contracts/source/interfaces/iexchangerates interface IExchangeRates { // Structs struct RateAndUpdatedTime { uint216 rate; uint40 time; } // Views function aggregators(bytes32 currencyKey) external view returns (address); function aggregatorWarningFlags() external view returns (address); function anyRateIsInvalid(bytes32[] calldata currencyKeys) external view returns (bool); function anyRateIsInvalidAtRound(bytes32[] calldata currencyKeys, uint[] calldata roundIds) external view returns (bool); function currenciesUsingAggregator(address aggregator) external view returns (bytes32[] memory); function effectiveValue( bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey ) external view returns (uint value); function effectiveValueAndRates( bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey ) external view returns ( uint value, uint sourceRate, uint destinationRate ); function effectiveValueAndRatesAtRound( bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey, uint roundIdForSrc, uint roundIdForDest ) external view returns ( uint value, uint sourceRate, uint destinationRate ); function effectiveAtomicValueAndRates( bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey ) external view returns ( uint value, uint systemValue, uint systemSourceRate, uint systemDestinationRate ); function effectiveAtomicValueAndRates( IDirectIntegrationManager.ParameterIntegrationSettings calldata sourceSettings, uint sourceAmount, IDirectIntegrationManager.ParameterIntegrationSettings calldata destinationSettings, IDirectIntegrationManager.ParameterIntegrationSettings calldata usdSettings ) external view returns ( uint value, uint systemValue, uint systemSourceRate, uint systemDestinationRate ); function getCurrentRoundId(bytes32 currencyKey) external view returns (uint); function getLastRoundIdBeforeElapsedSecs( bytes32 currencyKey, uint startingRoundId, uint startingTimestamp, uint timediff ) external view returns (uint); function lastRateUpdateTimes(bytes32 currencyKey) external view returns (uint256); function rateAndTimestampAtRound(bytes32 currencyKey, uint roundId) external view returns (uint rate, uint time); function rateAndUpdatedTime(bytes32 currencyKey) external view returns (uint rate, uint time); function rateAndInvalid(bytes32 currencyKey) external view returns (uint rate, bool isInvalid); function rateForCurrency(bytes32 currencyKey) external view returns (uint); function rateIsFlagged(bytes32 currencyKey) external view returns (bool); function rateIsInvalid(bytes32 currencyKey) external view returns (bool); function rateIsStale(bytes32 currencyKey) external view returns (bool); function rateStalePeriod() external view returns (uint); function ratesAndUpdatedTimeForCurrencyLastNRounds( bytes32 currencyKey, uint numRounds, uint roundId ) external view returns (uint[] memory rates, uint[] memory times); function ratesAndInvalidForCurrencies(bytes32[] calldata currencyKeys) external view returns (uint[] memory rates, bool anyRateInvalid); function ratesForCurrencies(bytes32[] calldata currencyKeys) external view returns (uint[] memory); function synthTooVolatileForAtomicExchange(bytes32 currencyKey) external view returns (bool); function synthTooVolatileForAtomicExchange(IDirectIntegrationManager.ParameterIntegrationSettings calldata settings) external view returns (bool); function rateWithSafetyChecks(bytes32 currencyKey) external returns ( uint rate, bool broken, bool invalid ); } // 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); } 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 ); } // Inheritance // Libraries // Internal references // Chainlink /** * Compares current exchange rate to previous, and suspends a synth if the * difference is outside of deviation bounds. * Stores last "good" rate for each synth on each invocation. * Inteded use is to use in combination with ExchangeRates on mutative exchange-like * methods. * Suspend functionality is public, resume functionality is controlled by owner. * * https://docs.synthetix.io/contracts/source/contracts/CircuitBreaker */ contract CircuitBreaker is Owned, MixinSystemSettings, ICircuitBreaker { using SafeMath for uint; using SafeDecimalMath for uint; bytes32 public constant CONTRACT_NAME = "CircuitBreaker"; // is internal to have lastValue getter in interface in solidity v0.5 // TODO: after upgrading solidity, switch to just public lastValue instead // of maintaining this internal one mapping(address => uint) internal _lastValue; mapping(address => bool) internal _circuitBroken; /* ========== ADDRESS RESOLVER CONFIGURATION ========== */ bytes32 private constant CONTRACT_SYSTEMSTATUS = "SystemStatus"; bytes32 private constant CONTRACT_ISSUER = "Issuer"; bytes32 private constant CONTRACT_EXRATES = "ExchangeRates"; constructor(address _owner, address _resolver) public Owned(_owner) MixinSystemSettings(_resolver) {} /* ========== VIEWS ========== */ function resolverAddressesRequired() public view returns (bytes32[] memory addresses) { bytes32[] memory existingAddresses = MixinSystemSettings.resolverAddressesRequired(); bytes32[] memory newAddresses = new bytes32[](3); newAddresses[0] = CONTRACT_SYSTEMSTATUS; newAddresses[1] = CONTRACT_ISSUER; newAddresses[2] = CONTRACT_EXRATES; addresses = combineArrays(existingAddresses, newAddresses); } // Returns whether or not a rate would be come invalid // ignores systemStatus check function isInvalid(address oracleAddress, uint value) external view returns (bool) { return _circuitBroken[oracleAddress] || _isRateOutOfBounds(oracleAddress, value) || value == 0; } function isDeviationAboveThreshold(uint base, uint comparison) external view returns (bool) { return _isDeviationAboveThreshold(base, comparison); } function priceDeviationThresholdFactor() external view returns (uint) { return getPriceDeviationThresholdFactor(); } function lastValue(address oracleAddress) external view returns (uint) { return _lastValue[oracleAddress]; } function circuitBroken(address oracleAddress) external view returns (bool) { return _circuitBroken[oracleAddress]; } /* ========== Internal views ========== */ function systemStatus() internal view returns (ISystemStatus) { return ISystemStatus(requireAndGetAddress(CONTRACT_SYSTEMSTATUS)); } /* ========== Mutating ========== */ /** * Checks rate deviation from previous and its "invalid" oracle state (stale rate, of flagged by oracle). * If its valid, set the `circuitBoken` flag and return false. Continue storing price updates as normal. * Also, checks that system is not suspended currently, if it is - doesn't perform any checks, and * returns last rate and the current broken state, to prevent synths suspensions during maintenance. */ function probeCircuitBreaker(address oracleAddress, uint value) external onlyProbers returns (bool circuitBroken) { require(oracleAddress != address(0), "Oracle address is 0"); // these conditional statements are ordered for short circuit (heh) efficiency to reduce gas usage // in the usual case of no circuit broken. if ( // cases where the new price should be triggering a circuit break (value == 0 || _isRateOutOfBounds(oracleAddress, value)) && // other necessary states in order to break !_circuitBroken[oracleAddress] && !systemStatus().systemSuspended() ) { _circuitBroken[oracleAddress] = true; emit CircuitBroken(oracleAddress, _lastValue[oracleAddress], value); } _lastValue[oracleAddress] = value; return _circuitBroken[oracleAddress]; } /** * SIP-139 * resets the stored value for _lastValue for multiple currencies to the latest rate * can be used to enable synths after a broken circuit happenned * doesn't check deviations here, so believes that owner knows better * emits LastRateOverridden */ function resetLastValue(address[] calldata oracleAddresses, uint[] calldata values) external onlyOwner { for (uint i = 0; i < oracleAddresses.length; i++) { require(oracleAddresses[i] != address(0), "Oracle address is 0"); emit LastValueOverridden(oracleAddresses[i], _lastValue[oracleAddresses[i]], values[i]); _lastValue[oracleAddresses[i]] = values[i]; _circuitBroken[oracleAddresses[i]] = false; } } /* ========== INTERNAL FUNCTIONS ========== */ function _isDeviationAboveThreshold(uint base, uint comparison) internal view returns (bool) { if (base == 0 || comparison == 0) { return true; } uint factor; if (comparison > base) { factor = comparison.divideDecimal(base); } else { factor = base.divideDecimal(comparison); } return factor >= getPriceDeviationThresholdFactor(); } /** * Rate is invalid if it is outside of deviation bounds relative to previous non-zero rate */ function _isRateOutOfBounds(address oracleAddress, uint current) internal view returns (bool) { uint last = _lastValue[oracleAddress]; // `last == 0` indicates unset/unpopulated oracle. If we dont have any data on the previous oracle price, // we should skip the deviation check and allow it to be populated. if (last > 0) { return _isDeviationAboveThreshold(last, current); } return false; } // ========== MODIFIERS ======= modifier onlyProbers() { require( msg.sender == requireAndGetAddress(CONTRACT_ISSUER) || msg.sender == requireAndGetAddress(CONTRACT_EXRATES), "Only internal contracts can call this function" ); _; } // ========== EVENTS ========== // @notice signals that a the "last value" was overridden by one of the admin methods // with a value that didn't come directly from the ExchangeRates.getRates methods event LastValueOverridden(address indexed oracleAddress, uint256 previousValue, uint256 newValue); // @notice signals that the circuit was broken event CircuitBroken(address indexed oracleAddress, uint256 previousValue, uint256 newValue); }
[{"inputs":[{"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":true,"internalType":"address","name":"oracleAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"previousValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"CircuitBroken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oracleAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"previousValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"LastValueOverridden","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"},{"constant":true,"inputs":[],"name":"CONTRACT_NAME","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"oracleAddress","type":"address"}],"name":"circuitBroken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"base","type":"uint256"},{"internalType":"uint256","name":"comparison","type":"uint256"}],"name":"isDeviationAboveThreshold","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"oracleAddress","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"isInvalid","outputs":[{"internalType":"bool","name":"","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":[{"internalType":"address","name":"oracleAddress","type":"address"}],"name":"lastValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"priceDeviationThresholdFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"oracleAddress","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"probeCircuitBreaker","outputs":[{"internalType":"bool","name":"circuitBroken","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"rebuildCache","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address[]","name":"oracleAddresses","type":"address[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"resetLastValue","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"}]
Contract Creation Code
60806040523480156200001157600080fd5b506040516200179f3803806200179f8339810160408190526200003491620000fc565b8080836001600160a01b038116620000695760405162461bcd60e51b81526004016200006090620001b8565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0383161781556040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91620000b691849062000192565b60405180910390a150600280546001600160a01b0319166001600160a01b03929092169190911790555062000213915050565b8051620000f681620001f9565b92915050565b600080604083850312156200011057600080fd5b60006200011e8585620000e9565b92505060206200013185828601620000e9565b9150509250929050565b6200014681620001e5565b82525050565b6200014681620001d3565b600062000166601983620001ca565b7f4f776e657220616464726573732063616e6e6f74206265203000000000000000815260200192915050565b60408101620001a282856200013b565b620001b160208301846200014c565b9392505050565b60208082528101620000f68162000157565b90815260200190565b60006001600160a01b038216620000f6565b6000620000f6826000620000f682620001d3565b6200020481620001d3565b81146200021057600080fd5b50565b61157c80620002236000396000f3fe608060405234801561001057600080fd5b50600436106101005760003560e01c806374185360116100975780638da5cb5b116100665780638da5cb5b146101dd578063ba03e93f146101e5578063cfefbc7f146101f8578063ec5f638e1461020b57610100565b806374185360146101a557806378cb51cb146101ad57806379ba5097146101c0578063899ffef4146101c857610100565b8063372a395a116100d3578063372a395a14610160578063413caeb51461017557806353a47bb714610188578063614d08f81461019d57610100565b806304f3bcec146101055780631627540c1461012357806318b844ad146101385780632af64bd314610158575b600080fd5b61010d61021e565b60405161011a9190611418565b60405180910390f35b610136610131366004610f15565b61022d565b005b61014b610146366004610f59565b61028b565b60405161011a91906113b3565b61014b6102c9565b6101686103e1565b60405161011a91906113c1565b61014b610183366004610f59565b6103f0565b6101906105ea565b60405161011a9190611372565b6101686105f9565b61013661060e565b61014b6101bb36600461103f565b610764565b610136610770565b6101d061080c565b60405161011a91906113a2565b6101906108c4565b6101686101f3366004610f15565b6108d3565b610136610206366004610f93565b6108ee565b61014b610219366004610f15565b610abf565b6002546001600160a01b031681565b610235610add565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290610280908390611372565b60405180910390a150565b6001600160a01b03821660009081526005602052604081205460ff16806102b757506102b78383610b09565b806102c0575081155b90505b92915050565b600060606102d561080c565b905060005b81518110156103d75760008282815181106102f157fe5b602090810291909101810151600081815260039092526040918290205460025492516321f8a72160e01b81529193506001600160a01b039081169216906321f8a721906103429085906004016113c1565b60206040518083038186803b15801561035a57600080fd5b505afa15801561036e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506103929190810190610f3b565b6001600160a01b03161415806103bd57506000818152600360205260409020546001600160a01b0316155b156103ce57600093505050506103de565b506001016102da565b5060019150505b90565b60006103eb610b44565b905090565b60006104046524b9b9bab2b960d11b610bfc565b6001600160a01b0316336001600160a01b0316148061044c57506104376c45786368616e6765526174657360981b610bfc565b6001600160a01b0316336001600160a01b0316145b6104715760405162461bcd60e51b815260040161046890611487565b60405180910390fd5b6001600160a01b0383166104975760405162461bcd60e51b815260040161046890611457565b8115806104a957506104a98383610b09565b80156104ce57506001600160a01b03831660009081526005602052604090205460ff16155b801561054f57506104dd610c60565b6001600160a01b031663c0eee4436040518163ffffffff1660e01b815260040160206040518083038186803b15801561051557600080fd5b505afa158015610529573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061054d9190810190611003565b155b156105bc576001600160a01b0383166000818152600560209081526040808320805460ff191660011790556004909152908190205490517f67bad4b353dfb692ff5355991cbbb32b44e8b68fe393f9116791efc111beefe7916105b39186906113dd565b60405180910390a25b506001600160a01b039190911660009081526004602090815260408083209390935560059052205460ff1690565b6001546001600160a01b031681565b6d21b4b931bab4ba213932b0b5b2b960911b81565b606061061861080c565b905060005b815181101561076057600082828151811061063457fe5b602002602001015190506000600260009054906101000a90046001600160a01b03166001600160a01b031663dacb2d0183846040516020016106769190611367565b6040516020818303038152906040526040518363ffffffff1660e01b81526004016106a29291906113f8565b60206040518083038186803b1580156106ba57600080fd5b505afa1580156106ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506106f29190810190610f3b565b6000838152600360205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa689061074e90849084906113cf565b60405180910390a1505060010161061d565b5050565b60006102c08383610c7a565b6001546001600160a01b0316331461079a5760405162461bcd60e51b815260040161046890611437565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c926107dd926001600160a01b0391821692911690611380565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b606080610817610cd9565b60408051600380825260808201909252919250606091906020820183803883390190505090506b53797374656d53746174757360a01b8160008151811061085a57fe5b6020026020010181815250506524b9b9bab2b960d11b8160018151811061087d57fe5b6020026020010181815250506c45786368616e6765526174657360981b816002815181106108a757fe5b6020026020010181815250506108bd8282610d2a565b9250505090565b6000546001600160a01b031681565b6001600160a01b031660009081526004602052604090205490565b6108f6610add565b60005b83811015610ab857600085858381811061090f57fe5b90506020020160206109249190810190610f15565b6001600160a01b0316141561094b5760405162461bcd60e51b815260040161046890611457565b84848281811061095757fe5b905060200201602061096c9190810190610f15565b6001600160a01b03167f915f74751eb02d50f865435828021de99701d7eca4ccd06a308d5dc01ab70ace600460008888868181106109a657fe5b90506020020160206109bb9190810190610f15565b6001600160a01b03166001600160a01b03168152602001908152602001600020548585858181106109e857fe5b905060200201356040516109fd9291906113dd565b60405180910390a2828282818110610a1157fe5b9050602002013560046000878785818110610a2857fe5b9050602002016020610a3d9190810190610f15565b6001600160a01b03166001600160a01b0316815260200190815260200160002081905550600060056000878785818110610a7357fe5b9050602002016020610a889190810190610f15565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790556001016108f9565b5050505050565b6001600160a01b031660009081526005602052604090205460ff1690565b6000546001600160a01b03163314610b075760405162461bcd60e51b815260040161046890611467565b565b6001600160a01b0382166000908152600460205260408120548015610b3a57610b328184610c7a565b9150506102c3565b5060009392505050565b6000610b4e610ddf565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b7f7072696365446576696174696f6e5468726573686f6c64466163746f720000006040518363ffffffff1660e01b8152600401610bac9291906113dd565b60206040518083038186803b158015610bc457600080fd5b505afa158015610bd8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506103eb9190810190611021565b60008181526003602090815260408083205490516001600160a01b039091169182151591610c2c91869101611347565b60405160208183030381529060405290610c595760405162461bcd60e51b81526004016104689190611426565b5092915050565b60006103eb6b53797374656d53746174757360a01b610bfc565b6000821580610c87575081155b15610c94575060016102c3565b600083831115610cb557610cae838563ffffffff610dfc16565b9050610cc8565b610cc5848463ffffffff610dfc16565b90505b610cd0610b44565b11159392505050565b604080516001808252818301909252606091602080830190803883390190505090506e466c657869626c6553746f7261676560881b81600081518110610d1b57fe5b60200260200101818152505090565b60608151835101604051908082528060200260200182016040528015610d5a578160200160208202803883390190505b50905060005b8351811015610d9c57838181518110610d7557fe5b6020026020010151828281518110610d8957fe5b6020908102919091010152600101610d60565b5060005b8251811015610c5957828181518110610db557fe5b6020026020010151828286510181518110610dcc57fe5b6020908102919091010152600101610da0565b60006103eb6e466c657869626c6553746f7261676560881b610bfc565b60006102c082610e1a85670de0b6b3a764000063ffffffff610e2616565b9063ffffffff610e6016565b600082610e35575060006102c3565b82820282848281610e4257fe5b04146102c05760405162461bcd60e51b815260040161046890611477565b6000808211610e815760405162461bcd60e51b815260040161046890611447565b6000828481610e8c57fe5b04949350505050565b80356102c381611510565b80516102c381611510565b60008083601f840112610ebd57600080fd5b50813567ffffffffffffffff811115610ed557600080fd5b602083019150836020820283011115610eed57600080fd5b9250929050565b80516102c381611527565b80356102c381611530565b80516102c381611530565b600060208284031215610f2757600080fd5b6000610f338484610e95565b949350505050565b600060208284031215610f4d57600080fd5b6000610f338484610ea0565b60008060408385031215610f6c57600080fd5b6000610f788585610e95565b9250506020610f8985828601610eff565b9150509250929050565b60008060008060408587031215610fa957600080fd5b843567ffffffffffffffff811115610fc057600080fd5b610fcc87828801610eab565b9450945050602085013567ffffffffffffffff811115610feb57600080fd5b610ff787828801610eab565b95989497509550505050565b60006020828403121561101557600080fd5b6000610f338484610ef4565b60006020828403121561103357600080fd5b6000610f338484610f0a565b6000806040838503121561105257600080fd5b6000610f788585610eff565b600061106a83836110e3565b505060200190565b61107b816114af565b82525050565b600061108c8261149d565b61109681856114a1565b93506110a183611497565b8060005b838110156110cf5781516110b9888261105e565b97506110c483611497565b9250506001016110a5565b509495945050505050565b61107b816114ba565b61107b816103de565b61107b6110f8826103de565b6103de565b61107b816114cb565b60006111118261149d565b61111b81856114a1565b935061112b8185602086016114d6565b61113481611506565b9093019392505050565b600061114b6035836114a1565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b60006111a2601a836114a1565b7f536166654d6174683a206469766973696f6e206279207a65726f000000000000815260200192915050565b60006111db6011836114aa565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b60006112086013836114a1565b7204f7261636c652061646472657373206973203606c1b815260200192915050565b6000611237602f836114a1565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b60006112886021836114a1565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b60006112cb6019836114aa565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b6000611304602e836114a1565b7f4f6e6c7920696e7465726e616c20636f6e7472616374732063616e2063616c6c81526d103a3434b990333ab731ba34b7b760911b602082015260400192915050565b6000611352826111ce565b915061135e82846110ec565b50602001919050565b6000611352826112be565b602081016102c38284611072565b6040810161138e8285611072565b61139b6020830184611072565b9392505050565b602080825281016102c08184611081565b602081016102c382846110da565b602081016102c382846110e3565b6040810161138e82856110e3565b604081016113eb82856110e3565b61139b60208301846110e3565b6040810161140682856110e3565b8181036020830152610f338184611106565b602081016102c382846110fd565b602080825281016102c08184611106565b602080825281016102c38161113e565b602080825281016102c381611195565b602080825281016102c3816111fb565b602080825281016102c38161122a565b602080825281016102c38161127b565b602080825281016102c3816112f7565b60200190565b5190565b90815260200190565b919050565b60006102c3826114bf565b151590565b6001600160a01b031690565b60006102c3826114af565b60005b838110156114f15781810151838201526020016114d9565b83811115611500576000848401525b50505050565b601f01601f191690565b611519816114af565b811461152457600080fd5b50565b611519816114ba565b611519816103de56fea365627a7a723158206015efb58c3e29bbf7b75ef6cbb4e30e4af1745785f62beff66c4f737e0e4a506c6578706572696d656e74616cf564736f6c6343000510004000000000000000000000000048914229dedd5a9922f44441ffccfc2cb7856ee9000000000000000000000000529c553ef2d0370279dc8abf19702b98b166d252
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101005760003560e01c806374185360116100975780638da5cb5b116100665780638da5cb5b146101dd578063ba03e93f146101e5578063cfefbc7f146101f8578063ec5f638e1461020b57610100565b806374185360146101a557806378cb51cb146101ad57806379ba5097146101c0578063899ffef4146101c857610100565b8063372a395a116100d3578063372a395a14610160578063413caeb51461017557806353a47bb714610188578063614d08f81461019d57610100565b806304f3bcec146101055780631627540c1461012357806318b844ad146101385780632af64bd314610158575b600080fd5b61010d61021e565b60405161011a9190611418565b60405180910390f35b610136610131366004610f15565b61022d565b005b61014b610146366004610f59565b61028b565b60405161011a91906113b3565b61014b6102c9565b6101686103e1565b60405161011a91906113c1565b61014b610183366004610f59565b6103f0565b6101906105ea565b60405161011a9190611372565b6101686105f9565b61013661060e565b61014b6101bb36600461103f565b610764565b610136610770565b6101d061080c565b60405161011a91906113a2565b6101906108c4565b6101686101f3366004610f15565b6108d3565b610136610206366004610f93565b6108ee565b61014b610219366004610f15565b610abf565b6002546001600160a01b031681565b610235610add565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290610280908390611372565b60405180910390a150565b6001600160a01b03821660009081526005602052604081205460ff16806102b757506102b78383610b09565b806102c0575081155b90505b92915050565b600060606102d561080c565b905060005b81518110156103d75760008282815181106102f157fe5b602090810291909101810151600081815260039092526040918290205460025492516321f8a72160e01b81529193506001600160a01b039081169216906321f8a721906103429085906004016113c1565b60206040518083038186803b15801561035a57600080fd5b505afa15801561036e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506103929190810190610f3b565b6001600160a01b03161415806103bd57506000818152600360205260409020546001600160a01b0316155b156103ce57600093505050506103de565b506001016102da565b5060019150505b90565b60006103eb610b44565b905090565b60006104046524b9b9bab2b960d11b610bfc565b6001600160a01b0316336001600160a01b0316148061044c57506104376c45786368616e6765526174657360981b610bfc565b6001600160a01b0316336001600160a01b0316145b6104715760405162461bcd60e51b815260040161046890611487565b60405180910390fd5b6001600160a01b0383166104975760405162461bcd60e51b815260040161046890611457565b8115806104a957506104a98383610b09565b80156104ce57506001600160a01b03831660009081526005602052604090205460ff16155b801561054f57506104dd610c60565b6001600160a01b031663c0eee4436040518163ffffffff1660e01b815260040160206040518083038186803b15801561051557600080fd5b505afa158015610529573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061054d9190810190611003565b155b156105bc576001600160a01b0383166000818152600560209081526040808320805460ff191660011790556004909152908190205490517f67bad4b353dfb692ff5355991cbbb32b44e8b68fe393f9116791efc111beefe7916105b39186906113dd565b60405180910390a25b506001600160a01b039190911660009081526004602090815260408083209390935560059052205460ff1690565b6001546001600160a01b031681565b6d21b4b931bab4ba213932b0b5b2b960911b81565b606061061861080c565b905060005b815181101561076057600082828151811061063457fe5b602002602001015190506000600260009054906101000a90046001600160a01b03166001600160a01b031663dacb2d0183846040516020016106769190611367565b6040516020818303038152906040526040518363ffffffff1660e01b81526004016106a29291906113f8565b60206040518083038186803b1580156106ba57600080fd5b505afa1580156106ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506106f29190810190610f3b565b6000838152600360205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa689061074e90849084906113cf565b60405180910390a1505060010161061d565b5050565b60006102c08383610c7a565b6001546001600160a01b0316331461079a5760405162461bcd60e51b815260040161046890611437565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c926107dd926001600160a01b0391821692911690611380565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b606080610817610cd9565b60408051600380825260808201909252919250606091906020820183803883390190505090506b53797374656d53746174757360a01b8160008151811061085a57fe5b6020026020010181815250506524b9b9bab2b960d11b8160018151811061087d57fe5b6020026020010181815250506c45786368616e6765526174657360981b816002815181106108a757fe5b6020026020010181815250506108bd8282610d2a565b9250505090565b6000546001600160a01b031681565b6001600160a01b031660009081526004602052604090205490565b6108f6610add565b60005b83811015610ab857600085858381811061090f57fe5b90506020020160206109249190810190610f15565b6001600160a01b0316141561094b5760405162461bcd60e51b815260040161046890611457565b84848281811061095757fe5b905060200201602061096c9190810190610f15565b6001600160a01b03167f915f74751eb02d50f865435828021de99701d7eca4ccd06a308d5dc01ab70ace600460008888868181106109a657fe5b90506020020160206109bb9190810190610f15565b6001600160a01b03166001600160a01b03168152602001908152602001600020548585858181106109e857fe5b905060200201356040516109fd9291906113dd565b60405180910390a2828282818110610a1157fe5b9050602002013560046000878785818110610a2857fe5b9050602002016020610a3d9190810190610f15565b6001600160a01b03166001600160a01b0316815260200190815260200160002081905550600060056000878785818110610a7357fe5b9050602002016020610a889190810190610f15565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790556001016108f9565b5050505050565b6001600160a01b031660009081526005602052604090205460ff1690565b6000546001600160a01b03163314610b075760405162461bcd60e51b815260040161046890611467565b565b6001600160a01b0382166000908152600460205260408120548015610b3a57610b328184610c7a565b9150506102c3565b5060009392505050565b6000610b4e610ddf565b6001600160a01b03166323257c2b6d53797374656d53657474696e677360901b7f7072696365446576696174696f6e5468726573686f6c64466163746f720000006040518363ffffffff1660e01b8152600401610bac9291906113dd565b60206040518083038186803b158015610bc457600080fd5b505afa158015610bd8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506103eb9190810190611021565b60008181526003602090815260408083205490516001600160a01b039091169182151591610c2c91869101611347565b60405160208183030381529060405290610c595760405162461bcd60e51b81526004016104689190611426565b5092915050565b60006103eb6b53797374656d53746174757360a01b610bfc565b6000821580610c87575081155b15610c94575060016102c3565b600083831115610cb557610cae838563ffffffff610dfc16565b9050610cc8565b610cc5848463ffffffff610dfc16565b90505b610cd0610b44565b11159392505050565b604080516001808252818301909252606091602080830190803883390190505090506e466c657869626c6553746f7261676560881b81600081518110610d1b57fe5b60200260200101818152505090565b60608151835101604051908082528060200260200182016040528015610d5a578160200160208202803883390190505b50905060005b8351811015610d9c57838181518110610d7557fe5b6020026020010151828281518110610d8957fe5b6020908102919091010152600101610d60565b5060005b8251811015610c5957828181518110610db557fe5b6020026020010151828286510181518110610dcc57fe5b6020908102919091010152600101610da0565b60006103eb6e466c657869626c6553746f7261676560881b610bfc565b60006102c082610e1a85670de0b6b3a764000063ffffffff610e2616565b9063ffffffff610e6016565b600082610e35575060006102c3565b82820282848281610e4257fe5b04146102c05760405162461bcd60e51b815260040161046890611477565b6000808211610e815760405162461bcd60e51b815260040161046890611447565b6000828481610e8c57fe5b04949350505050565b80356102c381611510565b80516102c381611510565b60008083601f840112610ebd57600080fd5b50813567ffffffffffffffff811115610ed557600080fd5b602083019150836020820283011115610eed57600080fd5b9250929050565b80516102c381611527565b80356102c381611530565b80516102c381611530565b600060208284031215610f2757600080fd5b6000610f338484610e95565b949350505050565b600060208284031215610f4d57600080fd5b6000610f338484610ea0565b60008060408385031215610f6c57600080fd5b6000610f788585610e95565b9250506020610f8985828601610eff565b9150509250929050565b60008060008060408587031215610fa957600080fd5b843567ffffffffffffffff811115610fc057600080fd5b610fcc87828801610eab565b9450945050602085013567ffffffffffffffff811115610feb57600080fd5b610ff787828801610eab565b95989497509550505050565b60006020828403121561101557600080fd5b6000610f338484610ef4565b60006020828403121561103357600080fd5b6000610f338484610f0a565b6000806040838503121561105257600080fd5b6000610f788585610eff565b600061106a83836110e3565b505060200190565b61107b816114af565b82525050565b600061108c8261149d565b61109681856114a1565b93506110a183611497565b8060005b838110156110cf5781516110b9888261105e565b97506110c483611497565b9250506001016110a5565b509495945050505050565b61107b816114ba565b61107b816103de565b61107b6110f8826103de565b6103de565b61107b816114cb565b60006111118261149d565b61111b81856114a1565b935061112b8185602086016114d6565b61113481611506565b9093019392505050565b600061114b6035836114a1565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b60006111a2601a836114a1565b7f536166654d6174683a206469766973696f6e206279207a65726f000000000000815260200192915050565b60006111db6011836114aa565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b60006112086013836114a1565b7204f7261636c652061646472657373206973203606c1b815260200192915050565b6000611237602f836114a1565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b60006112886021836114a1565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b60006112cb6019836114aa565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b6000611304602e836114a1565b7f4f6e6c7920696e7465726e616c20636f6e7472616374732063616e2063616c6c81526d103a3434b990333ab731ba34b7b760911b602082015260400192915050565b6000611352826111ce565b915061135e82846110ec565b50602001919050565b6000611352826112be565b602081016102c38284611072565b6040810161138e8285611072565b61139b6020830184611072565b9392505050565b602080825281016102c08184611081565b602081016102c382846110da565b602081016102c382846110e3565b6040810161138e82856110e3565b604081016113eb82856110e3565b61139b60208301846110e3565b6040810161140682856110e3565b8181036020830152610f338184611106565b602081016102c382846110fd565b602080825281016102c08184611106565b602080825281016102c38161113e565b602080825281016102c381611195565b602080825281016102c3816111fb565b602080825281016102c38161122a565b602080825281016102c38161127b565b602080825281016102c3816112f7565b60200190565b5190565b90815260200190565b919050565b60006102c3826114bf565b151590565b6001600160a01b031690565b60006102c3826114af565b60005b838110156114f15781810151838201526020016114d9565b83811115611500576000848401525b50505050565b601f01601f191690565b611519816114af565b811461152457600080fd5b50565b611519816114ba565b611519816103de56fea365627a7a723158206015efb58c3e29bbf7b75ef6cbb4e30e4af1745785f62beff66c4f737e0e4a506c6578706572696d656e74616cf564736f6c63430005100040
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000048914229dedd5a9922f44441ffccfc2cb7856ee9000000000000000000000000529c553ef2d0370279dc8abf19702b98b166d252
-----Decoded View---------------
Arg [0] : _owner (address): 0x48914229deDd5A9922f44441ffCCfC2Cb7856Ee9
Arg [1] : _resolver (address): 0x529C553eF2d0370279DC8AbF19702B98b166D252
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 00000000000000000000000048914229dedd5a9922f44441ffccfc2cb7856ee9
Arg [1] : 000000000000000000000000529c553ef2d0370279dc8abf19702b98b166d252
Library Used
SafeDecimalMath : 0x2ad7ccaac0eeb396c3a5fc2b73a885435688c0d5SystemSettingsLib : 0x343b5efcbf331957d3f4236eb16c338d7256f62dSignedSafeDecimalMath : 0xc7dcc0929881530d3386de51d9ffdd35b8009c6eExchangeSettlementLib : 0x3f60ffaef1ebd84e3c2d0c9c0e12388365d5df12
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
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.