Contract 0x5671B249391cA5E6a8FE28CEb1e85Dc41c12Ba7D 9

 
 
Txn Hash
Method
Block
From
To
Value
0xe81becd1467bb4137a2549d442a07f13b86cd565ca5ffa13f73c7ee8c621d847Get Result160017202022-11-19 4:37:359 days 1 hr ago0xbb822268a9c454733cdb176f97fcdbe30d80f419 IN  Impermax: Price Oracle0 Ether0.00053447 11.68437446
0xb31e6dbd89ef2a219f6dac22fffa316ea6c6221bd8f7c6924ed05161785759d1Get Result160007982022-11-19 1:32:239 days 4 hrs ago0xbb822268a9c454733cdb176f97fcdbe30d80f419 IN  Impermax: Price Oracle0 Ether0.00056764 12.40952064
0x003a1348cd8a315c87ce5d80df7b831a1cd2f286276f0fa82fa2a41981deb67fGet Result159992182022-11-18 20:14:599 days 9 hrs ago0xaa20eea8f8aa1ded9194a22389780e1de4ed6635 IN  Impermax: Price Oracle0 Ether0.00062876 13.74569864
0x4a7ebd976a2ceefd65d50a51cfa0db1701d2e201e7fe36fa716bb38e7a0ddc29Get Result159953232022-11-18 7:11:479 days 22 hrs ago0xaa20eea8f8aa1ded9194a22389780e1de4ed6635 IN  Impermax: Price Oracle0 Ether0.0005686 12.43039406
0x542738dfe19d6263797676c5d834feaf5e1a55dc38da6b3b4e52f5c151d7aa1cGet Result158649432022-10-31 2:05:4728 days 3 hrs ago0x000052dfaafc69dd59cc859908fb19bbf1559c48 IN  Impermax: Price Oracle0 Ether0.00036298 7.93532064
0x03531f9b1b0bc5bfe44257107ad7673500eea6d7ec1ad28924a33cf2e4046342Get Result158521812022-10-29 7:19:2329 days 22 hrs ago0x000052dfaafc69dd59cc859908fb19bbf1559c48 IN  Impermax: Price Oracle0 Ether0.00033912 9.03038907
0x4a3b1dfa62c8131b0c1951a7d10a7312bfc532070c88f239d4cbc7a1d9d17cdcGet Result157874462022-10-20 6:14:1138 days 23 hrs ago0x000052dfaafc69dd59cc859908fb19bbf1559c48 IN  Impermax: Price Oracle0 Ether0.00099325 21.71431697
0xf52b5a28cd3e9a70319b352d0d6d0a0e36774cb2a4aa54121c42c464921a0fdeGet Result143075832022-03-02 12:29:41270 days 17 hrs ago0x4b14ee9f20cfe7767ac819f0462a376895fa135e IN  Impermax: Price Oracle0 Ether0.00138379 36.87168699
0x3dd929d3f7bb5893b51bb9676dde6d86bd35228d61ada89da34669119c9781d1Get Result140740492022-01-25 9:47:00306 days 20 hrs ago0x45425ee1c7246c95550cafd742dc4c47097a9705 IN  Impermax: Price Oracle0 Ether0.00331181 72.4003875
0x8d83bc695c4a79df679aaee53d72e6eeea62d090e18a1771a72952bb5caf1dddGet Result140740462022-01-25 9:46:26306 days 20 hrs ago0x45425ee1c7246c95550cafd742dc4c47097a9705 IN  Impermax: Price Oracle0 Ether0.00332918 72.80080466
0x68b4410db646a0f1242ee823cb29fef383b4449250fbb16fdee0457f7e87b67bGet Result140740442022-01-25 9:46:06306 days 20 hrs ago0x45425ee1c7246c95550cafd742dc4c47097a9705 IN  Impermax: Price Oracle0 Ether0.00330125 72.17115926
0x00404976b89d636bdabaddb3cefb5703049e73c2acf33af0fa7c95d7a5836108Get Result140740442022-01-25 9:46:06306 days 20 hrs ago0x45425ee1c7246c95550cafd742dc4c47097a9705 IN  Impermax: Price Oracle0 Ether0.00330125 72.17115926
0x473578555dd45d3b43308f7231cf02b1388bd525f814393d72043a990a1b56a9Get Result140740402022-01-25 9:45:42306 days 20 hrs ago0x45425ee1c7246c95550cafd742dc4c47097a9705 IN  Impermax: Price Oracle0 Ether0.00403996 88.31882491
0x6b7a3c9d3964eaac129f27852dc8ece5dded55374a56ab6469408b25ff338228Get Result140740392022-01-25 9:45:24306 days 20 hrs ago0x45425ee1c7246c95550cafd742dc4c47097a9705 IN  Impermax: Price Oracle0 Ether0.0037708 82.43458075
0xe59af92261dc49f683a4a339c89052e8f37c527f698c7beca7b5db627ef4c2a7Get Result137526152021-12-06 13:41:51356 days 16 hrs ago0x42de752112560af0be62eb969eb76ecc1b4d100d IN  Impermax: Price Oracle0 Ether0.00469289 102.62187482
0x8f678df2d37d040610fed222bcb9fb95332391a831163f8136e01e66d1d823bbGet Result137526152021-12-06 13:41:51356 days 16 hrs ago0x42de752112560af0be62eb969eb76ecc1b4d100d IN  Impermax: Price Oracle0 Ether0.00469412 102.62187482
0x8aaa1e07925c22a5164d75fa9ec4975dc85ce1a8c46dd655c8cbaa6f1cf30187Get Result137525772021-12-06 13:30:45356 days 16 hrs ago0x5ec869c1cb378bb77bc55bb56129399f6828c8c5 IN  Impermax: Price Oracle0 Ether0.00295218 64.53990308
0x7b02869b0af36ed83381180ce4bb8c6326f09989cfdf46412922469e97dc4c6fGet Result134492832021-10-19 16:36:02404 days 13 hrs ago0x6db0218813f3b99d37a02956d3f6d47fbb4c129a IN  Impermax: Price Oracle0 Ether0.00402172 87.92195344
0x6ad5c77388b68139b11acf55906ccccaba6db21f5fed1662a08479ab67af0366Get Result133729772021-10-07 16:49:59416 days 13 hrs ago0x45425ee1c7246c95550cafd742dc4c47097a9705 IN  Impermax: Price Oracle0 Ether0.00479579 104.84441031
0xe50580d4064e07a9ba3d4439e74bf9fc213ee6a2a2408fc07a9d50d3560e1c5cGet Result133710772021-10-07 9:48:11416 days 20 hrs ago0x45425ee1c7246c95550cafd742dc4c47097a9705 IN  Impermax: Price Oracle0 Ether0.00406664 88.9039838
0x129c042ff933d81091e9de4afeea21ac75a81c26a67a7e1fa3e16ae3bb604b2fGet Result132364942021-09-16 11:30:45437 days 18 hrs ago0x45425ee1c7246c95550cafd742dc4c47097a9705 IN  Impermax: Price Oracle0 Ether0.00193335 42.26555131
0x6b3ccac4b122f90e86b3a68d261820880cd4f1473c9ffae08f6ba36fe529bc0bGet Result131198272021-08-29 10:27:58455 days 19 hrs ago0x5ec869c1cb378bb77bc55bb56129399f6828c8c5 IN  Impermax: Price Oracle0 Ether0.002067 45.18732925
0xbd5da9861117e4fc431b5d72ee50a483e710b61dba6d3d52d74726bc844aaa36Get Result128701442021-07-21 13:48:40494 days 16 hrs ago0x45425ee1c7246c95550cafd742dc4c47097a9705 IN  Impermax: Price Oracle0 Ether0.0007776317
0xcc1bce2dcd1661c51b68ec4c2c0c1488d075da981c8d18a60087132b907434e1Get Result128624252021-07-20 8:47:52495 days 21 hrs ago0x5ec869c1cb378bb77bc55bb56129399f6828c8c5 IN  Impermax: Price Oracle0 Ether0.0011893126
0x1873cdd249d5e4a54e0f8d1298860317a80d0c4241a81d8056594434ccd24b67Get Result128624242021-07-20 8:47:43495 days 21 hrs ago0x5ec869c1cb378bb77bc55bb56129399f6828c8c5 IN  Impermax: Price Oracle0 Ether0.0011892926
[ Download CSV Export 
View more zero value Internal Transactions in Advanced View mode
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SimpleUniswapOracle

Compiler Version
v0.5.16+commit.9c3226ce

Optimization Enabled:
Yes with 999999 runs

Other Settings:
default evmVersion
File 1 of 4 : SimpleUniswapOracle.sol
pragma solidity =0.5.16;

import "./libraries/UQ112x112.sol";
import "./interfaces/IUniswapV2Pair.sol";
import "./interfaces/ISimpleUniswapOracle.sol";

contract SimpleUniswapOracle is ISimpleUniswapOracle {
	using UQ112x112 for uint224;
	
	uint32 public constant MIN_T = 1800;
	
	struct Pair {
		uint256 priceCumulativeA;
		uint256 priceCumulativeB;
		uint32 updateA;
		uint32 updateB;
		bool lastIsA;
		bool initialized;
	}
	mapping(address => Pair) public getPair;

	event PriceUpdate(address indexed pair, uint256 priceCumulative, uint32 blockTimestamp, bool lastIsA);
	
	function toUint224(uint256 input) internal pure returns (uint224) {
		require(input <= uint224(-1), "UniswapOracle: UINT224_OVERFLOW");
		return uint224(input);
	}
	
	function getPriceCumulativeCurrent(address uniswapV2Pair) internal view returns (uint256 priceCumulative) {
		priceCumulative = IUniswapV2Pair(uniswapV2Pair).price0CumulativeLast();
		(uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(uniswapV2Pair).getReserves();
		uint224 priceLast = UQ112x112.encode(reserve1).uqdiv(reserve0);
		uint32 timeElapsed = getBlockTimestamp() - blockTimestampLast; // overflow is desired
		// * never overflows, and + overflow is desired
		priceCumulative += uint256(priceLast) * timeElapsed;
	}
	
	function initialize(address uniswapV2Pair) external {
		Pair storage pairStorage = getPair[uniswapV2Pair];
		require(!pairStorage.initialized, "UniswapOracle: ALREADY_INITIALIZED");
		
		uint256 priceCumulativeCurrent = getPriceCumulativeCurrent(uniswapV2Pair);
		uint32 blockTimestamp = getBlockTimestamp();
		pairStorage.priceCumulativeA = priceCumulativeCurrent;
		pairStorage.priceCumulativeB = priceCumulativeCurrent;
		pairStorage.updateA = blockTimestamp;
		pairStorage.updateB = blockTimestamp;
		pairStorage.lastIsA = true;
		pairStorage.initialized = true;
		emit PriceUpdate(uniswapV2Pair, priceCumulativeCurrent, blockTimestamp, true);
	}
	
	function getResult(address uniswapV2Pair) external returns (uint224 price, uint32 T) {
		Pair memory pair = getPair[uniswapV2Pair];
		require(pair.initialized, "UniswapOracle: NOT_INITIALIZED");
		Pair storage pairStorage = getPair[uniswapV2Pair];
				
		uint32 blockTimestamp = getBlockTimestamp();
		uint32 updateLast = pair.lastIsA ? pair.updateA : pair.updateB;
		uint256 priceCumulativeCurrent = getPriceCumulativeCurrent(uniswapV2Pair);
		uint256 priceCumulativeLast;
		
		if (blockTimestamp - updateLast >= MIN_T) {
			// update
			priceCumulativeLast = pair.lastIsA ? pair.priceCumulativeA : pair.priceCumulativeB;
			if (pair.lastIsA) {
				pairStorage.priceCumulativeB = priceCumulativeCurrent;
				pairStorage.updateB = blockTimestamp;
			} else {
				pairStorage.priceCumulativeA = priceCumulativeCurrent;
				pairStorage.updateA = blockTimestamp;
			}
			pairStorage.lastIsA = !pair.lastIsA;
			emit PriceUpdate(uniswapV2Pair, priceCumulativeCurrent, blockTimestamp, !pair.lastIsA);
		}
		else {
			// don't update and return price using previous priceCumulative
			updateLast = pair.lastIsA ? pair.updateB : pair.updateA;
			priceCumulativeLast = pair.lastIsA ? pair.priceCumulativeB : pair.priceCumulativeA;
		}
		
		T = blockTimestamp - updateLast; // overflow is desired
		require(T >= MIN_T, "UniswapOracle: NOT_READY"); //reverts only if the pair has just been initialized
		// / is safe, and - overflow is desired
		price = toUint224((priceCumulativeCurrent - priceCumulativeLast) / T);
	}
	
	/*** Utilities ***/
	
	function getBlockTimestamp() public view returns (uint32) {
		return uint32(block.timestamp % 2**32);
	}
}

File 2 of 4 : ISimpleUniswapOracle.sol
pragma solidity =0.5.16;

interface ISimpleUniswapOracle {
	event PriceUpdate(address indexed pair, uint256 priceCumulative, uint32 blockTimestamp, bool lastIsA);
	function MIN_T() external pure returns (uint32);
	function getBlockTimestamp() external view returns (uint32);
	function getPair(address uniswapV2Pair) external view returns (
		uint256 priceCumulativeA,
		uint256 priceCumulativeB,
		uint32 updateA,
		uint32 updateB,
		bool lastIsA,
		bool initialized
	);
	function initialize(address uniswapV2Pair) external;
	function getResult(address uniswapV2Pair) external returns (uint224 price, uint32 T);
}

File 3 of 4 : IUniswapV2Pair.sol
pragma solidity =0.5.16;

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 view returns (string memory);
    function symbol() external view returns (string memory);
    function decimals() external view 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 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);
}

