Contract Address Details

0xd5C90541381ACFA8D395b1C256c381d056a2cc87

Contract Name
Oracle
Creator
0xafa414–714ba5 at 0xedd61a–b859c0
Balance
0 MOVR
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
3132038
Contract name:
Oracle




Optimization enabled
true
Compiler version
v0.8.4+commit.c7e474f2




Optimization runs
200
EVM Version
default




Verified at
2022-01-14 15:53:07.118369Z

Constructor Arguments

000000000000000000000000c881c93ebb075b3c80f16bc9e513a7784f794ef900000000000000000000000000000000000000000000000000000000000054600000000000000000000000000000000000000000000000000000000061e34545

Arg [0] (address) : 0xc881c93ebb075b3c80f16bc9e513a7784f794ef9
Arg [1] (uint256) : 21600
Arg [2] (uint256) : 1642284357

              

Contract source code

// Sources flattened with hardhat v2.8.0 https://hardhat.org
// File @openzeppelin/contracts/utils/math/SafeMath.sol@v4.4.1
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
// File contracts/lib/Babylonian.sol
pragma solidity ^0.8.0;
library Babylonian {
function sqrt(uint256 y) internal pure returns (uint256 z) {
if (y > 3) {
z = y;
uint256 x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
// else z = 0
}
}
// File contracts/lib/FixedPoint.sol
pragma solidity ^0.8.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 {
uint256 _x;
}
uint8 private constant RESOLUTION = 112;
uint256 private constant Q112 = uint256(1) << RESOLUTION;
uint256 private constant Q224 = Q112 << RESOLUTION;
// encode a uint112 as a UQ112x112
function encode(uint112 x) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(x) << RESOLUTION);
}
// encodes a uint144 as a UQ144x112
function encode144(uint144 x) internal pure returns (uq144x112 memory) {
return uq144x112(uint256(x) << RESOLUTION);
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) {
require(x != 0, "FixedPoint: DIV_BY_ZERO");
return uq112x112(self._x / uint224(x));
}
// multiply a UQ112x112 by a uint, returning a UQ144x112
// reverts on overflow
function mul(uq112x112 memory self, uint256 y) internal pure returns (uq144x112 memory) {
uint256 z;
require(y == 0 || (z = uint256(self._x) * y) / y == uint256(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW");
return uq144x112(z);
}
// returns a UQ112x112 which represents the ratio of the numerator to the denominator
// equivalent to encode(numerator).div(denominator)
function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {
require(denominator > 0, "FixedPoint: DIV_BY_ZERO");
return uq112x112((uint224(numerator) << RESOLUTION) / denominator);
}
// decode a UQ112x112 into a uint112 by truncating after the radix point
function decode(uq112x112 memory self) internal pure returns (uint112) {
return uint112(self._x >> RESOLUTION);
}
// decode a UQ144x112 into a uint144 by truncating after the radix point
function decode144(uq144x112 memory self) internal pure returns (uint144) {
return uint144(self._x >> RESOLUTION);
}
// take the reciprocal of a UQ112x112
function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {
require(self._x != 0, "FixedPoint: ZERO_RECIPROCAL");
return uq112x112(uint224(Q224 / self._x));
}
// square root of a UQ112x112
function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56));
}
}
// File contracts/interfaces/IUniswapV2Pair.sol
pragma solidity ^0.8.0;
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address owner) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function transfer(address to, uint256 value) external returns (bool);
function transferFrom(
address from,
address to,
uint256 value
) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint256);
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
event Mint(address indexed sender, uint256 amount0, uint256 amount1);
event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);
event Swap(address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint256);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves()
external
view
returns (
uint112 reserve0,
uint112 reserve1,
uint32 blockTimestampLast
);
function price0CumulativeLast() external view returns (uint256);
function price1CumulativeLast() external view returns (uint256);
function kLast() external view returns (uint256);
function mint(address to) external returns (uint256 liquidity);
function burn(address to) external returns (uint256 amount0, uint256 amount1);
function swap(
uint256 amount0Out,
uint256 amount1Out,
address to,
bytes calldata data
) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
// File contracts/lib/UniswapV2OracleLibrary.sol
pragma solidity ^0.8.0;
// 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 (
uint256 price0Cumulative,
uint256 price1Cumulative,
uint32 blockTimestamp
)
{
blockTimestamp = currentBlockTimestamp();
price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast();
price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast();
// if time has elapsed since the last update on the pair, mock the accumulated price values
(uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves();
if (blockTimestampLast != blockTimestamp) {
// subtraction overflow is desired
uint32 timeElapsed = blockTimestamp - blockTimestampLast;
// addition overflow is desired
// counterfactual
price0Cumulative += uint256(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;
// counterfactual
price1Cumulative += uint256(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;
}
}
}
// File @openzeppelin/contracts/utils/Context.sol@v4.4.1
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// File @openzeppelin/contracts/access/Ownable.sol@v4.4.1
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev 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 {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// File contracts/owner/Operator.sol
pragma solidity ^0.8.0;
contract Operator is Context, Ownable {
address private _operator;
event OperatorTransferred(address indexed previousOperator, address indexed newOperator);
constructor () {
_operator = _msgSender();
emit OperatorTransferred(address(0), _operator);
}
function operator() public view returns (address) {
return _operator;
}
modifier onlyOperator() {
require(_operator == msg.sender, "operator: caller is not the operator");
_;
}
function isOperator() public view returns (bool) {
return _msgSender() == _operator;
}
function transferOperator(address newOperator_) public onlyOwner {
_transferOperator(newOperator_);
}
function _transferOperator(address newOperator_) internal {
require(newOperator_ != address(0), "operator: zero address given for new operator");
emit OperatorTransferred(address(0), newOperator_);
_operator = newOperator_;
}
}
// File contracts/utils/Epoch.sol
pragma solidity ^0.8.0;
contract Epoch is Operator {
using SafeMath for uint256;
uint256 private period;
uint256 private startTime;
uint256 private lastEpochTime;
uint256 private epoch;
/* ========== CONSTRUCTOR ========== */
constructor(
uint256 _period,
uint256 _startTime,
uint256 _startEpoch
) {
period = _period;
startTime = _startTime;
epoch = _startEpoch;
lastEpochTime = startTime.sub(period);
}
/* ========== Modifier ========== */
modifier checkStartTime {
require(block.timestamp >= startTime, 'Epoch: not started yet');
_;
}
modifier checkEpoch {
uint256 _nextEpochPoint = nextEpochPoint();
if (block.timestamp < _nextEpochPoint) {
require(msg.sender == operator(), 'Epoch: only operator allowed for pre-epoch');
_;
} else {
_;
for (;;) {
lastEpochTime = _nextEpochPoint;
++epoch;
_nextEpochPoint = nextEpochPoint();
if (block.timestamp < _nextEpochPoint) break;
}
}
}
/* ========== VIEW FUNCTIONS ========== */
function getCurrentEpoch() public view returns (uint256) {
return epoch;
}
function getPeriod() public view returns (uint256) {
return period;
}
function getStartTime() public view returns (uint256) {
return startTime;
}
function getLastEpochTime() public view returns (uint256) {
return lastEpochTime;
}
function nextEpochPoint() public view returns (uint256) {
return lastEpochTime.add(period);
}
/* ========== GOVERNANCE ========== */
function setPeriod(uint256 _period) external onlyOperator {
require(_period >= 1 hours && _period <= 48 hours, '_period: out of range');
period = _period;
}
function setEpoch(uint256 _epoch) external onlyOperator {
epoch = _epoch;
}
}
// File contracts/Oracle.sol
pragma solidity ^0.8.0;
/*
_____ __ .__ _____
/ _ \_/ |_| |__ ____ ____ _____ / \ ____ ____ ____ ___.__.
/ /_\ \ __\ | \_/ __ \ / \\__ \ / \ / \ / _ \ / \_/ __ < | |
/ | \ | | Y \ ___/| | \/ __ \_ / Y ( <_> ) | \ ___/\___ |
\____|__ /__| |___| /\___ >___| (____ / \____|__ /\____/|___| /\___ > ____|
\/ \/ \/ \/ \/ \/ \/ \/\/
http://athena.money
*/
// fixed window oracle that recomputes the average price for the entire period once every period
// note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period
contract Oracle is Epoch {
using FixedPoint for *;
using SafeMath for uint256;
/* ========== STATE VARIABLES ========== */
// uniswap
address public token0;
address public token1;
IUniswapV2Pair public pair;
// oracle
uint32 public blockTimestampLast;
uint256 public price0CumulativeLast;
uint256 public price1CumulativeLast;
FixedPoint.uq112x112 public price0Average;
FixedPoint.uq112x112 public price1Average;
/* ========== CONSTRUCTOR ========== */
constructor(
IUniswapV2Pair _pair,
uint256 _period,
uint256 _startTime
) Epoch(_period, _startTime, 0) {
pair = _pair;
token0 = pair.token0();
token1 = pair.token1();
price0CumulativeLast = pair.price0CumulativeLast(); // fetch the current accumulated price value (1 / 0)
price1CumulativeLast = pair.price1CumulativeLast(); // fetch the current accumulated price value (0 / 1)
uint112 reserve0;
uint112 reserve1;
(reserve0, reserve1, blockTimestampLast) = pair.getReserves();
require(reserve0 != 0 && reserve1 != 0, "Oracle: NO_RESERVES"); // ensure that there's liquidity in the pair
}
/* ========== MUTABLE FUNCTIONS ========== */
/** @dev Updates 1-day EMA price from Uniswap. */
function update() external checkEpoch {
(uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp) = UniswapV2OracleLibrary.currentCumulativePrices(address(pair));
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed == 0) {
// prevent divided by zero
return;
}
// overflow is desired, casting never truncates
// cumulative price is in (uq112x112 price * seconds) units so we simply wrap it after division by time elapsed
price0Average = FixedPoint.uq112x112(uint224((price0Cumulative - price0CumulativeLast) / timeElapsed));
price1Average = FixedPoint.uq112x112(uint224((price1Cumulative - price1CumulativeLast) / timeElapsed));
price0CumulativeLast = price0Cumulative;
price1CumulativeLast = price1Cumulative;
blockTimestampLast = blockTimestamp;
emit Updated(price0Cumulative, price1Cumulative);
}
// note this will always return 0 before update has been called successfully for the first time.
function consult(address _token, uint256 _amountIn) external view returns (uint144 amountOut) {
if (_token == token0) {
amountOut = price0Average.mul(_amountIn).decode144();
} else {
require(_token == token1, "Oracle: INVALID_TOKEN");
amountOut = price1Average.mul(_amountIn).decode144();
}
}
function twap(address _token, uint256 _amountIn) external view returns (uint144 _amountOut) {
(uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp) = UniswapV2OracleLibrary.currentCumulativePrices(address(pair));
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (_token == token0) {
_amountOut = FixedPoint.uq112x112(uint224((price0Cumulative - price0CumulativeLast) / timeElapsed)).mul(_amountIn).decode144();
} else if (_token == token1) {
_amountOut = FixedPoint.uq112x112(uint224((price1Cumulative - price1CumulativeLast) / timeElapsed)).mul(_amountIn).decode144();
}
}
event Updated(uint256 price0CumulativeLast, uint256 price1CumulativeLast);
}

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_pair","internalType":"contract IUniswapV2Pair"},{"type":"uint256","name":"_period","internalType":"uint256"},{"type":"uint256","name":"_startTime","internalType":"uint256"}]},{"type":"event","name":"OperatorTransferred","inputs":[{"type":"address","name":"previousOperator","internalType":"address","indexed":true},{"type":"address","name":"newOperator","internalType":"address","indexed":true}],"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":"Updated","inputs":[{"type":"uint256","name":"price0CumulativeLast","internalType":"uint256","indexed":false},{"type":"uint256","name":"price1CumulativeLast","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"blockTimestampLast","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint144","name":"amountOut","internalType":"uint144"}],"name":"consult","inputs":[{"type":"address","name":"_token","internalType":"address"},{"type":"uint256","name":"_amountIn","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getCurrentEpoch","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getLastEpochTime","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getPeriod","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getStartTime","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isOperator","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"nextEpochPoint","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"operator","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IUniswapV2Pair"}],"name":"pair","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint224","name":"_x","internalType":"uint224"}],"name":"price0Average","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"price0CumulativeLast","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint224","name":"_x","internalType":"uint224"}],"name":"price1Average","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"price1CumulativeLast","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setEpoch","inputs":[{"type":"uint256","name":"_epoch","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPeriod","inputs":[{"type":"uint256","name":"_period","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"token0","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"token1","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOperator","inputs":[{"type":"address","name":"newOperator_","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint144","name":"_amountOut","internalType":"uint144"}],"name":"twap","inputs":[{"type":"address","name":"_token","internalType":"address"},{"type":"uint256","name":"_amountIn","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"update","inputs":[]}]
            

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106101585760003560e01c8063715018a6116100c3578063ba5224581161007c578063ba522458146102de578063c5700a02146102e6578063c5967c2614610312578063c828371e1461031a578063d21220a714610322578063f2fde38b1461033557600080fd5b8063715018a61461028f5780638da5cb5b14610297578063a2e62045146102a8578063a6bb4539146102b0578063a8aa1b31146102c3578063b97dd9e2146102d657600080fd5b80634456eda2116101155780634456eda214610210578063570ca7351461022e5780635909c0d51461023f5780635a3d5493146102485780635e6aaf2c146102515780636808a1281461027c57600080fd5b80630ceb2cef1461015d5780630dfe1681146101725780630f3a9f65146101a25780631ed24195146101b557806329605e77146101c75780633ddac953146101da575b600080fd5b61017061016b366004610fb5565b610348565b005b600654610185906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6101706101b0366004610fb5565b610380565b6002545b604051908152602001610199565b6101706101d5366004610f24565b610408565b6101ed6101e8366004610f3e565b61043e565b60405171ffffffffffffffffffffffffffffffffffff9091168152602001610199565b6001546001600160a01b031633146040519015158152602001610199565b6001546001600160a01b0316610185565b6101b960095481565b6101b9600a5481565b600c54610264906001600160e01b031681565b6040516001600160e01b039091168152602001610199565b6101ed61028a366004610f3e565b610511565b610170610600565b6000546001600160a01b0316610185565b610170610636565b600b54610264906001600160e01b031681565b600854610185906001600160a01b031681565b6005546101b9565b6004546101b9565b6008546102fd90600160a01b900463ffffffff1681565b60405163ffffffff9091168152602001610199565b6101b96109a4565b6003546101b9565b600754610185906001600160a01b031681565b610170610343366004610f24565b6109c2565b6001546001600160a01b0316331461037b5760405162461bcd60e51b81526004016103729061101a565b60405180910390fd5b600555565b6001546001600160a01b031633146103aa5760405162461bcd60e51b81526004016103729061101a565b610e1081101580156103bf57506202a3008111155b6104035760405162461bcd60e51b81526020600482015260156024820152745f706572696f643a206f7574206f662072616e676560581b6044820152606401610372565b600255565b6000546001600160a01b031633146104325760405162461bcd60e51b815260040161037290610fe5565b61043b81610a66565b50565b6006546000906001600160a01b038481169116141561048c576040805160208101909152600b546001600160e01b031681526104859061047e9084610b2a565b5160701c90565b905061050b565b6007546001600160a01b038481169116146104e15760405162461bcd60e51b815260206004820152601560248201527427b930b1b6329d1024a72b20a624a22faa27a5a2a760591b6044820152606401610372565b6040805160208101909152600c546001600160e01b031681526105089061047e9084610b2a565b90505b92915050565b60085460009081908190819061052f906001600160a01b0316610bd4565b600854929550909350915060009061055490600160a01b900463ffffffff16836110e6565b6006549091506001600160a01b03888116911614156105b6576105af61047e8760405180602001604052808563ffffffff166009548a61059491906110cf565b61059e919061109c565b6001600160e01b0316905290610b2a565b94506105f6565b6007546001600160a01b03888116911614156105f6576105f361047e8760405180602001604052808563ffffffff16600a548961059491906110cf565b94505b5050505092915050565b6000546001600160a01b0316331461062a5760405162461bcd60e51b815260040161037290610fe5565b6106346000610dd4565b565b60006106406109a4565b905080421015610814576001546001600160a01b031633146106b75760405162461bcd60e51b815260206004820152602a60248201527f45706f63683a206f6e6c79206f70657261746f7220616c6c6f77656420666f72604482015269040e0e4ca5acae0dec6d60b31b6064820152608401610372565b600854600090819081906106d3906001600160a01b0316610bd4565b60085492955090935091506000906106f890600160a01b900463ffffffff16836110e6565b905063ffffffff811661070c575050505050565b60405180602001604052808263ffffffff166009548761072c91906110cf565b610736919061109c565b6001600160e01b039081169091529051600b80546001600160e01b031916919092161790556040805160208101909152600a54819063ffffffff84169061077d90876110cf565b610787919061109c565b6001600160e01b039081169091529051600c80546001600160e01b031916919092161790556009849055600a8390556008805463ffffffff60a01b1916600160a01b63ffffffff85160217905560408051858152602081018590527fd78a0cb8bb633d06981248b816e7bd33c2a35a6089241d099fa519e361cab902910160405180910390a15050505050565b60085460009081908190610830906001600160a01b0316610bd4565b600854929550909350915060009061085590600160a01b900463ffffffff16836110e6565b905063ffffffff811661086b5750505050610971565b60405180602001604052808263ffffffff166009548761088b91906110cf565b610895919061109c565b6001600160e01b039081169091529051600b80546001600160e01b031916919092161790556040805160208101909152600a54819063ffffffff8416906108dc90876110cf565b6108e6919061109c565b6001600160e01b039081169091529051600c80546001600160e01b031916919092161790556009849055600a8390556008805463ffffffff60a01b1916600160a01b63ffffffff85160217905560408051858152602081018590527fd78a0cb8bb633d06981248b816e7bd33c2a35a6089241d099fa519e361cab902910160405180910390a1505050505b6004819055600580546000906109869061110b565b909155506109926109a4565b90508042101561099f5750565b610971565b60006109bd600254600454610e2490919063ffffffff16565b905090565b6000546001600160a01b031633146109ec5760405162461bcd60e51b815260040161037290610fe5565b6001600160a01b038116610a515760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610372565b61043b81610dd4565b600061050882846110cf565b6001600160a01b038116610ad25760405162461bcd60e51b815260206004820152602d60248201527f6f70657261746f723a207a65726f206164647265737320676976656e20666f7260448201526c103732bb9037b832b930ba37b960991b6064820152608401610372565b6040516001600160a01b038216906000907f74da04524d50c64947f5dd5381ef1a4dca5cba8ed1d816243f9e48aa0b5617ed908290a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b6040805160208101909152600081526000821580610b67575083516001600160e01b031683610b5981836110b0565b9250610b65908361109c565b145b610bbf5760405162461bcd60e51b815260206004820152602360248201527f4669786564506f696e743a204d554c5449504c49434154494f4e5f4f564552466044820152624c4f5760e81b6064820152608401610372565b60408051602081019091529081529392505050565b6000806000610be1610e30565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b815260040160206040518083038186803b158015610c1c57600080fd5b505afa158015610c30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c549190610fcd565b9250836001600160a01b0316635a3d54936040518163ffffffff1660e01b815260040160206040518083038186803b158015610c8f57600080fd5b505afa158015610ca3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cc79190610fcd565b91506000806000866001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015610d0757600080fd5b505afa158015610d1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3f9190610f67565b9250925092508363ffffffff168163ffffffff1614610dca576000610d6482866110e6565b90508063ffffffff16610d778486610e41565b51610d8b91906001600160e01b03166110b0565b610d95908861105e565b96508063ffffffff16610da88585610e41565b51610dbc91906001600160e01b03166110b0565b610dc6908761105e565b9550505b5050509193909250565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610508828461105e565b60006109bd64010000000042611126565b6040805160208101909152600081526000826001600160701b031611610ea95760405162461bcd60e51b815260206004820152601760248201527f4669786564506f696e743a204449565f42595f5a45524f0000000000000000006044820152606401610372565b604080516020810190915280610edf6001600160701b0385166dffffffffffffffffffffffffffff60701b607088901b16611076565b6001600160e01b031690529392505050565b80356001600160a01b0381168114610f0857600080fd5b919050565b80516001600160701b0381168114610f0857600080fd5b600060208284031215610f35578081fd5b61050882610ef1565b60008060408385031215610f50578081fd5b610f5983610ef1565b946020939093013593505050565b600080600060608486031215610f7b578081fd5b610f8484610f0d565b9250610f9260208501610f0d565b9150604084015163ffffffff81168114610faa578182fd5b809150509250925092565b600060208284031215610fc6578081fd5b5035919050565b600060208284031215610fde578081fd5b5051919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526024908201527f6f70657261746f723a2063616c6c6572206973206e6f7420746865206f70657260408201526330ba37b960e11b606082015260800190565b600082198211156110715761107161113a565b500190565b60006001600160e01b038381168061109057611090611150565b92169190910492915050565b6000826110ab576110ab611150565b500490565b60008160001904831182151516156110ca576110ca61113a565b500290565b6000828210156110e1576110e161113a565b500390565b600063ffffffff838116908316818110156111035761110361113a565b039392505050565b600060001982141561111f5761111f61113a565b5060010190565b60008261113557611135611150565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fdfea2646970667358221220c544d43238e690b40b13ea84b07c2a77d5739178ce0387adafdaa82e456f0b1264736f6c63430008040033