Mumbai Testnet

Contract

0x5F1670bdbAfcbEA39579083Dfd56984bb4A34d25

Overview

MATIC Balance

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Value
0x60806040256462902022-03-24 10:51:53797 days ago1648119113IN
 Create: OracleAggregator
0 MATIC0.0039297719.99999997

Parent Transaction Hash Block From To Value
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
OracleAggregator

Compiler Version
v0.8.5+commit.a4f2e591

Optimization Enabled:
Yes with 800 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 1 : OracleAggregator.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.5;

/**
    Error codes:
    - O1 = ERROR_ORACLE_AGGREGATOR_DATA_ALREADY_EXISTS
    - O2 = ERROR_ORACLE_AGGREGATOR_DATA_DOESNT_EXIST
 */

/// @title Opium.OracleAggregator contract requests and caches the data from `oracleId`s and provides them to the Core for positions execution
contract OracleAggregator {
    event LogDataProvided(address indexed _oracleId, uint256 indexed _timestamp, uint256 indexed _data);
    // Storage for the `oracleId` results
    // dataCache[oracleId][timestamp] => data
    mapping(address => mapping(uint256 => uint256)) private dataCache;

    // Flags whether data were provided
    // dataExist[oracleId][timestamp] => bool
    mapping(address => mapping(uint256 => bool)) private dataExist;

    // EXTERNAL FUNCTIONS

    /// @notice Receives and caches data from `msg.sender`
    /// @param timestamp uint256 Timestamp of data
    /// @param data uint256 Data itself
    function __callback(uint256 timestamp, uint256 data) external {
        // Don't allow to push data twice
        require(!dataExist[msg.sender][timestamp], "O1");

        // Saving data
        dataCache[msg.sender][timestamp] = data;

        // Flagging that data were received
        dataExist[msg.sender][timestamp] = true;

        emit LogDataProvided(msg.sender, timestamp, data);
    }

    // VIEW FUNCTIONS

    /// @notice Returns cached data if they exist, or reverts with an error
    /// @param oracleId address Address of the `oracleId` smart contract
    /// @param timestamp uint256 Timestamp at which data were requested
    /// @return dataResult uint256 Cached data provided by `oracleId`
    function getData(address oracleId, uint256 timestamp) external view returns (uint256 dataResult) {
        // Check if Opium.OracleAggregator has data
        require(hasData(oracleId, timestamp), "O2");

        // Return cached data
        dataResult = dataCache[oracleId][timestamp];
    }

    /// @notice Getter for dataExist mapping
    /// @param oracleId address Address of the `oracleId` smart contract
    /// @param timestamp uint256 Timestamp at which data were requested
    /// @param result bool Returns whether data were provided already
    function hasData(address oracleId, uint256 timestamp) public view returns (bool result) {
        return dataExist[oracleId][timestamp];
    }

    // Reserved storage space to allow for layout changes in the future.
    uint256[50] private __gap;
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 800
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_oracleId","type":"address"},{"indexed":true,"internalType":"uint256","name":"_timestamp","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_data","type":"uint256"}],"name":"LogDataProvided","type":"event"},{"inputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint256","name":"data","type":"uint256"}],"name":"__callback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"oracleId","type":"address"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"getData","outputs":[{"internalType":"uint256","name":"dataResult","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"oracleId","type":"address"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"hasData","outputs":[{"internalType":"bool","name":"result","type":"bool"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50610297806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80632979d025146100465780633102e5ab1461006c578063c8384d2f14610081575b600080fd5b610059610054366004610207565b6100ca565b6040519081526020015b60405180910390f35b61007f61007a36600461023f565b61014d565b005b6100ba61008f366004610207565b6001600160a01b03919091166000908152600160209081526040808320938352929052205460ff1690565b6040519015158152602001610063565b6001600160a01b038216600090815260016020908152604080832084845290915281205460ff166101275760405162461bcd60e51b8152602060048201526002602482015261279960f11b60448201526064015b60405180910390fd5b506001600160a01b03909116600090815260208181526040808320938352929052205490565b33600090815260016020908152604080832085845290915290205460ff161561019d5760405162461bcd60e51b81526020600482015260026024820152614f3160f01b604482015260640161011e565b3360008181526020818152604080832086845282528083208590558383526001808352818420878552909252808320805460ff1916909217909155518392859290917fbafe09c91210ac772a509fe28b36bf6b3c82f1aa1db44d58721d57a9595417de9190a45050565b6000806040838503121561021a57600080fd5b82356001600160a01b038116811461023157600080fd5b946020939093013593505050565b6000806040838503121561025257600080fd5b5050803592602090910135915056fea2646970667358221220285c5e7f5702c9e18d23c3371355364ac0c60109d736d927c56bd1a49355bd7864736f6c63430008050033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100415760003560e01c80632979d025146100465780633102e5ab1461006c578063c8384d2f14610081575b600080fd5b610059610054366004610207565b6100ca565b6040519081526020015b60405180910390f35b61007f61007a36600461023f565b61014d565b005b6100ba61008f366004610207565b6001600160a01b03919091166000908152600160209081526040808320938352929052205460ff1690565b6040519015158152602001610063565b6001600160a01b038216600090815260016020908152604080832084845290915281205460ff166101275760405162461bcd60e51b8152602060048201526002602482015261279960f11b60448201526064015b60405180910390fd5b506001600160a01b03909116600090815260208181526040808320938352929052205490565b33600090815260016020908152604080832085845290915290205460ff161561019d5760405162461bcd60e51b81526020600482015260026024820152614f3160f01b604482015260640161011e565b3360008181526020818152604080832086845282528083208590558383526001808352818420878552909252808320805460ff1916909217909155518392859290917fbafe09c91210ac772a509fe28b36bf6b3c82f1aa1db44d58721d57a9595417de9190a45050565b6000806040838503121561021a57600080fd5b82356001600160a01b038116811461023157600080fd5b946020939093013593505050565b6000806040838503121561025257600080fd5b5050803592602090910135915056fea2646970667358221220285c5e7f5702c9e18d23c3371355364ac0c60109d736d927c56bd1a49355bd7864736f6c63430008050033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ 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.