File 4 of 4 : UQ112x112.sol
pragma solidity =0.5.16;

// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))

// range: [0, 2**112 - 1]
// resolution: 1 / 2**112

library UQ112x112 {
    uint224 constant Q112 = 2**112;

    // encode a uint112 as a UQ112x112
    function encode(uint112 y) internal pure returns (uint224 z) {
        z = uint224(y) * Q112; // never overflows
    }

    // divide a UQ112x112 by a uint112, returning a UQ112x112
    function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {
        z = x / uint224(y);
    }
}

Settings
{
  "remappings": [],
  "optimizer": {
    "enabled": true,
    "runs": 999999
  },
  "evmVersion": "istanbul",
  "libraries": {},
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pair","type":"address"},{"indexed":false,"internalType":"uint256","name":"priceCumulative","type":"uint256"},{"indexed":false,"internalType":"uint32","name":"blockTimestamp","type":"uint32"},{"indexed":false,"internalType":"bool","name":"lastIsA","type":"bool"}],"name":"PriceUpdate","type":"event"},{"constant":true,"inputs":[],"name":"MIN_T","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getBlockTimestamp","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"getPair","outputs":[{"internalType":"uint256","name":"priceCumulativeA","type":"uint256"},{"internalType":"uint256","name":"priceCumulativeB","type":"uint256"},{"internalType":"uint32","name":"updateA","type":"uint32"},{"internalType":"uint32","name":"updateB","type":"uint32"},{"internalType":"bool","name":"lastIsA","type":"bool"},{"internalType":"bool","name":"initialized","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"uniswapV2Pair","type":"address"}],"name":"getResult","outputs":[{"internalType":"uint224","name":"price","type":"uint224"},{"internalType":"uint32","name":"T","type":"uint32"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"uniswapV2Pair","type":"address"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50610a99806100206000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c8063796b89b911610050578063796b89b91461014d578063c4d66de81461016e578063f51b5531146101a357610067565b80631a788a021461006c578063446a37e0146100dd575b600080fd5b61009f6004803603602081101561008257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166101ab565b60408051968752602087019590955263ffffffff938416868601529190921660608501529015156080840152151560a0830152519081900360c00190f35b610110600480360360208110156100f357600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610200565b604080517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff909316835263ffffffff90911660208301528051918290030190f35b61015561058f565b6040805163ffffffff9092168252519081900360200190f35b6101a16004803603602081101561018457600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610599565b005b61015561076f565b60006020819052908152604090208054600182015460029092015490919063ffffffff8082169164010000000081049091169060ff680100000000000000008204811691690100000000000000000090041686565b60008061020b610a0d565b5073ffffffffffffffffffffffffffffffffffffffff831660009081526020818152604091829020825160c081018452815481526001820154928101929092526002015463ffffffff808216938301939093526401000000008104909216606082015260ff6801000000000000000083048116151560808301526901000000000000000000909204909116151560a0820181905261030a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f556e69737761704f7261636c653a204e4f545f494e495449414c495a45440000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff841660009081526020819052604081209061033861058f565b90506000836080015161034f578360600151610355565b83604001515b9050600061036288610775565b9050600061070883850363ffffffff16106104b857856080015161038a57856020015161038d565b85515b90508560800151156103de57600185018290556002850180547fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff1664010000000063ffffffff871602179055610414565b8185556002850180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000001663ffffffff86161790555b60808601516002860180546801000000000000000092159283027fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff9091161790556040805184815263ffffffff87166020820152808201929092525173ffffffffffffffffffffffffffffffffffffffff8b16917fc58c63744da19faddae8e37958053493f49d71b8f78d4facf6002cd1c2618fcf919081900360600190a26104ec565b85608001516104cb5785604001516104d1565b85606001515b925085608001516104e35785516104e9565b85602001515b90505b828403965061070863ffffffff8816101561056857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f556e69737761704f7261636c653a204e4f545f52454144590000000000000000604482015290519081900360640190fd5b6105828763ffffffff168284038161057c57fe5b04610917565b9750505050505050915091565b63ffffffff421690565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260208190526040902060028101546901000000000000000000900460ff1615610629576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610a436022913960400191505060405180910390fd5b600061063483610775565b9050600061064061058f565b82845560018085018490556002850180546901000000000000000000680100000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000090921663ffffffff86169081177fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff166401000000008202177fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16929092177fffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffffff161790915560408051868152602081019290925281810192909252905191925073ffffffffffffffffffffffffffffffffffffffff8616917fc58c63744da19faddae8e37958053493f49d71b8f78d4facf6002cd1c2618fcf916060908290030190a250505050565b61070881565b60008173ffffffffffffffffffffffffffffffffffffffff16635909c0d56040518163ffffffff1660e01b815260040160206040518083038186803b1580156107bd57600080fd5b505afa1580156107d1573d6000803e3d6000fd5b505050506040513d60208110156107e757600080fd5b5051604080517f0902f1ac00000000000000000000000000000000000000000000000000000000815290519192506000918291829173ffffffffffffffffffffffffffffffffffffffff871691630902f1ac916004808301926060929190829003018186803b15801561085957600080fd5b505afa15801561086d573d6000803e3d6000fd5b505050506040513d606081101561088357600080fd5b5080516020820151604090920151909450909250905060006108d2846108a8856109a8565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff6109cc16565b90506000826108df61058f565b0390508063ffffffff16827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1602860195505050505050919050565b60007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8211156109a457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f556e69737761704f7261636c653a2055494e543232345f4f564552464c4f5700604482015290519081900360640190fd5b5090565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681610a0557fe5b049392505050565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a08101919091529056fe556e69737761704f7261636c653a20414c52454144595f494e495449414c495a4544a265627a7a72315820dad917d6d934fc03eefe520cad27d09e3cd5a3da667c792e26ccb077cc014b9e64736f6c63430005100032

Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.

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.