Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 147 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Update | 20488811 | 6 hrs ago | IN | 0 ETH | 0.00006949 | ||||
Update | 20467298 | 3 days ago | IN | 0 ETH | 0.00015336 | ||||
Update | 20452956 | 5 days ago | IN | 0 ETH | 0.00006358 | ||||
Update | 20445785 | 6 days ago | IN | 0 ETH | 0.00007067 | ||||
Update | 20438637 | 7 days ago | IN | 0 ETH | 0.00010333 | ||||
Update | 20436538 | 7 days ago | IN | 0 ETH | 0.00031625 | ||||
Update | 20436538 | 7 days ago | IN | 0 ETH | 0.00052121 | ||||
Update | 20414392 | 10 days ago | IN | 0 ETH | 0.00013014 | ||||
Update | 20414392 | 10 days ago | IN | 0 ETH | 0.00021448 | ||||
Update | 20402812 | 12 days ago | IN | 0 ETH | 0.00006383 | ||||
Update | 20395653 | 13 days ago | IN | 0 ETH | 0.00006638 | ||||
Update | 20394118 | 13 days ago | IN | 0 ETH | 0.0001124 | ||||
Update | 20388492 | 14 days ago | IN | 0 ETH | 0.00009091 | ||||
Update | 20381332 | 15 days ago | IN | 0 ETH | 0.00016237 | ||||
Update | 20374172 | 16 days ago | IN | 0 ETH | 0.00011825 | ||||
Update | 20367001 | 17 days ago | IN | 0 ETH | 0.00014881 | ||||
Update | 20357385 | 18 days ago | IN | 0 ETH | 0.00123355 | ||||
Update | 20345795 | 20 days ago | IN | 0 ETH | 0.00015825 | ||||
Update | 20337927 | 21 days ago | IN | 0 ETH | 0.00023787 | ||||
Update | 20337926 | 21 days ago | IN | 0 ETH | 0.00038646 | ||||
Update | 20303960 | 26 days ago | IN | 0 ETH | 0.00018828 | ||||
Update | 20271902 | 30 days ago | IN | 0 ETH | 0.00021892 | ||||
Update | 20260488 | 32 days ago | IN | 0 ETH | 0.00019393 | ||||
Update | 20247965 | 33 days ago | IN | 0 ETH | 0.00025707 | ||||
Update | 20247459 | 33 days ago | IN | 0 ETH | 0.00014457 |
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
19755764 | 102 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Contract Name:
V2Oracle
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
pragma solidity >=0.6.6; import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol"; // import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol"; import "./uniswapv2/libraries/FixedPoint.sol"; // import "./uniswapv2/libraries/UniswapV2OracleLibrary.sol"; // import "./uniswapv2/libraries/UniswapV2Library.sol"; import "./uniswapv2/libraries/SafeMath.sol"; // import "@uniswap/v2-core/contracts/libraries/SafeMath.sol"; // import "@uniswap/lib/contracts/libraries/FixedPoint.sol"; interface IUniswapV2PairLocal { event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 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 (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 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 (uint256); function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint256); 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 (uint256); function price1CumulativeLast() external view returns (uint256); function kLast() external view returns (uint256); function mint(address to) external returns (uint256 liquidity); function burn(address to) external returns (uint256 amount0, uint256 amount1); function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } 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 = IUniswapV2PairLocal(pair).price0CumulativeLast(); price1Cumulative = IUniswapV2PairLocal(pair).price1CumulativeLast(); // if time has elapsed since the last update on the pair, mock the accumulated price values (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2PairLocal(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; } } } library UniswapV2Library { using SafeMathUniswap 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"); } // calculates the CREATE2 address for a pair without making any external calls function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address( uint160( uint256( keccak256( abi.encodePacked( hex"ff", factory, keccak256(abi.encodePacked(token0, token1)), hex"96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f" // init code hash ) ) ) ) ); } // 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,) = IUniswapV2PairLocal(IUniswapV2Factory(factory).getPair(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; 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); } } } // fixed window oracle that recomputes the average price for the entire period once every period // note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period contract V2Oracle { using FixedPoint for *; uint256 public constant PERIOD = 5 minutes; IUniswapV2PairLocal public immutable pair; 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) { IUniswapV2PairLocal _pair = IUniswapV2PairLocal(IUniswapV2Factory(factory).getPair(address(tokenA), address(tokenB))); 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, "ExampleOracleSimple: NO_RESERVES"); // ensure that there's liquidity in the pair } function canUpdate() external 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)); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired // ensure that at least one full period has passed since the last update require(timeElapsed >= PERIOD, "ExampleOracleSimple: 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; } // note this will always return 0 before update has been called successfully for the first time. function consult(address token, uint256 amountIn) external view returns (uint256 amountOut) { if (token == token0) { amountOut = price0Average.mul(amountIn).decode144(); } else { require(token == token1, "ExampleOracleSimple: INVALID_TOKEN"); amountOut = price1Average.mul(amountIn).decode144(); } } }
pragma solidity >=0.5.0; 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; }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.4.0; import "./FullMathV2.sol"; import "./Babylonian.sol"; import "./BitMath.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 public constant RESOLUTION = 112; uint256 public constant Q112 = 0x10000000000000000000000000000; // 2**112 uint256 private constant Q224 = 0x100000000000000000000000000000000000000000000000000000000; // 2**224 uint256 private constant LOWER_MASK = 0xffffffffffffffffffffffffffff; // decimal of UQ*x112 (lower 112 bits) // 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); } // 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); } // 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 = 0; require(y == 0 || (z = self._x * y) / y == self._x, "FixedPoint::mul: overflow"); return uq144x112(z); } // multiply a UQ112x112 by an int and decode, returning an int // reverts on overflow function muli(uq112x112 memory self, int256 y) internal pure returns (int256) { uint256 z = FullMathV2.mulDiv(self._x, uint256(y < 0 ? -y : y), Q112); require(z < 2 ** 255, "FixedPoint::muli: overflow"); return y < 0 ? -int256(z) : int256(z); } // multiply a UQ112x112 by a UQ112x112, returning a UQ112x112 // lossy function muluq(uq112x112 memory self, uq112x112 memory other) internal pure returns (uq112x112 memory) { if (self._x == 0 || other._x == 0) { return uq112x112(0); } uint112 upper_self = uint112(self._x >> RESOLUTION); // * 2^0 uint112 lower_self = uint112(self._x & LOWER_MASK); // * 2^-112 uint112 upper_other = uint112(other._x >> RESOLUTION); // * 2^0 uint112 lower_other = uint112(other._x & LOWER_MASK); // * 2^-112 // partial products uint224 upper = uint224(upper_self) * upper_other; // * 2^0 uint224 lower = uint224(lower_self) * lower_other; // * 2^-224 uint224 uppers_lowero = uint224(upper_self) * lower_other; // * 2^-112 uint224 uppero_lowers = uint224(upper_other) * lower_self; // * 2^-112 // so the bit shift does not overflow require(upper <= uint112(5192296858534827628530496329220095), "FixedPoint::muluq: upper overflow"); // this cannot exceed 256 bits, all values are 224 bits uint256 sum = uint256(upper << RESOLUTION) + uppers_lowero + uppero_lowers + (lower >> RESOLUTION); // so the cast does not overflow require( sum <= uint224(26959946667150639794667015087019630673637144422540572481103610249215), "FixedPoint::muluq: sum overflow" ); return uq112x112(uint224(sum)); } // divide a UQ112x112 by a UQ112x112, returning a UQ112x112 function divuq(uq112x112 memory self, uq112x112 memory other) internal pure returns (uq112x112 memory) { require(other._x > 0, "FixedPoint::divuq: division by zero"); if (self._x == other._x) { return uq112x112(uint224(Q112)); } if (self._x <= uint144(22300745198530623141535718272648361505980415)) { uint256 value = (uint256(self._x) << RESOLUTION) / other._x; require( value <= uint224(26959946667150639794667015087019630673637144422540572481103610249215), "FixedPoint::divuq: overflow" ); return uq112x112(uint224(value)); } uint256 result = FullMathV2.mulDiv(Q112, self._x, other._x); require( result <= uint224(26959946667150639794667015087019630673637144422540572481103610249215), "FixedPoint::divuq: overflow" ); return uq112x112(uint224(result)); } // returns a UQ112x112 which represents the ratio of the numerator to the denominator // can be lossy function fraction(uint256 numerator, uint256 denominator) internal pure returns (uq112x112 memory) { require(denominator > 0, "FixedPoint::fraction: division by zero"); if (numerator == 0) return FixedPoint.uq112x112(0); if (numerator <= uint144(22300745198530623141535718272648361505980415)) { uint256 result = (numerator << RESOLUTION) / denominator; require( result <= uint224(26959946667150639794667015087019630673637144422540572481103610249215), "FixedPoint::fraction: overflow" ); return uq112x112(uint224(result)); } else { uint256 result = FullMathV2.mulDiv(numerator, Q112, denominator); require( result <= uint224(26959946667150639794667015087019630673637144422540572481103610249215), "FixedPoint::fraction: overflow" ); return uq112x112(uint224(result)); } } // take the reciprocal of a UQ112x112 // reverts on overflow // lossy function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) { require(self._x != 0, "FixedPoint::reciprocal: reciprocal of zero"); require(self._x != 1, "FixedPoint::reciprocal: overflow"); return uq112x112(uint224(Q224 / self._x)); } // square root of a UQ112x112 // lossy between 0/1 and 40 bits function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) { if (self._x <= uint144(22300745198530623141535718272648361505980415)) { return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << 112))); } uint8 safeShiftBits = 255 - BitMath.mostSignificantBit(self._x); safeShiftBits -= safeShiftBits % 2; return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << safeShiftBits) << ((112 - safeShiftBits) / 2))); } }
pragma solidity >=0.6.12; // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math) library SafeMathUniswap { function add(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x + y) >= x, "ds-math-add-overflow"); } function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x - y) <= x, "ds-math-sub-underflow"); } function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { require(y == 0 || (z = x * y) / y == x, "ds-math-mul-overflow"); } }
// SPDX-License-Identifier: CC-BY-4.0 pragma solidity >=0.4.0; // taken from https://medium.com/coinmonks/math-in-solidity-part-3-percents-and-proportions-4db014e080b1 // license is CC-BY-4.0 library FullMathV2 { function fullMul(uint256 x, uint256 y) internal pure returns (uint256 l, uint256 h) { uint256 mm = mulmod(x, y, type(uint256).max); l = x * y; h = mm - l; if (mm < l) h -= 1; } function fullDiv(uint256 l, uint256 h, uint256 d) private pure returns (uint256) { uint256 pow2 = d & type(uint256).max - d + 1; d /= pow2; l /= pow2; l += h * ((type(uint256).max - pow2 + 1) / pow2 + 1); uint256 r = 1; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; return l * r; } function mulDiv(uint256 x, uint256 y, uint256 d) internal pure returns (uint256) { (uint256 l, uint256 h) = fullMul(x, y); uint256 mm = mulmod(x, y, d); if (mm > l) h -= 1; l -= mm; if (h == 0) return l / d; require(h < d, "FullMath: FULLDIV_OVERFLOW"); return fullDiv(l, h, d); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.4.0; // computes square roots using the babylonian method // https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method library Babylonian { // credit for this implementation goes to // https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMath64x64.sol#L687 function sqrt(uint256 x) internal pure returns (uint256) { if (x == 0) return 0; // this block is equivalent to r = uint256(1) << (BitMath.mostSignificantBit(x) / 2); // however that code costs significantly more gas uint256 xx = x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; // Seven iterations should be enough uint256 r1 = x / r; return (r < r1 ? r : r1); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.5.0; library BitMath { // returns the 0 indexed position of the most significant bit of the input x // s.t. x >= 2**msb and x < 2**(msb+1) function mostSignificantBit(uint256 x) internal pure returns (uint8 r) { require(x > 0, "BitMath::mostSignificantBit: zero"); if (x >= 0x100000000000000000000000000000000) { x >>= 128; r += 128; } if (x >= 0x10000000000000000) { x >>= 64; r += 64; } if (x >= 0x100000000) { x >>= 32; r += 32; } if (x >= 0x10000) { x >>= 16; r += 16; } if (x >= 0x100) { x >>= 8; r += 8; } if (x >= 0x10) { x >>= 4; r += 4; } if (x >= 0x4) { x >>= 2; r += 2; } if (x >= 0x2) r += 1; } // returns the 0 indexed position of the least significant bit of the input x // s.t. (x & 2**lsb) != 0 and (x & (2**(lsb) - 1)) == 0) // i.e. the bit at the index is set and the mask of all lower bits is 0 function leastSignificantBit(uint256 x) internal pure returns (uint8 r) { require(x > 0, "BitMath::leastSignificantBit: zero"); r = 255; if (x & uint128(340282366920938463463374607431768211455) > 0) { r -= 128; } else { x >>= 128; } if (x & uint64(18446744073709551615) > 0) { r -= 64; } else { x >>= 64; } if (x & uint32(4294967295) > 0) { r -= 32; } else { x >>= 32; } if (x & uint16(32767) > 0) { r -= 16; } else { x >>= 16; } if (x & uint8(255) > 0) { r -= 8; } else { x >>= 8; } if (x & 0xf > 0) { r -= 4; } else { x >>= 4; } if (x & 0x3 > 0) { r -= 2; } else { x >>= 2; } if (x & 0x1 > 0) r -= 1; } }
{ "remappings": [ "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "ds-test/=lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "@uniswap/lib/=lib/solidity-lib/", "@uniswap/v2-core/=lib/v2-core/", "abdk-libraries-solidity/=lib/abdk-libraries-solidity/", "@uniswap/v3-core/=lib/v3-core/", "@uniswap/v3-periphery/=lib/v3-periphery/", "base64-sol/=lib/base64/", "base64/=lib/base64/", "solidity-lib/=lib/solidity-lib/contracts/", "v2-core/=lib/v2-core/contracts/", "v3-core/=lib/v3-core/contracts/", "v3-periphery/=lib/v3-periphery/contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"factory","type":"address"},{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"}],"name":"consult","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pair","outputs":[{"internalType":"contract IUniswapV2PairLocal","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":"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":[],"name":"update","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60e06040523480156200001157600080fd5b5060405162001221380380620012218339810160408190526200003491620003bd565b60405163e6a4390560e01b81526001600160a01b03838116600483015282811660248301526000919085169063e6a4390590604401602060405180830381865afa15801562000087573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000ad919062000407565b9050806001600160a01b03166080816001600160a01b031681525050806001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000108573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200012e919062000407565b6001600160a01b031660a0816001600160a01b031681525050806001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000186573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001ac919062000407565b6001600160a01b031660c0816001600160a01b031681525050806001600160a01b0316635909c0d56040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000204573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200022a91906200042c565b600081905550806001600160a01b0316635a3d54936040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200026f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200029591906200042c565b600181905550600080826001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015620002dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200030391906200045e565b6002805463ffffffff191663ffffffff9290921691909117905590925090506001600160701b038216158015906200034357506001600160701b03811615155b620003945760405162461bcd60e51b815260206004820181905260248201527f4578616d706c654f7261636c6553696d706c653a204e4f5f5245534552564553604482015260640160405180910390fd5b505050505050620004b4565b80516001600160a01b0381168114620003b857600080fd5b919050565b600080600060608486031215620003d357600080fd5b620003de84620003a0565b9250620003ee60208501620003a0565b9150620003fe60408501620003a0565b90509250925092565b6000602082840312156200041a57600080fd5b6200042582620003a0565b9392505050565b6000602082840312156200043f57600080fd5b5051919050565b80516001600160701b0381168114620003b857600080fd5b6000806000606084860312156200047457600080fd5b6200047f8462000446565b92506200048f6020850162000446565b9150604084015163ffffffff81168114620004a957600080fd5b809150509250925092565b60805160a05160c051610d29620004f8600039600081816101ea015261028701526000818160be015261021001526000818161019501526103910152610d296000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c8063a2e6204511610071578063a2e6204514610173578063a6bb45391461017d578063a8aa1b3114610190578063b4d1d795146101b7578063c5700a02146101c0578063d21220a7146101e557600080fd5b80630dfe1681146100b95780633ddac953146100fd5780635909c0d51461011e5780635a3d5493146101275780635e6aaf2c14610130578063a17a26851461015b575b600080fd5b6100e07f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b61011061010b366004610b81565b61020c565b6040519081526020016100f4565b61011060005481565b61011060015481565b600454610143906001600160e01b031681565b6040516001600160e01b0390911681526020016100f4565b61016361034f565b60405190151581526020016100f4565b61017b610387565b005b600354610143906001600160e01b031681565b6100e07f000000000000000000000000000000000000000000000000000000000000000081565b61011061012c81565b6002546101d09063ffffffff1681565b60405163ffffffff90911681526020016100f4565b6100e07f000000000000000000000000000000000000000000000000000000000000000081565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b0316036102855760408051602081019091526003546001600160e01b031681526102759061026e9084610502565b5160701c90565b6001600160901b03169050610349565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b0316146103165760405162461bcd60e51b815260206004820152602260248201527f4578616d706c654f7261636c6553696d706c653a20494e56414c49445f544f4b60448201526122a760f11b60648201526084015b60405180910390fd5b60408051602081019091526004546001600160e01b0316815261033d9061026e9084610502565b6001600160901b031690505b92915050565b60008061035a6105a0565b6002549091506000906103739063ffffffff1683610bcf565b61012c63ffffffff90911610159392505050565b60008060006103b57f00000000000000000000000000000000000000000000000000000000000000006105b6565b60025492955090935091506000906103d39063ffffffff1683610bcf565b905061012c8163ffffffff16101561043d5760405162461bcd60e51b815260206004820152602760248201527f4578616d706c654f7261636c6553696d706c653a20504552494f445f4e4f545f6044820152661153105414d15160ca1b606482015260840161030d565b60405180602001604052808263ffffffff166000548761045d9190610bf3565b6104679190610c1c565b6001600160e01b039081169091529051600380546001600160e01b031916919092161790556040805160208101909152600154819063ffffffff8416906104ae9087610bf3565b6104b89190610c1c565b6001600160e01b039081169091529051600480546001600160e01b03191691909216179055506000929092556001556002805463ffffffff191663ffffffff909216919091179055565b604080516020810190915260008152600082158061053f575083516001600160e01b0316836105318183610c30565b925061053d9083610c1c565b145b61058b5760405162461bcd60e51b815260206004820152601960248201527f4669786564506f696e743a3a6d756c3a206f766572666c6f7700000000000000604482015260640161030d565b60408051602081019091529081529392505050565b60006105b164010000000042610c47565b905090565b60008060006105c36105a0565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610603573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106279190610c5b565b9250836001600160a01b0316635a3d54936040518163ffffffff1660e01b8152600401602060405180830381865afa158015610667573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068b9190610c5b565b91506000806000866001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa1580156106d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f49190610c90565b9250925092508363ffffffff168163ffffffff16146107a35760006107198286610bcf565b90508063ffffffff1661073e846001600160701b0316866001600160701b03166107ad565b5161075291906001600160e01b0316610c30565b61075c9088610ce0565b96508063ffffffff16610781856001600160701b0316856001600160701b03166107ad565b5161079591906001600160e01b0316610c30565b61079f9087610ce0565b9550505b5050509193909250565b6040805160208101909152600081526000821161081b5760405162461bcd60e51b815260206004820152602660248201527f4669786564506f696e743a3a6672616374696f6e3a206469766973696f6e206260448201526579207a65726f60d01b606482015260840161030d565b826000036108385750604080516020810190915260008152610349565b6001600160901b0383116108cf57600061085683607086901b610c1c565b90506001600160e01b038111156108af5760405162461bcd60e51b815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015260640161030d565b6040518060200160405280826001600160e01b0316815250915050610349565b600061085684600160701b8560008060006108ea86866109a8565b91509150600084806108fe576108fe610c06565b86880990508281111561091957610916600183610bf3565b91505b6109238184610bf3565b925081600003610941576109378584610c1c565b93505050506109a1565b8482106109905760405162461bcd60e51b815260206004820152601a60248201527f46756c6c4d6174683a2046554c4c4449565f4f564552464c4f57000000000000604482015260640161030d565b61099b8383876109ea565b93505050505b9392505050565b6000808060001984860990506109be8486610c30565b92506109ca8382610bf3565b9150828110156109e2576109df600183610bf3565b91505b509250929050565b6000806109f983600019610bf3565b610a04906001610ce0565b83169050610a128184610c1c565b9250610a1e8186610c1c565b945080610a2d81600019610bf3565b610a38906001610ce0565b610a429190610c1c565b610a4d906001610ce0565b610a579085610c30565b610a619086610ce0565b94506001610a6f8185610c30565b610a7a906002610bf3565b610a849082610c30565b9050610a908185610c30565b610a9b906002610bf3565b610aa59082610c30565b9050610ab18185610c30565b610abc906002610bf3565b610ac69082610c30565b9050610ad28185610c30565b610add906002610bf3565b610ae79082610c30565b9050610af38185610c30565b610afe906002610bf3565b610b089082610c30565b9050610b148185610c30565b610b1f906002610bf3565b610b299082610c30565b9050610b358185610c30565b610b40906002610bf3565b610b4a9082610c30565b9050610b568185610c30565b610b61906002610bf3565b610b6b9082610c30565b9050610b778187610c30565b9695505050505050565b60008060408385031215610b9457600080fd5b82356001600160a01b0381168114610bab57600080fd5b946020939093013593505050565b634e487b7160e01b600052601160045260246000fd5b63ffffffff828116828216039080821115610bec57610bec610bb9565b5092915050565b8181038181111561034957610349610bb9565b634e487b7160e01b600052601260045260246000fd5b600082610c2b57610c2b610c06565b500490565b808202811582820484141761034957610349610bb9565b600082610c5657610c56610c06565b500690565b600060208284031215610c6d57600080fd5b5051919050565b80516001600160701b0381168114610c8b57600080fd5b919050565b600080600060608486031215610ca557600080fd5b610cae84610c74565b9250610cbc60208501610c74565b9150604084015163ffffffff81168114610cd557600080fd5b809150509250925092565b8082018082111561034957610349610bb956fea26469706673582212204cdec9e6b036d1675bcafb1e72f0b333239efccb9789d99497916e6d757d94d864736f6c634300081400330000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f00000000000000000000000070536d44820fe3ddd4a2e3eedbc937b8b9d566c700000000000000000000000080f0c1c49891dcfdd40b6e0f960f84e6042bcb6f
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c8063a2e6204511610071578063a2e6204514610173578063a6bb45391461017d578063a8aa1b3114610190578063b4d1d795146101b7578063c5700a02146101c0578063d21220a7146101e557600080fd5b80630dfe1681146100b95780633ddac953146100fd5780635909c0d51461011e5780635a3d5493146101275780635e6aaf2c14610130578063a17a26851461015b575b600080fd5b6100e07f00000000000000000000000070536d44820fe3ddd4a2e3eedbc937b8b9d566c781565b6040516001600160a01b0390911681526020015b60405180910390f35b61011061010b366004610b81565b61020c565b6040519081526020016100f4565b61011060005481565b61011060015481565b600454610143906001600160e01b031681565b6040516001600160e01b0390911681526020016100f4565b61016361034f565b60405190151581526020016100f4565b61017b610387565b005b600354610143906001600160e01b031681565b6100e07f00000000000000000000000098134cde70ff7280bb4b9f4eba2154009f2c13ac81565b61011061012c81565b6002546101d09063ffffffff1681565b60405163ffffffff90911681526020016100f4565b6100e07f00000000000000000000000080f0c1c49891dcfdd40b6e0f960f84e6042bcb6f81565b60007f00000000000000000000000070536d44820fe3ddd4a2e3eedbc937b8b9d566c76001600160a01b0316836001600160a01b0316036102855760408051602081019091526003546001600160e01b031681526102759061026e9084610502565b5160701c90565b6001600160901b03169050610349565b7f00000000000000000000000080f0c1c49891dcfdd40b6e0f960f84e6042bcb6f6001600160a01b0316836001600160a01b0316146103165760405162461bcd60e51b815260206004820152602260248201527f4578616d706c654f7261636c6553696d706c653a20494e56414c49445f544f4b60448201526122a760f11b60648201526084015b60405180910390fd5b60408051602081019091526004546001600160e01b0316815261033d9061026e9084610502565b6001600160901b031690505b92915050565b60008061035a6105a0565b6002549091506000906103739063ffffffff1683610bcf565b61012c63ffffffff90911610159392505050565b60008060006103b57f00000000000000000000000098134cde70ff7280bb4b9f4eba2154009f2c13ac6105b6565b60025492955090935091506000906103d39063ffffffff1683610bcf565b905061012c8163ffffffff16101561043d5760405162461bcd60e51b815260206004820152602760248201527f4578616d706c654f7261636c6553696d706c653a20504552494f445f4e4f545f6044820152661153105414d15160ca1b606482015260840161030d565b60405180602001604052808263ffffffff166000548761045d9190610bf3565b6104679190610c1c565b6001600160e01b039081169091529051600380546001600160e01b031916919092161790556040805160208101909152600154819063ffffffff8416906104ae9087610bf3565b6104b89190610c1c565b6001600160e01b039081169091529051600480546001600160e01b03191691909216179055506000929092556001556002805463ffffffff191663ffffffff909216919091179055565b604080516020810190915260008152600082158061053f575083516001600160e01b0316836105318183610c30565b925061053d9083610c1c565b145b61058b5760405162461bcd60e51b815260206004820152601960248201527f4669786564506f696e743a3a6d756c3a206f766572666c6f7700000000000000604482015260640161030d565b60408051602081019091529081529392505050565b60006105b164010000000042610c47565b905090565b60008060006105c36105a0565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610603573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106279190610c5b565b9250836001600160a01b0316635a3d54936040518163ffffffff1660e01b8152600401602060405180830381865afa158015610667573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068b9190610c5b565b91506000806000866001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa1580156106d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f49190610c90565b9250925092508363ffffffff168163ffffffff16146107a35760006107198286610bcf565b90508063ffffffff1661073e846001600160701b0316866001600160701b03166107ad565b5161075291906001600160e01b0316610c30565b61075c9088610ce0565b96508063ffffffff16610781856001600160701b0316856001600160701b03166107ad565b5161079591906001600160e01b0316610c30565b61079f9087610ce0565b9550505b5050509193909250565b6040805160208101909152600081526000821161081b5760405162461bcd60e51b815260206004820152602660248201527f4669786564506f696e743a3a6672616374696f6e3a206469766973696f6e206260448201526579207a65726f60d01b606482015260840161030d565b826000036108385750604080516020810190915260008152610349565b6001600160901b0383116108cf57600061085683607086901b610c1c565b90506001600160e01b038111156108af5760405162461bcd60e51b815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015260640161030d565b6040518060200160405280826001600160e01b0316815250915050610349565b600061085684600160701b8560008060006108ea86866109a8565b91509150600084806108fe576108fe610c06565b86880990508281111561091957610916600183610bf3565b91505b6109238184610bf3565b925081600003610941576109378584610c1c565b93505050506109a1565b8482106109905760405162461bcd60e51b815260206004820152601a60248201527f46756c6c4d6174683a2046554c4c4449565f4f564552464c4f57000000000000604482015260640161030d565b61099b8383876109ea565b93505050505b9392505050565b6000808060001984860990506109be8486610c30565b92506109ca8382610bf3565b9150828110156109e2576109df600183610bf3565b91505b509250929050565b6000806109f983600019610bf3565b610a04906001610ce0565b83169050610a128184610c1c565b9250610a1e8186610c1c565b945080610a2d81600019610bf3565b610a38906001610ce0565b610a429190610c1c565b610a4d906001610ce0565b610a579085610c30565b610a619086610ce0565b94506001610a6f8185610c30565b610a7a906002610bf3565b610a849082610c30565b9050610a908185610c30565b610a9b906002610bf3565b610aa59082610c30565b9050610ab18185610c30565b610abc906002610bf3565b610ac69082610c30565b9050610ad28185610c30565b610add906002610bf3565b610ae79082610c30565b9050610af38185610c30565b610afe906002610bf3565b610b089082610c30565b9050610b148185610c30565b610b1f906002610bf3565b610b299082610c30565b9050610b358185610c30565b610b40906002610bf3565b610b4a9082610c30565b9050610b568185610c30565b610b61906002610bf3565b610b6b9082610c30565b9050610b778187610c30565b9695505050505050565b60008060408385031215610b9457600080fd5b82356001600160a01b0381168114610bab57600080fd5b946020939093013593505050565b634e487b7160e01b600052601160045260246000fd5b63ffffffff828116828216039080821115610bec57610bec610bb9565b5092915050565b8181038181111561034957610349610bb9565b634e487b7160e01b600052601260045260246000fd5b600082610c2b57610c2b610c06565b500490565b808202811582820484141761034957610349610bb9565b600082610c5657610c56610c06565b500690565b600060208284031215610c6d57600080fd5b5051919050565b80516001600160701b0381168114610c8b57600080fd5b919050565b600080600060608486031215610ca557600080fd5b610cae84610c74565b9250610cbc60208501610c74565b9150604084015163ffffffff81168114610cd557600080fd5b809150509250925092565b8082018082111561034957610349610bb956fea26469706673582212204cdec9e6b036d1675bcafb1e72f0b333239efccb9789d99497916e6d757d94d864736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f00000000000000000000000070536d44820fe3ddd4a2e3eedbc937b8b9d566c700000000000000000000000080f0c1c49891dcfdd40b6e0f960f84e6042bcb6f
-----Decoded View---------------
Arg [0] : factory (address): 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f
Arg [1] : tokenA (address): 0x70536D44820fE3ddd4A2e3eEdbC937b8B9D566C7
Arg [2] : tokenB (address): 0x80f0C1c49891dcFDD40b6e0F960F84E6042bcB6F
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f
Arg [1] : 00000000000000000000000070536d44820fe3ddd4a2e3eedbc937b8b9d566c7
Arg [2] : 00000000000000000000000080f0c1c49891dcfdd40b6e0f960f84e6042bcb6f
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 26 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
[ 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.