Address Details
contract

0x7BF9DbEcb37BF634769Cc0A93fAAB2Df157128C4

Contract Name
PriceFeedFactory
Creator
0x643c57–e72624 at 0x09a0fc–a7d516
Balance
0 CELO ( )
Locked CELO Balance
0.00 CELO
Voting CELO Balance
0.00 CELO
Pending Unlocked Gold
0.00 CELO
Tokens
Fetching tokens...
Transactions
638,411 Transactions
Transfers
0 Transfers
Gas Used
343,018,483,200
Last Balance Update
24310754
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
PriceFeedFactory




Optimization enabled
true
Compiler version
v0.8.9+commit.e5eed63a




Optimization runs
999999
EVM Version
london




Verified at
2021-12-03T15:10:56.473887Z

contracts/PriceFeedFactory.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;

import '@openzeppelin/contracts/access/Ownable.sol';
import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol';
import './PriceFeed.sol';
import './SlidingWindowOracle.sol';
import './ISlidingWindowOracle.sol';
import './UniswapV2Library.sol';


contract PriceFeedFactory is Ownable {
    uint public lastObservation;

    address[] internal _pairs;
    mapping(address => PriceFeed) public oracles;
    mapping(address => bool) public workers;

    event OracleCreated(address oracle);

    ISlidingWindowOracle public immutable slidingWindowOracle;
    address public immutable factory;
    uint public immutable periodSize;

    event WorkerSet(address worker, bool enabled);

    constructor(address _factory, uint _windowSize, uint8 _granularity) {
        slidingWindowOracle = ISlidingWindowOracle(address(new SlidingWindowOracle(_factory, _windowSize, _granularity)));
        periodSize = slidingWindowOracle.periodSize();
        factory = _factory;
    }

    function pairs() external view returns (address[] memory) {
        return _pairs;
    }

    function updatePair(address pair) external onlyOwner {
        _update(pair);
    }

    function setWorker(address worker, bool enabled) external onlyOwner {
        workers[worker] = enabled;
        emit WorkerSet(worker, enabled);
    }

    function addOracle(address tokenA, address tokenB) external onlyOwner {
        address pair = getPair(tokenA, tokenB);
        require(address(oracles[pair]) == address(0), "PriceFeedFactory: oracle exist");
        PriceFeed oracle = new PriceFeed(tokenA, tokenB, slidingWindowOracle);
        _pairs.push(pair);
        oracles[pair] = oracle;
        emit OracleCreated(address(oracle));
    }

    function getPair(address tokenA, address tokenB) public view returns (address) {
        return UniswapV2Library.pairFor(factory, tokenA, tokenB);
    }

    function getOracle(address tokenA, address tokenB) external view returns (PriceFeed) {
        return oracles[getPair(tokenA, tokenB)];
    }

    function work() external {
        require(workers[msg.sender], "PriceFeedFactory: !worker");
        require(workable(), "PriceFeedFactory: !work");
        for (uint i = 0; i < _pairs.length; i++) {
            _update(_pairs[i]);
        }
        lastObservation = block.timestamp;
    }

    function workable() public view returns (bool) {
        return block.timestamp / periodSize * periodSize > lastObservation;
    }

    function _update(address pair) internal {
        slidingWindowOracle.update(IUniswapV2Pair(pair).token0(), IUniswapV2Pair(pair).token1());
    }
}
        

/_openzeppelin/contracts/access/Ownable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _setOwner(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _setOwner(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
          

/_openzeppelin/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
          

/_uniswap/lib/contracts/libraries/FixedPoint.sol

pragma solidity >=0.4.0;

// 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 {
        uint _x;
    }

    uint8 private constant RESOLUTION = 112;

    // encode a uint112 as a UQ112x112
    function encode(uint112 x) internal pure returns (uq112x112 memory) {
        return uq112x112(uint224(x) << RESOLUTION);
    }

    // encodes a uint144 as a UQ144x112
    function encode144(uint144 x) internal pure returns (uq144x112 memory) {
        return uq144x112(uint256(x) << RESOLUTION);
    }

    // divide a UQ112x112 by a uint112, returning a UQ112x112
    function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) {
        require(x != 0, 'FixedPoint: DIV_BY_ZERO');
        return uq112x112(self._x / uint224(x));
    }

    // multiply a UQ112x112 by a uint, returning a UQ144x112
    // reverts on overflow
    function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) {
        uint z;
        require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW");
        return uq144x112(z);
    }

    // returns a UQ112x112 which represents the ratio of the numerator to the denominator
    // equivalent to encode(numerator).div(denominator)
    function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {
        require(denominator > 0, "FixedPoint: DIV_BY_ZERO");
        return uq112x112((uint224(numerator) << RESOLUTION) / denominator);
    }

    // decode a UQ112x112 into a uint112 by truncating after the radix point
    function decode(uq112x112 memory self) internal pure returns (uint112) {
        return uint112(self._x >> RESOLUTION);
    }

    // decode a UQ144x112 into a uint144 by truncating after the radix point
    function decode144(uq144x112 memory self) internal pure returns (uint144) {
        return uint144(self._x >> RESOLUTION);
    }
}
          

