MATIC Price: $0.709336 (-0.86%)
Gas: 32 GWei
 

Overview

MATIC Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 MATIC

MATIC Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
0x60806040215539532021-11-19 12:30:28911 days ago1637325028IN
 Contract Creation
0 MATIC0.0153125430

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

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x48152e8C...717af2C09
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
ToMaticOracle

Compiler Version
v0.5.14+commit.01f1aaa4

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, GNU LGPLv2.1 license
/**
 *Submitted for verification at polygonscan.com on 2021-11-23
*/

pragma solidity 0.5.14;


interface AggregatorInterface {
  function latestAnswer() external view returns (int256);
  function latestTimestamp() external view returns (uint256);
  function latestRound() external view returns (uint256);
  function getAnswer(uint256 roundId) external view returns (int256);
  function getTimestamp(uint256 roundId) external view returns (uint256);

  event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 timestamp);
  event NewRound(uint256 indexed roundId, address indexed startedBy);
}

library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     *
     * _Available since v2.4.0._
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

// SPDX-License-Identifier: BUSL-1.1
contract ToMaticOracle {
    using SafeMath for uint256;
    string public tokenPairName;
    string public maticPairName;
    string public targetPairName;
    // example pair DAI/ETH
    AggregatorInterface public tokenPriceOracle;
    // example pair MATIC/ETH
    AggregatorInterface public maticPriceOracle;

    constructor(
        string memory _targetPairName,
        string memory _tokenPairName,
        AggregatorInterface _tokenPriceOracle,
        string memory _maticPairName,
        AggregatorInterface _maticPriceOracle
    ) public {
        targetPairName = _targetPairName;

        // pair1
        tokenPairName = _tokenPairName;
        tokenPriceOracle = _tokenPriceOracle;

        // pair2
        maticPairName = _maticPairName;
        maticPriceOracle = _maticPriceOracle;
    }

    function latestAnswer() external view returns (int256) {
        // 1 DAI rate is represented in ETH
        uint256 tokenPrice = toUint256(tokenPriceOracle.latestAnswer());
        // 1 MATIC rate is repsented in ETH
        uint256 maticPrice = toUint256(maticPriceOracle.latestAnswer());
        // number of MATIC in 1 ETH
        // `10^18 / maticPrice = X`   number of MATIC
        // `tokenPrice * X` = DAI/MATIC rate
        return toInt256(tokenPrice.mul(10**18).div(maticPrice));

    }

    function toInt256(uint256 value) internal pure returns (int256) {
        require(value < uint256(-1), "value doesn\'t fit in 256 bits");
        return int256(value);
    }

    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "value must be positive");
        return uint256(value);
    }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"string","name":"_targetPairName","type":"string"},{"internalType":"string","name":"_tokenPairName","type":"string"},{"internalType":"contract AggregatorInterface","name":"_tokenPriceOracle","type":"address"},{"internalType":"string","name":"_maticPairName","type":"string"},{"internalType":"contract AggregatorInterface","name":"_maticPriceOracle","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":true,"inputs":[],"name":"latestAnswer","outputs":[{"internalType":"int256","name":"","type":"int256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"maticPairName","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"maticPriceOracle","outputs":[{"internalType":"contract AggregatorInterface","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"targetPairName","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"tokenPairName","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"tokenPriceOracle","outputs":[{"internalType":"contract AggregatorInterface","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100625760003560e01c80632ac50df11461006757806350d25bcd1461008b5780639187179e146100a5578063a763d42e14610122578063da82ed1a1461012a578063f397f22a14610132575b600080fd5b61006f61013a565b604080516001600160a01b039092168252519081900360200190f35b610093610149565b60408051918252519081900360200190f35b6100ad61025c565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100e75781810151838201526020016100cf565b50505050905090810190601f1680156101145780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100ad6102e9565b61006f610344565b6100ad610353565b6003546001600160a01b031681565b6000806101ce600360009054906101000a90046001600160a01b03166001600160a01b03166350d25bcd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561019d57600080fd5b505afa1580156101b1573d6000803e3d6000fd5b505050506040513d60208110156101c757600080fd5b50516103ab565b90506000610223600460009054906101000a90046001600160a01b03166001600160a01b03166350d25bcd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561019d57600080fd5b90506102556102508261024485670de0b6b3a764000063ffffffff6103ff16565b9063ffffffff61046116565b6104a3565b9250505090565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156102e15780601f106102b6576101008083540402835291602001916102e1565b820191906000526020600020905b8154815290600101906020018083116102c457829003601f168201915b505050505081565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156102e15780601f106102b6576101008083540402835291602001916102e1565b6004546001600160a01b031681565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156102e15780601f106102b6576101008083540402835291602001916102e1565b6000808212156103fb576040805162461bcd60e51b815260206004820152601660248201527576616c7565206d75737420626520706f73697469766560501b604482015290519081900360640190fd5b5090565b60008261040e5750600061045b565b8282028284828161041b57fe5b04146104585760405162461bcd60e51b815260040180806020018281038252602181526020018061059e6021913960400191505060405180910390fd5b90505b92915050565b600061045883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506104fb565b600060001982106103fb576040805162461bcd60e51b815260206004820152601d60248201527f76616c756520646f65736e27742066697420696e203235362062697473000000604482015290519081900360640190fd5b600081836105875760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561054c578181015183820152602001610534565b50505050905090810190601f1680156105795780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161059357fe5b049594505050505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a265627a7a72315820c9150160820586cb2c9e00ddd0dd05d28e3ecb3faa64b0a12ec2869b3d27487864736f6c634300050e0032

Deployed Bytecode Sourcemap

5449:1706:0:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;5449:1706:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5644:43;;;:::i;:::-;;;;-1:-1:-1;;;;;5644:43:0;;;;;;;;;;;;;;6292:507;;;:::i;:::-;;;;;;;;;;;;;;;;5546:27;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:100:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;5546:27:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5512;;;:::i;5725:43::-;;;:::i;5580:28::-;;;:::i;5644:43::-;;;-1:-1:-1;;;;;5644:43:0;;:::o;6292:507::-;6339:6;6403:18;6424:42;6434:16;;;;;;;;;-1:-1:-1;;;;;6434:16:0;-1:-1:-1;;;;;6434:29:0;;:31;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;6434:31:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;6434:31:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;6434:31:0;6424:9;:42::i;:::-;6403:63;;6522:18;6543:42;6553:16;;;;;;;;;-1:-1:-1;;;;;6553:16:0;-1:-1:-1;;;;;6553:29:0;;:31;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;6543:42:0;6522:63;-1:-1:-1;6741:48:0;6750:38;6522:63;6750:22;:10;6765:6;6750:22;:14;:22;:::i;:::-;:26;:38;:26;:38;:::i;:::-;6741:8;:48::i;:::-;6734:55;;;;6292:507;:::o;5546:27::-;;;;;;;;;;;;;;;-1:-1:-1;;5546:27:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;5512:::-;;;;;;;;;;;;;;;-1:-1:-1;;5512:27:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5725:43;;;-1:-1:-1;;;;;5725:43:0;;:::o;5580:28::-;;;;;;;;;;;;;;-1:-1:-1;;5580:28:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6991:161;7047:7;7084:1;7075:5;:10;;7067:45;;;;;-1:-1:-1;;;7067:45:0;;;;;;;;;;;;-1:-1:-1;;;7067:45:0;;;;;;;;;;;;;;;-1:-1:-1;7138:5:0;6991:161::o;2186:471::-;2244:7;2489:6;2485:47;;-1:-1:-1;2519:1:0;2512:8;;2485:47;2556:5;;;2560:1;2556;:5;:1;2580:5;;;;;:10;2572:56;;;;-1:-1:-1;;;2572:56:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2648:1;-1:-1:-1;2186:471:0;;;;;:::o;3125:132::-;3183:7;3210:39;3214:1;3217;3210:39;;;;;;;;;;;;;;;;;:3;:39::i;6807:176::-;6863:6;-1:-1:-1;;6890:5:0;:19;6882:62;;;;;-1:-1:-1;;;6882:62:0;;;;;;;;;;;;;;;;;;;;;;;;;;;3787:345;3873:7;3975:12;3968:5;3960:28;;;;-1:-1:-1;;;3960:28:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;3960:28:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3999:9;4015:1;4011;:5;;;;;;;3787:345;-1:-1:-1;;;;;3787:345:0:o

Swarm Source

bzzr://c9150160820586cb2c9e00ddd0dd05d28e3ecb3faa64b0a12ec2869b3d274878

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction 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.