ETH Price: $3,374.78 (-8.24%)

Contract

0x8fD3D838ffCEeB4FF4Dd5B0221A99C3B1dDB9aC9
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
UniswapV2PriceOracle

Compiler Version
v0.7.0+commit.9e61f92b

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, Apache-2.0 license

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2020-08-26
*/

// SPDX-License-Identifier: UNLICENSED
// https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/interfaces/IUniswapV2Pair.sol
pragma solidity ^0.7.0;

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}
// https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/interfaces/IUniswapV2Factory.sol


interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}
// Copyright 2017 Loopring Technology Limited.



/// @title Utility Functions for uint
/// @author Daniel Wang - <[email protected]>
library MathUint
{
    function mul(
        uint a,
        uint b
        )
        internal
        pure
        returns (uint c)
    {
        c = a * b;
        require(a == 0 || c / a == b, "MUL_OVERFLOW");
    }

    function sub(
        uint a,
        uint b
        )
        internal
        pure
        returns (uint)
    {
        require(b <= a, "SUB_UNDERFLOW");
        return a - b;
    }

    function add(
        uint a,
        uint b
        )
        internal
        pure
        returns (uint c)
    {
        c = a + b;
        require(c >= a, "ADD_OVERFLOW");
    }
}

// Copyright 2017 Loopring Technology Limited.



/// @title PriceOracle
interface PriceOracle
{
    // @dev Return's the token's value in ETH
    function tokenValue(address token, uint amount)
        external
        view
        returns (uint value);
}
// Copyright 2017 Loopring Technology Limited.








