Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
Latest 25 from a total of 265 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Set Offchain Pri... | 8466748 | 283 days ago | IN | 0 ETH | 0.000003260832 | ||||
Set Offchain Pri... | 8466743 | 283 days ago | IN | 0 ETH | 0.000003290961 | ||||
Set Offchain Pri... | 8466739 | 283 days ago | IN | 0 ETH | 0.00000337602 | ||||
Set Offchain Pri... | 8466734 | 283 days ago | IN | 0 ETH | 0.000003796811 | ||||
Add Associated C... | 8466203 | 283 days ago | IN | 0 ETH | 0.000003134978 | ||||
Add Associated C... | 8465740 | 283 days ago | IN | 0 ETH | 0.000003260852 | ||||
Add Associated C... | 8465291 | 283 days ago | IN | 0 ETH | 0.000002911855 | ||||
Add Associated C... | 8464836 | 283 days ago | IN | 0 ETH | 0.000003015538 | ||||
Set Offchain Pri... | 7463081 | 307 days ago | IN | 0 ETH | 0.000017055477 | ||||
Set Offchain Pri... | 7463076 | 307 days ago | IN | 0 ETH | 0.000017006402 | ||||
Set Offchain Pri... | 7463071 | 307 days ago | IN | 0 ETH | 0.000017868087 | ||||
Set Offchain Pri... | 7463068 | 307 days ago | IN | 0 ETH | 0.000017868087 | ||||
Set Offchain Pri... | 7463065 | 307 days ago | IN | 0 ETH | 0.000017868087 | ||||
Set Offchain Pri... | 7463061 | 307 days ago | IN | 0 ETH | 0.000017918473 | ||||
Set Offchain Pri... | 7463056 | 307 days ago | IN | 0 ETH | 0.000015948692 | ||||
Set Offchain Pri... | 7463049 | 307 days ago | IN | 0 ETH | 0.000017027633 | ||||
Set Offchain Pri... | 7463044 | 307 days ago | IN | 0 ETH | 0.000016438999 | ||||
Set Offchain Pri... | 7463039 | 307 days ago | IN | 0 ETH | 0.000016438999 | ||||
Set Offchain Pri... | 7463036 | 307 days ago | IN | 0 ETH | 0.000017411823 | ||||
Set Offchain Pri... | 7463032 | 307 days ago | IN | 0 ETH | 0.00001859277 | ||||
Set Offchain Pri... | 7463027 | 307 days ago | IN | 0 ETH | 0.000018196164 | ||||
Set Offchain Pri... | 7463022 | 307 days ago | IN | 0 ETH | 0.000017500785 | ||||
Set Offchain Pri... | 7463017 | 307 days ago | IN | 0 ETH | 0.000017973715 | ||||
Set Offchain Pri... | 7463012 | 307 days ago | IN | 0 ETH | 0.000017973715 | ||||
Set Offchain Pri... | 7463007 | 307 days ago | IN | 0 ETH | 0.000018066223 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
16727509 | 92 days ago | 1 wei | ||||
16727509 | 92 days ago | 1 wei | ||||
16725892 | 92 days ago | 1 wei | ||||
16725892 | 92 days ago | 1 wei | ||||
16725868 | 92 days ago | 1 wei | ||||
16725868 | 92 days ago | 1 wei | ||||
16466443 | 98 days ago | 1 wei | ||||
16466443 | 98 days ago | 1 wei | ||||
16465844 | 98 days ago | 1 wei | ||||
16465844 | 98 days ago | 1 wei | ||||
16464262 | 98 days ago | 1 wei | ||||
16464262 | 98 days ago | 1 wei | ||||
16462860 | 98 days ago | 1 wei | ||||
16462860 | 98 days ago | 1 wei | ||||
16462457 | 98 days ago | 1 wei | ||||
16462457 | 98 days ago | 1 wei | ||||
16462361 | 98 days ago | 1 wei | ||||
16462361 | 98 days ago | 1 wei | ||||
15582654 | 119 days ago | 1 wei | ||||
15582654 | 119 days ago | 1 wei | ||||
14458018 | 145 days ago | 1 wei | ||||
14458018 | 145 days ago | 1 wei | ||||
14457979 | 145 days ago | 1 wei | ||||
14457979 | 145 days ago | 1 wei | ||||
14457639 | 145 days ago | 1 wei |
Loading...
Loading
Contract Name:
PerpsV2ExchangeRate
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: PerpsV2ExchangeRate.sol * * Latest source (may be newer): https://github.com/Synthetixio/synthetix/blob/master/contracts/PerpsV2ExchangeRate.sol * Docs: https://docs.synthetix.io/contracts/PerpsV2ExchangeRate * * Contract Dependencies: * - IAddressResolver * - MixinResolver * - MixinSystemSettings * - Owned * - ReentrancyGuard * Libraries: * - AddressSetLib * * 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); } } /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier * available, which can be aplied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. */ contract ReentrancyGuard { /// @dev counter to allow mutex lock with only one SSTORE operation uint256 private _guardCounter; constructor () internal { // The counter starts at one to prevent changing it from zero to a non-zero // value, which is a more expensive operation. _guardCounter = 1; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { _guardCounter += 1; uint256 localCounter = _guardCounter; _; require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call"); } } // import "@pythnetwork/pyth-sdk-solidity/PythStructs.sol"; contract PythStructs { // A price with a degree of uncertainty, represented as a price +- a confidence interval. // // The confidence interval roughly corresponds to the standard error of a normal distribution. // Both the price and confidence are stored in a fixed-point numeric representation, // `x * (10^expo)`, where `expo` is the exponent. // // Please refer to the documentation at https://docs.pyth.network/consumers/best-practices for how // to how this price safely. struct Price { // Price int64 price; // Confidence interval around the price uint64 conf; // Price exponent int32 expo; // Unix timestamp describing when the price was published uint publishTime; } // PriceFeed represents a current aggregate price from pyth publisher feeds. struct PriceFeed { // The price ID. bytes32 id; // Latest available price Price price; // Latest available exponentially-weighted moving average price Price emaPrice; } } pragma experimental ABIEncoderV2; // import "@pythnetwork/pyth-sdk-solidity/IPyth.sol"; /// @title Consume prices from the Pyth Network (https://pyth.network/). /// @dev Please refer to the guidance at https://docs.pyth.network/consumers/best-practices for how to consume prices safely. /// @author Pyth Data Association interface IPyth { /// @dev Emitted when the price feed with `id` has received a fresh update. /// @param id The Pyth Price Feed ID. /// @param publishTime Publish time of the given price update. /// @param price Price of the given price update. /// @param conf Confidence interval of the given price update. event PriceFeedUpdate(bytes32 indexed id, uint64 publishTime, int64 price, uint64 conf); /// @dev Emitted when a batch price update is processed successfully. /// @param chainId ID of the source chain that the batch price update comes from. /// @param sequenceNumber Sequence number of the batch price update. event BatchPriceFeedUpdate(uint16 chainId, uint64 sequenceNumber); /// @notice Returns the period (in seconds) that a price feed is considered valid since its publish time function getValidTimePeriod() external view returns (uint validTimePeriod); /// @notice Returns the price and confidence interval. /// @dev Reverts if the price has not been updated within the last `getValidTimePeriod()` seconds. /// @param id The Pyth Price Feed ID of which to fetch the price and confidence interval. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getPrice(bytes32 id) external view returns (PythStructs.Price memory price); /// @notice Returns the exponentially-weighted moving average price and confidence interval. /// @dev Reverts if the EMA price is not available. /// @param id The Pyth Price Feed ID of which to fetch the EMA price and confidence interval. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getEmaPrice(bytes32 id) external view returns (PythStructs.Price memory price); /// @notice Returns the price of a price feed without any sanity checks. /// @dev This function returns the most recent price update in this contract without any recency checks. /// This function is unsafe as the returned price update may be arbitrarily far in the past. /// /// Users of this function should check the `publishTime` in the price to ensure that the returned price is /// sufficiently recent for their application. If you are considering using this function, it may be /// safer / easier to use either `getPrice` or `getPriceNoOlderThan`. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getPriceUnsafe(bytes32 id) external view returns (PythStructs.Price memory price); /// @notice Returns the price that is no older than `age` seconds of the current time. /// @dev This function is a sanity-checked version of `getPriceUnsafe` which is useful in /// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently /// recently. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getPriceNoOlderThan(bytes32 id, uint age) external view returns (PythStructs.Price memory price); /// @notice Returns the exponentially-weighted moving average price of a price feed without any sanity checks. /// @dev This function returns the same price as `getEmaPrice` in the case where the price is available. /// However, if the price is not recent this function returns the latest available price. /// /// The returned price can be from arbitrarily far in the past; this function makes no guarantees that /// the returned price is recent or useful for any particular application. /// /// Users of this function should check the `publishTime` in the price to ensure that the returned price is /// sufficiently recent for their application. If you are considering using this function, it may be /// safer / easier to use either `getEmaPrice` or `getEmaPriceNoOlderThan`. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getEmaPriceUnsafe(bytes32 id) external view returns (PythStructs.Price memory price); /// @notice Returns the exponentially-weighted moving average price that is no older than `age` seconds /// of the current time. /// @dev This function is a sanity-checked version of `getEmaPriceUnsafe` which is useful in /// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently /// recently. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getEmaPriceNoOlderThan(bytes32 id, uint age) external view returns (PythStructs.Price memory price); /// @notice Update price feeds with given update messages. /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling /// `getUpdateFee` with the length of the `updateData` array. /// Prices will be updated if they are more recent than the current stored prices. /// The call will succeed even if the update is not the most recent. /// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid. /// @param updateData Array of price update data. function updatePriceFeeds(bytes[] calldata updateData) external payable; /// @notice Wrapper around updatePriceFeeds that rejects fast if a price update is not necessary. A price update is /// necessary if the current on-chain publishTime is older than the given publishTime. It relies solely on the /// given `publishTimes` for the price feeds and does not read the actual price update publish time within `updateData`. /// /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling /// `getUpdateFee` with the length of the `updateData` array. /// /// `priceIds` and `publishTimes` are two arrays with the same size that correspond to senders known publishTime /// of each priceId when calling this method. If all of price feeds within `priceIds` have updated and have /// a newer or equal publish time than the given publish time, it will reject the transaction to save gas. /// Otherwise, it calls updatePriceFeeds method to update the prices. /// /// @dev Reverts if update is not needed or the transferred fee is not sufficient or the updateData is invalid. /// @param updateData Array of price update data. /// @param priceIds Array of price ids. /// @param publishTimes Array of publishTimes. `publishTimes[i]` corresponds to known `publishTime` of `priceIds[i]` function updatePriceFeedsIfNecessary( bytes[] calldata updateData, bytes32[] calldata priceIds, uint64[] calldata publishTimes ) external payable; /// @notice Returns the required fee to update an array of price updates. /// @param updateData Array of price update data. /// @return feeAmount The required fee in Wei. function getUpdateFee(bytes[] calldata updateData) external view returns (uint feeAmount); /// @notice Parse `updateData` and return price feeds of the given `priceIds` if they are all published /// within `minPublishTime` and `maxPublishTime`. /// /// You can use this method if you want to use a Pyth price at a fixed time and not the most recent price; /// otherwise, please consider using `updatePriceFeeds`. This method does not store the price updates on-chain. /// /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling /// `getUpdateFee` with the length of the `updateData` array. /// /// /// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid or there is /// no update for any of the given `priceIds` within the given time range. /// @param updateData Array of price update data. /// @param priceIds Array of price ids. /// @param minPublishTime minimum acceptable publishTime for the given `priceIds`. /// @param maxPublishTime maximum acceptable publishTime for the given `priceIds`. /// @return priceFeeds Array of the price feeds corresponding to the given `priceIds` (with the same order). function parsePriceFeedUpdates( bytes[] calldata updateData, bytes32[] calldata priceIds, uint64 minPublishTime, uint64 maxPublishTime ) external payable returns (PythStructs.PriceFeed[] memory priceFeeds); } // https://docs.synthetix.io/contracts/source/libraries/addresssetlib/ library AddressSetLib { struct AddressSet { address[] elements; mapping(address => uint) indices; } function contains(AddressSet storage set, address candidate) internal view returns (bool) { if (set.elements.length == 0) { return false; } uint index = set.indices[candidate]; return index != 0 || set.elements[0] == candidate; } function getPage( AddressSet storage set, uint index, uint pageSize ) internal view returns (address[] memory) { // NOTE: This implementation should be converted to slice operators if the compiler is updated to v0.6.0+ uint endIndex = index + pageSize; // The check below that endIndex <= index handles overflow. // If the page extends past the end of the list, truncate it. if (endIndex > set.elements.length) { endIndex = set.elements.length; } if (endIndex <= index) { return new address[](0); } uint n = endIndex - index; // We already checked for negative overflow. address[] memory page = new address[](n); for (uint i; i < n; i++) { page[i] = set.elements[i + index]; } return page; } function add(AddressSet storage set, address element) internal { // Adding to a set is an idempotent operation. if (!contains(set, element)) { set.indices[element] = set.elements.length; set.elements.push(element); } } function remove(AddressSet storage set, address element) internal { require(contains(set, element), "Element not in set."); // Replace the removed element with the last element of the list. uint index = set.indices[element]; uint lastIndex = set.elements.length - 1; // We required that element is in the list, so it is not empty. if (index != lastIndex) { // No need to shift the last element if it is the one we want to delete. address shiftedElement = set.elements[lastIndex]; set.elements[index] = shiftedElement; set.indices[shiftedElement] = index; } set.elements.pop(); delete set.indices[element]; } } // Inheritance // Libraries // https://docs.synthetix.io/contracts/source/contracts/PerpsV2ExchangeRate contract PerpsV2ExchangeRate is Owned, ReentrancyGuard, MixinSystemSettings { using AddressSetLib for AddressSetLib.AddressSet; bytes32 public constant CONTRACT_NAME = "PerpsV2ExchangeRate"; bytes32 internal constant SETTING_OFFCHAIN_ORACLE = "offchainOracle"; bytes32 internal constant SETTING_OFFCHAIN_PRICE_FEED_ID = "priceFeedId"; AddressSetLib.AddressSet internal _associatedContracts; /* ========== CONSTRUCTOR ========== */ constructor(address _owner, address _resolver) public Owned(_owner) MixinSystemSettings(_resolver) {} /* ========== SETTERS ========== */ function setOffchainOracle(address offchainOracle) external onlyOwner { flexibleStorage().setAddressValue(CONTRACT_NAME, SETTING_OFFCHAIN_ORACLE, offchainOracle); emit OffchainOracleUpdated(offchainOracle); } function setOffchainPriceFeedId(bytes32 assetId, bytes32 priceFeedId) external onlyOwner { flexibleStorage().setBytes32Value( CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_OFFCHAIN_PRICE_FEED_ID, assetId)), priceFeedId ); emit OffchainPriceFeedIdUpdated(assetId, priceFeedId); } /* ========== ACCESS CONTROL ========== */ // Add associated contracts function addAssociatedContracts(address[] calldata associatedContracts) external onlyOwner { for (uint i = 0; i < associatedContracts.length; i++) { if (!_associatedContracts.contains(associatedContracts[i])) { _associatedContracts.add(associatedContracts[i]); emit AssociatedContractAdded(associatedContracts[i]); } } } // Remove associated contracts function removeAssociatedContracts(address[] calldata associatedContracts) external onlyOwner { for (uint i = 0; i < associatedContracts.length; i++) { if (_associatedContracts.contains(associatedContracts[i])) { _associatedContracts.remove(associatedContracts[i]); emit AssociatedContractRemoved(associatedContracts[i]); } } } function associatedContracts() external view returns (address[] memory) { return _associatedContracts.getPage(0, _associatedContracts.elements.length); } /* ========== VIEWS ========== */ function offchainOracle() public view returns (IPyth) { return IPyth(flexibleStorage().getAddressValue(CONTRACT_NAME, SETTING_OFFCHAIN_ORACLE)); } function offchainPriceFeedId(bytes32 assetId) public view returns (bytes32) { return flexibleStorage().getBytes32Value( CONTRACT_NAME, keccak256(abi.encodePacked(SETTING_OFFCHAIN_PRICE_FEED_ID, assetId)) ); } /* ---------- priceFeeds mutation ---------- */ function updatePythPrice(address sender, bytes[] calldata priceUpdateData) external payable nonReentrant onlyAssociatedContracts { // Get fee amount to pay to Pyth uint fee = offchainOracle().getUpdateFee(priceUpdateData); require(msg.value >= fee, "Not enough eth for paying the fee"); // Update the price data (and pay the fee) offchainOracle().updatePriceFeeds.value(fee)(priceUpdateData); if (msg.value - fee > 0) { // Need to refund caller. Try to return unused value, or revert if failed // solhint-disable-next-line avoid-low-level-calls (bool success, ) = sender.call.value(msg.value - fee)(""); require(success, "Failed to refund caller"); } } // it is a view but it can revert function resolveAndGetPrice(bytes32 assetId, uint maxAge) external view returns (uint price, uint publishTime) { bytes32 priceFeedId = offchainPriceFeedId(assetId); require(priceFeedId != 0, "No price feed found for asset"); return _getPythPrice(priceFeedId, maxAge); } // it is a view but it can revert function resolveAndGetLatestPrice(bytes32 assetId) external view returns (uint price, uint publishTime) { bytes32 priceFeedId = offchainPriceFeedId(assetId); require(priceFeedId != 0, "No price feed found for asset"); return _getPythPriceUnsafe(priceFeedId); } function _calculatePrice(PythStructs.Price memory retrievedPrice) internal view returns (uint price) { /* retrievedPrice.price fixed-point representation base retrievedPrice.expo fixed-point representation exponent (to go from base to decimal) retrievedPrice.conf fixed-point representation of confidence i.e. .price = 12276250 .expo = -5 price = 12276250 * 10^(-5) = 122.76250 to go to 18 decimals => rebasedPrice = 12276250 * 10^(18-5) = 122762500000000000000 */ // Adjust exponent (using base as 18 decimals) uint baseConvertion = 10**uint(int(18) + retrievedPrice.expo); price = uint(retrievedPrice.price * int(baseConvertion)); } function _getPythPriceUnsafe(bytes32 priceFeedId) internal view returns (uint price, uint publishTime) { // It will revert if there's no price for the priceFeedId PythStructs.Price memory retrievedPrice = offchainOracle().getPriceUnsafe(priceFeedId); price = _calculatePrice(retrievedPrice); publishTime = retrievedPrice.publishTime; } function _getPythPrice(bytes32 priceFeedId, uint maxAge) internal view returns (uint price, uint publishTime) { // It will revert if the price is older than maxAge PythStructs.Price memory retrievedPrice = offchainOracle().getPriceNoOlderThan(priceFeedId, maxAge); price = _calculatePrice(retrievedPrice); publishTime = retrievedPrice.publishTime; } /* ========== MODIFIERS ========== */ modifier onlyAssociatedContracts() { require(_associatedContracts.contains(msg.sender), "Only an associated contract can perform this action"); _; } /* ========== EVENTS ========== */ event AssociatedContractAdded(address associatedContract); event AssociatedContractRemoved(address associatedContract); event OffchainOracleUpdated(address offchainOracle); event OffchainPriceFeedIdUpdated(bytes32 assetId, bytes32 priceFeedId); }
[{"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":"address","name":"associatedContract","type":"address"}],"name":"AssociatedContractAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"associatedContract","type":"address"}],"name":"AssociatedContractRemoved","type":"event"},{"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":"address","name":"offchainOracle","type":"address"}],"name":"OffchainOracleUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"assetId","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"priceFeedId","type":"bytes32"}],"name":"OffchainPriceFeedIdUpdated","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":false,"inputs":[{"internalType":"address[]","name":"associatedContracts","type":"address[]"}],"name":"addAssociatedContracts","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"associatedContracts","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isResolverCached","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":"offchainOracle","outputs":[{"internalType":"contract IPyth","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"assetId","type":"bytes32"}],"name":"offchainPriceFeedId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"rebuildCache","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address[]","name":"associatedContracts","type":"address[]"}],"name":"removeAssociatedContracts","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"assetId","type":"bytes32"}],"name":"resolveAndGetLatestPrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"publishTime","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"assetId","type":"bytes32"},{"internalType":"uint256","name":"maxAge","type":"uint256"}],"name":"resolveAndGetPrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"publishTime","type":"uint256"}],"payable":false,"stateMutability":"view","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":"offchainOracle","type":"address"}],"name":"setOffchainOracle","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"assetId","type":"bytes32"},{"internalType":"bytes32","name":"priceFeedId","type":"bytes32"}],"name":"setOffchainPriceFeedId","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"bytes[]","name":"priceUpdateData","type":"bytes[]"}],"name":"updatePythPrice","outputs":[],"payable":true,"stateMutability":"payable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b506040516200206138038062002061833981016040819052620000349162000101565b8080836001600160a01b038116620000695760405162461bcd60e51b81526004016200006090620001bd565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0383161781556040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91620000b691849062000197565b60405180910390a1506001600255600380546001600160a01b0319166001600160a01b03929092169190911790555062000218915050565b8051620000fb81620001fe565b92915050565b600080604083850312156200011557600080fd5b6000620001238585620000ee565b92505060206200013685828601620000ee565b9150509250929050565b6200014b81620001ea565b82525050565b6200014b81620001d8565b60006200016b601983620001cf565b7f4f776e657220616464726573732063616e6e6f74206265203000000000000000815260200192915050565b60408101620001a7828562000140565b620001b6602083018462000151565b9392505050565b60208082528101620000fb816200015c565b90815260200190565b60006001600160a01b038216620000fb565b6000620000fb826000620000fb82620001d8565b6200020981620001d8565b81146200021557600080fd5b50565b611e3980620002286000396000f3fe6080604052600436106101145760003560e01c8063475dea55116100a057806379ba50971161006457806379ba5097146102e4578063899ffef4146102f95780638da5cb5b1461031b578063c040b5db14610330578063c679ce4b1461035057610114565b8063475dea551461024b57806353a47bb714610278578063614d08f81461029a5780636d2da02f146102af57806374185360146102cf57610114565b80632af64bd3116100e75780632af64bd314610199578063312d6b73146101bb578063368bde96146101dd5780633b798e8a1461020b57806342a449be1461022b57610114565b806304f3bcec1461011957806308f9c88e146101445780631627540c14610159578063230ee97b14610179575b600080fd5b34801561012557600080fd5b5061012e610365565b60405161013b9190611c0a565b60405180910390f35b610157610152366004611517565b610374565b005b34801561016557600080fd5b506101576101743660046114db565b610579565b34801561018557600080fd5b5061015761019436600461156d565b6105d7565b3480156101a557600080fd5b506101ae6106b7565b60405161013b9190611b55565b3480156101c757600080fd5b506101d06107cf565b60405161013b9190611b21565b3480156101e957600080fd5b506101fd6101f83660046115df565b6107ed565b60405161013b929190611b7f565b34801561021757600080fd5b506101fd6102263660046115a3565b610831565b34801561023757600080fd5b5061015761024636600461156d565b610871565b34801561025757600080fd5b5061026b6102663660046115a3565b61092a565b60405161013b9190611b63565b34801561028457600080fd5b5061028d610a03565b60405161013b9190611af8565b3480156102a657600080fd5b5061026b610a12565b3480156102bb57600080fd5b506101576102ca3660046114db565b610a2c565b3480156102db57600080fd5b50610157610af3565b3480156102f057600080fd5b50610157610c49565b34801561030557600080fd5b5061030e610ce5565b60405161013b9190611b32565b34801561032757600080fd5b5061028d610d36565b34801561033c57600080fd5b5061015761034b3660046115df565b610d45565b34801561035c57600080fd5b5061012e610e3e565b6003546001600160a01b031681565b600280546001019081905561039060053363ffffffff610eec16565b6103b55760405162461bcd60e51b81526004016103ac90611c59565b60405180910390fd5b60006103bf610e3e565b6001600160a01b031663d47eed4585856040518363ffffffff1660e01b81526004016103ec929190611b43565b60206040518083038186803b15801561040457600080fd5b505afa158015610418573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061043c91908101906115c1565b90508034101561045e5760405162461bcd60e51b81526004016103ac90611c89565b610466610e3e565b6001600160a01b031663ef9e5e288286866040518463ffffffff1660e01b8152600401610494929190611b43565b6000604051808303818588803b1580156104ad57600080fd5b505af11580156104c1573d6000803e3d6000fd5b505050505060008134031115610551576000856001600160a01b03168234036040516104ec90611aed565b60006040518083038185875af1925050503d8060008114610529576040519150601f19603f3d011682016040523d82523d6000602084013e61052e565b606091505b505090508061054f5760405162461bcd60e51b81526004016103ac90611c79565b505b5060025481146105735760405162461bcd60e51b81526004016103ac90611c99565b50505050565b610581610f5a565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906105cc908390611af8565b60405180910390a150565b6105df610f5a565b60005b818110156106b25761061c8383838181106105f957fe5b905060200201602061060e91908101906114db565b60059063ffffffff610eec16565b6106aa5761065283838381811061062f57fe5b905060200201602061064491908101906114db565b60059063ffffffff610f8616565b7f326fb9158ce5b588ffd9c639338d799b5aab6f47ee92ea9abb914a05724d050f83838381811061067f57fe5b905060200201602061069491908101906114db565b6040516106a19190611af8565b60405180910390a15b6001016105e2565b505050565b600060606106c3610ce5565b905060005b81518110156107c55760008282815181106106df57fe5b60209081029190910181015160008181526004928390526040908190205460035491516321f8a72160e01b81529294506001600160a01b03908116939116916321f8a7219161073091869101611b63565b60206040518083038186803b15801561074857600080fd5b505afa15801561075c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061078091908101906114f9565b6001600160a01b03161415806107ab57506000818152600460205260409020546001600160a01b0316155b156107bc57600093505050506107cc565b506001016106c8565b5060019150505b90565b600580546060916107e89160009063ffffffff610fd816565b905090565b60008060006107fb8561092a565b90508061081a5760405162461bcd60e51b81526004016103ac90611c49565b61082481856110ae565b92509250505b9250929050565b600080600061083f8461092a565b90508061085e5760405162461bcd60e51b81526004016103ac90611c49565b6108678161115a565b9250925050915091565b610879610f5a565b60005b818110156106b2576108938383838181106105f957fe5b15610922576108ca8383838181106108a757fe5b90506020020160206108bc91908101906114db565b60059063ffffffff61120216565b7f9faa24f7f20c2e0f689165e6886278f3005b15b94407109799ead3257067a66a8383838181106108f757fe5b905060200201602061090c91908101906114db565b6040516109199190611af8565b60405180910390a15b60010161087c565b6000610934611318565b6001600160a01b031663f7833c5d725065727073563245786368616e67655261746560681b6a1c1c9a58d951995959125960aa1b8560405160200161097a929190611a9c565b604051602081830303815290604052805190602001206040518363ffffffff1660e01b81526004016109ad929190611b7f565b60206040518083038186803b1580156109c557600080fd5b505afa1580156109d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506109fd91908101906115c1565b92915050565b6001546001600160a01b031681565b725065727073563245786368616e67655261746560681b81565b610a34610f5a565b610a3c611318565b6001600160a01b0316634dca0978725065727073563245786368616e67655261746560681b6d6f6666636861696e4f7261636c6560901b846040518463ffffffff1660e01b8152600401610a9293929190611b9a565b600060405180830381600087803b158015610aac57600080fd5b505af1158015610ac0573d6000803e3d6000fd5b505050507ff8ad76f417192ced84abe3abf840e1da06bc5fe7d88fb07002eeb763a6a70655816040516105cc9190611af8565b6060610afd610ce5565b905060005b8151811015610c45576000828281518110610b1957fe5b602002602001015190506000600360009054906101000a90046001600160a01b03166001600160a01b031663dacb2d018384604051602001610b5b9190611ae2565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401610b87929190611bea565b60206040518083038186803b158015610b9f57600080fd5b505afa158015610bb3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610bd791908101906114f9565b6000838152600460205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa6890610c339084908490611b71565b60405180910390a15050600101610b02565b5050565b6001546001600160a01b03163314610c735760405162461bcd60e51b81526004016103ac90611c29565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c92610cb6926001600160a01b0391821692911690611b06565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b604080516001808252818301909252606091602080830190803883390190505090506e466c657869626c6553746f7261676560881b81600081518110610d2757fe5b60200260200101818152505090565b6000546001600160a01b031681565b610d4d610f5a565b610d55611318565b6001600160a01b0316624b62d6725065727073563245786368616e67655261746560681b6a1c1c9a58d951995959125960aa1b85604051602001610d9a929190611a9c565b60405160208183030381529060405280519060200120846040518463ffffffff1660e01b8152600401610dcf93929190611bc2565b600060405180830381600087803b158015610de957600080fd5b505af1158015610dfd573d6000803e3d6000fd5b505050507f96a8b94dfd7ff7c78db402b935e8a43578fe44aaaf032a4dc471539cc3987f3c8282604051610e32929190611b7f565b60405180910390a15050565b6000610e48611318565b6001600160a01b0316639ee5955a725065727073563245786368616e67655261746560681b6d6f6666636861696e4f7261636c6560901b6040518363ffffffff1660e01b8152600401610e9c929190611b7f565b60206040518083038186803b158015610eb457600080fd5b505afa158015610ec8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107e891908101906114f9565b8154600090610efd575060006109fd565b6001600160a01b038216600090815260018401602052604090205480151580610f525750826001600160a01b031684600001600081548110610f3b57fe5b6000918252602090912001546001600160a01b0316145b949350505050565b6000546001600160a01b03163314610f845760405162461bcd60e51b81526004016103ac90611c69565b565b610f908282610eec565b610c455781546001600160a01b038216600081815260018086016020908152604083208590559084018655858252902090910180546001600160a01b03191690911790555050565b825460609083830190811115610fec575083545b8381116110095750506040805160008152602081019091526110a7565b604080518583038082526020808202830101909252606090828015611038578160200160208202803883390190505b50905060005b828110156110a157876000018782018154811061105757fe5b9060005260206000200160009054906101000a90046001600160a01b031682828151811061108157fe5b6001600160a01b039092166020928302919091019091015260010161103e565b50925050505b9392505050565b6000806110b96113b6565b6110c1610e3e565b6001600160a01b031663a4ae35e086866040518363ffffffff1660e01b81526004016110ee929190611b7f565b60806040518083038186803b15801561110657600080fd5b505afa15801561111a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061113e9190810190611619565b905061114981611335565b925080606001519150509250929050565b6000806111656113b6565b61116d610e3e565b6001600160a01b03166396834ad3856040518263ffffffff1660e01b81526004016111989190611b63565b60806040518083038186803b1580156111b057600080fd5b505afa1580156111c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506111e89190810190611619565b90506111f381611335565b92508060600151915050915091565b61120c8282610eec565b6112285760405162461bcd60e51b81526004016103ac90611c39565b6001600160a01b03811660009081526001830160205260409020548254600019018082146112c757600084600001828154811061126157fe5b60009182526020909120015485546001600160a01b039091169150819086908590811061128a57fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b0394851617905592909116815260018601909152604090208290555b83548490806112d257fe5b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b0394909416815260019490940190925250506040812055565b60006107e86e466c657869626c6553746f7261676560881b611352565b6040810151905160070b601260039290920b91909101600a0a0290565b60008181526004602090815260408083205490516001600160a01b03909116918215159161138291869101611ac2565b604051602081830303815290604052906113af5760405162461bcd60e51b81526004016103ac9190611c18565b5092915050565b60408051608081018252600080825260208201819052918101829052606081019190915290565b80356109fd81611dbb565b80516109fd81611dbb565b60008083601f84011261140557600080fd5b50813567ffffffffffffffff81111561141d57600080fd5b60208301915083602082028301111561082a57600080fd5b80356109fd81611dd2565b80516109fd81611dd2565b80516109fd81611ddb565b80516109fd81611de4565b60006080828403121561147357600080fd5b61147d6080611ca9565b9050600061148b8484611456565b825250602061149c848483016114d0565b60208301525060406114b08482850161144b565b60408301525060606114c484828501611440565b60608301525092915050565b80516109fd81611ded565b6000602082840312156114ed57600080fd5b6000610f5284846113dd565b60006020828403121561150b57600080fd5b6000610f5284846113e8565b60008060006040848603121561152c57600080fd5b600061153886866113dd565b935050602084013567ffffffffffffffff81111561155557600080fd5b611561868287016113f3565b92509250509250925092565b6000806020838503121561158057600080fd5b823567ffffffffffffffff81111561159757600080fd5b610824858286016113f3565b6000602082840312156115b557600080fd5b6000610f528484611435565b6000602082840312156115d357600080fd5b6000610f528484611440565b600080604083850312156115f257600080fd5b60006115fe8585611435565b925050602061160f85828601611435565b9150509250929050565b60006080828403121561162b57600080fd5b6000610f528484611461565b60006116438383611664565b505060200190565b60006116438383611792565b6000610f528484846117ac565b61166d81611d39565b82525050565b600061167e82611cd6565b6116888185611cda565b935061169383611cd0565b8060005b838110156116c15781516116ab8882611637565b97506116b683611cd0565b925050600101611697565b509495945050505050565b60006116d782611cd6565b6116e18185611cda565b93506116ec83611cd0565b8060005b838110156116c1578151611704888261164b565b975061170f83611cd0565b9250506001016116f0565b60006117268385611cda565b935083602084028501611738846107cc565b8060005b8781101561177c5784840389526117538284611ce8565b61175e868284611657565b955061176984611cd0565b60209b909b019a9350505060010161173c565b5091979650505050505050565b61166d81611d44565b61166d816107cc565b61166d6117a7826107cc565b6107cc565b60006117b88385611cda565b93506117c5838584611d79565b6117ce83611db1565b9093019392505050565b61166d81611d6e565b60006117ec82611cd6565b6117f68185611cda565b9350611806818560208601611d85565b6117ce81611db1565b600061181c603583611cda565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b6000611873601383611cda565b7222b632b6b2b73a103737ba1034b71039b2ba1760691b815260200192915050565b60006118a2601183611ce3565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b60006118cf601d83611cda565b7f4e6f207072696365206665656420666f756e6420666f72206173736574000000815260200192915050565b6000611908603383611cda565b7f4f6e6c7920616e206173736f63696174656420636f6e74726163742063616e208152723832b93337b936903a3434b99030b1ba34b7b760691b602082015260400192915050565b600061195d602f83611cda565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b60006119ae601783611cda565b7f4661696c656420746f20726566756e642063616c6c6572000000000000000000815260200192915050565b60006119e7602183611cda565b7f4e6f7420656e6f7567682065746820666f7220706179696e67207468652066658152606560f81b602082015260400192915050565b6000611a2a601983611ce3565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b60006109fd600083611ce3565b6000611a70601f83611cda565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00815260200192915050565b6000611aa8828561179b565b602082019150611ab8828461179b565b5060200192915050565b6000611acd82611895565b9150611ad9828461179b565b50602001919050565b6000611acd82611a1d565b60006109fd82611a56565b602081016109fd8284611664565b60408101611b148285611664565b6110a76020830184611664565b602080825281016110a78184611673565b602080825281016110a781846116cc565b60208082528101610f5281848661171a565b602081016109fd8284611789565b602081016109fd8284611792565b60408101611b148285611792565b60408101611b8d8285611792565b6110a76020830184611792565b60608101611ba88286611792565b611bb56020830185611792565b610f526040830184611664565b60608101611bd08286611792565b611bdd6020830185611792565b610f526040830184611792565b60408101611bf88285611792565b8181036020830152610f5281846117e1565b602081016109fd82846117d8565b602080825281016110a781846117e1565b602080825281016109fd8161180f565b602080825281016109fd81611866565b602080825281016109fd816118c2565b602080825281016109fd816118fb565b602080825281016109fd81611950565b602080825281016109fd816119a1565b602080825281016109fd816119da565b602080825281016109fd81611a63565b60405181810167ffffffffffffffff81118282101715611cc857600080fd5b604052919050565b60200190565b5190565b90815260200190565b919050565b6000808335601e1936859003018112611d0057600080fd5b83810160208101935035915067ffffffffffffffff821115611d2157600080fd5b36829003841315611d3157600080fd5b509250929050565b60006109fd82611d55565b151590565b60030b90565b60070b90565b6001600160a01b031690565b67ffffffffffffffff1690565b60006109fd82611d39565b82818337506000910152565b60005b83811015611da0578181015183820152602001611d88565b838111156105735750506000910152565b601f01601f191690565b611dc481611d39565b8114611dcf57600080fd5b50565b611dc4816107cc565b611dc481611d49565b611dc481611d4f565b611dc481611d6156fea365627a7a72315820bb332cea9303aa96012b9f671f0948068428091e326ecdcc3fa61bbba79b77f16c6578706572696d656e74616cf564736f6c6343000510004000000000000000000000000048914229dedd5a9922f44441ffccfc2cb7856ee9000000000000000000000000529c553ef2d0370279dc8abf19702b98b166d252
Deployed Bytecode
0x6080604052600436106101145760003560e01c8063475dea55116100a057806379ba50971161006457806379ba5097146102e4578063899ffef4146102f95780638da5cb5b1461031b578063c040b5db14610330578063c679ce4b1461035057610114565b8063475dea551461024b57806353a47bb714610278578063614d08f81461029a5780636d2da02f146102af57806374185360146102cf57610114565b80632af64bd3116100e75780632af64bd314610199578063312d6b73146101bb578063368bde96146101dd5780633b798e8a1461020b57806342a449be1461022b57610114565b806304f3bcec1461011957806308f9c88e146101445780631627540c14610159578063230ee97b14610179575b600080fd5b34801561012557600080fd5b5061012e610365565b60405161013b9190611c0a565b60405180910390f35b610157610152366004611517565b610374565b005b34801561016557600080fd5b506101576101743660046114db565b610579565b34801561018557600080fd5b5061015761019436600461156d565b6105d7565b3480156101a557600080fd5b506101ae6106b7565b60405161013b9190611b55565b3480156101c757600080fd5b506101d06107cf565b60405161013b9190611b21565b3480156101e957600080fd5b506101fd6101f83660046115df565b6107ed565b60405161013b929190611b7f565b34801561021757600080fd5b506101fd6102263660046115a3565b610831565b34801561023757600080fd5b5061015761024636600461156d565b610871565b34801561025757600080fd5b5061026b6102663660046115a3565b61092a565b60405161013b9190611b63565b34801561028457600080fd5b5061028d610a03565b60405161013b9190611af8565b3480156102a657600080fd5b5061026b610a12565b3480156102bb57600080fd5b506101576102ca3660046114db565b610a2c565b3480156102db57600080fd5b50610157610af3565b3480156102f057600080fd5b50610157610c49565b34801561030557600080fd5b5061030e610ce5565b60405161013b9190611b32565b34801561032757600080fd5b5061028d610d36565b34801561033c57600080fd5b5061015761034b3660046115df565b610d45565b34801561035c57600080fd5b5061012e610e3e565b6003546001600160a01b031681565b600280546001019081905561039060053363ffffffff610eec16565b6103b55760405162461bcd60e51b81526004016103ac90611c59565b60405180910390fd5b60006103bf610e3e565b6001600160a01b031663d47eed4585856040518363ffffffff1660e01b81526004016103ec929190611b43565b60206040518083038186803b15801561040457600080fd5b505afa158015610418573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061043c91908101906115c1565b90508034101561045e5760405162461bcd60e51b81526004016103ac90611c89565b610466610e3e565b6001600160a01b031663ef9e5e288286866040518463ffffffff1660e01b8152600401610494929190611b43565b6000604051808303818588803b1580156104ad57600080fd5b505af11580156104c1573d6000803e3d6000fd5b505050505060008134031115610551576000856001600160a01b03168234036040516104ec90611aed565b60006040518083038185875af1925050503d8060008114610529576040519150601f19603f3d011682016040523d82523d6000602084013e61052e565b606091505b505090508061054f5760405162461bcd60e51b81526004016103ac90611c79565b505b5060025481146105735760405162461bcd60e51b81526004016103ac90611c99565b50505050565b610581610f5a565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906105cc908390611af8565b60405180910390a150565b6105df610f5a565b60005b818110156106b25761061c8383838181106105f957fe5b905060200201602061060e91908101906114db565b60059063ffffffff610eec16565b6106aa5761065283838381811061062f57fe5b905060200201602061064491908101906114db565b60059063ffffffff610f8616565b7f326fb9158ce5b588ffd9c639338d799b5aab6f47ee92ea9abb914a05724d050f83838381811061067f57fe5b905060200201602061069491908101906114db565b6040516106a19190611af8565b60405180910390a15b6001016105e2565b505050565b600060606106c3610ce5565b905060005b81518110156107c55760008282815181106106df57fe5b60209081029190910181015160008181526004928390526040908190205460035491516321f8a72160e01b81529294506001600160a01b03908116939116916321f8a7219161073091869101611b63565b60206040518083038186803b15801561074857600080fd5b505afa15801561075c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061078091908101906114f9565b6001600160a01b03161415806107ab57506000818152600460205260409020546001600160a01b0316155b156107bc57600093505050506107cc565b506001016106c8565b5060019150505b90565b600580546060916107e89160009063ffffffff610fd816565b905090565b60008060006107fb8561092a565b90508061081a5760405162461bcd60e51b81526004016103ac90611c49565b61082481856110ae565b92509250505b9250929050565b600080600061083f8461092a565b90508061085e5760405162461bcd60e51b81526004016103ac90611c49565b6108678161115a565b9250925050915091565b610879610f5a565b60005b818110156106b2576108938383838181106105f957fe5b15610922576108ca8383838181106108a757fe5b90506020020160206108bc91908101906114db565b60059063ffffffff61120216565b7f9faa24f7f20c2e0f689165e6886278f3005b15b94407109799ead3257067a66a8383838181106108f757fe5b905060200201602061090c91908101906114db565b6040516109199190611af8565b60405180910390a15b60010161087c565b6000610934611318565b6001600160a01b031663f7833c5d725065727073563245786368616e67655261746560681b6a1c1c9a58d951995959125960aa1b8560405160200161097a929190611a9c565b604051602081830303815290604052805190602001206040518363ffffffff1660e01b81526004016109ad929190611b7f565b60206040518083038186803b1580156109c557600080fd5b505afa1580156109d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506109fd91908101906115c1565b92915050565b6001546001600160a01b031681565b725065727073563245786368616e67655261746560681b81565b610a34610f5a565b610a3c611318565b6001600160a01b0316634dca0978725065727073563245786368616e67655261746560681b6d6f6666636861696e4f7261636c6560901b846040518463ffffffff1660e01b8152600401610a9293929190611b9a565b600060405180830381600087803b158015610aac57600080fd5b505af1158015610ac0573d6000803e3d6000fd5b505050507ff8ad76f417192ced84abe3abf840e1da06bc5fe7d88fb07002eeb763a6a70655816040516105cc9190611af8565b6060610afd610ce5565b905060005b8151811015610c45576000828281518110610b1957fe5b602002602001015190506000600360009054906101000a90046001600160a01b03166001600160a01b031663dacb2d018384604051602001610b5b9190611ae2565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401610b87929190611bea565b60206040518083038186803b158015610b9f57600080fd5b505afa158015610bb3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610bd791908101906114f9565b6000838152600460205260409081902080546001600160a01b0319166001600160a01b038416179055519091507f88a93678a3692f6789d9546fc621bf7234b101ddb7d4fe479455112831b8aa6890610c339084908490611b71565b60405180910390a15050600101610b02565b5050565b6001546001600160a01b03163314610c735760405162461bcd60e51b81526004016103ac90611c29565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c92610cb6926001600160a01b0391821692911690611b06565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b604080516001808252818301909252606091602080830190803883390190505090506e466c657869626c6553746f7261676560881b81600081518110610d2757fe5b60200260200101818152505090565b6000546001600160a01b031681565b610d4d610f5a565b610d55611318565b6001600160a01b0316624b62d6725065727073563245786368616e67655261746560681b6a1c1c9a58d951995959125960aa1b85604051602001610d9a929190611a9c565b60405160208183030381529060405280519060200120846040518463ffffffff1660e01b8152600401610dcf93929190611bc2565b600060405180830381600087803b158015610de957600080fd5b505af1158015610dfd573d6000803e3d6000fd5b505050507f96a8b94dfd7ff7c78db402b935e8a43578fe44aaaf032a4dc471539cc3987f3c8282604051610e32929190611b7f565b60405180910390a15050565b6000610e48611318565b6001600160a01b0316639ee5955a725065727073563245786368616e67655261746560681b6d6f6666636861696e4f7261636c6560901b6040518363ffffffff1660e01b8152600401610e9c929190611b7f565b60206040518083038186803b158015610eb457600080fd5b505afa158015610ec8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107e891908101906114f9565b8154600090610efd575060006109fd565b6001600160a01b038216600090815260018401602052604090205480151580610f525750826001600160a01b031684600001600081548110610f3b57fe5b6000918252602090912001546001600160a01b0316145b949350505050565b6000546001600160a01b03163314610f845760405162461bcd60e51b81526004016103ac90611c69565b565b610f908282610eec565b610c455781546001600160a01b038216600081815260018086016020908152604083208590559084018655858252902090910180546001600160a01b03191690911790555050565b825460609083830190811115610fec575083545b8381116110095750506040805160008152602081019091526110a7565b604080518583038082526020808202830101909252606090828015611038578160200160208202803883390190505b50905060005b828110156110a157876000018782018154811061105757fe5b9060005260206000200160009054906101000a90046001600160a01b031682828151811061108157fe5b6001600160a01b039092166020928302919091019091015260010161103e565b50925050505b9392505050565b6000806110b96113b6565b6110c1610e3e565b6001600160a01b031663a4ae35e086866040518363ffffffff1660e01b81526004016110ee929190611b7f565b60806040518083038186803b15801561110657600080fd5b505afa15801561111a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061113e9190810190611619565b905061114981611335565b925080606001519150509250929050565b6000806111656113b6565b61116d610e3e565b6001600160a01b03166396834ad3856040518263ffffffff1660e01b81526004016111989190611b63565b60806040518083038186803b1580156111b057600080fd5b505afa1580156111c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506111e89190810190611619565b90506111f381611335565b92508060600151915050915091565b61120c8282610eec565b6112285760405162461bcd60e51b81526004016103ac90611c39565b6001600160a01b03811660009081526001830160205260409020548254600019018082146112c757600084600001828154811061126157fe5b60009182526020909120015485546001600160a01b039091169150819086908590811061128a57fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b0394851617905592909116815260018601909152604090208290555b83548490806112d257fe5b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b0394909416815260019490940190925250506040812055565b60006107e86e466c657869626c6553746f7261676560881b611352565b6040810151905160070b601260039290920b91909101600a0a0290565b60008181526004602090815260408083205490516001600160a01b03909116918215159161138291869101611ac2565b604051602081830303815290604052906113af5760405162461bcd60e51b81526004016103ac9190611c18565b5092915050565b60408051608081018252600080825260208201819052918101829052606081019190915290565b80356109fd81611dbb565b80516109fd81611dbb565b60008083601f84011261140557600080fd5b50813567ffffffffffffffff81111561141d57600080fd5b60208301915083602082028301111561082a57600080fd5b80356109fd81611dd2565b80516109fd81611dd2565b80516109fd81611ddb565b80516109fd81611de4565b60006080828403121561147357600080fd5b61147d6080611ca9565b9050600061148b8484611456565b825250602061149c848483016114d0565b60208301525060406114b08482850161144b565b60408301525060606114c484828501611440565b60608301525092915050565b80516109fd81611ded565b6000602082840312156114ed57600080fd5b6000610f5284846113dd565b60006020828403121561150b57600080fd5b6000610f5284846113e8565b60008060006040848603121561152c57600080fd5b600061153886866113dd565b935050602084013567ffffffffffffffff81111561155557600080fd5b611561868287016113f3565b92509250509250925092565b6000806020838503121561158057600080fd5b823567ffffffffffffffff81111561159757600080fd5b610824858286016113f3565b6000602082840312156115b557600080fd5b6000610f528484611435565b6000602082840312156115d357600080fd5b6000610f528484611440565b600080604083850312156115f257600080fd5b60006115fe8585611435565b925050602061160f85828601611435565b9150509250929050565b60006080828403121561162b57600080fd5b6000610f528484611461565b60006116438383611664565b505060200190565b60006116438383611792565b6000610f528484846117ac565b61166d81611d39565b82525050565b600061167e82611cd6565b6116888185611cda565b935061169383611cd0565b8060005b838110156116c15781516116ab8882611637565b97506116b683611cd0565b925050600101611697565b509495945050505050565b60006116d782611cd6565b6116e18185611cda565b93506116ec83611cd0565b8060005b838110156116c1578151611704888261164b565b975061170f83611cd0565b9250506001016116f0565b60006117268385611cda565b935083602084028501611738846107cc565b8060005b8781101561177c5784840389526117538284611ce8565b61175e868284611657565b955061176984611cd0565b60209b909b019a9350505060010161173c565b5091979650505050505050565b61166d81611d44565b61166d816107cc565b61166d6117a7826107cc565b6107cc565b60006117b88385611cda565b93506117c5838584611d79565b6117ce83611db1565b9093019392505050565b61166d81611d6e565b60006117ec82611cd6565b6117f68185611cda565b9350611806818560208601611d85565b6117ce81611db1565b600061181c603583611cda565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b6000611873601383611cda565b7222b632b6b2b73a103737ba1034b71039b2ba1760691b815260200192915050565b60006118a2601183611ce3565b70026b4b9b9b4b7339030b2323932b9b99d1607d1b815260110192915050565b60006118cf601d83611cda565b7f4e6f207072696365206665656420666f756e6420666f72206173736574000000815260200192915050565b6000611908603383611cda565b7f4f6e6c7920616e206173736f63696174656420636f6e74726163742063616e208152723832b93337b936903a3434b99030b1ba34b7b760691b602082015260400192915050565b600061195d602f83611cda565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b60006119ae601783611cda565b7f4661696c656420746f20726566756e642063616c6c6572000000000000000000815260200192915050565b60006119e7602183611cda565b7f4e6f7420656e6f7567682065746820666f7220706179696e67207468652066658152606560f81b602082015260400192915050565b6000611a2a601983611ce3565b7f5265736f6c766572206d697373696e67207461726765743a2000000000000000815260190192915050565b60006109fd600083611ce3565b6000611a70601f83611cda565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00815260200192915050565b6000611aa8828561179b565b602082019150611ab8828461179b565b5060200192915050565b6000611acd82611895565b9150611ad9828461179b565b50602001919050565b6000611acd82611a1d565b60006109fd82611a56565b602081016109fd8284611664565b60408101611b148285611664565b6110a76020830184611664565b602080825281016110a78184611673565b602080825281016110a781846116cc565b60208082528101610f5281848661171a565b602081016109fd8284611789565b602081016109fd8284611792565b60408101611b148285611792565b60408101611b8d8285611792565b6110a76020830184611792565b60608101611ba88286611792565b611bb56020830185611792565b610f526040830184611664565b60608101611bd08286611792565b611bdd6020830185611792565b610f526040830184611792565b60408101611bf88285611792565b8181036020830152610f5281846117e1565b602081016109fd82846117d8565b602080825281016110a781846117e1565b602080825281016109fd8161180f565b602080825281016109fd81611866565b602080825281016109fd816118c2565b602080825281016109fd816118fb565b602080825281016109fd81611950565b602080825281016109fd816119a1565b602080825281016109fd816119da565b602080825281016109fd81611a63565b60405181810167ffffffffffffffff81118282101715611cc857600080fd5b604052919050565b60200190565b5190565b90815260200190565b919050565b6000808335601e1936859003018112611d0057600080fd5b83810160208101935035915067ffffffffffffffff821115611d2157600080fd5b36829003841315611d3157600080fd5b509250929050565b60006109fd82611d55565b151590565b60030b90565b60070b90565b6001600160a01b031690565b67ffffffffffffffff1690565b60006109fd82611d39565b82818337506000910152565b60005b83811015611da0578181015183820152602001611d88565b838111156105735750506000910152565b601f01601f191690565b611dc481611d39565b8114611dcf57600080fd5b50565b611dc4816107cc565b611dc481611d49565b611dc481611d4f565b611dc481611d6156fea365627a7a72315820bb332cea9303aa96012b9f671f0948068428091e326ecdcc3fa61bbba79b77f16c6578706572696d656e74616cf564736f6c63430005100040
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 ]
[ 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.