ETH Price: $3,419.99 (+1.13%)
Gas: 4 Gwei

Contract

0x488490185c32f183A39d787ED311ee8EfAd715C9
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Value
Update Cumulativ...201973832024-06-29 12:36:3530 hrs ago1719664595IN
0x48849018...EfAd715C9
0 ETH0.000191942.95739767
Update Cumulativ...201970622024-06-29 11:31:3532 hrs ago1719660695IN
0x48849018...EfAd715C9
0 ETH0.000245833.78765802
Update Cumulativ...201967382024-06-29 10:26:3533 hrs ago1719656795IN
0x48849018...EfAd715C9
0 ETH0.000167652.58306929
Update Cumulativ...201964142024-06-29 9:21:3534 hrs ago1719652895IN
0x48849018...EfAd715C9
0 ETH0.000193722.98477802
Update Cumulativ...201960922024-06-29 8:16:3535 hrs ago1719648995IN
0x48849018...EfAd715C9
0 ETH0.000250813.86442593
Update Cumulativ...201957702024-06-29 7:11:3536 hrs ago1719645095IN
0x48849018...EfAd715C9
0 ETH0.000204853.15621448
Update Cumulativ...201954462024-06-29 6:06:3537 hrs ago1719641195IN
0x48849018...EfAd715C9
0 ETH0.000189172.91473219
Update Cumulativ...201951222024-06-29 5:01:3538 hrs ago1719637295IN
0x48849018...EfAd715C9
0 ETH0.000164312.53170424
Update Cumulativ...201947992024-06-29 3:56:3539 hrs ago1719633395IN
0x48849018...EfAd715C9
0 ETH0.00016352.51917118
Update Cumulativ...201944762024-06-29 2:51:3540 hrs ago1719629495IN
0x48849018...EfAd715C9
0 ETH0.000172752.66172925
Update Cumulativ...201941542024-06-29 1:46:3541 hrs ago1719625595IN
0x48849018...EfAd715C9
0 ETH0.000160272.46936123
Update Cumulativ...201938302024-06-29 0:41:3542 hrs ago1719621695IN
0x48849018...EfAd715C9
0 ETH0.000164132.52886916
Update Cumulativ...201935092024-06-28 23:36:3543 hrs ago1719617795IN
0x48849018...EfAd715C9
0 ETH0.000252293.88725787
Update Cumulativ...201931872024-06-28 22:31:3545 hrs ago1719613895IN
0x48849018...EfAd715C9
0 ETH0.000242573.73746937
Update Cumulativ...201928622024-06-28 21:26:3546 hrs ago1719609995IN
0x48849018...EfAd715C9
0 ETH0.000209023.22054478
Update Cumulativ...201925412024-06-28 20:21:3547 hrs ago1719606095IN
0x48849018...EfAd715C9
0 ETH0.000258083.97647725
Update Cumulativ...201922162024-06-28 19:16:352 days ago1719602195IN
0x48849018...EfAd715C9
0 ETH0.000232363.58008343
Update Cumulativ...201918922024-06-28 18:11:472 days ago1719598307IN
0x48849018...EfAd715C9
0 ETH0.000448556.91098399
Update Cumulativ...201915682024-06-28 17:06:352 days ago1719594395IN
0x48849018...EfAd715C9
0 ETH0.000522658.05269414
Update Cumulativ...201912472024-06-28 16:01:352 days ago1719590495IN
0x48849018...EfAd715C9
0 ETH0.0009070113.97465326
Update Cumulativ...201909242024-06-28 14:56:352 days ago1719586595IN
0x48849018...EfAd715C9
0 ETH0.0008021512.35905628
Update Cumulativ...201906002024-06-28 13:51:352 days ago1719582695IN
0x48849018...EfAd715C9
0 ETH0.000454567.00364093
Update Cumulativ...201902762024-06-28 12:46:352 days ago1719578795IN
0x48849018...EfAd715C9
0 ETH0.000480247.39931466
Update Cumulativ...201899512024-06-28 11:41:352 days ago1719574895IN
0x48849018...EfAd715C9
0 ETH0.000290724.47931376
Update Cumulativ...201896292024-06-28 10:36:352 days ago1719570995IN
0x48849018...EfAd715C9
0 ETH0.000461287.1071228
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
UniswapV2TwapOracle

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion
File 1 of 15 : UniswapV2TwapOracle.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "contracts/interfaces/IUniswapV2TwapOracle.sol";
import "contracts/uniswap/libraries/FixedPoint.sol";
import "contracts/uniswap/libraries/UniswapV2OracleLibrary.sol";
import "contracts/uniswap/libraries/UniswapV2Library.sol";