/// @title Uniswap2PriceOracle
/// @dev Returns the value in Ether for any given ERC20 token.
contract UniswapV2PriceOracle is PriceOracle
{
    using MathUint   for uint;

    IUniswapV2Factory factory;
    address wethAddress;

    constructor(
        IUniswapV2Factory _factory,
        address           _wethAddress
        )
    {
        factory = _factory;
        wethAddress = _wethAddress;
        require(_wethAddress != address(0), "INVALID_WETH_ADDRESS");
    }

    function tokenValue(address token, uint amount)
        external
        view
        override
        returns (uint)
    {
        if (amount == 0) return 0;
        if (token == address(0) || token == wethAddress) return amount;

        address pair = factory.getPair(token, wethAddress);
        if (pair == address(0)) {
            return 0;
        }

        (uint112 reserve0, uint112 reserve1,) = IUniswapV2Pair(pair).getReserves();

        if (reserve0 == 0 || reserve1 == 0) {
            return 0;
        }

        if (token < wethAddress) {
            return amount.mul(reserve1) / reserve0;
        } else {
            return amount.mul(reserve0) / reserve1;
        }
    }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract IUniswapV2Factory","name":"_factory","type":"address"},{"internalType":"address","name":"_wethAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"tokenValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b506040516103c23803806103c28339818101604052604081101561003357600080fd5b508051602090910151600080546001600160a01b038085166001600160a01b0319928316179092556001805492841692909116821790556100bb576040805162461bcd60e51b815260206004820152601460248201527f494e56414c49445f574554485f41444452455353000000000000000000000000604482015290519081900360640190fd5b50506102f6806100cc6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063f182178314610030575b600080fd5b61005c6004803603604081101561004657600080fd5b506001600160a01b03813516906020013561006e565b60408051918252519081900360200190f35b60008161007d57506000610262565b6001600160a01b03831615806100a057506001546001600160a01b038481169116145b156100ac575080610262565b600080546001546040805163e6a4390560e01b81526001600160a01b03888116600483015292831660248201529051919092169163e6a43905916044808301926020929190829003018186803b15801561010557600080fd5b505afa158015610119573d6000803e3d6000fd5b505050506040513d602081101561012f57600080fd5b505190506001600160a01b03811661014b576000915050610262565b600080826001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561018757600080fd5b505afa15801561019b573d6000803e3d6000fd5b505050506040513d60608110156101b157600080fd5b50805160209091015190925090506001600160701b03821615806101dc57506001600160701b038116155b156101ed5760009350505050610262565b6001546001600160a01b03908116908716101561023c57816001600160701b031661022a826001600160701b03168761026890919063ffffffff16565b8161023157fe5b049350505050610262565b806001600160701b031661022a836001600160701b03168761026890919063ffffffff16565b92915050565b81810282158061028057508183828161027d57fe5b04145b610262576040805162461bcd60e51b815260206004820152600c60248201526b4d554c5f4f564552464c4f5760a01b604482015290519081900360640190fdfea26469706673582212200d4aabfbb8d256f4cbcf777c7bd3731be119dc2d39fda35b454aae27185503bd64736f6c634300070000330000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063f182178314610030575b600080fd5b61005c6004803603604081101561004657600080fd5b506001600160a01b03813516906020013561006e565b60408051918252519081900360200190f35b60008161007d57506000610262565b6001600160a01b03831615806100a057506001546001600160a01b038481169116145b156100ac575080610262565b600080546001546040805163e6a4390560e01b81526001600160a01b03888116600483015292831660248201529051919092169163e6a43905916044808301926020929190829003018186803b15801561010557600080fd5b505afa158015610119573d6000803e3d6000fd5b505050506040513d602081101561012f57600080fd5b505190506001600160a01b03811661014b576000915050610262565b600080826001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561018757600080fd5b505afa15801561019b573d6000803e3d6000fd5b505050506040513d60608110156101b157600080fd5b50805160209091015190925090506001600160701b03821615806101dc57506001600160701b038116155b156101ed5760009350505050610262565b6001546001600160a01b03908116908716101561023c57816001600160701b031661022a826001600160701b03168761026890919063ffffffff16565b8161023157fe5b049350505050610262565b806001600160701b031661022a836001600160701b03168761026890919063ffffffff16565b92915050565b81810282158061028057508183828161027d57fe5b04145b610262576040805162461bcd60e51b815260206004820152600c60248201526b4d554c5f4f564552464c4f5760a01b604482015290519081900360640190fdfea26469706673582212200d4aabfbb8d256f4cbcf777c7bd3731be119dc2d39fda35b454aae27185503bd64736f6c63430007000033

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

0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

-----Decoded View---------------
Arg [0] : _factory (address): 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f
Arg [1] : _wethAddress (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f
Arg [1] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2


Deployed Bytecode Sourcemap

4579:1127:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4984:719;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;4984:719:0;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;5100:4;5126:11;5122:25;;-1:-1:-1;5146:1:0;5139:8;;5122:25;-1:-1:-1;;;;;5162:19:0;;;;:43;;-1:-1:-1;5194:11:0;;-1:-1:-1;;;;;5185:20:0;;;5194:11;;5185:20;5162:43;5158:62;;;-1:-1:-1;5214:6:0;5207:13;;5158:62;5233:12;5248:7;;;5271:11;5248:35;;;-1:-1:-1;;;5248:35:0;;-1:-1:-1;;;;;5248:35:0;;;;;;;5271:11;;;5248:35;;;;;;:7;;;;;:15;;:35;;;;;;;;;;;;;;:7;:35;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;5248:35:0;;-1:-1:-1;;;;;;5298:18:0;;5294:59;;5340:1;5333:8;;;;;5294:59;5366:16;5384;5420:4;-1:-1:-1;;;;;5405:32:0;;:34;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;5405:34:0;;;;;;;;;-1:-1:-1;5405:34:0;-1:-1:-1;;;;;;5456:13:0;;;;:30;;-1:-1:-1;;;;;;5473:13:0;;;5456:30;5452:71;;;5510:1;5503:8;;;;;;;5452:71;5547:11;;-1:-1:-1;;;;;5547:11:0;;;5539:19;;;;5535:161;;;5605:8;-1:-1:-1;;;;;5582:31:0;:20;5593:8;-1:-1:-1;;;;;5582:20:0;:6;:10;;:20;;;;:::i;:::-;:31;;;;;;5575:38;;;;;;;5535:161;5676:8;-1:-1:-1;;;;;5653:31:0;:20;5664:8;-1:-1:-1;;;;;5653:20:0;:6;:10;;:20;;;;:::i;4984:719::-;;;;;:::o;3537:205::-;3673:5;;;3697:6;;;:20;;;3716:1;3711;3707;:5;;;;;;:10;3697:20;3689:45;;;;;-1:-1:-1;;;3689:45:0;;;;;;;;;;;;-1:-1:-1;;;3689:45:0;;;;;;;;;;;;;

Swarm Source

ipfs://0d4aabfbb8d256f4cbcf777c7bd3731be119dc2d39fda35b454aae27185503bd

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

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

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.