Contract Overview
Balance:
0 CRO
CRO Value:
$0.00
My Name Tag:
Not Available, login to update
[ Download CSV Export ]
Contract Name:
Oracle
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity >0.6.12; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./lib/Babylonian.sol"; import "./lib/FixedPoint.sol"; import "./lib/UniswapV2OracleLibrary.sol"; import "./utils/Epoch.sol"; import "./interfaces/IUniswapV2Pair.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; // 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 Ownable, 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; bool public initialized = false; /* ========== CONSTRUCTOR ========== */ constructor( IUniswapV2Pair _pair, uint256 _period, uint256 _startTime ) public Epoch(_period, _startTime, 0) { pair = _pair; token0 = pair.token0(); token1 = pair.token1(); } function init() public onlyOwner { require(!initialized, "already initialized!!"); 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 initialized = true; } /* ========== MUTABLE FUNCTIONS ========== */ /** @dev Updates 1-day EMA price from Uniswap. */ function update() external checkEpoch { require(initialized, "not initialized yet!"); (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) { require(initialized, "not initialized yet!"); 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) { require(initialized, "not initialized yet!"); (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); }
// 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; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, _allowances[owner][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = _allowances[owner][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Spend `amount` form the allowance of `owner` toward `spender`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
pragma solidity >0.6.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 } }
pragma solidity >0.6.0; import "./Babylonian.sol"; // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) library FixedPoint { // range: [0, 2**112 - 1] // resolution: 1 / 2**112 struct uq112x112 { uint224 _x; } // range: [0, 2**144 - 1] // resolution: 1 / 2**112 struct uq144x112 { uint256 _x; } uint8 private constant RESOLUTION = 112; uint256 private constant Q112 = uint256(1) << RESOLUTION; uint256 private constant Q224 = Q112 << RESOLUTION; // encode a uint112 as a UQ112x112 function encode(uint112 x) internal pure returns (uq112x112 memory) { return uq112x112(uint224(x) << RESOLUTION); } // encodes a uint144 as a UQ144x112 function encode144(uint144 x) internal pure returns (uq144x112 memory) { return uq144x112(uint256(x) << RESOLUTION); } // divide a UQ112x112 by a uint112, returning a UQ112x112 function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) { require(x != 0, "FixedPoint: DIV_BY_ZERO"); return uq112x112(self._x / uint224(x)); } // multiply a UQ112x112 by a uint, returning a UQ144x112 // reverts on overflow function mul(uq112x112 memory self, uint256 y) internal pure returns (uq144x112 memory) { uint256 z; require(y == 0 || (z = uint256(self._x) * y) / y == uint256(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW"); return uq144x112(z); } // returns a UQ112x112 which represents the ratio of the numerator to the denominator // equivalent to encode(numerator).div(denominator) function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) { require(denominator > 0, "FixedPoint: DIV_BY_ZERO"); return uq112x112((uint224(numerator) << RESOLUTION) / denominator); } // decode a UQ112x112 into a uint112 by truncating after the radix point function decode(uq112x112 memory self) internal pure returns (uint112) { return uint112(self._x >> RESOLUTION); } // decode a UQ144x112 into a uint144 by truncating after the radix point function decode144(uq144x112 memory self) internal pure returns (uint144) { return uint144(self._x >> RESOLUTION); } // take the reciprocal of a UQ112x112 function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) { require(self._x != 0, "FixedPoint: ZERO_RECIPROCAL"); return uq112x112(uint224(Q224 / self._x)); } // square root of a UQ112x112 function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) { return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56)); } }
pragma solidity >0.6.0; import "./FixedPoint.sol"; import "../interfaces/IUniswapV2Pair.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 ( 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; } } }
pragma solidity >0.6.0; import '@openzeppelin/contracts/utils/math/SafeMath.sol'; import '../owner/Operator.sol'; 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 ) public { 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 { _; uint256 unixDiff = block.timestamp.sub(_nextEpochPoint); uint256 epochsLapsed = unixDiff.div(period); lastEpochTime = _nextEpochPoint.add(epochsLapsed.mul(period)); epoch = epoch.add(epochsLapsed.add(1)); } } /* ========== 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 >= 15 && _period <= 48 hours, '_period: out of range'); period = _period; } function setEpoch(uint256 _epoch) external onlyOperator { epoch = _epoch; } }
pragma solidity >0.6.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; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev 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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity >0.6.12; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; 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_; } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"inputs":[{"internalType":"contract IUniswapV2Pair","name":"_pair","type":"address"},{"internalType":"uint256","name":"_period","type":"uint256"},{"internalType":"uint256","name":"_startTime","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOperator","type":"address"},{"indexed":true,"internalType":"address","name":"newOperator","type":"address"}],"name":"OperatorTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"price0CumulativeLast","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price1CumulativeLast","type":"uint256"}],"name":"Updated","type":"event"},{"inputs":[],"name":"blockTimestampLast","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"}],"name":"consult","outputs":[{"internalType":"uint144","name":"amountOut","type":"uint144"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentEpoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastEpochTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStartTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isOperator","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextEpochPoint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"operator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pair","outputs":[{"internalType":"contract IUniswapV2Pair","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price0Average","outputs":[{"internalType":"uint224","name":"_x","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price0CumulativeLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price1Average","outputs":[{"internalType":"uint224","name":"_x","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price1CumulativeLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_epoch","type":"uint256"}],"name":"setEpoch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_period","type":"uint256"}],"name":"setPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token0","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOperator_","type":"address"}],"name":"transferOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"}],"name":"twap","outputs":[{"internalType":"uint144","name":"_amountOut","type":"uint144"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"update","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6080604052600d805460ff191690553480156200001b57600080fd5b5060405162001883380380620018838339810160408190526200003e916200028d565b818160006200004d3362000209565b600180546001600160a01b031916339081179091556040516000907f74da04524d50c64947f5dd5381ef1a4dca5cba8ed1d816243f9e48aa0b5617ed908290a3600283905560038290556005819055620000b4828462000259602090811b62000e0317901c565b6004908155600880546001600160a01b0319166001600160a01b03891690811790915560408051630dfe168160e01b81529051919550630dfe16819450808301935060209290829003018186803b1580156200010f57600080fd5b505afa15801562000124573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200014a91906200026e565b600680546001600160a01b0319166001600160a01b039283161790556008546040805163d21220a760e01b81529051919092169163d21220a7916004808301926020929190829003018186803b158015620001a457600080fd5b505afa158015620001b9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001df91906200026e565b600780546001600160a01b0319166001600160a01b03929092169190911790555062000303915050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000620002678284620002c6565b9392505050565b60006020828403121562000280578081fd5b81516200026781620002ea565b600080600060608486031215620002a2578182fd5b8351620002af81620002ea565b602085015160409095015190969495509392505050565b600082821015620002e557634e487b7160e01b81526011600452602481fd5b500390565b6001600160a01b03811681146200030057600080fd5b50565b61157080620003136000396000f3fe608060405234801561001057600080fd5b506004361061018e5760003560e01c8063715018a6116100de578063ba52245811610097578063c828371e11610071578063c828371e14610362578063d21220a71461036a578063e1c7392a1461037d578063f2fde38b1461038557600080fd5b8063ba52245814610326578063c5700a021461032e578063c5967c261461035a57600080fd5b8063715018a6146102d75780638da5cb5b146102df578063a2e62045146102f0578063a6bb4539146102f8578063a8aa1b311461030b578063b97dd9e21461031e57600080fd5b80633ddac9531161014b5780635909c0d5116101255780635909c0d5146102875780635a3d5493146102905780635e6aaf2c146102995780636808a128146102c457600080fd5b80633ddac9531461022d5780634456eda214610263578063570ca7351461027657600080fd5b80630ceb2cef146101935780630dfe1681146101a85780630f3a9f65146101d8578063158ef93e146101eb5780631ed241951461020857806329605e771461021a575b600080fd5b6101a66101a1366004611376565b610398565b005b6006546101bb906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6101a66101e6366004611376565b6103d0565b600d546101f89060ff1681565b60405190151581526020016101cf565b6002545b6040519081526020016101cf565b6101a66102283660046112e5565b610457565b61024061023b3660046112ff565b61048d565b60405171ffffffffffffffffffffffffffffffffffff90911681526020016101cf565b6001546001600160a01b031633146101f8565b6001546001600160a01b03166101bb565b61020c60095481565b61020c600a5481565b600c546102ac906001600160e01b031681565b6040516001600160e01b0390911681526020016101cf565b6102406102d23660046112ff565b610582565b6101a6610694565b6000546001600160a01b03166101bb565b6101a66106ca565b600b546102ac906001600160e01b031681565b6008546101bb906001600160a01b031681565b60055461020c565b60045461020c565b60085461034590600160a01b900463ffffffff1681565b60405163ffffffff90911681526020016101cf565b61020c610ab1565b60035461020c565b6007546101bb906001600160a01b031681565b6101a6610acf565b6101a66103933660046112e5565b610d6b565b6001546001600160a01b031633146103cb5760405162461bcd60e51b81526004016103c290611409565b60405180910390fd5b600555565b6001546001600160a01b031633146103fa5760405162461bcd60e51b81526004016103c290611409565b600f811015801561040e57506202a3008111155b6104525760405162461bcd60e51b81526020600482015260156024820152745f706572696f643a206f7574206f662072616e676560581b60448201526064016103c2565b600255565b6000546001600160a01b031633146104815760405162461bcd60e51b81526004016103c2906113d4565b61048a81610e0f565b50565b600d5460009060ff166104b25760405162461bcd60e51b81526004016103c2906113a6565b6006546001600160a01b03848116911614156104fd576040805160208101909152600b546001600160e01b031681526104f6906104ef9084610ed3565b5160701c90565b905061057c565b6007546001600160a01b038481169116146105525760405162461bcd60e51b815260206004820152601560248201527427b930b1b6329d1024a72b20a624a22faa27a5a2a760591b60448201526064016103c2565b6040805160208101909152600c546001600160e01b03168152610579906104ef9084610ed3565b90505b92915050565b600d5460009060ff166105a75760405162461bcd60e51b81526004016103c2906113a6565b600854600090819081906105c3906001600160a01b0316610f7d565b60085492955090935091506000906105e890600160a01b900463ffffffff16836114d5565b6006549091506001600160a01b038881169116141561064a576106436104ef8760405180602001604052808563ffffffff166009548a61062891906114be565b610632919061148b565b6001600160e01b0316905290610ed3565b945061068a565b6007546001600160a01b038881169116141561068a576106876104ef8760405180602001604052808563ffffffff16600a548961062891906114be565b94505b5050505092915050565b6000546001600160a01b031633146106be5760405162461bcd60e51b81526004016103c2906113d4565b6106c8600061117d565b565b60006106d4610ab1565b9050804210156108ca576001546001600160a01b0316331461074b5760405162461bcd60e51b815260206004820152602a60248201527f45706f63683a206f6e6c79206f70657261746f7220616c6c6f77656420666f72604482015269040e0e4ca5acae0dec6d60b31b60648201526084016103c2565b600d5460ff1661076d5760405162461bcd60e51b81526004016103c2906113a6565b60085460009081908190610789906001600160a01b0316610f7d565b60085492955090935091506000906107ae90600160a01b900463ffffffff16836114d5565b905063ffffffff81166107c2575050505050565b60405180602001604052808263ffffffff16600954876107e291906114be565b6107ec919061148b565b6001600160e01b039081169091529051600b80546001600160e01b031916919092161790556040805160208101909152600a54819063ffffffff84169061083390876114be565b61083d919061148b565b6001600160e01b039081169091529051600c80546001600160e01b031916919092161790556009849055600a8390556008805463ffffffff60a01b1916600160a01b63ffffffff85160217905560408051858152602081018590527fd78a0cb8bb633d06981248b816e7bd33c2a35a6089241d099fa519e361cab902910160405180910390a15050505050565b600d5460ff166108ec5760405162461bcd60e51b81526004016103c2906113a6565b60085460009081908190610908906001600160a01b0316610f7d565b600854929550909350915060009061092d90600160a01b900463ffffffff16836114d5565b905063ffffffff81166109435750505050610a49565b60405180602001604052808263ffffffff166009548761096391906114be565b61096d919061148b565b6001600160e01b039081169091529051600b80546001600160e01b031916919092161790556040805160208101909152600a54819063ffffffff8416906109b490876114be565b6109be919061148b565b6001600160e01b039081169091529051600c80546001600160e01b031916919092161790556009849055600a8390556008805463ffffffff60a01b1916600160a01b63ffffffff85160217905560408051858152602081018590527fd78a0cb8bb633d06981248b816e7bd33c2a35a6089241d099fa519e361cab902910160405180910390a1505050505b6000610a554283610e03565b90506000610a6e600254836111cd90919063ffffffff16565b9050610a8f610a88600254836111d990919063ffffffff16565b84906111e5565b600455610aa9610aa08260016111e5565b600554906111e5565b600555505050565b6000610aca6002546004546111e590919063ffffffff16565b905090565b6000546001600160a01b03163314610af95760405162461bcd60e51b81526004016103c2906113d4565b600d5460ff1615610b445760405162461bcd60e51b8152602060048201526015602482015274616c726561647920696e697469616c697a6564212160581b60448201526064016103c2565b600860009054906101000a90046001600160a01b03166001600160a01b0316635909c0d56040518163ffffffff1660e01b815260040160206040518083038186803b158015610b9257600080fd5b505afa158015610ba6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bca919061138e565b60095560085460408051635a3d549360e01b815290516001600160a01b0390921691635a3d549391600480820192602092909190829003018186803b158015610c1257600080fd5b505afa158015610c26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4a919061138e565b600a5560085460408051630240bc6b60e21b8152905160009283926001600160a01b0390911691630902f1ac91600480820192606092909190829003018186803b158015610c9757600080fd5b505afa158015610cab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ccf9190611328565b6008805463ffffffff909216600160a01b0263ffffffff60a01b1990921691909117905590925090506001600160701b03821615801590610d1857506001600160701b03811615155b610d5a5760405162461bcd60e51b81526020600482015260136024820152724f7261636c653a204e4f5f524553455256455360681b60448201526064016103c2565b5050600d805460ff19166001179055565b6000546001600160a01b03163314610d955760405162461bcd60e51b81526004016103c2906113d4565b6001600160a01b038116610dfa5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103c2565b61048a8161117d565b600061057982846114be565b6001600160a01b038116610e7b5760405162461bcd60e51b815260206004820152602d60248201527f6f70657261746f723a207a65726f206164647265737320676976656e20666f7260448201526c103732bb9037b832b930ba37b960991b60648201526084016103c2565b6040516001600160a01b038216906000907f74da04524d50c64947f5dd5381ef1a4dca5cba8ed1d816243f9e48aa0b5617ed908290a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b6040805160208101909152600081526000821580610f10575083516001600160e01b031683610f02818361149f565b9250610f0e908361148b565b145b610f685760405162461bcd60e51b815260206004820152602360248201527f4669786564506f696e743a204d554c5449504c49434154494f4e5f4f564552466044820152624c4f5760e81b60648201526084016103c2565b60408051602081019091529081529392505050565b6000806000610f8a6111f1565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b815260040160206040518083038186803b158015610fc557600080fd5b505afa158015610fd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffd919061138e565b9250836001600160a01b0316635a3d54936040518163ffffffff1660e01b815260040160206040518083038186803b15801561103857600080fd5b505afa15801561104c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611070919061138e565b91506000806000866001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b1580156110b057600080fd5b505afa1580156110c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110e89190611328565b9250925092508363ffffffff168163ffffffff161461117357600061110d82866114d5565b90508063ffffffff166111208486611202565b5161113491906001600160e01b031661149f565b61113e908861144d565b96508063ffffffff166111518585611202565b5161116591906001600160e01b031661149f565b61116f908761144d565b9550505b5050509193909250565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610579828461148b565b6000610579828461149f565b6000610579828461144d565b6000610aca640100000000426114fa565b6040805160208101909152600081526000826001600160701b03161161126a5760405162461bcd60e51b815260206004820152601760248201527f4669786564506f696e743a204449565f42595f5a45524f00000000000000000060448201526064016103c2565b6040805160208101909152806112a06001600160701b0385166dffffffffffffffffffffffffffff60701b607088901b16611465565b6001600160e01b031690529392505050565b80356001600160a01b03811681146112c957600080fd5b919050565b80516001600160701b03811681146112c957600080fd5b6000602082840312156112f6578081fd5b610579826112b2565b60008060408385031215611311578081fd5b61131a836112b2565b946020939093013593505050565b60008060006060848603121561133c578081fd5b611345846112ce565b9250611353602085016112ce565b9150604084015163ffffffff8116811461136b578182fd5b809150509250925092565b600060208284031215611387578081fd5b5035919050565b60006020828403121561139f578081fd5b5051919050565b6020808252601490820152736e6f7420696e697469616c697a6564207965742160601b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526024908201527f6f70657261746f723a2063616c6c6572206973206e6f7420746865206f70657260408201526330ba37b960e11b606082015260800190565b600082198211156114605761146061150e565b500190565b60006001600160e01b038381168061147f5761147f611524565b92169190910492915050565b60008261149a5761149a611524565b500490565b60008160001904831182151516156114b9576114b961150e565b500290565b6000828210156114d0576114d061150e565b500390565b600063ffffffff838116908316818110156114f2576114f261150e565b039392505050565b60008261150957611509611524565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fdfea2646970667358221220b591daff14939fcc4f21be737e56a0fbce93d6fa015d0d132f1a2a4792a2750864736f6c634300080400330000000000000000000000003bbd40be4d5463a1b5b7b0eb343305028b9632e0000000000000000000000000000000000000000000000000000000000000002d0000000000000000000000000000000000000000000000000000000062bf5240
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061018e5760003560e01c8063715018a6116100de578063ba52245811610097578063c828371e11610071578063c828371e14610362578063d21220a71461036a578063e1c7392a1461037d578063f2fde38b1461038557600080fd5b8063ba52245814610326578063c5700a021461032e578063c5967c261461035a57600080fd5b8063715018a6146102d75780638da5cb5b146102df578063a2e62045146102f0578063a6bb4539146102f8578063a8aa1b311461030b578063b97dd9e21461031e57600080fd5b80633ddac9531161014b5780635909c0d5116101255780635909c0d5146102875780635a3d5493146102905780635e6aaf2c146102995780636808a128146102c457600080fd5b80633ddac9531461022d5780634456eda214610263578063570ca7351461027657600080fd5b80630ceb2cef146101935780630dfe1681146101a85780630f3a9f65146101d8578063158ef93e146101eb5780631ed241951461020857806329605e771461021a575b600080fd5b6101a66101a1366004611376565b610398565b005b6006546101bb906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6101a66101e6366004611376565b6103d0565b600d546101f89060ff1681565b60405190151581526020016101cf565b6002545b6040519081526020016101cf565b6101a66102283660046112e5565b610457565b61024061023b3660046112ff565b61048d565b60405171ffffffffffffffffffffffffffffffffffff90911681526020016101cf565b6001546001600160a01b031633146101f8565b6001546001600160a01b03166101bb565b61020c60095481565b61020c600a5481565b600c546102ac906001600160e01b031681565b6040516001600160e01b0390911681526020016101cf565b6102406102d23660046112ff565b610582565b6101a6610694565b6000546001600160a01b03166101bb565b6101a66106ca565b600b546102ac906001600160e01b031681565b6008546101bb906001600160a01b031681565b60055461020c565b60045461020c565b60085461034590600160a01b900463ffffffff1681565b60405163ffffffff90911681526020016101cf565b61020c610ab1565b60035461020c565b6007546101bb906001600160a01b031681565b6101a6610acf565b6101a66103933660046112e5565b610d6b565b6001546001600160a01b031633146103cb5760405162461bcd60e51b81526004016103c290611409565b60405180910390fd5b600555565b6001546001600160a01b031633146103fa5760405162461bcd60e51b81526004016103c290611409565b600f811015801561040e57506202a3008111155b6104525760405162461bcd60e51b81526020600482015260156024820152745f706572696f643a206f7574206f662072616e676560581b60448201526064016103c2565b600255565b6000546001600160a01b031633146104815760405162461bcd60e51b81526004016103c2906113d4565b61048a81610e0f565b50565b600d5460009060ff166104b25760405162461bcd60e51b81526004016103c2906113a6565b6006546001600160a01b03848116911614156104fd576040805160208101909152600b546001600160e01b031681526104f6906104ef9084610ed3565b5160701c90565b905061057c565b6007546001600160a01b038481169116146105525760405162461bcd60e51b815260206004820152601560248201527427b930b1b6329d1024a72b20a624a22faa27a5a2a760591b60448201526064016103c2565b6040805160208101909152600c546001600160e01b03168152610579906104ef9084610ed3565b90505b92915050565b600d5460009060ff166105a75760405162461bcd60e51b81526004016103c2906113a6565b600854600090819081906105c3906001600160a01b0316610f7d565b60085492955090935091506000906105e890600160a01b900463ffffffff16836114d5565b6006549091506001600160a01b038881169116141561064a576106436104ef8760405180602001604052808563ffffffff166009548a61062891906114be565b610632919061148b565b6001600160e01b0316905290610ed3565b945061068a565b6007546001600160a01b038881169116141561068a576106876104ef8760405180602001604052808563ffffffff16600a548961062891906114be565b94505b5050505092915050565b6000546001600160a01b031633146106be5760405162461bcd60e51b81526004016103c2906113d4565b6106c8600061117d565b565b60006106d4610ab1565b9050804210156108ca576001546001600160a01b0316331461074b5760405162461bcd60e51b815260206004820152602a60248201527f45706f63683a206f6e6c79206f70657261746f7220616c6c6f77656420666f72604482015269040e0e4ca5acae0dec6d60b31b60648201526084016103c2565b600d5460ff1661076d5760405162461bcd60e51b81526004016103c2906113a6565b60085460009081908190610789906001600160a01b0316610f7d565b60085492955090935091506000906107ae90600160a01b900463ffffffff16836114d5565b905063ffffffff81166107c2575050505050565b60405180602001604052808263ffffffff16600954876107e291906114be565b6107ec919061148b565b6001600160e01b039081169091529051600b80546001600160e01b031916919092161790556040805160208101909152600a54819063ffffffff84169061083390876114be565b61083d919061148b565b6001600160e01b039081169091529051600c80546001600160e01b031916919092161790556009849055600a8390556008805463ffffffff60a01b1916600160a01b63ffffffff85160217905560408051858152602081018590527fd78a0cb8bb633d06981248b816e7bd33c2a35a6089241d099fa519e361cab902910160405180910390a15050505050565b600d5460ff166108ec5760405162461bcd60e51b81526004016103c2906113a6565b60085460009081908190610908906001600160a01b0316610f7d565b600854929550909350915060009061092d90600160a01b900463ffffffff16836114d5565b905063ffffffff81166109435750505050610a49565b60405180602001604052808263ffffffff166009548761096391906114be565b61096d919061148b565b6001600160e01b039081169091529051600b80546001600160e01b031916919092161790556040805160208101909152600a54819063ffffffff8416906109b490876114be565b6109be919061148b565b6001600160e01b039081169091529051600c80546001600160e01b031916919092161790556009849055600a8390556008805463ffffffff60a01b1916600160a01b63ffffffff85160217905560408051858152602081018590527fd78a0cb8bb633d06981248b816e7bd33c2a35a6089241d099fa519e361cab902910160405180910390a1505050505b6000610a554283610e03565b90506000610a6e600254836111cd90919063ffffffff16565b9050610a8f610a88600254836111d990919063ffffffff16565b84906111e5565b600455610aa9610aa08260016111e5565b600554906111e5565b600555505050565b6000610aca6002546004546111e590919063ffffffff16565b905090565b6000546001600160a01b03163314610af95760405162461bcd60e51b81526004016103c2906113d4565b600d5460ff1615610b445760405162461bcd60e51b8152602060048201526015602482015274616c726561647920696e697469616c697a6564212160581b60448201526064016103c2565b600860009054906101000a90046001600160a01b03166001600160a01b0316635909c0d56040518163ffffffff1660e01b815260040160206040518083038186803b158015610b9257600080fd5b505afa158015610ba6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bca919061138e565b60095560085460408051635a3d549360e01b815290516001600160a01b0390921691635a3d549391600480820192602092909190829003018186803b158015610c1257600080fd5b505afa158015610c26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4a919061138e565b600a5560085460408051630240bc6b60e21b8152905160009283926001600160a01b0390911691630902f1ac91600480820192606092909190829003018186803b158015610c9757600080fd5b505afa158015610cab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ccf9190611328565b6008805463ffffffff909216600160a01b0263ffffffff60a01b1990921691909117905590925090506001600160701b03821615801590610d1857506001600160701b03811615155b610d5a5760405162461bcd60e51b81526020600482015260136024820152724f7261636c653a204e4f5f524553455256455360681b60448201526064016103c2565b5050600d805460ff19166001179055565b6000546001600160a01b03163314610d955760405162461bcd60e51b81526004016103c2906113d4565b6001600160a01b038116610dfa5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103c2565b61048a8161117d565b600061057982846114be565b6001600160a01b038116610e7b5760405162461bcd60e51b815260206004820152602d60248201527f6f70657261746f723a207a65726f206164647265737320676976656e20666f7260448201526c103732bb9037b832b930ba37b960991b60648201526084016103c2565b6040516001600160a01b038216906000907f74da04524d50c64947f5dd5381ef1a4dca5cba8ed1d816243f9e48aa0b5617ed908290a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b6040805160208101909152600081526000821580610f10575083516001600160e01b031683610f02818361149f565b9250610f0e908361148b565b145b610f685760405162461bcd60e51b815260206004820152602360248201527f4669786564506f696e743a204d554c5449504c49434154494f4e5f4f564552466044820152624c4f5760e81b60648201526084016103c2565b60408051602081019091529081529392505050565b6000806000610f8a6111f1565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b815260040160206040518083038186803b158015610fc557600080fd5b505afa158015610fd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffd919061138e565b9250836001600160a01b0316635a3d54936040518163ffffffff1660e01b815260040160206040518083038186803b15801561103857600080fd5b505afa15801561104c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611070919061138e565b91506000806000866001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b1580156110b057600080fd5b505afa1580156110c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110e89190611328565b9250925092508363ffffffff168163ffffffff161461117357600061110d82866114d5565b90508063ffffffff166111208486611202565b5161113491906001600160e01b031661149f565b61113e908861144d565b96508063ffffffff166111518585611202565b5161116591906001600160e01b031661149f565b61116f908761144d565b9550505b5050509193909250565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610579828461148b565b6000610579828461149f565b6000610579828461144d565b6000610aca640100000000426114fa565b6040805160208101909152600081526000826001600160701b03161161126a5760405162461bcd60e51b815260206004820152601760248201527f4669786564506f696e743a204449565f42595f5a45524f00000000000000000060448201526064016103c2565b6040805160208101909152806112a06001600160701b0385166dffffffffffffffffffffffffffff60701b607088901b16611465565b6001600160e01b031690529392505050565b80356001600160a01b03811681146112c957600080fd5b919050565b80516001600160701b03811681146112c957600080fd5b6000602082840312156112f6578081fd5b610579826112b2565b60008060408385031215611311578081fd5b61131a836112b2565b946020939093013593505050565b60008060006060848603121561133c578081fd5b611345846112ce565b9250611353602085016112ce565b9150604084015163ffffffff8116811461136b578182fd5b809150509250925092565b600060208284031215611387578081fd5b5035919050565b60006020828403121561139f578081fd5b5051919050565b6020808252601490820152736e6f7420696e697469616c697a6564207965742160601b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526024908201527f6f70657261746f723a2063616c6c6572206973206e6f7420746865206f70657260408201526330ba37b960e11b606082015260800190565b600082198211156114605761146061150e565b500190565b60006001600160e01b038381168061147f5761147f611524565b92169190910492915050565b60008261149a5761149a611524565b500490565b60008160001904831182151516156114b9576114b961150e565b500290565b6000828210156114d0576114d061150e565b500390565b600063ffffffff838116908316818110156114f2576114f261150e565b039392505050565b60008261150957611509611524565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fdfea2646970667358221220b591daff14939fcc4f21be737e56a0fbce93d6fa015d0d132f1a2a4792a2750864736f6c63430008040033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000003bbd40be4d5463a1b5b7b0eb343305028b9632e0000000000000000000000000000000000000000000000000000000000000002d0000000000000000000000000000000000000000000000000000000062bf5240
-----Decoded View---------------
Arg [0] : _pair (address): 0x3bbd40be4d5463a1b5b7b0eb343305028b9632e0
Arg [1] : _period (uint256): 45
Arg [2] : _startTime (uint256): 1656705600
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000003bbd40be4d5463a1b5b7b0eb343305028b9632e0
Arg [1] : 000000000000000000000000000000000000000000000000000000000000002d
Arg [2] : 0000000000000000000000000000000000000000000000000000000062bf5240
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.