/// @title Uniswap V2 TWAP Oracle
/// @notice PriceFeedAggregator uses this contract to be TWAP price of USC and CHI tokens
/// @notice One instance of this contract handles one Uniswap V2 pair
/// @notice This contract takes snapshots of cumulative prices and calculates TWAP price from them
contract UniswapV2TwapOracle is IUniswapV2TwapOracle {
  using FixedPoint for *;

  AggregatorV3Interface public immutable quoteTokenChainlinkFeed;
  IUniswapV2Pair public immutable pair;

  uint8 public immutable decimals;
  uint32 public immutable updatePeriod;
  uint32 public immutable minPeriodFromLastSnapshot;

  address public immutable baseToken;
  uint128 public immutable baseAmount; // should be 10^baseToken.decimals

  address public immutable token0;
  address public immutable token1;

  CumulativePriceSnapshot public previousSnapshot;
  CumulativePriceSnapshot public lastSnapshot;

  constructor(
    address _factory,
    address _baseToken,
    address _quoteToken,
    uint32 _updatePeriod,
    uint32 _minPeriodFromLastSnapshot,
    AggregatorV3Interface _quoteTokenChainlinkFeed
  ) {
    baseToken = _baseToken;
    baseAmount = uint128(10 ** (IERC20Metadata(baseToken).decimals()));

    updatePeriod = _updatePeriod;
    minPeriodFromLastSnapshot = _minPeriodFromLastSnapshot;

    quoteTokenChainlinkFeed = _quoteTokenChainlinkFeed;
    decimals = _quoteTokenChainlinkFeed.decimals();

    IUniswapV2Pair _pair = IUniswapV2Pair(UniswapV2Library.pairFor(_factory, _baseToken, _quoteToken));
    pair = _pair;
    token0 = _pair.token0();
    token1 = _pair.token1();

    (uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp) = UniswapV2OracleLibrary
      .currentCumulativePrices(address(pair));

    lastSnapshot = CumulativePriceSnapshot({
      price0: price0Cumulative,
      price1: price1Cumulative,
      blockTimestamp: blockTimestamp
    });
    previousSnapshot = lastSnapshot;

    uint112 reserve0;
    uint112 reserve1;
    (reserve0, reserve1, lastSnapshot.blockTimestamp) = _pair.getReserves();

    // ensure that there's liquidity in the pair
    if (reserve0 == 0 || reserve1 == 0) {
      revert NoReserves();
    }
  }

  /// @inheritdoc IOracle
  function name() external view returns (string memory) {
    return string(abi.encodePacked("UniV2 TWAP - ", IERC20Metadata(baseToken).symbol()));
  }

  /// @inheritdoc IUniswapV2TwapOracle
  function updateCumulativePricesSnapshot() public {
    (uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp) = UniswapV2OracleLibrary
      .currentCumulativePrices(address(pair));

    if (blockTimestamp - lastSnapshot.blockTimestamp < updatePeriod) {
      revert PeriodNotPassed();
    }

    previousSnapshot = lastSnapshot;
    lastSnapshot = CumulativePriceSnapshot({
      price0: price0Cumulative,
      price1: price1Cumulative,
      blockTimestamp: blockTimestamp
    });

    emit UpdateCumulativePricesSnapshot();
  }

  /// @inheritdoc IUniswapV2TwapOracle
  function getTwapQuote(address token, uint256 amountIn) public view returns (uint256 amountOut) {
    (uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp) = UniswapV2OracleLibrary
      .currentCumulativePrices(address(pair));

    uint32 timeElapsedFromLast = blockTimestamp - lastSnapshot.blockTimestamp;

    CumulativePriceSnapshot storage snapshot;
    if (timeElapsedFromLast >= minPeriodFromLastSnapshot) {
      snapshot = lastSnapshot;
    } else {
      snapshot = previousSnapshot;
    }

    uint32 timeElapsed = blockTimestamp - snapshot.blockTimestamp;

    if (token == token0) {
      // overflow is desired, casting never truncates
      // cumulative price is in (uq112x112 price * seconds) units so we simply wrap it after division by time elapsed
      FixedPoint.uq112x112 memory price0Average = FixedPoint.uq112x112(
        uint224((price0Cumulative - snapshot.price0) / timeElapsed)
      );
      amountOut = price0Average.mul(amountIn).decode144();
    } else {
      if (token != token1) {
        revert InvalidToken();
      }
      FixedPoint.uq112x112 memory price1Average = FixedPoint.uq112x112(
        uint224((price1Cumulative - snapshot.price1) / timeElapsed)
      );
      amountOut = price1Average.mul(amountIn).decode144();
    }

    return amountOut;
  }

  /// @inheritdoc IUniswapV2TwapOracle
  function peek() external view returns (uint256 price) {
    uint256 quotedAmount = getTwapQuote(baseToken, baseAmount);

    (, int256 quoteTokenPriceInUSD, , , ) = quoteTokenChainlinkFeed.latestRoundData();
    uint256 priceInUSD = (uint256(quoteTokenPriceInUSD) * quotedAmount) / baseAmount; // quote token price will be always greater than 0, so it's ok to convert int to uint

    return priceInUSD;
  }
}

File 2 of 15 : AggregatorV3Interface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface AggregatorV3Interface {
  function decimals() external view returns (uint8);

  function description() external view returns (string memory);

  function version() external view returns (uint256);

  function getRoundData(uint80 _roundId)
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

  function latestRoundData()
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );
}

File 3 of 15 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 4 of 15 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}

File 5 of 15 : IUniswapV2Factory.sol
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;
}

File 6 of 15 : IUniswapV2Pair.sol
pragma solidity >=0.5.0;

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

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

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

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

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

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

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

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

    function initialize(address, address) external;
}

File 7 of 15 : IOracle.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IOracle {
  /// @notice Gets name of price adapter
  /// @return name Name of price adapter
  function name() external view returns (string memory name);

  /// @notice Gets decimals of price adapter
  /// @return decimals Decimals of price adapter
  function decimals() external view returns (uint8 decimals);

  /// @notice Gets price base token from Chainlink price feed
  /// @return price price in USD for the 1 baseToken
  function peek() external view returns (uint256 price);
}