/_uniswap/v2-core/contracts/interfaces/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;
}
          

/_uniswap/v2-core/contracts/interfaces/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;
}
          

/contracts/ISlidingWindowOracle.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;


interface ISlidingWindowOracle {
    function consult(address tokenIn, uint amountIn, address tokenOut) external view returns (uint amountOut);
    function update(address tokenA, address tokenB) external;
    function periodSize() external view returns (uint);
}
          

/contracts/PriceFeed.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;

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


interface IERC20 {
    function decimals() external view returns(uint8);
}


contract PriceFeed {
    address public immutable tokenIn;
    address public immutable tokenOut;
    uint public immutable oneToken;
    ISlidingWindowOracle public immutable slidingWindowOracle;

    constructor(address _tokenIn, address _tokenOut, ISlidingWindowOracle _slidingWindowOracle) {
        tokenIn = _tokenIn;
        tokenOut = _tokenOut;
        slidingWindowOracle = _slidingWindowOracle;
        oneToken = uint(10)**(IERC20(tokenIn).decimals());
    }

    function consult() external view returns (uint) {
        return slidingWindowOracle.consult(tokenIn, oneToken, tokenOut);
    }
}
          

/contracts/SafeMath.sol

// SPDX-License-Identifier: MIT
pragma solidity =0.8.9;


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

/contracts/SlidingWindowOracle.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;

import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol';
import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol';
import '@uniswap/lib/contracts/libraries/FixedPoint.sol';

import './UniswapV2Library.sol';
import './UniswapV2OracleLibrary.sol';


// sliding window oracle that uses observations collected over a window to provide moving price averages in the past
// `windowSize` with a precision of `windowSize / granularity`
// note this is a singleton oracle and only needs to be deployed once per desired parameters, which
// differs from the simple oracle which must be deployed once per pair.
contract SlidingWindowOracle {
    using FixedPoint for *;

    struct Observation {
        uint timestamp;
        uint price0Cumulative;
        uint price1Cumulative;
    }

    address public immutable factory;
    address public immutable feedFactory;
    // the desired amount of time over which the moving average should be computed, e.g. 24 hours
    uint public immutable windowSize;
    // the number of observations stored for each pair, i.e. how many price observations are stored for the window.
    // as granularity increases from 1, more frequent updates are needed, but moving averages become more precise.
    // averages are computed over intervals with sizes in the range:
    //   [windowSize - (windowSize / granularity) * 2, windowSize]
    // e.g. if the window size is 24 hours, and the granularity is 24, the oracle will return the average price for
    //   the period:
    //   [now - [22 hours, 24 hours], now]
    uint8 public immutable granularity;
    // this is redundant with granularity and windowSize, but stored for gas savings & informational purposes.
    uint public immutable periodSize;

    // mapping from pair address to a list of price observations of that pair
    mapping(address => Observation[]) public pairObservations;

    constructor(address factory_, uint windowSize_, uint8 granularity_) {
        require(granularity_ > 1, 'SlidingWindowOracle: GRANULARITY');
        require(
            (periodSize = windowSize_ / granularity_) * granularity_ == windowSize_,
            'SlidingWindowOracle: WINDOW_NOT_EVENLY_DIVISIBLE'
        );
        factory = factory_;
        windowSize = windowSize_;
        granularity = granularity_;
        feedFactory = msg.sender;
    }

    // returns the index of the observation corresponding to the given timestamp
    function observationIndexOf(uint timestamp) public view returns (uint8 index) {
        uint epochPeriod = timestamp / periodSize;
        return uint8(epochPeriod % granularity);
    }

    // returns the observation from the oldest epoch (at the beginning of the window) relative to the current time
    function getFirstObservationInWindow(address pair) private view returns (Observation storage firstObservation) {
        uint8 observationIndex = observationIndexOf(block.timestamp);
        // no overflow issue. if observationIndex + 1 overflows, result is still zero.
        uint8 firstObservationIndex = (observationIndex + 1) % granularity;
        firstObservation = pairObservations[pair][firstObservationIndex];
    }

    // update the cumulative price for the observation at the current timestamp. each observation is updated at most
    // once per epoch period.
    function update(address tokenA, address tokenB) external {
        require(msg.sender == feedFactory, 'Only feedFactory');
        address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);

        // populate the array with empty observations (first call only)
        for (uint i = pairObservations[pair].length; i < granularity; i++) {
            pairObservations[pair].push();
        }

        // get the observation for the current period
        uint8 observationIndex = observationIndexOf(block.timestamp);
        Observation storage observation = pairObservations[pair][observationIndex];

        // we only want to commit updates once per period (i.e. windowSize / granularity)
        uint timeElapsed = block.timestamp - observation.timestamp;
        if (timeElapsed > periodSize) {
            (uint price0Cumulative, uint price1Cumulative,) = UniswapV2OracleLibrary.currentCumulativePrices(pair);
            observation.timestamp = block.timestamp;
            observation.price0Cumulative = price0Cumulative;
            observation.price1Cumulative = price1Cumulative;
        }
    }

    // given the cumulative prices of the start and end of a period, and the length of the period, compute the average
    // price in terms of how much amount out is received for the amount in
    function computeAmountOut(
        uint priceCumulativeStart, uint priceCumulativeEnd,
        uint timeElapsed, uint amountIn
    ) private pure returns (uint amountOut) {
        // overflow is desired.
        FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(
            uint224((priceCumulativeEnd - priceCumulativeStart) / timeElapsed)
        );
        amountOut = priceAverage.mul(amountIn).decode144();
    }

    // returns the amount out corresponding to the amount in for a given token using the moving average over the time
    // range [now - [windowSize, windowSize - periodSize * 2], now]
    // update must have been called for the bucket corresponding to timestamp `now - windowSize`
    function consult(address tokenIn, uint amountIn, address tokenOut) external view returns (uint amountOut) {
        address pair = UniswapV2Library.pairFor(factory, tokenIn, tokenOut);
        Observation storage firstObservation = getFirstObservationInWindow(pair);

        uint timeElapsed = block.timestamp - firstObservation.timestamp;
        require(timeElapsed <= windowSize, 'SlidingWindowOracle: MISSING_HISTORICAL_OBSERVATION');
        // should never happen.
        require(timeElapsed >= windowSize - periodSize * 2, 'SlidingWindowOracle: UNEXPECTED_TIME_ELAPSED');

        (uint price0Cumulative, uint price1Cumulative,) = UniswapV2OracleLibrary.currentCumulativePrices(pair);
        (address token0,) = UniswapV2Library.sortTokens(tokenIn, tokenOut);

        if (token0 == tokenIn) {
            return computeAmountOut(firstObservation.price0Cumulative, price0Cumulative, timeElapsed, amountIn);
        } else {
            return computeAmountOut(firstObservation.price1Cumulative, price1Cumulative, timeElapsed, amountIn);
        }
    }
}
          

