Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 7,929 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Update | 21439720 | 30 mins ago | IN | 0 ETH | 0.00100373 | ||||
Update | 21439421 | 1 hr ago | IN | 0 ETH | 0.00114182 | ||||
Update | 21439123 | 2 hrs ago | IN | 0 ETH | 0.00258966 | ||||
Update | 21438825 | 3 hrs ago | IN | 0 ETH | 0.00332977 | ||||
Update | 21438525 | 4 hrs ago | IN | 0 ETH | 0.00358903 | ||||
Update | 21438227 | 5 hrs ago | IN | 0 ETH | 0.00508276 | ||||
Update | 21437929 | 6 hrs ago | IN | 0 ETH | 0.00170748 | ||||
Update | 21437629 | 7 hrs ago | IN | 0 ETH | 0.00171429 | ||||
Update | 21437331 | 8 hrs ago | IN | 0 ETH | 0.00140528 | ||||
Update | 21437033 | 9 hrs ago | IN | 0 ETH | 0.00093852 | ||||
Update | 21436733 | 10 hrs ago | IN | 0 ETH | 0.00091064 | ||||
Update | 21436436 | 11 hrs ago | IN | 0 ETH | 0.00076983 | ||||
Update | 21436138 | 12 hrs ago | IN | 0 ETH | 0.00113969 | ||||
Update | 21435840 | 13 hrs ago | IN | 0 ETH | 0.00085794 | ||||
Update | 21435542 | 14 hrs ago | IN | 0 ETH | 0.00068633 | ||||
Update | 21435245 | 15 hrs ago | IN | 0 ETH | 0.00069188 | ||||
Update | 21434948 | 16 hrs ago | IN | 0 ETH | 0.00067242 | ||||
Update | 21434649 | 17 hrs ago | IN | 0 ETH | 0.00073611 | ||||
Update | 21434350 | 18 hrs ago | IN | 0 ETH | 0.00072284 | ||||
Update | 21434051 | 19 hrs ago | IN | 0 ETH | 0.00070712 | ||||
Update | 21433753 | 20 hrs ago | IN | 0 ETH | 0.00136354 | ||||
Update | 21433458 | 21 hrs ago | IN | 0 ETH | 0.00117535 | ||||
Update | 21433161 | 22 hrs ago | IN | 0 ETH | 0.00086619 | ||||
Update | 21432863 | 23 hrs ago | IN | 0 ETH | 0.00100996 | ||||
Update | 21432564 | 24 hrs ago | IN | 0 ETH | 0.00099469 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
UniswapV2OracleV2
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import '@openzeppelin/contracts/utils/math/SafeMath.sol'; import '@openzeppelin/contracts/access/Ownable.sol'; import '../libraries/FixedPoint.sol'; import '../interfaces/IPriceOracleAggregator.sol'; import '../interfaces/IUniswapV2Pair.sol'; import '../interfaces/IUniswapV2Factory.sol'; import {UniswapV2Oracle} from './UniswapV2Oracle.sol'; interface IERC20Metadata { function decimals() external view returns (uint8); } library UniswapV2Library { using SafeMath for uint256; // returns sorted token addresses, used to handle return values from pairs sorted in this order function sortTokens( address tokenA, address tokenB ) internal pure returns (address token0, address token1) { require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS'); } // Less efficient than the CREATE2 method below function pairFor( address factory, address tokenA, address tokenB ) internal view returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = IUniswapV2Factory(factory).getPair(token0, token1); } // calculates the CREATE2 address for a pair without making any external calls function pairForCreate2( address factory, address tokenA, address tokenB ) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address( uint160( bytes20( keccak256( abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash ) ) ) ) ); // this matches the CREATE2 in UniswapV2Factory.createPair } // fetches and sorts the reserves for a pair function getReserves( address factory, address tokenA, address tokenB ) internal view returns (uint256 reserveA, uint256 reserveB) { (address token0, ) = sortTokens(tokenA, tokenB); (uint256 reserve0, uint256 reserve1, ) = IUniswapV2Pair( pairFor(factory, tokenA, tokenB) ).getReserves(); (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0); } // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset function quote( uint256 amountA, uint256 reserveA, uint256 reserveB ) internal pure returns (uint256 amountB) { require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT'); require( reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY' ); amountB = amountA.mul(reserveB) / reserveA; } // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut( uint256 amountIn, uint256 reserveIn, uint256 reserveOut ) internal pure returns (uint256 amountOut) { require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT'); require( reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY' ); uint256 amountInWithFee = amountIn.mul(997); uint256 numerator = amountInWithFee.mul(reserveOut); uint256 denominator = reserveIn.mul(1000).add(amountInWithFee); amountOut = numerator / denominator; } // given an output amount of an asset and pair reserves, returns a required input amount of the other asset function getAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut ) internal pure returns (uint256 amountIn) { require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT'); require( reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY' ); uint256 numerator = reserveIn.mul(amountOut).mul(1000); uint256 denominator = reserveOut.sub(amountOut).mul(997); amountIn = (numerator / denominator).add(1); } // performs chained getAmountOut calculations on any number of pairs function getAmountsOut( address factory, uint256 amountIn, address[] memory path ) internal view returns (uint256[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint256[](path.length); amounts[0] = amountIn; for (uint256 i = 0; i < path.length - 1; i++) { (uint256 reserveIn, uint256 reserveOut) = getReserves( factory, path[i], path[i + 1] ); amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut); } } // performs chained getAmountIn calculations on any number of pairs function getAmountsIn( address factory, uint256 amountOut, address[] memory path ) internal view returns (uint256[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint256[](path.length); amounts[amounts.length - 1] = amountOut; for (uint256 i = path.length - 1; i > 0; i--) { (uint256 reserveIn, uint256 reserveOut) = getReserves( factory, path[i - 1], path[i] ); amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut); } } } library UniswapV2OracleLibrary { using FixedPoint for *; // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1] function currentBlockTimestamp() internal view returns (uint32) { return uint32(block.timestamp % 2 ** 32); } // produces the cumulative price using counterfactuals to save gas and avoid a call to sync. function currentCumulativePrices( address pair ) internal view returns ( uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp ) { blockTimestamp = currentBlockTimestamp(); price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast(); price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast(); // if time has elapsed since the last update on the pair, mock the accumulated price values ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ) = IUniswapV2Pair(pair).getReserves(); if (blockTimestampLast != blockTimestamp) { // subtraction overflow is desired uint32 timeElapsed = blockTimestamp - blockTimestampLast; // addition overflow is desired // counterfactual price0Cumulative += uint256(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed; // counterfactual price1Cumulative += uint256(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed; } } } contract UniswapV2OracleV2 is IOracle, Ownable { using FixedPoint for *; /// @notice oracle that returns price in USD IPriceOracleAggregator public immutable aggregator; uint256 public PERIOD = 1; // 1 hour TWAP (time-weighted average price) uint256 public CONSULT_LENIENCY = 120; // Used for being able to consult past the period end bool public ALLOW_STALE_CONSULTS = false; // If false, consult() will fail if the TWAP is stale IUniswapV2Pair public immutable pair; bool public isFirstToken; address public immutable token0; address public immutable token1; uint256 public price0CumulativeLast; uint256 public price1CumulativeLast; uint32 public blockTimestampLast; FixedPoint.uq112x112 public price0Average; FixedPoint.uq112x112 public price1Average; constructor(address _prevAggregator) { aggregator = UniswapV2Oracle(_prevAggregator).aggregator(); PERIOD = UniswapV2Oracle(_prevAggregator).PERIOD(); CONSULT_LENIENCY = UniswapV2Oracle(_prevAggregator).CONSULT_LENIENCY(); ALLOW_STALE_CONSULTS = UniswapV2Oracle(_prevAggregator) .ALLOW_STALE_CONSULTS(); pair = UniswapV2Oracle(_prevAggregator).pair(); isFirstToken = UniswapV2Oracle(_prevAggregator).isFirstToken(); token0 = UniswapV2Oracle(_prevAggregator).token0(); token1 = UniswapV2Oracle(_prevAggregator).token1(); price0CumulativeLast = UniswapV2Oracle(_prevAggregator) .price0CumulativeLast(); price1CumulativeLast = UniswapV2Oracle(_prevAggregator) .price1CumulativeLast(); blockTimestampLast = UniswapV2Oracle(_prevAggregator) .blockTimestampLast(); price0Average = FixedPoint.uq112x112( UniswapV2Oracle(_prevAggregator).price0Average() ); price1Average = FixedPoint.uq112x112( UniswapV2Oracle(_prevAggregator).price1Average() ); } function setPeriod(uint256 _period) external onlyOwner { PERIOD = _period; } function setConsultLeniency(uint256 _consult_leniency) external onlyOwner { CONSULT_LENIENCY = _consult_leniency; } function setAllowStaleConsults( bool _allow_stale_consults ) external onlyOwner { ALLOW_STALE_CONSULTS = _allow_stale_consults; } // Check if update() can be called instead of wasting gas calling it function canUpdate() public view returns (bool) { uint32 blockTimestamp = UniswapV2OracleLibrary.currentBlockTimestamp(); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // Overflow is desired return (timeElapsed >= PERIOD); } function update() external { ( uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp ) = UniswapV2OracleLibrary.currentCumulativePrices(address(pair)); // overflow is desired uint256 timeElapsed = blockTimestamp > blockTimestampLast ? blockTimestamp - blockTimestampLast : uint256(blockTimestamp) + 2 ** 32 - uint256(blockTimestampLast); // Ensure that at least one full period has passed since the last update require( timeElapsed >= PERIOD && timeElapsed < 2 ** 32, 'UniswapPairOracle: PERIOD_NOT_ELAPSED' ); // Overflow is desired, casting never truncates // Cumulative price is in (uq112x112 price * seconds) units so we simply wrap it after division by time elapsed price0Average = FixedPoint.uq112x112( uint224((price0Cumulative - price0CumulativeLast) / timeElapsed) ); price1Average = FixedPoint.uq112x112( uint224((price1Cumulative - price1CumulativeLast) / timeElapsed) ); price0CumulativeLast = price0Cumulative; price1CumulativeLast = price1Cumulative; blockTimestampLast = blockTimestamp; } /// @dev returns the latest price of asset function viewPriceInUSD() external view override returns (uint256 price) { uint32 blockTimestamp = UniswapV2OracleLibrary.currentBlockTimestamp(); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // Overflow is desired // Ensure that the price is not stale require( (timeElapsed < (PERIOD + CONSULT_LENIENCY)) || ALLOW_STALE_CONSULTS, 'UniswapPairOracle: PRICE_IS_STALE_NEED_TO_CALL_UPDATE' ); if (isFirstToken) { price = (aggregator.viewPriceInUSD(token1) * (10 ** IERC20Metadata(token0).decimals())) / ( price1Average .mul(10 ** IERC20Metadata(token1).decimals()) .decode144() ); } else { price = (aggregator.viewPriceInUSD(token0) * (10 ** IERC20Metadata(token1).decimals())) / ( price0Average .mul(10 ** IERC20Metadata(token0).decimals()) .decode144() ); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // 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 (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @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) { return a + b; } /** * @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 a - b; } /** * @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) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting 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 a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting 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. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * 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, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; interface IOracle { function viewPriceInUSD() external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import {IOracle} from './IOracle.sol'; interface IPriceOracleAggregator { event UpdateOracle(address token, IOracle oracle); function updateOracleForAsset(address _asset, IOracle _oracle) external; function viewPriceInUSD(address _token) external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; interface IUniswapV2Factory { function getPair( address tokenA, address tokenB ) external view returns (address pair); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; 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; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; library Babylonian { function sqrt(uint256 y) internal pure returns (uint256 z) { if (y > 3) { z = y; uint256 x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } // else z = 0 } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import './Babylonian.sol'; // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) library FixedPoint { // range: [0, 2**112 - 1] // resolution: 1 / 2**112 struct uq112x112 { uint224 _x; } // range: [0, 2**144 - 1] // resolution: 1 / 2**112 struct uq144x112 { uint256 _x; } uint8 private constant RESOLUTION = 112; uint256 private constant Q112 = uint256(1) << RESOLUTION; uint256 private constant Q224 = Q112 << RESOLUTION; // encode a uint112 as a UQ112x112 function encode(uint112 x) internal pure returns (uq112x112 memory) { return uq112x112(uint224(x) << RESOLUTION); } // encodes a uint144 as a UQ144x112 function encode144(uint144 x) internal pure returns (uq144x112 memory) { return uq144x112(uint256(x) << RESOLUTION); } // divide a UQ112x112 by a uint112, returning a UQ112x112 function div( uq112x112 memory self, uint112 x ) internal pure returns (uq112x112 memory) { require(x != 0, 'FixedPoint: DIV_BY_ZERO'); return uq112x112(self._x / uint224(x)); } // multiply a UQ112x112 by a uint, returning a UQ144x112 // reverts on overflow function mul( uq112x112 memory self, uint256 y ) internal pure returns (uq144x112 memory) { uint256 z; require( y == 0 || (z = uint256(self._x) * y) / y == uint256(self._x), 'FixedPoint: MULTIPLICATION_OVERFLOW' ); return uq144x112(z); } // returns a UQ112x112 which represents the ratio of the numerator to the denominator // equivalent to encode(numerator).div(denominator) function fraction( uint112 numerator, uint112 denominator ) internal pure returns (uq112x112 memory) { require(denominator > 0, 'FixedPoint: DIV_BY_ZERO'); return uq112x112((uint224(numerator) << RESOLUTION) / denominator); } // decode a UQ112x112 into a uint112 by truncating after the radix point function decode(uq112x112 memory self) internal pure returns (uint112) { return uint112(self._x >> RESOLUTION); } // decode a UQ144x112 into a uint144 by truncating after the radix point function decode144(uq144x112 memory self) internal pure returns (uint144) { return uint144(self._x >> RESOLUTION); } // take the reciprocal of a UQ112x112 function reciprocal( uq112x112 memory self ) internal pure returns (uq112x112 memory) { require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL'); return uq112x112(uint224(Q224 / self._x)); } // square root of a UQ112x112 function sqrt( uq112x112 memory self ) internal pure returns (uq112x112 memory) { return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56)); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import '@openzeppelin/contracts/utils/math/SafeMath.sol'; import '@openzeppelin/contracts/access/Ownable.sol'; import '../libraries/FixedPoint.sol'; import '../interfaces/IPriceOracleAggregator.sol'; import '../interfaces/IUniswapV2Pair.sol'; import '../interfaces/IUniswapV2Factory.sol'; interface IERC20Metadata { function decimals() external view returns (uint8); } library UniswapV2Library { using SafeMath for uint256; // returns sorted token addresses, used to handle return values from pairs sorted in this order function sortTokens( address tokenA, address tokenB ) internal pure returns (address token0, address token1) { require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS'); } // Less efficient than the CREATE2 method below function pairFor( address factory, address tokenA, address tokenB ) internal view returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = IUniswapV2Factory(factory).getPair(token0, token1); } // calculates the CREATE2 address for a pair without making any external calls function pairForCreate2( address factory, address tokenA, address tokenB ) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address( uint160( bytes20( keccak256( abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash ) ) ) ) ); // this matches the CREATE2 in UniswapV2Factory.createPair } // fetches and sorts the reserves for a pair function getReserves( address factory, address tokenA, address tokenB ) internal view returns (uint256 reserveA, uint256 reserveB) { (address token0, ) = sortTokens(tokenA, tokenB); (uint256 reserve0, uint256 reserve1, ) = IUniswapV2Pair( pairFor(factory, tokenA, tokenB) ).getReserves(); (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0); } // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset function quote( uint256 amountA, uint256 reserveA, uint256 reserveB ) internal pure returns (uint256 amountB) { require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT'); require( reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY' ); amountB = amountA.mul(reserveB) / reserveA; } // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut( uint256 amountIn, uint256 reserveIn, uint256 reserveOut ) internal pure returns (uint256 amountOut) { require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT'); require( reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY' ); uint256 amountInWithFee = amountIn.mul(997); uint256 numerator = amountInWithFee.mul(reserveOut); uint256 denominator = reserveIn.mul(1000).add(amountInWithFee); amountOut = numerator / denominator; } // given an output amount of an asset and pair reserves, returns a required input amount of the other asset function getAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut ) internal pure returns (uint256 amountIn) { require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT'); require( reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY' ); uint256 numerator = reserveIn.mul(amountOut).mul(1000); uint256 denominator = reserveOut.sub(amountOut).mul(997); amountIn = (numerator / denominator).add(1); } // performs chained getAmountOut calculations on any number of pairs function getAmountsOut( address factory, uint256 amountIn, address[] memory path ) internal view returns (uint256[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint256[](path.length); amounts[0] = amountIn; for (uint256 i = 0; i < path.length - 1; i++) { (uint256 reserveIn, uint256 reserveOut) = getReserves( factory, path[i], path[i + 1] ); amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut); } } // performs chained getAmountIn calculations on any number of pairs function getAmountsIn( address factory, uint256 amountOut, address[] memory path ) internal view returns (uint256[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint256[](path.length); amounts[amounts.length - 1] = amountOut; for (uint256 i = path.length - 1; i > 0; i--) { (uint256 reserveIn, uint256 reserveOut) = getReserves( factory, path[i - 1], path[i] ); amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut); } } } library UniswapV2OracleLibrary { using FixedPoint for *; // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1] function currentBlockTimestamp() internal view returns (uint32) { return uint32(block.timestamp % 2 ** 32); } // produces the cumulative price using counterfactuals to save gas and avoid a call to sync. function currentCumulativePrices( address pair ) internal view returns ( uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp ) { blockTimestamp = currentBlockTimestamp(); price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast(); price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast(); // if time has elapsed since the last update on the pair, mock the accumulated price values ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ) = IUniswapV2Pair(pair).getReserves(); if (blockTimestampLast != blockTimestamp) { // subtraction overflow is desired uint32 timeElapsed = blockTimestamp - blockTimestampLast; // addition overflow is desired // counterfactual price0Cumulative += uint256(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed; // counterfactual price1Cumulative += uint256(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed; } } } contract UniswapV2Oracle is IOracle, Ownable { using FixedPoint for *; /// @notice oracle that returns price in USD IPriceOracleAggregator public immutable aggregator; uint256 public PERIOD = 1; // 1 hour TWAP (time-weighted average price) uint256 public CONSULT_LENIENCY = 120; // Used for being able to consult past the period end bool public ALLOW_STALE_CONSULTS = false; // If false, consult() will fail if the TWAP is stale IUniswapV2Pair public immutable pair; bool public isFirstToken; address public immutable token0; address public immutable token1; uint256 public price0CumulativeLast; uint256 public price1CumulativeLast; uint32 public blockTimestampLast; FixedPoint.uq112x112 public price0Average; FixedPoint.uq112x112 public price1Average; constructor( address _factory, address _tokenA, address _tokenB, address _priceOracleAggregator ) { require( _priceOracleAggregator != address(0), 'UNIV2: Invalid Aggregator' ); require(_factory != address(0), 'UNIV2: Invalid factory'); require(_tokenA != address(0), 'UNIV2: Invalid tokenA'); require(_tokenB != address(0), 'UNIV2: Invalid tokenB'); aggregator = IPriceOracleAggregator(_priceOracleAggregator); IUniswapV2Pair _pair = IUniswapV2Pair( UniswapV2Library.pairFor(_factory, _tokenA, _tokenB) ); require(address(_pair) != address(0), 'UNIV2: Invalid Pair'); pair = _pair; token0 = _pair.token0(); token1 = _pair.token1(); price0CumulativeLast = _pair.price0CumulativeLast(); // fetch the current accumulated price value (1 / 0) price1CumulativeLast = _pair.price1CumulativeLast(); // fetch the current accumulated price value (0 / 1) uint112 reserve0; uint112 reserve1; (reserve0, reserve1, blockTimestampLast) = _pair.getReserves(); require(reserve0 != 0 && reserve1 != 0, 'UNIV2: NO_RESERVES'); // ensure that there's liquidity in the pair if (_tokenA == _pair.token0()) { isFirstToken = true; } else { isFirstToken = false; } } function setPeriod(uint256 _period) external onlyOwner { PERIOD = _period; } function setConsultLeniency(uint256 _consult_leniency) external onlyOwner { CONSULT_LENIENCY = _consult_leniency; } function setAllowStaleConsults( bool _allow_stale_consults ) external onlyOwner { ALLOW_STALE_CONSULTS = _allow_stale_consults; } // Check if update() can be called instead of wasting gas calling it function canUpdate() public view returns (bool) { uint32 blockTimestamp = UniswapV2OracleLibrary.currentBlockTimestamp(); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // Overflow is desired return (timeElapsed >= PERIOD); } function update() external { ( uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp ) = UniswapV2OracleLibrary.currentCumulativePrices(address(pair)); // overflow is desired uint256 timeElapsed = blockTimestamp > blockTimestampLast ? blockTimestamp - blockTimestampLast : uint256(blockTimestamp) + 2 ** 32 - uint256(blockTimestampLast); // Ensure that at least one full period has passed since the last update require(timeElapsed >= PERIOD, 'UniswapPairOracle: PERIOD_NOT_ELAPSED'); // Overflow is desired, casting never truncates // Cumulative price is in (uq112x112 price * seconds) units so we simply wrap it after division by time elapsed price0Average = FixedPoint.uq112x112( uint224((price0Cumulative - price0CumulativeLast) / timeElapsed) ); price1Average = FixedPoint.uq112x112( uint224((price1Cumulative - price1CumulativeLast) / timeElapsed) ); price0CumulativeLast = price0Cumulative; price1CumulativeLast = price1Cumulative; blockTimestampLast = blockTimestamp; } /// @dev returns the latest price of asset function viewPriceInUSD() external view override returns (uint256 price) { uint32 blockTimestamp = UniswapV2OracleLibrary.currentBlockTimestamp(); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // Overflow is desired // Ensure that the price is not stale require( (timeElapsed < (PERIOD + CONSULT_LENIENCY)) || ALLOW_STALE_CONSULTS, 'UniswapPairOracle: PRICE_IS_STALE_NEED_TO_CALL_UPDATE' ); if (isFirstToken) { price = (aggregator.viewPriceInUSD(token1) * (10 ** IERC20Metadata(token0).decimals())) / ( price1Average .mul(10 ** IERC20Metadata(token1).decimals()) .decode144() ); } else { price = (aggregator.viewPriceInUSD(token0) * (10 ** IERC20Metadata(token1).decimals())) / ( price0Average .mul(10 ** IERC20Metadata(token0).decimals()) .decode144() ); } } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_prevAggregator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"ALLOW_STALE_CONSULTS","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CONSULT_LENIENCY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"aggregator","outputs":[{"internalType":"contract IPriceOracleAggregator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"blockTimestampLast","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"canUpdate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isFirstToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pair","outputs":[{"internalType":"contract IUniswapV2Pair","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price0Average","outputs":[{"internalType":"uint224","name":"_x","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price0CumulativeLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price1Average","outputs":[{"internalType":"uint224","name":"_x","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price1CumulativeLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_allow_stale_consults","type":"bool"}],"name":"setAllowStaleConsults","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_consult_leniency","type":"uint256"}],"name":"setConsultLeniency","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_period","type":"uint256"}],"name":"setPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token0","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"update","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"viewPriceInUSD","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
6101006040526001805560786002556003805460ff191690553480156200002557600080fd5b50604051620019dd380380620019dd833981016040819052620000489162000717565b6200005333620006ae565b806001600160a01b031663245a7bfc6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000092573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000b8919062000717565b6001600160a01b03166080816001600160a01b031681525050806001600160a01b031663b4d1d7956040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000110573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200013691906200073e565b600181905550806001600160a01b0316633fcb55ca6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200017b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001a191906200073e565b600281905550806001600160a01b0316631ac2c8256040518163ffffffff1660e01b8152600401602060405180830381865afa158015620001e6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200020c919062000758565b600360006101000a81548160ff021916908315150217905550806001600160a01b031663a8aa1b316040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000264573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200028a919062000717565b6001600160a01b031660a0816001600160a01b031681525050806001600160a01b031663575b97fb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015620002e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000308919062000758565b600360016101000a81548160ff021916908315150217905550806001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000360573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000386919062000717565b6001600160a01b031660c0816001600160a01b031681525050806001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015620003de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000404919062000717565b6001600160a01b031660e0816001600160a01b031681525050806001600160a01b0316635909c0d56040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200045c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200048291906200073e565b600481905550806001600160a01b0316635a3d54936040518163ffffffff1660e01b8152600401602060405180830381865afa158015620004c7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620004ed91906200073e565b600581905550806001600160a01b031663c5700a026040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000532573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200055891906200077c565b600660006101000a81548163ffffffff021916908363ffffffff1602179055506040518060200160405280826001600160a01b031663a6bb45396040518163ffffffff1660e01b8152600401602060405180830381865afa158015620005c2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005e89190620007a4565b6001600160e01b039081169091529051600780546001600160e01b0319169190921617905560408051602080820180845263179aabcb60e21b90529151909182916001600160a01b03851691635e6aaf2c9160248086019291908187030181865afa1580156200065c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620006829190620007a4565b6001600160e01b039081169091529051600880546001600160e01b0319169190921617905550620007cf565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03811681146200071457600080fd5b50565b6000602082840312156200072a57600080fd5b81516200073781620006fe565b9392505050565b6000602082840312156200075157600080fd5b5051919050565b6000602082840312156200076b57600080fd5b815180151581146200073757600080fd5b6000602082840312156200078f57600080fd5b815163ffffffff811681146200073757600080fd5b600060208284031215620007b757600080fd5b81516001600160e01b03811681146200073757600080fd5b60805160a05160c05160e05161119562000848600039600081816102f3015281816106cc0152818161082a015261099601526000818161014c01528181610788015281816108e10152610a3801526000818161029e01526103b30152600081816101c2015281816108520152610a6001526111956000f3fe608060405234801561001057600080fd5b50600436106101425760003560e01c80638da5cb5b116100b8578063b4d1d7951161007c578063b4d1d795146102c0578063c5700a02146102c9578063d21220a7146102ee578063f1551aea14610315578063f2fde38b14610328578063f55fa17f1461033b57600080fd5b80638da5cb5b14610265578063a17a268514610276578063a2e620451461027e578063a6bb453914610286578063a8aa1b311461029957600080fd5b8063575b97fb1161010a578063575b97fb146101fb5780635909c0d51461020d5780635a3d5493146102165780635cb9a7141461021f5780635e6aaf2c14610232578063715018a61461025d57600080fd5b80630dfe1681146101475780630f3a9f651461018b5780631ac2c825146101a0578063245a7bfc146101bd5780633fcb55ca146101e4575b600080fd5b61016e7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b61019e610199366004610e7e565b610343565b005b6003546101ad9060ff1681565b6040519015158152602001610182565b61016e7f000000000000000000000000000000000000000000000000000000000000000081565b6101ed60025481565b604051908152602001610182565b6003546101ad90610100900460ff1681565b6101ed60045481565b6101ed60055481565b61019e61022d366004610e7e565b610350565b600854610245906001600160e01b031681565b6040516001600160e01b039091168152602001610182565b61019e61035d565b6000546001600160a01b031661016e565b6101ad610371565b61019e6103a9565b600754610245906001600160e01b031681565b61016e7f000000000000000000000000000000000000000000000000000000000000000081565b6101ed60015481565b6006546102d99063ffffffff1681565b60405163ffffffff9091168152602001610182565b61016e7f000000000000000000000000000000000000000000000000000000000000000081565b61019e610323366004610e97565b61056b565b61019e610336366004610ec0565b610586565b6101ed6105ff565b61034b610a8f565b600155565b610358610a8f565b600255565b610365610a8f565b61036f6000610ae9565b565b60008061037c610b39565b6006549091506000906103959063ffffffff1683610eff565b60015463ffffffff90911610159392505050565b60008060006103d77f0000000000000000000000000000000000000000000000000000000000000000610b4f565b600654929550909350915060009063ffffffff908116908316116104215760065463ffffffff90811690610412908416640100000000610f23565b61041c9190610f36565b61043b565b6006546104349063ffffffff1683610eff565b63ffffffff165b90506001548110158015610453575064010000000081105b6104b25760405162461bcd60e51b815260206004820152602560248201527f556e6973776170506169724f7261636c653a20504552494f445f4e4f545f454c604482015264105414d15160da1b60648201526084015b60405180910390fd5b604051806020016040528082600454876104cc9190610f36565b6104d69190610f5f565b6001600160e01b039081169091529051600780546001600160e01b031916919092161790556040805160208101909152600554819083906105179087610f36565b6105219190610f5f565b6001600160e01b039081169091529051600880546001600160e01b03191691909216179055506004929092556005556006805463ffffffff191663ffffffff909216919091179055565b610573610a8f565b6003805460ff1916911515919091179055565b61058e610a8f565b6001600160a01b0381166105f35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016104a9565b6105fc81610ae9565b50565b60008061060a610b39565b6006549091506000906106239063ffffffff1683610eff565b90506002546001546106359190610f23565b8163ffffffff16108061064a575060035460ff165b6106b45760405162461bcd60e51b815260206004820152603560248201527f556e6973776170506169724f7261636c653a2050524943455f49535f5354414c604482015274455f4e4545445f544f5f43414c4c5f55504441544560581b60648201526084016104a9565b600354610100900460ff16156108d95761077d6107767f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610728573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061074c9190610f73565b61075790600a61107a565b60408051602081019091526008546001600160e01b0316815290610d22565b5160701c90565b6001600160901b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108089190610f73565b61081390600a61107a565b60405163eb9d14a960e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063eb9d14a9906024015b602060405180830381865afa15801561089a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108be9190611089565b6108c891906110a2565b6108d29190610f5f565b9250505090565b61098b6107767f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561093d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109619190610f73565b61096c90600a61107a565b60408051602081019091526007546001600160e01b0316815290610d22565b6001600160901b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109f2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a169190610f73565b610a2190600a61107a565b60405163eb9d14a960e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063eb9d14a99060240161087d565b6000546001600160a01b0316331461036f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104a9565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610b4a640100000000426110b9565b905090565b6000806000610b5c610b39565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc09190611089565b9250836001600160a01b0316635a3d54936040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c249190611089565b91506000806000866001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610c69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c8d91906110e9565b9250925092508363ffffffff168163ffffffff1614610d18576000610cb28286610eff565b90508063ffffffff16610cc58486610dce565b51610cd991906001600160e01b03166110a2565b610ce39088610f23565b96508063ffffffff16610cf68585610dce565b51610d0a91906001600160e01b03166110a2565b610d149087610f23565b9550505b5050509193909250565b6040805160208101909152600081526000821580610d5f575083516001600160e01b031683610d5181836110a2565b9250610d5d9083610f5f565b145b610db75760405162461bcd60e51b815260206004820152602360248201527f4669786564506f696e743a204d554c5449504c49434154494f4e5f4f564552466044820152624c4f5760e81b60648201526084016104a9565b604080516020810190915290815290505b92915050565b6040805160208101909152600081526000826001600160701b031611610e365760405162461bcd60e51b815260206004820152601760248201527f4669786564506f696e743a204449565f42595f5a45524f00000000000000000060448201526064016104a9565b604080516020810190915280610e6c6001600160701b0385166dffffffffffffffffffffffffffff60701b607088901b16611139565b6001600160e01b031690529392505050565b600060208284031215610e9057600080fd5b5035919050565b600060208284031215610ea957600080fd5b81358015158114610eb957600080fd5b9392505050565b600060208284031215610ed257600080fd5b81356001600160a01b0381168114610eb957600080fd5b634e487b7160e01b600052601160045260246000fd5b63ffffffff828116828216039080821115610f1c57610f1c610ee9565b5092915050565b80820180821115610dc857610dc8610ee9565b81810381811115610dc857610dc8610ee9565b634e487b7160e01b600052601260045260246000fd5b600082610f6e57610f6e610f49565b500490565b600060208284031215610f8557600080fd5b815160ff81168114610eb957600080fd5b600181815b80851115610fd1578160001904821115610fb757610fb7610ee9565b80851615610fc457918102915b93841c9390800290610f9b565b509250929050565b600082610fe857506001610dc8565b81610ff557506000610dc8565b816001811461100b576002811461101557611031565b6001915050610dc8565b60ff84111561102657611026610ee9565b50506001821b610dc8565b5060208310610133831016604e8410600b8410161715611054575081810a610dc8565b61105e8383610f96565b806000190482111561107257611072610ee9565b029392505050565b6000610eb960ff841683610fd9565b60006020828403121561109b57600080fd5b5051919050565b8082028115828204841417610dc857610dc8610ee9565b6000826110c8576110c8610f49565b500690565b80516001600160701b03811681146110e457600080fd5b919050565b6000806000606084860312156110fe57600080fd5b611107846110cd565b9250611115602085016110cd565b9150604084015163ffffffff8116811461112e57600080fd5b809150509250925092565b60006001600160e01b038381168061115357611153610f49565b9216919091049291505056fea2646970667358221220f94f6f36f7d77a2b0c9a067fbd4fd2ab814a716a37f081d6f1de1ee254a2bce064736f6c6343000811003300000000000000000000000079edee4fd2d844775aeda9f2e6753a4d2761775a
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101425760003560e01c80638da5cb5b116100b8578063b4d1d7951161007c578063b4d1d795146102c0578063c5700a02146102c9578063d21220a7146102ee578063f1551aea14610315578063f2fde38b14610328578063f55fa17f1461033b57600080fd5b80638da5cb5b14610265578063a17a268514610276578063a2e620451461027e578063a6bb453914610286578063a8aa1b311461029957600080fd5b8063575b97fb1161010a578063575b97fb146101fb5780635909c0d51461020d5780635a3d5493146102165780635cb9a7141461021f5780635e6aaf2c14610232578063715018a61461025d57600080fd5b80630dfe1681146101475780630f3a9f651461018b5780631ac2c825146101a0578063245a7bfc146101bd5780633fcb55ca146101e4575b600080fd5b61016e7f0000000000000000000000005fe72ed557d8a02fff49b3b826792c765d5ce16281565b6040516001600160a01b0390911681526020015b60405180910390f35b61019e610199366004610e7e565b610343565b005b6003546101ad9060ff1681565b6040519015158152602001610182565b61016e7f00000000000000000000000060a50662a240908c3b0d5fc25e4e21e4930ae91a81565b6101ed60025481565b604051908152602001610182565b6003546101ad90610100900460ff1681565b6101ed60045481565b6101ed60055481565b61019e61022d366004610e7e565b610350565b600854610245906001600160e01b031681565b6040516001600160e01b039091168152602001610182565b61019e61035d565b6000546001600160a01b031661016e565b6101ad610371565b61019e6103a9565b600754610245906001600160e01b031681565b61016e7f00000000000000000000000074e6cac32234133fe06bd0f4d8237dee1dede05781565b6101ed60015481565b6006546102d99063ffffffff1681565b60405163ffffffff9091168152602001610182565b61016e7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b61019e610323366004610e97565b61056b565b61019e610336366004610ec0565b610586565b6101ed6105ff565b61034b610a8f565b600155565b610358610a8f565b600255565b610365610a8f565b61036f6000610ae9565b565b60008061037c610b39565b6006549091506000906103959063ffffffff1683610eff565b60015463ffffffff90911610159392505050565b60008060006103d77f00000000000000000000000074e6cac32234133fe06bd0f4d8237dee1dede057610b4f565b600654929550909350915060009063ffffffff908116908316116104215760065463ffffffff90811690610412908416640100000000610f23565b61041c9190610f36565b61043b565b6006546104349063ffffffff1683610eff565b63ffffffff165b90506001548110158015610453575064010000000081105b6104b25760405162461bcd60e51b815260206004820152602560248201527f556e6973776170506169724f7261636c653a20504552494f445f4e4f545f454c604482015264105414d15160da1b60648201526084015b60405180910390fd5b604051806020016040528082600454876104cc9190610f36565b6104d69190610f5f565b6001600160e01b039081169091529051600780546001600160e01b031916919092161790556040805160208101909152600554819083906105179087610f36565b6105219190610f5f565b6001600160e01b039081169091529051600880546001600160e01b03191691909216179055506004929092556005556006805463ffffffff191663ffffffff909216919091179055565b610573610a8f565b6003805460ff1916911515919091179055565b61058e610a8f565b6001600160a01b0381166105f35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016104a9565b6105fc81610ae9565b50565b60008061060a610b39565b6006549091506000906106239063ffffffff1683610eff565b90506002546001546106359190610f23565b8163ffffffff16108061064a575060035460ff165b6106b45760405162461bcd60e51b815260206004820152603560248201527f556e6973776170506169724f7261636c653a2050524943455f49535f5354414c604482015274455f4e4545445f544f5f43414c4c5f55504441544560581b60648201526084016104a9565b600354610100900460ff16156108d95761077d6107767f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610728573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061074c9190610f73565b61075790600a61107a565b60408051602081019091526008546001600160e01b0316815290610d22565b5160701c90565b6001600160901b03167f0000000000000000000000005fe72ed557d8a02fff49b3b826792c765d5ce1626001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108089190610f73565b61081390600a61107a565b60405163eb9d14a960e01b81526001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2811660048301527f00000000000000000000000060a50662a240908c3b0d5fc25e4e21e4930ae91a169063eb9d14a9906024015b602060405180830381865afa15801561089a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108be9190611089565b6108c891906110a2565b6108d29190610f5f565b9250505090565b61098b6107767f0000000000000000000000005fe72ed557d8a02fff49b3b826792c765d5ce1626001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561093d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109619190610f73565b61096c90600a61107a565b60408051602081019091526007546001600160e01b0316815290610d22565b6001600160901b03167f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109f2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a169190610f73565b610a2190600a61107a565b60405163eb9d14a960e01b81526001600160a01b037f0000000000000000000000005fe72ed557d8a02fff49b3b826792c765d5ce162811660048301527f00000000000000000000000060a50662a240908c3b0d5fc25e4e21e4930ae91a169063eb9d14a99060240161087d565b6000546001600160a01b0316331461036f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104a9565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610b4a640100000000426110b9565b905090565b6000806000610b5c610b39565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc09190611089565b9250836001600160a01b0316635a3d54936040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c249190611089565b91506000806000866001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610c69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c8d91906110e9565b9250925092508363ffffffff168163ffffffff1614610d18576000610cb28286610eff565b90508063ffffffff16610cc58486610dce565b51610cd991906001600160e01b03166110a2565b610ce39088610f23565b96508063ffffffff16610cf68585610dce565b51610d0a91906001600160e01b03166110a2565b610d149087610f23565b9550505b5050509193909250565b6040805160208101909152600081526000821580610d5f575083516001600160e01b031683610d5181836110a2565b9250610d5d9083610f5f565b145b610db75760405162461bcd60e51b815260206004820152602360248201527f4669786564506f696e743a204d554c5449504c49434154494f4e5f4f564552466044820152624c4f5760e81b60648201526084016104a9565b604080516020810190915290815290505b92915050565b6040805160208101909152600081526000826001600160701b031611610e365760405162461bcd60e51b815260206004820152601760248201527f4669786564506f696e743a204449565f42595f5a45524f00000000000000000060448201526064016104a9565b604080516020810190915280610e6c6001600160701b0385166dffffffffffffffffffffffffffff60701b607088901b16611139565b6001600160e01b031690529392505050565b600060208284031215610e9057600080fd5b5035919050565b600060208284031215610ea957600080fd5b81358015158114610eb957600080fd5b9392505050565b600060208284031215610ed257600080fd5b81356001600160a01b0381168114610eb957600080fd5b634e487b7160e01b600052601160045260246000fd5b63ffffffff828116828216039080821115610f1c57610f1c610ee9565b5092915050565b80820180821115610dc857610dc8610ee9565b81810381811115610dc857610dc8610ee9565b634e487b7160e01b600052601260045260246000fd5b600082610f6e57610f6e610f49565b500490565b600060208284031215610f8557600080fd5b815160ff81168114610eb957600080fd5b600181815b80851115610fd1578160001904821115610fb757610fb7610ee9565b80851615610fc457918102915b93841c9390800290610f9b565b509250929050565b600082610fe857506001610dc8565b81610ff557506000610dc8565b816001811461100b576002811461101557611031565b6001915050610dc8565b60ff84111561102657611026610ee9565b50506001821b610dc8565b5060208310610133831016604e8410600b8410161715611054575081810a610dc8565b61105e8383610f96565b806000190482111561107257611072610ee9565b029392505050565b6000610eb960ff841683610fd9565b60006020828403121561109b57600080fd5b5051919050565b8082028115828204841417610dc857610dc8610ee9565b6000826110c8576110c8610f49565b500690565b80516001600160701b03811681146110e457600080fd5b919050565b6000806000606084860312156110fe57600080fd5b611107846110cd565b9250611115602085016110cd565b9150604084015163ffffffff8116811461112e57600080fd5b809150509250925092565b60006001600160e01b038381168061115357611153610f49565b9216919091049291505056fea2646970667358221220f94f6f36f7d77a2b0c9a067fbd4fd2ab814a716a37f081d6f1de1ee254a2bce064736f6c63430008110033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000079edee4fd2d844775aeda9f2e6753a4d2761775a
-----Decoded View---------------
Arg [0] : _prevAggregator (address): 0x79edee4fd2D844775AedA9f2e6753A4d2761775A
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 00000000000000000000000079edee4fd2d844775aeda9f2e6753a4d2761775a
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ 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.