Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
This contract has been verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- FetchFlexOracle
- Optimization enabled
- true
- Compiler version
- v0.8.17+commit.8df45f5f
- Optimization runs
- 1200
- EVM Version
- london
- Verified at
- 2026-02-12T04:29:38.791464Z
Constructor Arguments
0000000000000000000000006f390b99201bb43a05757019efe9c99651e04584
Arg [0] (address) : 0x6f390b99201bb43a05757019efe9c99651e04584
contracts/fetchoracle/FetchFlexOracle.sol
// SPDX-License-Identifier: MIT
pragma solidity ~0.8.17;
import {UsingFetch} from "./UsingFetch.sol";
error PriceOutdated();
error ZeroValue();
contract FetchFlexOracle is UsingFetch {
constructor(address payable _fetchAddress) UsingFetch(_fetchAddress) {}
function latestAnswer() public view returns (int256) {
bytes memory _plsQueryId = abi.encode(
"SpotPrice",
abi.encode("pls", "usd")
);
bytes32 _queryId = keccak256(_plsQueryId);
(bytes memory _value, uint256 _timestampRetrieved) = getDataBefore(
_queryId,
block.timestamp - 20 minutes
);
if (_timestampRetrieved == 0) {
revert ZeroValue();
}
if (block.timestamp - _timestampRetrieved > 24 hours) {
revert PriceOutdated();
}
uint256 price = abi.decode(_value, (uint256));
// convert value to chainlink oracle format
int256 oraclePrice = int256((price * 1e8) / 1e18);
if (oraclePrice == 0) {
revert ZeroValue();
}
return oraclePrice;
}
}
/
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
/**
* @dev EIP2362 Interface for pull oracles
* https://github.com/tellor-io/EIP-2362
*/
interface IERC2362 {
/**
* @dev Exposed function pertaining to EIP standards
* @param _id bytes32 ID of the query
* @return int,uint,uint returns the value, timestamp, and status code of query
*/
function valueFor(
bytes32 _id
) external view returns (int256, uint256, uint256);
}
/
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
interface IFetch {
//Controller
function addresses(bytes32) external view returns (address);
function uints(bytes32) external view returns (uint256);
function burn(uint256 _amount) external;
function changeDeity(address _newDeity) external;
function changeOwner(address _newOwner) external;
function changeUint(bytes32 _target, uint256 _amount) external;
function migrate() external;
function mint(address _reciever, uint256 _amount) external;
function init() external;
function getAllDisputeVars(
uint256 _disputeId
)
external
view
returns (
bytes32,
bool,
bool,
bool,
address,
address,
address,
uint256[9] memory,
int256
);
function getDisputeIdByDisputeHash(
bytes32 _hash
) external view returns (uint256);
function getDisputeUintVars(
uint256 _disputeId,
bytes32 _data
) external view returns (uint256);
function getLastNewValueById(
uint256 _requestId
) external view returns (uint256, bool);
function retrieveData(
uint256 _requestId,
uint256 _timestamp
) external view returns (uint256);
function getNewValueCountbyRequestId(
uint256 _requestId
) external view returns (uint256);
function getAddressVars(bytes32 _data) external view returns (address);
function getUintVar(bytes32 _data) external view returns (uint256);
function totalSupply() external view returns (uint256);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function isMigrated(address _addy) external view returns (bool);
function allowance(
address _user,
address _spender
) external view returns (uint256);
function allowedToTrade(
address _user,
uint256 _amount
) external view returns (bool);
function approve(address _spender, uint256 _amount) external returns (bool);
function approveAndTransferFrom(
address _from,
address _to,
uint256 _amount
) external returns (bool);
function balanceOf(address _user) external view returns (uint256);
function balanceOfAt(
address _user,
uint256 _blockNumber
) external view returns (uint256);
function transfer(
address _to,
uint256 _amount
) external returns (bool success);
function transferFrom(
address _from,
address _to,
uint256 _amount
) external returns (bool success);
function depositStake() external;
function requestStakingWithdraw() external;
function withdrawStake() external;
function changeStakingStatus(address _reporter, uint256 _status) external;
function slashReporter(address _reporter, address _disputer) external;
function getStakerInfo(
address _staker
) external view returns (uint256, uint256);
function getTimestampbyRequestIDandIndex(
uint256 _requestId,
uint256 _index
) external view returns (uint256);
function getNewCurrentVariables()
external
view
returns (bytes32 _c, uint256[5] memory _r, uint256 _d, uint256 _t);
function getNewValueCountbyQueryId(
bytes32 _queryId
) external view returns (uint256);
function getTimestampbyQueryIdandIndex(
bytes32 _queryId,
uint256 _index
) external view returns (uint256);
function retrieveData(
bytes32 _queryId,
uint256 _timestamp
) external view returns (bytes memory);
//Governance
enum VoteResult {
FAILED,
PASSED,
INVALID
}
function setApprovedFunction(bytes4 _func, bool _val) external;
function beginDispute(bytes32 _queryId, uint256 _timestamp) external;
function delegate(address _delegate) external;
function delegateOfAt(
address _user,
uint256 _blockNumber
) external view returns (address);
function executeVote(uint256 _disputeId) external;
function proposeVote(
address _contract,
bytes4 _function,
bytes calldata _data,
uint256 _timestamp
) external;
function tallyVotes(uint256 _disputeId) external;
function governance() external view returns (address);
function updateMinDisputeFee() external;
function verify() external pure returns (uint256);
function vote(
uint256 _disputeId,
bool _supports,
bool _invalidQuery
) external;
function voteFor(
address[] calldata _addys,
uint256 _disputeId,
bool _supports,
bool _invalidQuery
) external;
function getDelegateInfo(
address _holder
) external view returns (address, uint256);
function isFunctionApproved(bytes4 _func) external view returns (bool);
function isApprovedGovernanceContract(
address _contract
) external returns (bool);
function getVoteRounds(
bytes32 _hash
) external view returns (uint256[] memory);
function getVoteCount() external view returns (uint256);
function getVoteInfo(
uint256 _disputeId
)
external
view
returns (
bytes32,
uint256[9] memory,
bool[2] memory,
VoteResult,
bytes memory,
bytes4,
address[2] memory
);
function getDisputeInfo(
uint256 _disputeId
) external view returns (uint256, uint256, bytes memory, address);
function getOpenDisputesOnId(
bytes32 _queryId
) external view returns (uint256);
function didVote(
uint256 _disputeId,
address _voter
) external view returns (bool);
//Oracle
function getReportTimestampByIndex(
bytes32 _queryId,
uint256 _index
) external view returns (uint256);
function getValueByTimestamp(
bytes32 _queryId,
uint256 _timestamp
) external view returns (bytes memory);
function getBlockNumberByTimestamp(
bytes32 _queryId,
uint256 _timestamp
) external view returns (uint256);
function getReportingLock() external view returns (uint256);
function getReporterByTimestamp(
bytes32 _queryId,
uint256 _timestamp
) external view returns (address);
function reportingLock() external view returns (uint256);
function removeValue(bytes32 _queryId, uint256 _timestamp) external;
function getTipsByUser(address _user) external view returns (uint256);
function tipQuery(
bytes32 _queryId,
uint256 _tip,
bytes memory _queryData
) external;
function submitValue(
bytes32 _queryId,
bytes calldata _value,
uint256 _nonce,
bytes memory _queryData
) external;
function burnTips() external;
function changeReportingLock(uint256 _newReportingLock) external;
function getReportsSubmittedByAddress(
address _reporter
) external view returns (uint256);
function changeTimeBasedReward(uint256 _newTimeBasedReward) external;
function getReporterLastTimestamp(
address _reporter
) external view returns (uint256);
function getTipsById(bytes32 _queryId) external view returns (uint256);
function getTimeBasedReward() external view returns (uint256);
function getTimestampCountById(
bytes32 _queryId
) external view returns (uint256);
function getTimestampIndexByTimestamp(
bytes32 _queryId,
uint256 _timestamp
) external view returns (uint256);
function getCurrentReward(
bytes32 _queryId
) external view returns (uint256, uint256);
function getCurrentValue(
bytes32 _queryId
) external view returns (bytes memory);
function getDataBefore(
bytes32 _queryId,
uint256 _timestamp
)
external
view
returns (
bool _ifRetrieve,
bytes memory _value,
uint256 _timestampRetrieved
);
function getTimeOfLastNewValue() external view returns (uint256);
function depositStake(uint256 _amount) external;
function requestStakingWithdraw(uint256 _amount) external;
//Test functions
function changeAddressVar(bytes32 _id, address _addy) external;
//parachute functions
function killContract() external;
function migrateFor(address _destination, uint256 _amount) external;
function rescue51PercentAttack(address _tokenHolder) external;
function rescueBrokenDataReporting() external;
function rescueFailedUpdate() external;
//Fetch 360
function addStakingRewards(uint256 _amount) external;
function _sliceUint(
bytes memory _b
) external pure returns (uint256 _number);
function claimOneTimeTip(
bytes32 _queryId,
uint256[] memory _timestamps
) external;
function claimTip(
bytes32 _feedId,
bytes32 _queryId,
uint256[] memory _timestamps
) external;
function fee() external view returns (uint256);
function feedsWithFunding(uint256) external view returns (bytes32);
function fundFeed(
bytes32 _feedId,
bytes32 _queryId,
uint256 _amount
) external;
function getCurrentFeeds(
bytes32 _queryId
) external view returns (bytes32[] memory);
function getCurrentTip(bytes32 _queryId) external view returns (uint256);
function getDataAfter(
bytes32 _queryId,
uint256 _timestamp
) external view returns (bytes memory _value, uint256 _timestampRetrieved);
function getDataFeed(
bytes32 _feedId
) external view returns (Autopay.FeedDetails memory);
function getFundedFeeds() external view returns (bytes32[] memory);
function getFundedQueryIds() external view returns (bytes32[] memory);
function getIndexForDataAfter(
bytes32 _queryId,
uint256 _timestamp
) external view returns (bool _found, uint256 _index);
function getIndexForDataBefore(
bytes32 _queryId,
uint256 _timestamp
) external view returns (bool _found, uint256 _index);
function getMultipleValuesBefore(
bytes32 _queryId,
uint256 _timestamp,
uint256 _maxAge,
uint256 _maxCount
)
external
view
returns (uint256[] memory _values, uint256[] memory _timestamps);
function getPastTipByIndex(
bytes32 _queryId,
uint256 _index
) external view returns (Autopay.Tip memory);
function getPastTipCount(bytes32 _queryId) external view returns (uint256);
function getPastTips(
bytes32 _queryId
) external view returns (Autopay.Tip[] memory);
function getQueryIdFromFeedId(
bytes32 _feedId
) external view returns (bytes32);
function getRewardAmount(
bytes32 _feedId,
bytes32 _queryId,
uint256[] memory _timestamps
) external view returns (uint256 _cumulativeReward);
function getRewardClaimedStatus(
bytes32 _feedId,
bytes32 _queryId,
uint256 _timestamp
) external view returns (bool);
function getTipsByAddress(address _user) external view returns (uint256);
function isInDispute(
bytes32 _queryId,
uint256 _timestamp
) external view returns (bool);
function queryIdFromDataFeedId(bytes32) external view returns (bytes32);
function queryIdsWithFunding(uint256) external view returns (bytes32);
function queryIdsWithFundingIndex(bytes32) external view returns (uint256);
function setupDataFeed(
bytes32 _queryId,
uint256 _reward,
uint256 _startTime,
uint256 _interval,
uint256 _window,
uint256 _priceThreshold,
uint256 _rewardIncreasePerSecond,
bytes memory _queryData,
uint256 _amount
) external;
function fetch() external view returns (address);
function tip(
bytes32 _queryId,
uint256 _amount,
bytes memory _queryData
) external;
function tips(
bytes32,
uint256
) external view returns (uint256 amount, uint256 timestamp);
function token() external view returns (address);
function userTipsTotal(address) external view returns (uint256);
function valueFor(
bytes32 _id
)
external
view
returns (int256 _value, uint256 _timestamp, uint256 _statusCode);
}
interface Autopay {
struct FeedDetails {
uint256 reward;
uint256 balance;
uint256 startTime;
uint256 interval;
uint256 window;
uint256 priceThreshold;
uint256 rewardIncreasePerSecond;
uint256 feedsWithFundingIndex;
}
struct Tip {
uint256 amount;
uint256 timestamp;
}
function getStakeAmount() external view returns (uint256);
function stakeAmount() external view returns (uint256);
function token() external view returns (address);
}
/
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IMappingContract {
function getFetchID(bytes32 _id) external view returns (bytes32);
}
/
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IFetch.sol";
import "./IERC2362.sol";
import "./IMappingContract.sol";
/**
@author Fetch Inc
@title UsingFetch
@dev This contract helps smart contracts read data from Fetch
*/
contract UsingFetch is IERC2362 {
IFetch public fetch;
IMappingContract public idMappingContract;
/*Constructor*/
/**
* @dev the constructor sets the oracle address in storage
* @param _fetch is the Fetch Oracle address
*/
constructor(address payable _fetch) {
fetch = IFetch(_fetch);
}
/*Getters*/
/**
* @dev Retrieves the next value for the queryId after the specified timestamp
* @param _queryId is the queryId to look up the value for
* @param _timestamp after which to search for next value
* @return _value the value retrieved
* @return _timestampRetrieved the value's timestamp
*/
function getDataAfter(
bytes32 _queryId,
uint256 _timestamp
) public view returns (bytes memory _value, uint256 _timestampRetrieved) {
(bool _found, uint256 _index) = getIndexForDataAfter(
_queryId,
_timestamp
);
if (!_found) {
return ("", 0);
}
_timestampRetrieved = getTimestampbyQueryIdandIndex(_queryId, _index);
_value = retrieveData(_queryId, _timestampRetrieved);
return (_value, _timestampRetrieved);
}
/**
* @dev Retrieves the latest value for the queryId before the specified timestamp
* @param _queryId is the queryId to look up the value for
* @param _timestamp before which to search for latest value
* @return _value the value retrieved
* @return _timestampRetrieved the value's timestamp
*/
function getDataBefore(
bytes32 _queryId,
uint256 _timestamp
) public view returns (bytes memory _value, uint256 _timestampRetrieved) {
(, _value, _timestampRetrieved) = fetch.getDataBefore(
_queryId,
_timestamp
);
}
/**
* @dev Retrieves latest array index of data before the specified timestamp for the queryId
* @param _queryId is the queryId to look up the index for
* @param _timestamp is the timestamp before which to search for the latest index
* @return _found whether the index was found
* @return _index the latest index found before the specified timestamp
*/
// slither-disable-next-line calls-loop
function getIndexForDataAfter(
bytes32 _queryId,
uint256 _timestamp
) public view returns (bool _found, uint256 _index) {
uint256 _count = getNewValueCountbyQueryId(_queryId);
if (_count == 0) return (false, 0);
_count--;
bool _search = true; // perform binary search
uint256 _middle = 0;
uint256 _start = 0;
uint256 _end = _count;
uint256 _timestampRetrieved;
// checking boundaries to short-circuit the algorithm
_timestampRetrieved = getTimestampbyQueryIdandIndex(_queryId, _end);
if (_timestampRetrieved <= _timestamp) return (false, 0);
_timestampRetrieved = getTimestampbyQueryIdandIndex(_queryId, _start);
if (_timestampRetrieved > _timestamp) {
// candidate found, check for disputes
_search = false;
}
// since the value is within our boundaries, do a binary search
while (_search) {
_middle = (_end + _start) / 2;
_timestampRetrieved = getTimestampbyQueryIdandIndex(
_queryId,
_middle
);
if (_timestampRetrieved > _timestamp) {
// get immediate previous value
uint256 _prevTime = getTimestampbyQueryIdandIndex(
_queryId,
_middle - 1
);
if (_prevTime <= _timestamp) {
// candidate found, check for disputes
_search = false;
} else {
// look from start to middle -1(prev value)
_end = _middle - 1;
}
} else {
// get immediate next value
uint256 _nextTime = getTimestampbyQueryIdandIndex(
_queryId,
_middle + 1
);
if (_nextTime > _timestamp) {
// candidate found, check for disputes
_search = false;
_middle++;
_timestampRetrieved = _nextTime;
} else {
// look from middle + 1(next value) to end
_start = _middle + 1;
}
}
}
// candidate found, check for disputed values
if (!isInDispute(_queryId, _timestampRetrieved)) {
// _timestampRetrieved is correct
return (true, _middle);
} else {
// iterate forward until we find a non-disputed value
while (
isInDispute(_queryId, _timestampRetrieved) && _middle < _count
) {
_middle++;
_timestampRetrieved = getTimestampbyQueryIdandIndex(
_queryId,
_middle
);
}
if (
_middle == _count && isInDispute(_queryId, _timestampRetrieved)
) {
return (false, 0);
}
// _timestampRetrieved is correct
return (true, _middle);
}
}
/**
* @dev Retrieves latest array index of data before the specified timestamp for the queryId
* @param _queryId is the queryId to look up the index for
* @param _timestamp is the timestamp before which to search for the latest index
* @return _found whether the index was found
* @return _index the latest index found before the specified timestamp
*/
// slither-disable-next-line calls-loop
function getIndexForDataBefore(
bytes32 _queryId,
uint256 _timestamp
) public view returns (bool _found, uint256 _index) {
return fetch.getIndexForDataBefore(_queryId, _timestamp);
}
/**
* @dev Retrieves multiple uint256 values before the specified timestamp
* @param _queryId the unique id of the data query
* @param _timestamp the timestamp before which to search for values
* @param _maxAge the maximum number of seconds before the _timestamp to search for values
* @param _maxCount the maximum number of values to return
* @return _values the values retrieved, ordered from oldest to newest
* @return _timestamps the timestamps of the values retrieved
*/
function getMultipleValuesBefore(
bytes32 _queryId,
uint256 _timestamp,
uint256 _maxAge,
uint256 _maxCount
)
public
view
returns (bytes[] memory _values, uint256[] memory _timestamps)
{
// get index of first possible value
(bool _ifRetrieve, uint256 _startIndex) = getIndexForDataAfter(
_queryId,
_timestamp - _maxAge
);
// no value within range
if (!_ifRetrieve) {
return (new bytes[](0), new uint256[](0));
}
uint256 _endIndex;
// get index of last possible value
(_ifRetrieve, _endIndex) = getIndexForDataBefore(_queryId, _timestamp);
// no value before _timestamp
if (!_ifRetrieve) {
return (new bytes[](0), new uint256[](0));
}
uint256 _valCount = 0;
uint256 _index = 0;
uint256[] memory _timestampsArrayTemp = new uint256[](_maxCount);
// generate array of non-disputed timestamps within range
while (_valCount < _maxCount && _endIndex + 1 - _index > _startIndex) {
uint256 _timestampRetrieved = getTimestampbyQueryIdandIndex(
_queryId,
_endIndex - _index
);
if (!isInDispute(_queryId, _timestampRetrieved)) {
_timestampsArrayTemp[_valCount] = _timestampRetrieved;
_valCount++;
}
_index++;
}
bytes[] memory _valuesArray = new bytes[](_valCount);
uint256[] memory _timestampsArray = new uint256[](_valCount);
// retrieve values and reverse timestamps order
for (uint256 _i = 0; _i < _valCount; _i++) {
_timestampsArray[_i] = _timestampsArrayTemp[_valCount - 1 - _i];
_valuesArray[_i] = retrieveData(_queryId, _timestampsArray[_i]);
}
return (_valuesArray, _timestampsArray);
}
/**
* @dev Counts the number of values that have been submitted for the queryId
* @param _queryId the id to look up
* @return uint256 count of the number of values received for the queryId
*/
function getNewValueCountbyQueryId(
bytes32 _queryId
) public view returns (uint256) {
return fetch.getNewValueCountbyQueryId(_queryId);
}
/**
* @dev Returns the address of the reporter who submitted a value for a data ID at a specific time
* @param _queryId is ID of the specific data feed
* @param _timestamp is the timestamp to find a corresponding reporter for
* @return address of the reporter who reported the value for the data ID at the given timestamp
*/
function getReporterByTimestamp(
bytes32 _queryId,
uint256 _timestamp
) public view returns (address) {
return fetch.getReporterByTimestamp(_queryId, _timestamp);
}
/**
* @dev Gets the timestamp for the value based on their index
* @param _queryId is the id to look up
* @param _index is the value index to look up
* @return uint256 timestamp
*/
function getTimestampbyQueryIdandIndex(
bytes32 _queryId,
uint256 _index
) public view returns (uint256) {
return fetch.getTimestampbyQueryIdandIndex(_queryId, _index);
}
/**
* @dev Determines whether a value with a given queryId and timestamp has been disputed
* @param _queryId is the value id to look up
* @param _timestamp is the timestamp of the value to look up
* @return bool true if queryId/timestamp is under dispute
*/
function isInDispute(
bytes32 _queryId,
uint256 _timestamp
) public view returns (bool) {
return fetch.isInDispute(_queryId, _timestamp);
}
/**
* @dev Retrieve value from oracle based on queryId/timestamp
* @param _queryId being requested
* @param _timestamp to retrieve data/value from
* @return bytes value for query/timestamp submitted
*/
function retrieveData(
bytes32 _queryId,
uint256 _timestamp
) public view returns (bytes memory) {
return fetch.retrieveData(_queryId, _timestamp);
}
/**
* @dev allows dev to set mapping contract for valueFor (EIP2362)
* @param _addy address of mapping contract
*/
function setIdMappingContract(address _addy) external {
require(address(idMappingContract) == address(0));
idMappingContract = IMappingContract(_addy);
}
/**
* @dev Retrieve most recent int256 value from oracle based on queryId
* @param _id being requested
* @return _value most recent value submitted
* @return _timestamp timestamp of most recent value
* @return _statusCode 200 if value found, 404 if not found
*/
function valueFor(
bytes32 _id
)
external
view
override
returns (int256 _value, uint256 _timestamp, uint256 _statusCode)
{
bytes32 _queryId = idMappingContract.getFetchID(_id);
bytes memory _valueBytes;
(_valueBytes, _timestamp) = getDataBefore(
_queryId,
block.timestamp + 1
);
if (_timestamp == 0) {
return (0, 0, 404);
}
uint256 _valueUint = _sliceUint(_valueBytes);
_value = int256(_valueUint);
return (_value, _timestamp, 200);
}
// Internal functions
/**
* @dev Convert bytes to uint256
* @param _b bytes value to convert to uint256
* @return _number uint256 converted from bytes
*/
function _sliceUint(
bytes memory _b
) internal pure returns (uint256 _number) {
for (uint256 _i = 0; _i < _b.length; _i++) {
_number = _number * 256 + uint8(_b[_i]);
}
}
}
Compiler Settings
{"remappings":[],"optimizer":{"runs":1200,"enabled":true},"metadata":{"useLiteralContent":true,"bytecodeHash":"ipfs"},"libraries":{},"evmVersion":"london","compilationTarget":{"contracts/fetchoracle/FetchFlexOracle.sol":"FetchFlexOracle"}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_fetchAddress","internalType":"address payable"}]},{"type":"error","name":"PriceOutdated","inputs":[]},{"type":"error","name":"ZeroValue","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IFetch"}],"name":"fetch","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes","name":"_value","internalType":"bytes"},{"type":"uint256","name":"_timestampRetrieved","internalType":"uint256"}],"name":"getDataAfter","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_timestamp","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes","name":"_value","internalType":"bytes"},{"type":"uint256","name":"_timestampRetrieved","internalType":"uint256"}],"name":"getDataBefore","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_timestamp","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"_found","internalType":"bool"},{"type":"uint256","name":"_index","internalType":"uint256"}],"name":"getIndexForDataAfter","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_timestamp","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"_found","internalType":"bool"},{"type":"uint256","name":"_index","internalType":"uint256"}],"name":"getIndexForDataBefore","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_timestamp","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes[]","name":"_values","internalType":"bytes[]"},{"type":"uint256[]","name":"_timestamps","internalType":"uint256[]"}],"name":"getMultipleValuesBefore","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_timestamp","internalType":"uint256"},{"type":"uint256","name":"_maxAge","internalType":"uint256"},{"type":"uint256","name":"_maxCount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getNewValueCountbyQueryId","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getReporterByTimestamp","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_timestamp","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getTimestampbyQueryIdandIndex","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IMappingContract"}],"name":"idMappingContract","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isInDispute","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_timestamp","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"int256","name":"","internalType":"int256"}],"name":"latestAnswer","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes","name":"","internalType":"bytes"}],"name":"retrieveData","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_timestamp","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setIdMappingContract","inputs":[{"type":"address","name":"_addy","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"int256","name":"_value","internalType":"int256"},{"type":"uint256","name":"_timestamp","internalType":"uint256"},{"type":"uint256","name":"_statusCode","internalType":"uint256"}],"name":"valueFor","inputs":[{"type":"bytes32","name":"_id","internalType":"bytes32"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b5060405161141638038061141683398101604081905261002f91610054565b600080546001600160a01b0319166001600160a01b0392909216919091179055610084565b60006020828403121561006657600080fd5b81516001600160a01b038116811461007d57600080fd5b9392505050565b611383806100936000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c8063a792765f11610097578063e07c548611610066578063e07c54861461022f578063f66f49c314610242578063f78eea8314610255578063fcd4a5461461028357600080fd5b8063a792765f146101d6578063a95c372d146101e9578063c5958af9146101fc578063ce5e11bf1461021c57600080fd5b806344e87f91116100d357806344e87f911461016957806350d25bcd1461018c57806364ee3c6d146101a257806377b03e0d146101c357600080fd5b8063193b505b146100fa578063294490851461010f5780632af8aae01461013e575b600080fd5b61010d610108366004610ee0565b6102a4565b005b61012261011d366004610f04565b6102f4565b6040805192151583526020830191909152015b60405180910390f35b600154610151906001600160a01b031681565b6040516001600160a01b039091168152602001610135565b61017c610177366004610f04565b61038d565b6040519015158152602001610135565b610194610424565b604051908152602001610135565b6101b56101b0366004610f04565b6105b9565b604051610135929190610f76565b6101946101d1366004610f98565b610612565b6101b56101e4366004610f04565b610699565b600054610151906001600160a01b031681565b61020f61020a366004610f04565b610739565b6040516101359190610fb1565b61019461022a366004610f04565b6107cb565b61015161023d366004610f04565b610859565b610122610250366004610f04565b6108e7565b610268610263366004610f98565b610aa4565b60408051938452602084019290925290820152606001610135565b610296610291366004610fc4565b610b82565b604051610135929190610ff6565b6001546001600160a01b0316156102ba57600080fd5b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b600080546040517f29449085000000000000000000000000000000000000000000000000000000008152600481018590526024810184905282916001600160a01b0316906329449085906044016040805180830381865afa15801561035d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061038191906110a6565b915091505b9250929050565b600080546040517f44e87f9100000000000000000000000000000000000000000000000000000000815260048101859052602481018490526001600160a01b03909116906344e87f9190604401602060405180830381865afa1580156103f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041b91906110d2565b90505b92915050565b60008060405160200161049c90604080825260039082018190527f706c73000000000000000000000000000000000000000000000000000000000060608301526080602083018190528201527f757364000000000000000000000000000000000000000000000000000000000060a082015260c00190565b60408051601f19818403018152908290526104b9916020016110ed565b60408051601f19818403018152919052805160208201209091506000806104e6836101e46104b04261114a565b915091508060000361050b57604051637c946ed760e01b815260040160405180910390fd5b62015180610519824261114a565b1115610551576040517f3baab38100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600082806020019051810190610567919061115d565b90506000670de0b6b3a7640000610582836305f5e100611176565b61058c919061118d565b9050806000036105af57604051637c946ed760e01b815260040160405180910390fd5b9695505050505050565b606060008060006105ca86866108e7565b91509150816105f15760006040518060200160405280600081525090935093505050610386565b6105fb86826107cb565b92506106078684610739565b935050509250929050565b600080546040517f77b03e0d000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b03909116906377b03e0d90602401602060405180830381865afa158015610675573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041e919061115d565b600080546040517fa792765f0000000000000000000000000000000000000000000000000000000081526004810185905260248101849052606092916001600160a01b03169063a792765f90604401600060405180830381865afa158015610705573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261072d9190810190611243565b90969095509350505050565b6000546040517fc5958af900000000000000000000000000000000000000000000000000000000815260048101849052602481018390526060916001600160a01b03169063c5958af990604401600060405180830381865afa1580156107a3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261041b919081019061129a565b600080546040517fce5e11bf00000000000000000000000000000000000000000000000000000000815260048101859052602481018490526001600160a01b039091169063ce5e11bf90604401602060405180830381865afa158015610835573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041b919061115d565b600080546040517fe07c548600000000000000000000000000000000000000000000000000000000815260048101859052602481018490526001600160a01b039091169063e07c548690604401602060405180830381865afa1580156108c3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041b91906112d7565b60008060006108f585610612565b90508060000361090c576000809250925050610386565b80610916816112f4565b915060019050600080838161092b8a836107cb565b90508881116109465760008097509750505050505050610386565b6109508a846107cb565b90508881111561095f57600094505b8415610a0f576002610971848461130b565b61097b919061118d565b93506109878a856107cb565b9050888111156109c85760006109a28b61022a60018861114a565b90508981116109b457600095506109c2565b6109bf60018661114a565b92505b5061095f565b60006109d98b61022a87600161130b565b9050898111156109fc5760009550846109f18161131e565b9550508091506109c2565b610a0785600161130b565b93505061095f565b610a198a8261038d565b610a2f5760018497509750505050505050610386565b610a398a8261038d565b8015610a4457508584105b15610a675783610a538161131e565b945050610a608a856107cb565b9050610a2f565b8584148015610a7b5750610a7b8a8261038d565b15610a925760008097509750505050505050610386565b60018497509750505050505050610386565b6001546040517fd21d79ee000000000000000000000000000000000000000000000000000000008152600481018390526000918291829182916001600160a01b039091169063d21d79ee90602401602060405180830381865afa158015610b0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b33919061115d565b90506060610b46826101e442600161130b565b945090506000849003610b66576000806101949450945094505050610b7b565b6000610b7182610e71565b955060c893505050505b9193909250565b606080600080610b9688610250888a61114a565b9150915081610be7576040805160008082526020820190925290610bca565b6060815260200190600190039081610bb55790505b506040805160008152602081019091529094509250610e68915050565b6000610bf389896102f4565b909350905082610c46576040805160008082526020820190925290610c28565b6060815260200190600190039081610c135790505b506040805160008152602081019091529095509350610e6892505050565b60008060008867ffffffffffffffff811115610c6457610c646111af565b604051908082528060200260200182016040528015610c8d578160200160208202803683370190505b5090505b8883108015610cb457508482610ca886600161130b565b610cb2919061114a565b115b15610d18576000610cc98d61022a858861114a565b9050610cd58d8261038d565b610d055780828581518110610cec57610cec611337565b602090810291909101015283610d018161131e565b9450505b82610d0f8161131e565b93505050610c91565b60008367ffffffffffffffff811115610d3357610d336111af565b604051908082528060200260200182016040528015610d6657816020015b6060815260200190600190039081610d515790505b50905060008467ffffffffffffffff811115610d8457610d846111af565b604051908082528060200260200182016040528015610dad578160200160208202803683370190505b50905060005b85811015610e5b578381610dc860018961114a565b610dd2919061114a565b81518110610de257610de2611337565b6020026020010151828281518110610dfc57610dfc611337565b602002602001018181525050610e2b8f838381518110610e1e57610e1e611337565b6020026020010151610739565b838281518110610e3d57610e3d611337565b60200260200101819052508080610e539061131e565b915050610db3565b5090985096505050505050505b94509492505050565b6000805b8251811015610ec257828181518110610e9057610e90611337565b016020015160f81c610ea483610100611176565b610eae919061130b565b915080610eba8161131e565b915050610e75565b50919050565b6001600160a01b0381168114610edd57600080fd5b50565b600060208284031215610ef257600080fd5b8135610efd81610ec8565b9392505050565b60008060408385031215610f1757600080fd5b50508035926020909101359150565b60005b83811015610f41578181015183820152602001610f29565b50506000910152565b60008151808452610f62816020860160208601610f26565b601f01601f19169290920160200192915050565b604081526000610f896040830185610f4a565b90508260208301529392505050565b600060208284031215610faa57600080fd5b5035919050565b60208152600061041b6020830184610f4a565b60008060008060808587031215610fda57600080fd5b5050823594602084013594506040840135936060013592509050565b6000604082016040835280855180835260608501915060608160051b8601019250602080880160005b8381101561104d57605f1988870301855261103b868351610f4a565b9550938201939082019060010161101f565b50508584038187015286518085528782019482019350915060005b8281101561108457845184529381019392810192600101611068565b5091979650505050505050565b805180151581146110a157600080fd5b919050565b600080604083850312156110b957600080fd5b6110c283611091565b9150602083015190509250929050565b6000602082840312156110e457600080fd5b61041b82611091565b60408152600960408201527f53706f7450726963650000000000000000000000000000000000000000000000606082015260806020820152600061041b6080830184610f4a565b634e487b7160e01b600052601160045260246000fd5b8181038181111561041e5761041e611134565b60006020828403121561116f57600080fd5b5051919050565b808202811582820484141761041e5761041e611134565b6000826111aa57634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126111d657600080fd5b815167ffffffffffffffff808211156111f1576111f16111af565b604051601f8301601f19908116603f01168101908282118183101715611219576112196111af565b8160405283815286602085880101111561123257600080fd5b6105af846020830160208901610f26565b60008060006060848603121561125857600080fd5b61126184611091565b9250602084015167ffffffffffffffff81111561127d57600080fd5b611289868287016111c5565b925050604084015190509250925092565b6000602082840312156112ac57600080fd5b815167ffffffffffffffff8111156112c357600080fd5b6112cf848285016111c5565b949350505050565b6000602082840312156112e957600080fd5b8151610efd81610ec8565b60008161130357611303611134565b506000190190565b8082018082111561041e5761041e611134565b60006001820161133057611330611134565b5060010190565b634e487b7160e01b600052603260045260246000fdfea2646970667358221220c18bf256f6e2aa5fcf858d68699089d64f5a35e065833654314ce0748c862ea364736f6c634300081100330000000000000000000000006f390b99201bb43a05757019efe9c99651e04584
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c8063a792765f11610097578063e07c548611610066578063e07c54861461022f578063f66f49c314610242578063f78eea8314610255578063fcd4a5461461028357600080fd5b8063a792765f146101d6578063a95c372d146101e9578063c5958af9146101fc578063ce5e11bf1461021c57600080fd5b806344e87f91116100d357806344e87f911461016957806350d25bcd1461018c57806364ee3c6d146101a257806377b03e0d146101c357600080fd5b8063193b505b146100fa578063294490851461010f5780632af8aae01461013e575b600080fd5b61010d610108366004610ee0565b6102a4565b005b61012261011d366004610f04565b6102f4565b6040805192151583526020830191909152015b60405180910390f35b600154610151906001600160a01b031681565b6040516001600160a01b039091168152602001610135565b61017c610177366004610f04565b61038d565b6040519015158152602001610135565b610194610424565b604051908152602001610135565b6101b56101b0366004610f04565b6105b9565b604051610135929190610f76565b6101946101d1366004610f98565b610612565b6101b56101e4366004610f04565b610699565b600054610151906001600160a01b031681565b61020f61020a366004610f04565b610739565b6040516101359190610fb1565b61019461022a366004610f04565b6107cb565b61015161023d366004610f04565b610859565b610122610250366004610f04565b6108e7565b610268610263366004610f98565b610aa4565b60408051938452602084019290925290820152606001610135565b610296610291366004610fc4565b610b82565b604051610135929190610ff6565b6001546001600160a01b0316156102ba57600080fd5b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b600080546040517f29449085000000000000000000000000000000000000000000000000000000008152600481018590526024810184905282916001600160a01b0316906329449085906044016040805180830381865afa15801561035d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061038191906110a6565b915091505b9250929050565b600080546040517f44e87f9100000000000000000000000000000000000000000000000000000000815260048101859052602481018490526001600160a01b03909116906344e87f9190604401602060405180830381865afa1580156103f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041b91906110d2565b90505b92915050565b60008060405160200161049c90604080825260039082018190527f706c73000000000000000000000000000000000000000000000000000000000060608301526080602083018190528201527f757364000000000000000000000000000000000000000000000000000000000060a082015260c00190565b60408051601f19818403018152908290526104b9916020016110ed565b60408051601f19818403018152919052805160208201209091506000806104e6836101e46104b04261114a565b915091508060000361050b57604051637c946ed760e01b815260040160405180910390fd5b62015180610519824261114a565b1115610551576040517f3baab38100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600082806020019051810190610567919061115d565b90506000670de0b6b3a7640000610582836305f5e100611176565b61058c919061118d565b9050806000036105af57604051637c946ed760e01b815260040160405180910390fd5b9695505050505050565b606060008060006105ca86866108e7565b91509150816105f15760006040518060200160405280600081525090935093505050610386565b6105fb86826107cb565b92506106078684610739565b935050509250929050565b600080546040517f77b03e0d000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b03909116906377b03e0d90602401602060405180830381865afa158015610675573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041e919061115d565b600080546040517fa792765f0000000000000000000000000000000000000000000000000000000081526004810185905260248101849052606092916001600160a01b03169063a792765f90604401600060405180830381865afa158015610705573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261072d9190810190611243565b90969095509350505050565b6000546040517fc5958af900000000000000000000000000000000000000000000000000000000815260048101849052602481018390526060916001600160a01b03169063c5958af990604401600060405180830381865afa1580156107a3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261041b919081019061129a565b600080546040517fce5e11bf00000000000000000000000000000000000000000000000000000000815260048101859052602481018490526001600160a01b039091169063ce5e11bf90604401602060405180830381865afa158015610835573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041b919061115d565b600080546040517fe07c548600000000000000000000000000000000000000000000000000000000815260048101859052602481018490526001600160a01b039091169063e07c548690604401602060405180830381865afa1580156108c3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041b91906112d7565b60008060006108f585610612565b90508060000361090c576000809250925050610386565b80610916816112f4565b915060019050600080838161092b8a836107cb565b90508881116109465760008097509750505050505050610386565b6109508a846107cb565b90508881111561095f57600094505b8415610a0f576002610971848461130b565b61097b919061118d565b93506109878a856107cb565b9050888111156109c85760006109a28b61022a60018861114a565b90508981116109b457600095506109c2565b6109bf60018661114a565b92505b5061095f565b60006109d98b61022a87600161130b565b9050898111156109fc5760009550846109f18161131e565b9550508091506109c2565b610a0785600161130b565b93505061095f565b610a198a8261038d565b610a2f5760018497509750505050505050610386565b610a398a8261038d565b8015610a4457508584105b15610a675783610a538161131e565b945050610a608a856107cb565b9050610a2f565b8584148015610a7b5750610a7b8a8261038d565b15610a925760008097509750505050505050610386565b60018497509750505050505050610386565b6001546040517fd21d79ee000000000000000000000000000000000000000000000000000000008152600481018390526000918291829182916001600160a01b039091169063d21d79ee90602401602060405180830381865afa158015610b0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b33919061115d565b90506060610b46826101e442600161130b565b945090506000849003610b66576000806101949450945094505050610b7b565b6000610b7182610e71565b955060c893505050505b9193909250565b606080600080610b9688610250888a61114a565b9150915081610be7576040805160008082526020820190925290610bca565b6060815260200190600190039081610bb55790505b506040805160008152602081019091529094509250610e68915050565b6000610bf389896102f4565b909350905082610c46576040805160008082526020820190925290610c28565b6060815260200190600190039081610c135790505b506040805160008152602081019091529095509350610e6892505050565b60008060008867ffffffffffffffff811115610c6457610c646111af565b604051908082528060200260200182016040528015610c8d578160200160208202803683370190505b5090505b8883108015610cb457508482610ca886600161130b565b610cb2919061114a565b115b15610d18576000610cc98d61022a858861114a565b9050610cd58d8261038d565b610d055780828581518110610cec57610cec611337565b602090810291909101015283610d018161131e565b9450505b82610d0f8161131e565b93505050610c91565b60008367ffffffffffffffff811115610d3357610d336111af565b604051908082528060200260200182016040528015610d6657816020015b6060815260200190600190039081610d515790505b50905060008467ffffffffffffffff811115610d8457610d846111af565b604051908082528060200260200182016040528015610dad578160200160208202803683370190505b50905060005b85811015610e5b578381610dc860018961114a565b610dd2919061114a565b81518110610de257610de2611337565b6020026020010151828281518110610dfc57610dfc611337565b602002602001018181525050610e2b8f838381518110610e1e57610e1e611337565b6020026020010151610739565b838281518110610e3d57610e3d611337565b60200260200101819052508080610e539061131e565b915050610db3565b5090985096505050505050505b94509492505050565b6000805b8251811015610ec257828181518110610e9057610e90611337565b016020015160f81c610ea483610100611176565b610eae919061130b565b915080610eba8161131e565b915050610e75565b50919050565b6001600160a01b0381168114610edd57600080fd5b50565b600060208284031215610ef257600080fd5b8135610efd81610ec8565b9392505050565b60008060408385031215610f1757600080fd5b50508035926020909101359150565b60005b83811015610f41578181015183820152602001610f29565b50506000910152565b60008151808452610f62816020860160208601610f26565b601f01601f19169290920160200192915050565b604081526000610f896040830185610f4a565b90508260208301529392505050565b600060208284031215610faa57600080fd5b5035919050565b60208152600061041b6020830184610f4a565b60008060008060808587031215610fda57600080fd5b5050823594602084013594506040840135936060013592509050565b6000604082016040835280855180835260608501915060608160051b8601019250602080880160005b8381101561104d57605f1988870301855261103b868351610f4a565b9550938201939082019060010161101f565b50508584038187015286518085528782019482019350915060005b8281101561108457845184529381019392810192600101611068565b5091979650505050505050565b805180151581146110a157600080fd5b919050565b600080604083850312156110b957600080fd5b6110c283611091565b9150602083015190509250929050565b6000602082840312156110e457600080fd5b61041b82611091565b60408152600960408201527f53706f7450726963650000000000000000000000000000000000000000000000606082015260806020820152600061041b6080830184610f4a565b634e487b7160e01b600052601160045260246000fd5b8181038181111561041e5761041e611134565b60006020828403121561116f57600080fd5b5051919050565b808202811582820484141761041e5761041e611134565b6000826111aa57634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126111d657600080fd5b815167ffffffffffffffff808211156111f1576111f16111af565b604051601f8301601f19908116603f01168101908282118183101715611219576112196111af565b8160405283815286602085880101111561123257600080fd5b6105af846020830160208901610f26565b60008060006060848603121561125857600080fd5b61126184611091565b9250602084015167ffffffffffffffff81111561127d57600080fd5b611289868287016111c5565b925050604084015190509250925092565b6000602082840312156112ac57600080fd5b815167ffffffffffffffff8111156112c357600080fd5b6112cf848285016111c5565b949350505050565b6000602082840312156112e957600080fd5b8151610efd81610ec8565b60008161130357611303611134565b506000190190565b8082018082111561041e5761041e611134565b60006001820161133057611330611134565b5060010190565b634e487b7160e01b600052603260045260246000fdfea2646970667358221220c18bf256f6e2aa5fcf858d68699089d64f5a35e065833654314ce0748c862ea364736f6c63430008110033