File 8 of 15 : IUniswapV2TwapOracle.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IOracle.sol";

interface IUniswapV2TwapOracle is IOracle {
  struct CumulativePriceSnapshot {
    uint256 price0;
    uint256 price1;
    uint32 blockTimestamp;
  }

  event UpdateCumulativePricesSnapshot();

  error NoReserves();
  error InvalidToken();
  error PeriodNotPassed();

  /// @notice Takes cumulative price snapshot and updates previous and last snapshots
  /// @notice Cumulative price is in quote token
  /// @custom:usage This function should be called periodically by external keeper
  function updateCumulativePricesSnapshot() external;

  /// @notice Gets TWAP quote for given token
  /// @notice TWAP quote is in quote token
  /// @param token Token address
  /// @param amountIn Amount of token to get quote for
  /// @return amountOut Quote amount in quote token
  function getTwapQuote(address token, uint256 amountIn) external view returns (uint256 amountOut);

  /// @notice Gets TWAP quote for base token
  /// @dev This function is used by PriceFeedAggregator contract
  /// @return price price in USD for the 1 baseToken
  function peek() external view returns (uint256 price);
}

File 9 of 15 : Babylonian.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

// library copied from uniswap/lib/contracts/libraries/Babylonian.sol
// the only change is in pragma solidity version

// 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);
  }
}

File 10 of 15 : BitMath.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

// library copied from uniswap/lib/contracts/libraries/BitMath.sol
// the only change is in pragma solidity version

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 & type(uint128).max > 0) {
      r -= 128;
    } else {
      x >>= 128;
    }
    if (x & type(uint64).max > 0) {
      r -= 64;
    } else {
      x >>= 64;
    }
    if (x & type(uint32).max > 0) {
      r -= 32;
    } else {
      x >>= 32;
    }
    if (x & type(uint16).max > 0) {
      r -= 16;
    } else {
      x >>= 16;
    }
    if (x & type(uint8).max > 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;
  }
}

File 11 of 15 : FixedPoint.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

// library copied from uniswap/lib/contracts/libraries/FixedPoint.sol
// the only change is in pragma solidity version

import "./FullMath.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 = FullMath.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 <= type(uint112).max, "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 <= type(uint224).max, "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 <= type(uint144).max) {
      uint256 value = (uint256(self._x) << RESOLUTION) / other._x;
      require(value <= type(uint224).max, "FixedPoint::divuq: overflow");
      return uq112x112(uint224(value));
    }

    uint256 result = FullMath.mulDiv(Q112, self._x, other._x);
    require(result <= type(uint224).max, "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 <= type(uint144).max) {
      uint256 result = (numerator << RESOLUTION) / denominator;
      require(result <= type(uint224).max, "FixedPoint::fraction: overflow");
      return uq112x112(uint224(result));
    } else {
      uint256 result = FullMath.mulDiv(numerator, Q112, denominator);
      require(result <= type(uint224).max, "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 <= type(uint144).max) {
      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)));
  }
}

File 12 of 15 : FullMath.sol
// SPDX-License-Identifier: CC-BY-4.0
pragma solidity ^0.8.0;

// library copied from uniswap/lib/contracts/libraries/FullMath.sol
// the only change is in pragma solidity version

// taken from https://medium.com/coinmonks/math-in-solidity-part-3-percents-and-proportions-4db014e080b1
// license is CC-BY-4.0
library FullMath {
  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 & (~d + 1);
    d /= pow2;
    l /= pow2;
    l += h * ((~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);
  }
}

File 13 of 15 : SafeMath.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

// library copied from uniswap/v2-core/contracts/libraries/SafeMath.sol
// the only change is in pragma solidity version.
// this contract was the reason of incompatible solidity version error

// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)

library SafeMath {
  function add(uint x, uint y) internal pure returns (uint z) {
    require((z = x + y) >= x, "ds-math-add-overflow");
  }

  function sub(uint x, uint y) internal pure returns (uint z) {
    require((z = x - y) <= x, "ds-math-sub-underflow");
  }

  function mul(uint x, uint y) internal pure returns (uint z) {
    require(y == 0 || (z = x * y) / y == x, "ds-math-mul-overflow");
  }
}

File 14 of 15 : UniswapV2Library.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

// library copied from uniswap/v2-core/contracts/libraries/UniswapV2Library.sol
// the only change is in pragma solidity version.

import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";

import "./SafeMath.sol";

