POL Price: $0.69112 (-2.19%)
Gas: 30 GWei
 

Overview

POL Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 POL

POL Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

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

Contract Source Code Verified (Exact Match)

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"}]

608060405234801561001057600080fd5b50604051610963380380610963833981810160405260a081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b90830190602082018581111561006857600080fd5b825164010000000081118282018810171561008257600080fd5b82525081516020918201929091019080838360005b838110156100af578181015183820152602001610097565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156100ff57600080fd5b90830190602082018581111561011457600080fd5b825164010000000081118282018810171561012e57600080fd5b82525081516020918201929091019080838360005b8381101561015b578181015183820152602001610143565b50505050905090810190601f1680156101885780820380516001836020036101000a031916815260200191505b506040818152602083015192018051929491939192846401000000008211156101b057600080fd5b9083019060208201858111156101c557600080fd5b82516401000000008111828201881017156101df57600080fd5b82525081516020918201929091019080838360005b8381101561020c5781810151838201526020016101f4565b50505050905090810190601f1680156102395780820380516001836020036101000a031916815260200191505b50604052602090810151875190935061025892506002918801906102c6565b50835161026c9060009060208701906102c6565b50600380546001600160a01b0319166001600160a01b038516179055815161029b9060019060208501906102c6565b50600480546001600160a01b0319166001600160a01b03929092169190911790555061036192505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061030757805160ff1916838001178555610334565b82800160010185558215610334579182015b82811115610334578251825591602001919060010190610319565b50610340929150610344565b5090565b61035e91905b80821115610340576000815560010161034a565b90565b6105f3806103706000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c80632ac50df11461006757806350d25bcd1461008b5780639187179e146100a5578063a763d42e14610122578063da82ed1a1461012a578063f397f22a14610132575b600080fd5b61006f61013a565b604080516001600160a01b039092168252519081900360200190f35b610093610149565b60408051918252519081900360200190f35b6100ad61025c565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100e75781810151838201526020016100cf565b50505050905090810190601f1680156101145780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100ad6102e9565b61006f610344565b6100ad610353565b6003546001600160a01b031681565b6000806101ce600360009054906101000a90046001600160a01b03166001600160a01b03166350d25bcd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561019d57600080fd5b505afa1580156101b1573d6000803e3d6000fd5b505050506040513d60208110156101c757600080fd5b50516103ab565b90506000610223600460009054906101000a90046001600160a01b03166001600160a01b03166350d25bcd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561019d57600080fd5b90506102556102508261024485670de0b6b3a764000063ffffffff6103ff16565b9063ffffffff61046116565b6104a3565b9250505090565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156102e15780601f106102b6576101008083540402835291602001916102e1565b820191906000526020600020905b8154815290600101906020018083116102c457829003601f168201915b505050505081565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156102e15780601f106102b6576101008083540402835291602001916102e1565b6004546001600160a01b031681565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156102e15780601f106102b6576101008083540402835291602001916102e1565b6000808212156103fb576040805162461bcd60e51b815260206004820152601660248201527576616c7565206d75737420626520706f73697469766560501b604482015290519081900360640190fd5b5090565b60008261040e5750600061045b565b8282028284828161041b57fe5b04146104585760405162461bcd60e51b815260040180806020018281038252602181526020018061059e6021913960400191505060405180910390fd5b90505b92915050565b600061045883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506104fb565b600060001982106103fb576040805162461bcd60e51b815260206004820152601d60248201527f76616c756520646f65736e27742066697420696e203235362062697473000000604482015290519081900360640190fd5b600081836105875760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561054c578181015183820152602001610534565b50505050905090810190601f1680156105795780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161059357fe5b049594505050505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a265627a7a72315820c9150160820586cb2c9e00ddd0dd05d28e3ecb3faa64b0a12ec2869b3d27487864736f6c634300050e003200000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000fc539a559e170f848323e19dfd660075205100850000000000000000000000000000000000000000000000000000000000000120000000000000000000000000327e23a4855b6f663a28c5161541d69af897330200000000000000000000000000000000000000000000000000000000000000094441492f4d41544943000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000074441492f4554480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000094d415449432f4554480000000000000000000000000000000000000000000000

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100625760003560e01c80632ac50df11461006757806350d25bcd1461008b5780639187179e146100a5578063a763d42e14610122578063da82ed1a1461012a578063f397f22a14610132575b600080fd5b61006f61013a565b604080516001600160a01b039092168252519081900360200190f35b610093610149565b60408051918252519081900360200190f35b6100ad61025c565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100e75781810151838201526020016100cf565b50505050905090810190601f1680156101145780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100ad6102e9565b61006f610344565b6100ad610353565b6003546001600160a01b031681565b6000806101ce600360009054906101000a90046001600160a01b03166001600160a01b03166350d25bcd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561019d57600080fd5b505afa1580156101b1573d6000803e3d6000fd5b505050506040513d60208110156101c757600080fd5b50516103ab565b90506000610223600460009054906101000a90046001600160a01b03166001600160a01b03166350d25bcd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561019d57600080fd5b90506102556102508261024485670de0b6b3a764000063ffffffff6103ff16565b9063ffffffff61046116565b6104a3565b9250505090565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156102e15780601f106102b6576101008083540402835291602001916102e1565b820191906000526020600020905b8154815290600101906020018083116102c457829003601f168201915b505050505081565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156102e15780601f106102b6576101008083540402835291602001916102e1565b6004546001600160a01b031681565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156102e15780601f106102b6576101008083540402835291602001916102e1565b6000808212156103fb576040805162461bcd60e51b815260206004820152601660248201527576616c7565206d75737420626520706f73697469766560501b604482015290519081900360640190fd5b5090565b60008261040e5750600061045b565b8282028284828161041b57fe5b04146104585760405162461bcd60e51b815260040180806020018281038252602181526020018061059e6021913960400191505060405180910390fd5b90505b92915050565b600061045883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506104fb565b600060001982106103fb576040805162461bcd60e51b815260206004820152601d60248201527f76616c756520646f65736e27742066697420696e203235362062697473000000604482015290519081900360640190fd5b600081836105875760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561054c578181015183820152602001610534565b50505050905090810190601f1680156105795780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161059357fe5b049594505050505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a265627a7a72315820c9150160820586cb2c9e00ddd0dd05d28e3ecb3faa64b0a12ec2869b3d27487864736f6c634300050e0032

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000fc539a559e170f848323e19dfd660075205100850000000000000000000000000000000000000000000000000000000000000120000000000000000000000000327e23a4855b6f663a28c5161541d69af897330200000000000000000000000000000000000000000000000000000000000000094441492f4d41544943000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000074441492f4554480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000094d415449432f4554480000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _targetPairName (string): DAI/MATIC
Arg [1] : _tokenPairName (string): DAI/ETH
Arg [2] : _tokenPriceOracle (address): 0xFC539A559e170f848323e19dfD66007520510085
Arg [3] : _maticPairName (string): MATIC/ETH
Arg [4] : _maticPriceOracle (address): 0x327e23A4855b6F663a28c5161541d69Af8973302

-----Encoded View---------------
11 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000000000000000a0
Arg [1] : 00000000000000000000000000000000000000000000000000000000000000e0
Arg [2] : 000000000000000000000000fc539a559e170f848323e19dfd66007520510085
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000120
Arg [4] : 000000000000000000000000327e23a4855b6f663a28c5161541d69af8973302
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000009
Arg [6] : 4441492f4d415449430000000000000000000000000000000000000000000000
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000007
Arg [8] : 4441492f45544800000000000000000000000000000000000000000000000000
Arg [9] : 0000000000000000000000000000000000000000000000000000000000000009
Arg [10] : 4d415449432f4554480000000000000000000000000000000000000000000000


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

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

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.