/contracts/UniswapV2Library.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0;

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

/contracts/UniswapV2OracleLibrary.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0;

import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol';
import '@uniswap/lib/contracts/libraries/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;
        }
    }
}
          

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_factory","internalType":"address"},{"type":"uint256","name":"_windowSize","internalType":"uint256"},{"type":"uint8","name":"_granularity","internalType":"uint8"}]},{"type":"event","name":"OracleCreated","inputs":[{"type":"address","name":"oracle","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"WorkerSet","inputs":[{"type":"address","name":"worker","internalType":"address","indexed":false},{"type":"bool","name":"enabled","internalType":"bool","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addOracle","inputs":[{"type":"address","name":"tokenA","internalType":"address"},{"type":"address","name":"tokenB","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"factory","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract PriceFeed"}],"name":"getOracle","inputs":[{"type":"address","name":"tokenA","internalType":"address"},{"type":"address","name":"tokenB","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getPair","inputs":[{"type":"address","name":"tokenA","internalType":"address"},{"type":"address","name":"tokenB","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lastObservation","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract PriceFeed"}],"name":"oracles","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"pairs","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"periodSize","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setWorker","inputs":[{"type":"address","name":"worker","internalType":"address"},{"type":"bool","name":"enabled","internalType":"bool"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ISlidingWindowOracle"}],"name":"slidingWindowOracle","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updatePair","inputs":[{"type":"address","name":"pair","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"work","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"workable","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"workers","inputs":[{"type":"address","name":"","internalType":"address"}]}]
              

Contract Creation Code

0x60e06040523480156200001157600080fd5b506040516200307238038062003072833981016040819052620000349162000183565b6200003f3362000125565b828282604051620000509062000175565b6001600160a01b039093168352602083019190915260ff166040820152606001604051809103906000f0801580156200008d573d6000803e3d6000fd5b506001600160a01b03166080819052604080516372231f5960e11b8152905163e4463eb291600480820192602092909190829003018186803b158015620000d357600080fd5b505afa158015620000e8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200010e9190620001db565b60c05250506001600160a01b031660a052620001f5565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6115748062001afe83390190565b6000806000606084860312156200019957600080fd5b83516001600160a01b0381168114620001b157600080fd5b60208501516040860151919450925060ff81168114620001d057600080fd5b809150509250925092565b600060208284031215620001ee57600080fd5b5051919050565b60805160a05160c0516118bd62000241600039600081816102c4015261060e015260008181610274015261076401526000818161029c015281816108bd0152610ba401526118bd6000f3fe60806040523480156200001157600080fd5b5060043610620001325760003560e01c8063addd509911620000c0578063e4463eb2116200008b578063f0ca4adb116200006e578063f0ca4adb14620002fd578063f2fde38b1462000314578063ffb0a4a0146200032b57600080fd5b8063e4463eb214620002be578063e6a4390514620002e657600080fd5b8063addd5099146200021e578063c373d7f31462000257578063c45a0155146200026e578063c8d5cd6a146200029657600080fd5b80637f70313611620001015780637f703136146200019f57806380bb2bac14620001dc5780638a7b8cf214620001e65780638da5cb5b14620001ff57600080fd5b80631b56bbf91462000137578063322e9f0414620001505780634048a257146200015a578063715018a61462000195575b600080fd5b6200014e62000148366004620010d5565b62000344565b005b6200014e620003d9565b620001806200016b366004620010d5565b60046020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b6200014e62000532565b620001b6620001b0366004620010f5565b620005c3565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016200018c565b6200018062000606565b620001f060015481565b6040519081526020016200018c565b60005473ffffffffffffffffffffffffffffffffffffffff16620001b6565b620001b66200022f366004620010d5565b60036020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6200014e6200026836600462001133565b6200064b565b620001b67f000000000000000000000000000000000000000000000000000000000000000081565b620001b67f000000000000000000000000000000000000000000000000000000000000000081565b620001f07f000000000000000000000000000000000000000000000000000000000000000081565b620001b6620002f7366004620010f5565b6200075c565b6200014e6200030e366004620010f5565b62000792565b6200014e62000325366004620010d5565b620009fe565b6200033562000b31565b6040516200018c91906200116a565b60005473ffffffffffffffffffffffffffffffffffffffff163314620003cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b620003d68162000ba2565b50565b3360009081526004602052604090205460ff1662000454576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f507269636546656564466163746f72793a2021776f726b6572000000000000006044820152606401620003c2565b6200045e62000606565b620004c6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f507269636546656564466163746f72793a2021776f726b0000000000000000006044820152606401620003c2565b60005b6002548110156200052b576200051660028281548110620004ee57620004ee620011c6565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1662000ba2565b80620005228162001224565b915050620004c9565b5042600155565b60005473ffffffffffffffffffffffffffffffffffffffff163314620005b5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401620003c2565b620005c1600062000d6c565b565b600060036000620005d585856200075c565b73ffffffffffffffffffffffffffffffffffffffff9081168252602082019290925260400160002054169392505050565b6001546000907f000000000000000000000000000000000000000000000000000000000000000062000639814262001260565b6200064591906200129c565b11905090565b60005473ffffffffffffffffffffffffffffffffffffffff163314620006ce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401620003c2565b73ffffffffffffffffffffffffffffffffffffffff821660008181526004602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168515159081179091558251938452908301527f544b110ecbb53c12b4410a9e8876b834b4013375180ae9c9cc375b119a9ba38e910160405180910390a15050565b60006200078b7f0000000000000000000000000000000000000000000000000000000000000000848462000de1565b9392505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331462000815576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401620003c2565b60006200082383836200075c565b73ffffffffffffffffffffffffffffffffffffffff8082166000908152600360205260409020549192501615620008b7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f507269636546656564466163746f72793a206f7261636c6520657869737400006044820152606401620003c2565b600083837f0000000000000000000000000000000000000000000000000000000000000000604051620008ea90620010a4565b73ffffffffffffffffffffffffffffffffffffffff938416815291831660208301529091166040820152606001604051809103906000f08015801562000934573d6000803e3d6000fd5b5060028054600181019091557f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff8681169182179093556000908152600360209081526040918290208054909316938516938417909255519182529192507f5dba83b2e4f5ef7ead6ae8f4902f5335ce28561a5207952f0b0a9d9f3a01a1b7910160405180910390a150505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331462000a81576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401620003c2565b73ffffffffffffffffffffffffffffffffffffffff811662000b26576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401620003c2565b620003d68162000d6c565b6060600280548060200260200160405190810160405280929190818152602001828054801562000b9857602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff16815260019091019060200180831162000b6c575b5050505050905090565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c640752d8273ffffffffffffffffffffffffffffffffffffffff16630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801562000c2557600080fd5b505afa15801562000c3a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000c609190620012dc565b8373ffffffffffffffffffffffffffffffffffffffff1663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b15801562000ca757600080fd5b505afa15801562000cbc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000ce29190620012dc565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff928316600482015291166024820152604401600060405180830381600087803b15801562000d5057600080fd5b505af115801562000d65573d6000803e3d6000fd5b5050505050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080600062000df2858562000f19565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084811b8216602084015283901b166034820152919350915086906048016040516020818303038152906040528051906020012060405160200162000ed99291907fff00000000000000000000000000000000000000000000000000000000000000815260609290921b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016600183015260158201527fb3b8ff62960acea3a88039ebcf80699f15786f1b17cebd82802f7375827a339c603582015260550190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101209695505050505050565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141562000fda576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f556e697377617056324c6962726172793a204944454e544943414c5f4144445260448201527f45535345530000000000000000000000000000000000000000000000000000006064820152608401620003c2565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16106200101657828462001019565b83835b909250905073ffffffffffffffffffffffffffffffffffffffff82166200109d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f4144445245535300006044820152606401620003c2565b9250929050565b61058b80620012fd83390190565b73ffffffffffffffffffffffffffffffffffffffff81168114620003d657600080fd5b600060208284031215620010e857600080fd5b81356200078b81620010b2565b600080604083850312156200110957600080fd5b82356200111681620010b2565b915060208301356200112881620010b2565b809150509250929050565b600080604083850312156200114757600080fd5b82356200115481620010b2565b9150602083013580151581146200112857600080fd5b6020808252825182820181905260009190848201906040850190845b81811015620011ba57835173ffffffffffffffffffffffffffffffffffffffff168352928401929184019160010162001186565b50909695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415620012595762001259620011f5565b5060010190565b60008262001297577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615620012d757620012d7620011f5565b500290565b600060208284031215620012ef57600080fd5b81516200078b81620010b256fe61010060405234801561001157600080fd5b5060405161058b38038061058b833981016040819052610030916100e9565b6001600160a01b03808416608081905283821660a05290821660e0526040805163313ce56760e01b8152905163313ce56791600480820192602092909190829003018186803b15801561008257600080fd5b505afa158015610096573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100ba9190610136565b6100c590600a61025c565b60c0525061026b915050565b6001600160a01b03811681146100e657600080fd5b50565b6000806000606084860312156100fe57600080fd5b8351610109816100d1565b602085015190935061011a816100d1565b604085015190925061012b816100d1565b809150509250925092565b60006020828403121561014857600080fd5b815160ff8116811461015957600080fd5b9392505050565b634e487b7160e01b600052601160045260246000fd5b600181815b808511156101b157816000190482111561019757610197610160565b808516156101a457918102915b93841c939080029061017b565b509250929050565b6000826101c857506001610256565b816101d557506000610256565b81600181146101eb57600281146101f557610211565b6001915050610256565b60ff84111561020657610206610160565b50506001821b610256565b5060208310610133831016604e8410600b8410161715610234575081810a610256565b61023e8383610176565b806000190482111561025257610252610160565b0290505b92915050565b600061015960ff8416836101b9565b60805160a05160c05160e0516102ce6102bd6000396000818160ff01526101fe01526000818160d801526101ad01526000818161012601526101d30152600081816071015261018501526102ce6000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c8063a27eccc111610050578063a27eccc1146100d3578063c8d5cd6a146100fa578063d0202d3b1461012157600080fd5b80636daf390b1461006c5780637eeda703146100bd575b600080fd5b6100937f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6100c5610148565b6040519081526020016100b4565b6100c57f000000000000000000000000000000000000000000000000000000000000000081565b6100937f000000000000000000000000000000000000000000000000000000000000000081565b6100937f000000000000000000000000000000000000000000000000000000000000000081565b6040517f8c86f1e400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000811660048301527f000000000000000000000000000000000000000000000000000000000000000060248301527f0000000000000000000000000000000000000000000000000000000000000000811660448301526000917f000000000000000000000000000000000000000000000000000000000000000090911690638c86f1e49060640160206040518083038186803b15801561024257600080fd5b505afa158015610256573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027a919061027f565b905090565b60006020828403121561029157600080fd5b505191905056fea264697066735822122026dd96b88b5870a3e31739e017a07c2ba18ebc877bbe9c3394f89cf78e88daf964736f6c63430008090033a2646970667358221220fbf1f68a7ba16275bd5867f9264c612f3136dad701df6b2bf61ab1d4c228ad2264736f6c634300080900336101206040523480156200001257600080fd5b50604051620015743803806200157483398101604081905262000035916200013a565b60018160ff16116200008e5760405162461bcd60e51b815260206004820181905260248201527f536c6964696e6757696e646f774f7261636c653a204752414e554c415249545960448201526064015b60405180910390fd5b8160ff82166200009f818362000192565b610100819052620000b19190620001b5565b14620001195760405162461bcd60e51b815260206004820152603060248201527f536c6964696e6757696e646f774f7261636c653a2057494e444f575f4e4f545f60448201526f4556454e4c595f444956495349424c4560801b606482015260840162000085565b6001600160a01b0390921660805260c05260ff1660e0523360a052620001e3565b6000806000606084860312156200015057600080fd5b83516001600160a01b03811681146200016857600080fd5b60208501516040860151919450925060ff811681146200018757600080fd5b809150509250925092565b600082620001b057634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615620001de57634e487b7160e01b600052601160045260246000fd5b500290565b60805160a05160c05160e0516101005161130162000273600039600081816101fc015281816103270152818161069e01526106f401526000818160fe015281816105c801528181610722015261088f0152600081816101370152818161026f015261035301526000818160ad01526104e80152600081816101ad01528181610226015261057601526113016000f3fe608060405234801561001057600080fd5b50600436106100a35760003560e01c8063bfcc8e4211610076578063c640752d1161005b578063c640752d146101cf578063dbaad32f146101e4578063e4463eb2146101f757600080fd5b8063bfcc8e421461017a578063c45a0155146101a857600080fd5b806333dfbb19146100a8578063556f0dc7146100f95780638a14117a146101325780638c86f1e414610167575b600080fd5b6100cf7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6101207f000000000000000000000000000000000000000000000000000000000000000081565b60405160ff90911681526020016100f0565b6101597f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020016100f0565b610159610175366004610f91565b61021e565b61018d610188366004610fcd565b61048e565b604080519384526020840192909252908201526060016100f0565b6100cf7f000000000000000000000000000000000000000000000000000000000000000081565b6101e26101dd366004610ff7565b6104d0565b005b6101206101f236600461102a565b6106ec565b6101597f000000000000000000000000000000000000000000000000000000000000000081565b60008061024c7f00000000000000000000000000000000000000000000000000000000000000008685610748565b905060006102598261087d565b805490915060009061026b9042611072565b90507f0000000000000000000000000000000000000000000000000000000000000000811115610322576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f536c6964696e6757696e646f774f7261636c653a204d495353494e475f48495360448201527f544f524943414c5f4f42534552564154494f4e0000000000000000000000000060648201526084015b60405180910390fd5b61034d7f00000000000000000000000000000000000000000000000000000000000000006002611089565b610377907f0000000000000000000000000000000000000000000000000000000000000000611072565b811015610406576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f536c6964696e6757696e646f774f7261636c653a20554e45585045435445445f60448201527f54494d455f454c415053454400000000000000000000000000000000000000006064820152608401610319565b60008061041285610918565b509150915060006104238a89610b69565b5090508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156104775761046a856001015484868c610cee565b9650505050505050610487565b61046a856002015483868c610cee565b9392505050565b600060205281600052604060002081815481106104aa57600080fd5b600091825260209091206003909102018054600182015460029092015490935090915083565b3373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161461056f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f4f6e6c792066656564466163746f7279000000000000000000000000000000006044820152606401610319565b600061059c7f00000000000000000000000000000000000000000000000000000000000000008484610748565b73ffffffffffffffffffffffffffffffffffffffff81166000908152602081905260409020549091505b7f000000000000000000000000000000000000000000000000000000000000000060ff168110156106315773ffffffffffffffffffffffffffffffffffffffff8216600090815260208190526040812080546001018155905280610629816110c6565b9150506105c6565b50600061063d426106ec565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604081208054929350909160ff841690811061067c5761067c6110ff565b600091825260208220600390910201805490925061069a9042611072565b90507f00000000000000000000000000000000000000000000000000000000000000008111156106e4576000806106d086610918565b504286556001860191909155600285015550505b505050505050565b6000806107197f00000000000000000000000000000000000000000000000000000000000000008461115d565b905061048760ff7f00000000000000000000000000000000000000000000000000000000000000001682611171565b60008060006107578585610b69565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084811b8216602084015283901b166034820152919350915086906048016040516020818303038152906040528051906020012060405160200161083d9291907fff00000000000000000000000000000000000000000000000000000000000000815260609290921b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016600183015260158201527fb3b8ff62960acea3a88039ebcf80699f15786f1b17cebd82802f7375827a339c603582015260550190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101209695505050505050565b600080610889426106ec565b905060007f00000000000000000000000000000000000000000000000000000000000000006108b9836001611185565b6108c391906111aa565b73ffffffffffffffffffffffffffffffffffffffff8516600090815260208190526040902080549192509060ff8316908110610901576109016110ff565b906000526020600020906003020192505050919050565b6000806000610925610d67565b90508373ffffffffffffffffffffffffffffffffffffffff16635909c0d56040518163ffffffff1660e01b815260040160206040518083038186803b15801561096d57600080fd5b505afa158015610981573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a591906111cc565b92508373ffffffffffffffffffffffffffffffffffffffff16635a3d54936040518163ffffffff1660e01b815260040160206040518083038186803b1580156109ed57600080fd5b505afa158015610a01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a2591906111cc565b915060008060008673ffffffffffffffffffffffffffffffffffffffff16630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015610a7257600080fd5b505afa158015610a86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aaa9190611203565b9250925092508363ffffffff168163ffffffff1614610b5f576000610acf8286611253565b90508063ffffffff16610ae28486610d7d565b51610b0b91907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16611089565b610b159088611278565b96508063ffffffff16610b288585610d7d565b51610b5191907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16611089565b610b5b9087611278565b9550505b5050509193909250565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415610c28576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f556e697377617056324c6962726172793a204944454e544943414c5f4144445260448201527f45535345530000000000000000000000000000000000000000000000000000006064820152608401610319565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1610610c62578284610c65565b83835b909250905073ffffffffffffffffffffffffffffffffffffffff8216610ce7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f4144445245535300006044820152606401610319565b9250929050565b6000806040518060200160405280858888610d099190611072565b610d13919061115d565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1690529050610d49610d428285610e75565b5160701c90565b71ffffffffffffffffffffffffffffffffffff169695505050505050565b6000610d7864010000000042611171565b905090565b6040805160208101909152600081526000826dffffffffffffffffffffffffffff1611610e06576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4669786564506f696e743a204449565f42595f5a45524f0000000000000000006044820152606401610319565b604080516020810190915280610e4e6dffffffffffffffffffffffffffff85167bffffffffffffffffffffffffffff0000000000000000000000000000607088901b16611290565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1690529392505050565b6040805160208101909152600081526000821580610ec7575083517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1683610eb98183611089565b9250610ec5908361115d565b145b610f53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f4669786564506f696e743a204d554c5449504c49434154494f4e5f4f5645524660448201527f4c4f5700000000000000000000000000000000000000000000000000000000006064820152608401610319565b60408051602081019091529081529392505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610f8c57600080fd5b919050565b600080600060608486031215610fa657600080fd5b610faf84610f68565b925060208401359150610fc460408501610f68565b90509250925092565b60008060408385031215610fe057600080fd5b610fe983610f68565b946020939093013593505050565b6000806040838503121561100a57600080fd5b61101383610f68565b915061102160208401610f68565b90509250929050565b60006020828403121561103c57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008282101561108457611084611043565b500390565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156110c1576110c1611043565b500290565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156110f8576110f8611043565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261116c5761116c61112e565b500490565b6000826111805761118061112e565b500690565b600060ff821660ff84168060ff038211156111a2576111a2611043565b019392505050565b600060ff8316806111bd576111bd61112e565b8060ff84160691505092915050565b6000602082840312156111de57600080fd5b5051919050565b80516dffffffffffffffffffffffffffff81168114610f8c57600080fd5b60008060006060848603121561121857600080fd5b611221846111e5565b925061122f602085016111e5565b9150604084015163ffffffff8116811461124857600080fd5b809150509250925092565b600063ffffffff8381169083168181101561127057611270611043565b039392505050565b6000821982111561128b5761128b611043565b500190565b60007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff808416806112bf576112bf61112e565b9216919091049291505056fea26469706673582212205ba68a77f8d17e067a048f04d3a83d0adadba7a86d99e08736c8d5271ee03b8c64736f6c6343000809003300000000000000000000000062d5b84be28a183abb507e125b384122d2c25fae000000000000000000000000000000000000000000000000000000000000012c0000000000000000000000000000000000000000000000000000000000000005

Deployed ByteCode

0x60806040523480156200001157600080fd5b5060043610620001325760003560e01c8063addd509911620000c0578063e4463eb2116200008b578063f0ca4adb116200006e578063f0ca4adb14620002fd578063f2fde38b1462000314578063ffb0a4a0146200032b57600080fd5b8063e4463eb214620002be578063e6a4390514620002e657600080fd5b8063addd5099146200021e578063c373d7f31462000257578063c45a0155146200026e578063c8d5cd6a146200029657600080fd5b80637f70313611620001015780637f703136146200019f57806380bb2bac14620001dc5780638a7b8cf214620001e65780638da5cb5b14620001ff57600080fd5b80631b56bbf91462000137578063322e9f0414620001505780634048a257146200015a578063715018a61462000195575b600080fd5b6200014e62000148366004620010d5565b62000344565b005b6200014e620003d9565b620001806200016b366004620010d5565b60046020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b6200014e62000532565b620001b6620001b0366004620010f5565b620005c3565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016200018c565b6200018062000606565b620001f060015481565b6040519081526020016200018c565b60005473ffffffffffffffffffffffffffffffffffffffff16620001b6565b620001b66200022f366004620010d5565b60036020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6200014e6200026836600462001133565b6200064b565b620001b67f00000000000000000000000062d5b84be28a183abb507e125b384122d2c25fae81565b620001b67f00000000000000000000000007703c297310da365c22facaabe5b5bc6ecba51081565b620001f07f000000000000000000000000000000000000000000000000000000000000003c81565b620001b6620002f7366004620010f5565b6200075c565b6200014e6200030e366004620010f5565b62000792565b6200014e62000325366004620010d5565b620009fe565b6200033562000b31565b6040516200018c91906200116a565b60005473ffffffffffffffffffffffffffffffffffffffff163314620003cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b620003d68162000ba2565b50565b3360009081526004602052604090205460ff1662000454576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f507269636546656564466163746f72793a2021776f726b6572000000000000006044820152606401620003c2565b6200045e62000606565b620004c6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f507269636546656564466163746f72793a2021776f726b0000000000000000006044820152606401620003c2565b60005b6002548110156200052b576200051660028281548110620004ee57620004ee620011c6565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1662000ba2565b80620005228162001224565b915050620004c9565b5042600155565b60005473ffffffffffffffffffffffffffffffffffffffff163314620005b5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401620003c2565b620005c1600062000d6c565b565b600060036000620005d585856200075c565b73ffffffffffffffffffffffffffffffffffffffff9081168252602082019290925260400160002054169392505050565b6001546000907f000000000000000000000000000000000000000000000000000000000000003c62000639814262001260565b6200064591906200129c565b11905090565b60005473ffffffffffffffffffffffffffffffffffffffff163314620006ce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401620003c2565b73ffffffffffffffffffffffffffffffffffffffff821660008181526004602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168515159081179091558251938452908301527f544b110ecbb53c12b4410a9e8876b834b4013375180ae9c9cc375b119a9ba38e910160405180910390a15050565b60006200078b7f00000000000000000000000062d5b84be28a183abb507e125b384122d2c25fae848462000de1565b9392505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331462000815576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401620003c2565b60006200082383836200075c565b73ffffffffffffffffffffffffffffffffffffffff8082166000908152600360205260409020549192501615620008b7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f507269636546656564466163746f72793a206f7261636c6520657869737400006044820152606401620003c2565b600083837f00000000000000000000000007703c297310da365c22facaabe5b5bc6ecba510604051620008ea90620010a4565b73ffffffffffffffffffffffffffffffffffffffff938416815291831660208301529091166040820152606001604051809103906000f08015801562000934573d6000803e3d6000fd5b5060028054600181019091557f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff8681169182179093556000908152600360209081526040918290208054909316938516938417909255519182529192507f5dba83b2e4f5ef7ead6ae8f4902f5335ce28561a5207952f0b0a9d9f3a01a1b7910160405180910390a150505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331462000a81576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401620003c2565b73ffffffffffffffffffffffffffffffffffffffff811662000b26576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401620003c2565b620003d68162000d6c565b6060600280548060200260200160405190810160405280929190818152602001828054801562000b9857602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff16815260019091019060200180831162000b6c575b5050505050905090565b7f00000000000000000000000007703c297310da365c22facaabe5b5bc6ecba51073ffffffffffffffffffffffffffffffffffffffff1663c640752d8273ffffffffffffffffffffffffffffffffffffffff16630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801562000c2557600080fd5b505afa15801562000c3a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000c609190620012dc565b8373ffffffffffffffffffffffffffffffffffffffff1663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b15801562000ca757600080fd5b505afa15801562000cbc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000ce29190620012dc565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff928316600482015291166024820152604401600060405180830381600087803b15801562000d5057600080fd5b505af115801562000d65573d6000803e3d6000fd5b5050505050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080600062000df2858562000f19565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084811b8216602084015283901b166034820152919350915086906048016040516020818303038152906040528051906020012060405160200162000ed99291907fff00000000000000000000000000000000000000000000000000000000000000815260609290921b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016600183015260158201527fb3b8ff62960acea3a88039ebcf80699f15786f1b17cebd82802f7375827a339c603582015260550190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101209695505050505050565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141562000fda576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f556e697377617056324c6962726172793a204944454e544943414c5f4144445260448201527f45535345530000000000000000000000000000000000000000000000000000006064820152608401620003c2565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16106200101657828462001019565b83835b909250905073ffffffffffffffffffffffffffffffffffffffff82166200109d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f4144445245535300006044820152606401620003c2565b9250929050565b61058b80620012fd83390190565b73ffffffffffffffffffffffffffffffffffffffff81168114620003d657600080fd5b600060208284031215620010e857600080fd5b81356200078b81620010b2565b600080604083850312156200110957600080fd5b82356200111681620010b2565b915060208301356200112881620010b2565b809150509250929050565b600080604083850312156200114757600080fd5b82356200115481620010b2565b9150602083013580151581146200112857600080fd5b6020808252825182820181905260009190848201906040850190845b81811015620011ba57835173ffffffffffffffffffffffffffffffffffffffff168352928401929184019160010162001186565b50909695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415620012595762001259620011f5565b5060010190565b60008262001297577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615620012d757620012d7620011f5565b500290565b600060208284031215620012ef57600080fd5b81516200078b81620010b256fe61010060405234801561001157600080fd5b5060405161058b38038061058b833981016040819052610030916100e9565b6001600160a01b03808416608081905283821660a05290821660e0526040805163313ce56760e01b8152905163313ce56791600480820192602092909190829003018186803b15801561008257600080fd5b505afa158015610096573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100ba9190610136565b6100c590600a61025c565b60c0525061026b915050565b6001600160a01b03811681146100e657600080fd5b50565b6000806000606084860312156100fe57600080fd5b8351610109816100d1565b602085015190935061011a816100d1565b604085015190925061012b816100d1565b809150509250925092565b60006020828403121561014857600080fd5b815160ff8116811461015957600080fd5b9392505050565b634e487b7160e01b600052601160045260246000fd5b600181815b808511156101b157816000190482111561019757610197610160565b808516156101a457918102915b93841c939080029061017b565b509250929050565b6000826101c857506001610256565b816101d557506000610256565b81600181146101eb57600281146101f557610211565b6001915050610256565b60ff84111561020657610206610160565b50506001821b610256565b5060208310610133831016604e8410600b8410161715610234575081810a610256565b61023e8383610176565b806000190482111561025257610252610160565b0290505b92915050565b600061015960ff8416836101b9565b60805160a05160c05160e0516102ce6102bd6000396000818160ff01526101fe01526000818160d801526101ad01526000818161012601526101d30152600081816071015261018501526102ce6000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c8063a27eccc111610050578063a27eccc1146100d3578063c8d5cd6a146100fa578063d0202d3b1461012157600080fd5b80636daf390b1461006c5780637eeda703146100bd575b600080fd5b6100937f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6100c5610148565b6040519081526020016100b4565b6100c57f000000000000000000000000000000000000000000000000000000000000000081565b6100937f000000000000000000000000000000000000000000000000000000000000000081565b6100937f000000000000000000000000000000000000000000000000000000000000000081565b6040517f8c86f1e400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000811660048301527f000000000000000000000000000000000000000000000000000000000000000060248301527f0000000000000000000000000000000000000000000000000000000000000000811660448301526000917f000000000000000000000000000000000000000000000000000000000000000090911690638c86f1e49060640160206040518083038186803b15801561024257600080fd5b505afa158015610256573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027a919061027f565b905090565b60006020828403121561029157600080fd5b505191905056fea264697066735822122026dd96b88b5870a3e31739e017a07c2ba18ebc877bbe9c3394f89cf78e88daf964736f6c63430008090033a2646970667358221220fbf1f68a7ba16275bd5867f9264c612f3136dad701df6b2bf61ab1d4c228ad2264736f6c63430008090033