library UniswapV2Library {
  using SafeMath for uint;

  // 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(
        uint(
          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 (uint reserveA, uint reserveB) {
    (address token0, ) = sortTokens(tokenA, tokenB);
    (uint reserve0, uint 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(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint 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(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
    require(amountIn > 0, "UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT");
    require(reserveIn > 0 && reserveOut > 0, "UniswapV2Library: INSUFFICIENT_LIQUIDITY");
    uint amountInWithFee = amountIn.mul(997);
    uint numerator = amountInWithFee.mul(reserveOut);
    uint 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(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
    require(amountOut > 0, "UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT");
    require(reserveIn > 0 && reserveOut > 0, "UniswapV2Library: INSUFFICIENT_LIQUIDITY");
    uint numerator = reserveIn.mul(amountOut).mul(1000);
    uint denominator = reserveOut.sub(amountOut).mul(997);
    amountIn = (numerator / denominator).add(1);
  }

  // performs chained getAmountOut calculations on any number of pairs
  function getAmountsOut(
    address factory,
    uint amountIn,
    address[] memory path
  ) internal view returns (uint[] memory amounts) {
    require(path.length >= 2, "UniswapV2Library: INVALID_PATH");
    amounts = new uint[](path.length);
    amounts[0] = amountIn;
    for (uint i; i < path.length - 1; i++) {
      (uint reserveIn, uint 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,
    uint amountOut,
    address[] memory path
  ) internal view returns (uint[] memory amounts) {
    require(path.length >= 2, "UniswapV2Library: INVALID_PATH");
    amounts = new uint[](path.length);
    amounts[amounts.length - 1] = amountOut;
    for (uint i = path.length - 1; i > 0; i--) {
      (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
      amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
    }
  }
}

File 15 of 15 : UniswapV2OracleLibrary.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

// library copied from uniswap/v2-core/contracts/libraries/UniswapV2OracleLibrary.sol
// the only change is in pragma solidity version.

import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";

import "./FixedPoint.sol";

// library with helper methods for oracles that are concerned with computing average prices
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 (uint price0Cumulative, uint 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 += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;
      // counterfactual
      price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;
    }
  }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 1000
  },
  "viaIR": true,
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_factory","type":"address"},{"internalType":"address","name":"_baseToken","type":"address"},{"internalType":"address","name":"_quoteToken","type":"address"},{"internalType":"uint32","name":"_updatePeriod","type":"uint32"},{"internalType":"uint32","name":"_minPeriodFromLastSnapshot","type":"uint32"},{"internalType":"contract AggregatorV3Interface","name":"_quoteTokenChainlinkFeed","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidToken","type":"error"},{"inputs":[],"name":"NoReserves","type":"error"},{"inputs":[],"name":"PeriodNotPassed","type":"error"},{"anonymous":false,"inputs":[],"name":"UpdateCumulativePricesSnapshot","type":"event"},{"inputs":[],"name":"baseAmount","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"}],"name":"getTwapQuote","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastSnapshot","outputs":[{"internalType":"uint256","name":"price0","type":"uint256"},{"internalType":"uint256","name":"price1","type":"uint256"},{"internalType":"uint32","name":"blockTimestamp","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minPeriodFromLastSnapshot","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pair","outputs":[{"internalType":"contract IUniswapV2Pair","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"peek","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"previousSnapshot","outputs":[{"internalType":"uint256","name":"price0","type":"uint256"},{"internalType":"uint256","name":"price1","type":"uint256"},{"internalType":"uint32","name":"blockTimestamp","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"quoteTokenChainlinkFeed","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"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":"updateCumulativePricesSnapshot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updatePeriod","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"}]

6101a08060405234620007835760c08162001d588038038091620000248285620007a3565b83398101031262000783576200003a81620007c7565b906200004960208201620007c7565b916200005860408301620007c7565b906200006760608401620007dc565b9360a06200007860808601620007dc565b940151936001600160a01b0385168503620007835761012082815260405163313ce56760e01b81529096906020816004816001600160a01b0388165afa8015620004a85760ff915f916200075f575b501695604d871162000540576004926020926101409860018060801b0390600a0a16895260e05261010052806080526040519283809263313ce56760e01b825260018060a01b03165afa908115620004a8575f9162000729575b5060c0526001600160a01b038381169082168114620006d6576001600160a01b0382161015620006cf5791905b6001600160a01b038316156200068a576040516001600160601b0319606094851b81166020830190815293851b81166034830152602882526001600160401b039491939184019184831086841117620004b357826040528451902090608085019360ff60f81b855260601b16608185015260958401527f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f60b58401526055815260e083019181831085841117620004b3576040839052905190206001600160a01b031660a0819052630dfe168160e01b825290602081600481855afa928315620004a8575f9362000647575b505061016091825260405163d21220a760e01b815292602084600481855afa938415620004a8575f9462000603575b5061018093845260018060a01b0360a05116905f9063ffffffff92834216604051635909c0d560e01b8152602081600481865afa948515620005f7578095620005ba575b5050604051635a3d549360e01b81528490602081600481875afa908115620004a8575f916200057f575b50809160405191606083600481630240bc6b60e21b998a82525afa8015620004a857895f918295839162000554575b5016868103620004c7575b5050505050604051606081019481861090861117620004b3576040839160609682528781528360208201520152846003558060045563ffffffff19908160055416958387176005555f55600155600254161760025560046040518096819382525afa918215620004a8575f928394849162000468575b5016176005556001600160701b03908116159182156200045c575b50506200044a5760405192611118948562000c4086396080518581816101ab015261033a015260a0518581816101ef0152818161040501526108c9015260c051856105a9015260e05185818161023001526104470152610100518581816105ea0152610908015251848181610167015281816102e101526106960152518381816102ba015261056b01525182818161062e015261094b01525181818161011f01526109be0152f35b60405163d8b9cde160e01b8152600490fd5b161590505f80620003a2565b919350506200049491935060603d606011620004a0575b6200048b8183620007a3565b8101906200081e565b93919290935f62000387565b503d6200047f565b6040513d5f823e3d90fd5b634e487b7160e01b5f52604160045260245ffd5b9193985091935084038881116200054057620005136200052d6200051f936200052662000535976200051f8e9d60018060701b0380911694169d8e60018060e01b0397889187620008e3565b51169716809762000855565b9062000869565b9a620008e3565b511662000855565b5f8080808062000311565b634e487b7160e01b5f52601160045260245ffd5b9195505062000575915060603d606011620004a0576200048b8183620007a3565b9490945f62000306565b906020823d602011620005b1575b816200059c60209383620007a3565b81010312620005ae5750515f620002d7565b80fd5b3d91506200058d565b909194506020823d602011620005ee575b81620005da60209383620007a3565b81010312620005ae575051925f80620002ad565b3d9150620005cb565b604051903d90823e3d90fd5b90936020823d6020116200063e575b816200062160209383620007a3565b81010312620005ae57506200063690620007c7565b925f62000269565b3d915062000612565b60209081949293943d831162000682575b620006648186620007a3565b81010312620005ae57506200067990620007c7565b905f806200023a565b503d62000658565b60405162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f4144445245535300006044820152606490fd5b906200014e565b60405162461bcd60e51b815260206004820152602560248201527f556e697377617056324c6962726172793a204944454e544943414c5f41444452604482015264455353455360d81b6064820152608490fd5b62000750915060203d60201162000757575b620007478183620007a3565b810190620007ee565b5f62000121565b503d6200073b565b6200077c915060203d6020116200075757620007478183620007a3565b5f620000c7565b5f80fd5b602081019081106001600160401b03821117620004b357604052565b601f909101601f19168101906001600160401b03821190821017620004b357604052565b51906001600160a01b03821682036200078357565b519063ffffffff821682036200078357565b9081602091031262000783575160ff81168103620007835790565b51906001600160701b03821682036200078357565b908160609103126200078357620008358162000809565b916200085260406200084a6020850162000809565b9301620007dc565b90565b818102929181159184041417156200054057565b919082018092116200054057565b156200087f57565b60405162461bcd60e51b815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f7700006044820152606490fd5b8115620008cf570490565b634e487b7160e01b5f52601260045260245ffd5b905f604051620008f38162000787565b5280156200096b57811562000955576001600160901b0382116200094a576200091f9160701b620008c4565b6001600160e01b03620009358183111562000877565b60405191620009448362000787565b16815290565b6200091f91620009cd565b5050604051620009658162000787565b5f815290565b60405162461bcd60e51b815260206004820152602660248201527f4669786564506f696e743a3a6672616374696f6e3a206469766973696f6e206260448201526579207a65726f60d01b6064820152608490fd5b919082039182116200054057565b5f90600160701b905f199081838209908060701b9481860485148215171562000c2b575084620009fe8184620009bf565b921062000c18575b81938615620008cf578691099184831162000c02575b505062000a2a9192620009bf565b91811562000bf5578082101562000bb05780196001810180911162000540578162000a669162000a5f931692838092620008c4565b94620008c4565b9080199060018201809211620005405762000a8191620008c4565b9160018301809311620005405762000a9e926200051f9162000855565b818004600114821517156200054057600291808303838111620005405762000ac7818362000855565b8403848111620005405762000adc9162000855565b62000ae8818362000855565b8403848111620005405762000afd9162000855565b62000b09818362000855565b8403848111620005405762000b1e9162000855565b62000b2a818362000855565b8403848111620005405762000b3f9162000855565b62000b4b818362000855565b8403848111620005405762000b609162000855565b62000b6c818362000855565b840390848211620005405762000b8f9162000b879162000855565b809262000855565b83039283116200054057620008529262000ba99162000855565b9062000855565b60405162461bcd60e51b815260206004820152601a60248201527f46756c6c4d6174683a2046554c4c4449565f4f564552464c4f570000000000006044820152606490fd5b90506200085291620008c4565b810192508211620005405762000a2a5f62000a1c565b9082810190811162000540579062000a06565b634e487b7160e01b81526011600452602490fdfe608060409080825260049081361015610016575f80fd5b5f90813560e01c90816306fdde0314610652575080630dfe16811461060e5780633006c1cd146105cd578063313ce5671461058f5780634864d1401461054257806348e7a1e01461050d5780634bd41a42146103e657806359e02dd7146102945780635c74949e14610254578063a83627de14610213578063a8aa1b31146101cf578063b40833041461018b578063c55dae6314610147578063d21220a7146100ff5763fb861ac1146100c7575f80fd5b346100fc57806003193601126100fc575060035490546005549251918252602082015263ffffffff9091166040820152606090f35b80fd5b508234610143578160031936011261014357602090516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b5080fd5b508234610143578160031936011261014357602090516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b508234610143578160031936011261014357602090516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b508234610143578160031936011261014357602090516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b5082346101435781600319360112610143576020905163ffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b5091903461029057816003193601126102905735916001600160a01b03831683036100fc5750610289602092602435906108b9565b9051908152f35b8280fd5b509190346102905782600319360112610290576fffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001692610305847f00000000000000000000000000000000000000000000000000000000000000006108b9565b9160a0845180927ffeaf968c000000000000000000000000000000000000000000000000000000008252816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa9182156103db578092610380575b6020856102898861037b8888610a50565b61089b565b90915060a0823d82116103d3575b8161039b60a09383610842565b810103126100fc57509261037b61028992856103b8602097610a35565b506103c96080888301519201610a35565b509295509261036a565b3d915061038e565b8451903d90823e3d90fd5b50913461029057826003193601126102905761042a6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016610b30565b906005549463ffffffff93848716956104438786610864565b86807f0000000000000000000000000000000000000000000000000000000000000000169116106104e5576003548955825460015563ffffffff19968760025416176002555167ffffffffffffffff606082019182109111176104d25760035555169116176005557f3aa4e370ae737360da0791a606ddc0a9a8a69bf64386361678e8c6c6136821b38180a180f35b602488604184634e487b7160e01b835252fd5b9050517f1e10e942000000000000000000000000000000000000000000000000000000008152fd5b8382346100fc57806003193601126100fc57546001546002549251918252602082015263ffffffff9091166040820152606090f35b508234610143578160031936011261014357602090516fffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b5082346101435781600319360112610143576020905160ff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b5082346101435781600319360112610143576020905163ffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b508234610143578160031936011261014357602090516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b848484346100fc57806003193601126100fc577f95d89b41000000000000000000000000000000000000000000000000000000008452808483816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa9182156107e5578192610748575b61073a848481519061071f602d8360208101937f556e6956322054574150202d2000000000000000000000000000000000000000855261070f81518092602086860191016107f1565b810103600d810185520183610842565b825193849260208452518092816020860152858501906107f1565b601f01601f19168101030190f35b9091503d8083863e61075a8186610842565b8401916020858403126100fc57845167ffffffffffffffff9586821161029057019183601f840112156101435782519586116107d257508351926107a8601f8701601f191660200185610842565b858452602086840101116100fc575061073a936107cb91602080850191016107f1565b83806106c6565b906041602492634e487b7160e01b835252fd5b508251903d90823e3d90fd5b5f5b8381106108025750505f910152565b81810151838201526020016107f3565b6020810190811067ffffffffffffffff82111761082e57604052565b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff82111761082e57604052565b63ffffffff918216908216039190821161087a57565b634e487b7160e01b5f52601160045260245ffd5b9190820391821161087a57565b81156108a5570490565b634e487b7160e01b5f52601260045260245ffd5b906001600160a01b03916108ee837f000000000000000000000000000000000000000000000000000000000000000016610b30565b9063ffffffff9580610904886005541685610864565b5f907f00000000000000000000000000000000000000000000000000000000000000008a16908a1610610a2b57506109466003945b8960028701541690610864565b9516907f0000000000000000000000000000000000000000000000000000000000000000811682036109b557505050916109ae94610991610999936001600160e01b0395549061088e565b91169061089b565b16604051906109a782610812565b8152610a63565b5160701c90565b909193509391937f00000000000000000000000000000000000000000000000000000000000000001603610a01576109ae946109916109999360016001600160e01b039601549061088e565b60046040517fc1ab6dc1000000000000000000000000000000000000000000000000000000008152fd5b6109469094610939565b519069ffffffffffffffffffff82168203610a4c57565b5f80fd5b8181029291811591840414171561087a57565b5f604051610a7081610812565b525f918015918215610ada575b505015610a965760405190610a9182610812565b815290565b606460405162461bcd60e51b815260206004820152601960248201527f4669786564506f696e743a3a6d756c3a206f766572666c6f77000000000000006044820152fd5b915091506001600160e01b03610afd610af68483855116610a50565b938461089b565b915116145f80610a7d565b51906dffffffffffffffffffffffffffff82168203610a4c57565b9190820180921161087a57565b9063ffffffff916001600160a01b0383421691169160409384517f5909c0d50000000000000000000000000000000000000000000000000000000081526020958682600481895afa918215610d65575f92610d36575b5081968151927f5a3d549300000000000000000000000000000000000000000000000000000000845281846004818b5afa938415610d2c575f94610cfd575b506004606085998551928380927f0902f1ac0000000000000000000000000000000000000000000000000000000082525afa908115610cf3575f9384958593610c95575b5050508786821603610c1e575b505050505050565b610c7694959950610c8996985091610c7c610c8292610c76610c43610c6b968c610864565b966dffffffffffffffffffffffffffff80911694169c8d6001600160e01b0397889187610dba565b511697168097610a50565b90610b23565b99610dba565b5116610a50565b915f8080808080610c16565b9194955091506060843d8211610ceb575b81610cb360609383610842565b81010312610ce757610ccf610cc785610b08565b928501610b08565b9301519386851685036100fc575091925f8080610c09565b8480fd5b3d9150610ca6565b84513d5f823e3d90fd5b90938282813d8311610d25575b610d148183610842565b810103126100fc575051925f610bc5565b503d610d0a565b83513d5f823e3d90fd5b90918782813d8311610d5e575b610d4d8183610842565b810103126100fc575051905f610b86565b503d610d43565b50513d5f823e3d90fd5b15610d7657565b606460405162461bcd60e51b815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f7700006044820152fd5b905f604051610dc881610812565b528015610e3e578115610e2a5771ffffffffffffffffffffffffffffffffffff8211610e2157610dfa9160701b61089b565b6001600160e01b03610e0e81831115610d6f565b60405191610e1b83610812565b16815290565b610dfa91610ea8565b5050604051610e3881610812565b5f815290565b608460405162461bcd60e51b815260206004820152602660248201527f4669786564506f696e743a3a6672616374696f6e3a206469766973696f6e206260448201527f79207a65726f00000000000000000000000000000000000000000000000000006064820152fd5b5f905f196e0100000000000000000000000000009181838209908060701b948186048514821517156110ce575084610ee0818461088e565b92106110bd575b819386156108a557869109918483116110aa575b5050610f07919261088e565b91811561109f578082101561105b5780196001810180911161087a5781610f3c91610f3693169283809261089b565b9461089b565b908019906001820180921161087a57610f549161089b565b916001830180931161087a57610f6d92610c7691610a50565b8180046001148215171561087a5760029180830383811161087a57610f928183610a50565b840384811161087a57610fa491610a50565b610fae8183610a50565b840384811161087a57610fc091610a50565b610fca8183610a50565b840384811161087a57610fdc91610a50565b610fe68183610a50565b840384811161087a57610ff891610a50565b6110028183610a50565b840384811161087a5761101491610a50565b61101e8183610a50565b84039084821161087a5761103c9161103591610a50565b8092610a50565b830392831161087a576110589261105291610a50565b90610a50565b90565b606460405162461bcd60e51b815260206004820152601a60248201527f46756c6c4d6174683a2046554c4c4449565f4f564552464c4f570000000000006044820152fd5b90506110589161089b565b81019250821161087a57610f075f610efb565b9082810190811161087a5790610ee7565b80634e487b7160e01b602492526011600452fdfea26469706673582212209aa57c0952f03c9c9f81c9c9670d27bcddd7e9ab75bfe458b342c1d2e2b1d52464736f6c634300081400330000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000e1000000000000000000000000000000000000000000000000000000000000151800000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419

Deployed Bytecode

0x608060409080825260049081361015610016575f80fd5b5f90813560e01c90816306fdde0314610652575080630dfe16811461060e5780633006c1cd146105cd578063313ce5671461058f5780634864d1401461054257806348e7a1e01461050d5780634bd41a42146103e657806359e02dd7146102945780635c74949e14610254578063a83627de14610213578063a8aa1b31146101cf578063b40833041461018b578063c55dae6314610147578063d21220a7146100ff5763fb861ac1146100c7575f80fd5b346100fc57806003193601126100fc575060035490546005549251918252602082015263ffffffff9091166040820152606090f35b80fd5b508234610143578160031936011261014357602090516001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2168152f35b5080fd5b508234610143578160031936011261014357602090516001600160a01b037f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c168152f35b508234610143578160031936011261014357602090516001600160a01b037f0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419168152f35b508234610143578160031936011261014357602090516001600160a01b037f00000000000000000000000088d1ffb9f94fc881ea0d83dddcdb196ee9da8739168152f35b5082346101435781600319360112610143576020905163ffffffff7f0000000000000000000000000000000000000000000000000000000000000e10168152f35b5091903461029057816003193601126102905735916001600160a01b03831683036100fc5750610289602092602435906108b9565b9051908152f35b8280fd5b509190346102905782600319360112610290576fffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000de0b6b3a76400001692610305847f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c6108b9565b9160a0845180927ffeaf968c000000000000000000000000000000000000000000000000000000008252816001600160a01b037f0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419165afa9182156103db578092610380575b6020856102898861037b8888610a50565b61089b565b90915060a0823d82116103d3575b8161039b60a09383610842565b810103126100fc57509261037b61028992856103b8602097610a35565b506103c96080888301519201610a35565b509295509261036a565b3d915061038e565b8451903d90823e3d90fd5b50913461029057826003193601126102905761042a6001600160a01b037f00000000000000000000000088d1ffb9f94fc881ea0d83dddcdb196ee9da873916610b30565b906005549463ffffffff93848716956104438786610864565b86807f0000000000000000000000000000000000000000000000000000000000000e10169116106104e5576003548955825460015563ffffffff19968760025416176002555167ffffffffffffffff606082019182109111176104d25760035555169116176005557f3aa4e370ae737360da0791a606ddc0a9a8a69bf64386361678e8c6c6136821b38180a180f35b602488604184634e487b7160e01b835252fd5b9050517f1e10e942000000000000000000000000000000000000000000000000000000008152fd5b8382346100fc57806003193601126100fc57546001546002549251918252602082015263ffffffff9091166040820152606090f35b508234610143578160031936011261014357602090516fffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000de0b6b3a7640000168152f35b5082346101435781600319360112610143576020905160ff7f0000000000000000000000000000000000000000000000000000000000000008168152f35b5082346101435781600319360112610143576020905163ffffffff7f0000000000000000000000000000000000000000000000000000000000015180168152f35b508234610143578160031936011261014357602090516001600160a01b037f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c168152f35b848484346100fc57806003193601126100fc577f95d89b41000000000000000000000000000000000000000000000000000000008452808483816001600160a01b037f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c165afa9182156107e5578192610748575b61073a848481519061071f602d8360208101937f556e6956322054574150202d2000000000000000000000000000000000000000855261070f81518092602086860191016107f1565b810103600d810185520183610842565b825193849260208452518092816020860152858501906107f1565b601f01601f19168101030190f35b9091503d8083863e61075a8186610842565b8401916020858403126100fc57845167ffffffffffffffff9586821161029057019183601f840112156101435782519586116107d257508351926107a8601f8701601f191660200185610842565b858452602086840101116100fc575061073a936107cb91602080850191016107f1565b83806106c6565b906041602492634e487b7160e01b835252fd5b508251903d90823e3d90fd5b5f5b8381106108025750505f910152565b81810151838201526020016107f3565b6020810190811067ffffffffffffffff82111761082e57604052565b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff82111761082e57604052565b63ffffffff918216908216039190821161087a57565b634e487b7160e01b5f52601160045260245ffd5b9190820391821161087a57565b81156108a5570490565b634e487b7160e01b5f52601260045260245ffd5b906001600160a01b03916108ee837f00000000000000000000000088d1ffb9f94fc881ea0d83dddcdb196ee9da873916610b30565b9063ffffffff9580610904886005541685610864565b5f907f00000000000000000000000000000000000000000000000000000000000151808a16908a1610610a2b57506109466003945b8960028701541690610864565b9516907f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c811682036109b557505050916109ae94610991610999936001600160e01b0395549061088e565b91169061089b565b16604051906109a782610812565b8152610a63565b5160701c90565b909193509391937f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21603610a01576109ae946109916109999360016001600160e01b039601549061088e565b60046040517fc1ab6dc1000000000000000000000000000000000000000000000000000000008152fd5b6109469094610939565b519069ffffffffffffffffffff82168203610a4c57565b5f80fd5b8181029291811591840414171561087a57565b5f604051610a7081610812565b525f918015918215610ada575b505015610a965760405190610a9182610812565b815290565b606460405162461bcd60e51b815260206004820152601960248201527f4669786564506f696e743a3a6d756c3a206f766572666c6f77000000000000006044820152fd5b915091506001600160e01b03610afd610af68483855116610a50565b938461089b565b915116145f80610a7d565b51906dffffffffffffffffffffffffffff82168203610a4c57565b9190820180921161087a57565b9063ffffffff916001600160a01b0383421691169160409384517f5909c0d50000000000000000000000000000000000000000000000000000000081526020958682600481895afa918215610d65575f92610d36575b5081968151927f5a3d549300000000000000000000000000000000000000000000000000000000845281846004818b5afa938415610d2c575f94610cfd575b506004606085998551928380927f0902f1ac0000000000000000000000000000000000000000000000000000000082525afa908115610cf3575f9384958593610c95575b5050508786821603610c1e575b505050505050565b610c7694959950610c8996985091610c7c610c8292610c76610c43610c6b968c610864565b966dffffffffffffffffffffffffffff80911694169c8d6001600160e01b0397889187610dba565b511697168097610a50565b90610b23565b99610dba565b5116610a50565b915f8080808080610c16565b9194955091506060843d8211610ceb575b81610cb360609383610842565b81010312610ce757610ccf610cc785610b08565b928501610b08565b9301519386851685036100fc575091925f8080610c09565b8480fd5b3d9150610ca6565b84513d5f823e3d90fd5b90938282813d8311610d25575b610d148183610842565b810103126100fc575051925f610bc5565b503d610d0a565b83513d5f823e3d90fd5b90918782813d8311610d5e575b610d4d8183610842565b810103126100fc575051905f610b86565b503d610d43565b50513d5f823e3d90fd5b15610d7657565b606460405162461bcd60e51b815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f7700006044820152fd5b905f604051610dc881610812565b528015610e3e578115610e2a5771ffffffffffffffffffffffffffffffffffff8211610e2157610dfa9160701b61089b565b6001600160e01b03610e0e81831115610d6f565b60405191610e1b83610812565b16815290565b610dfa91610ea8565b5050604051610e3881610812565b5f815290565b608460405162461bcd60e51b815260206004820152602660248201527f4669786564506f696e743a3a6672616374696f6e3a206469766973696f6e206260448201527f79207a65726f00000000000000000000000000000000000000000000000000006064820152fd5b5f905f196e0100000000000000000000000000009181838209908060701b948186048514821517156110ce575084610ee0818461088e565b92106110bd575b819386156108a557869109918483116110aa575b5050610f07919261088e565b91811561109f578082101561105b5780196001810180911161087a5781610f3c91610f3693169283809261089b565b9461089b565b908019906001820180921161087a57610f549161089b565b916001830180931161087a57610f6d92610c7691610a50565b8180046001148215171561087a5760029180830383811161087a57610f928183610a50565b840384811161087a57610fa491610a50565b610fae8183610a50565b840384811161087a57610fc091610a50565b610fca8183610a50565b840384811161087a57610fdc91610a50565b610fe68183610a50565b840384811161087a57610ff891610a50565b6110028183610a50565b840384811161087a5761101491610a50565b61101e8183610a50565b84039084821161087a5761103c9161103591610a50565b8092610a50565b830392831161087a576110589261105291610a50565b90610a50565b90565b606460405162461bcd60e51b815260206004820152601a60248201527f46756c6c4d6174683a2046554c4c4449565f4f564552464c4f570000000000006044820152fd5b90506110589161089b565b81019250821161087a57610f075f610efb565b9082810190811161087a5790610ee7565b80634e487b7160e01b602492526011600452fdfea26469706673582212209aa57c0952f03c9c9f81c9c9670d27bcddd7e9ab75bfe458b342c1d2e2b1d52464736f6c63430008140033

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

0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000e1000000000000000000000000000000000000000000000000000000000000151800000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419

-----Decoded View---------------
Arg [0] : _factory (address): 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f
Arg [1] : _baseToken (address): 0x38547D918b9645F2D94336B6b61AEB08053E142c
Arg [2] : _quoteToken (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [3] : _updatePeriod (uint32): 3600
Arg [4] : _minPeriodFromLastSnapshot (uint32): 86400
Arg [5] : _quoteTokenChainlinkFeed (address): 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419

-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f
Arg [1] : 00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c
Arg [2] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000e10
Arg [4] : 0000000000000000000000000000000000000000000000000000000000015180
Arg [5] : 0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ 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.