Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
RFRMOracle
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 10000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; /** * @title RFRM Oracle * @notice This contract provides an oracle for RFRM token prices in various currencies. * @dev Reform DAO */ import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { AggregatorV3Interface } from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; import { UniswapV2OracleLibrary, FixedPoint } from "@uniswap/v2-periphery/contracts/libraries/UniswapV2OracleLibrary.sol"; /** * @title IERC20 * @notice Interface for ERC20 tokens */ interface IERC20 { function decimals() external view returns (uint8); } /** * @title SlidingWindowOracle * @notice An oracle contract that calculates the average price of an asset over a sliding time window. */ contract SlidingWindowOracle { using FixedPoint for *; struct Observation { uint256 timestamp; uint256 price0Cumulative; uint256 price1Cumulative; } // Pair contract address address public immutable pair; // The desired amount of time over which the moving average should be computed, e.g., 24 hours uint256 public immutable windowSize; // The number of observations stored for each pair, i.e., how many price observations are stored for the window. // As granularity increases from 1, more frequent updates are needed, but moving averages become more precise. uint8 public immutable granularity; // Time period uint256 public immutable periodSize; // Observations array Observation[] public pairObservations; // Event when price is updated. event PriceUpdated(uint256 timestamp); error InvalidGranularity(); error InvalidWindowSize(); error MissingHistoricalObservation(); error ZeroAddress(); /** * @dev Constructor to initialize the SlidingWindowOracle. * @param _windowSize The desired time window for computing the moving average. * @param _granularity The granularity of observations. * @param _pair The address of the Uniswap pair contract for the token. */ constructor(uint256 _windowSize, uint8 _granularity, address _pair) { if (_granularity <= 1) revert InvalidGranularity(); if ((periodSize = _windowSize / _granularity) * _granularity != _windowSize) revert InvalidWindowSize(); windowSize = _windowSize; granularity = _granularity; pair = _pair; // Populate the array with empty observations for (uint256 i = 0; i < granularity; i++) { pairObservations.push(); } } /** * @dev Update the oracle with the latest price observation. */ function update() external { uint8 observationIndex = observationIndexOf(block.timestamp); Observation storage observation = pairObservations[observationIndex]; // We only want to commit updates once per period (i.e., windowSize / granularity) uint256 timeElapsed = block.timestamp - observation.timestamp; if (timeElapsed > periodSize) { (uint256 price0Cumulative, uint256 price1Cumulative, ) = UniswapV2OracleLibrary.currentCumulativePrices( address(pair) ); observation.timestamp = block.timestamp; observation.price0Cumulative = price0Cumulative; observation.price1Cumulative = price1Cumulative; } emit PriceUpdated(block.timestamp); } /** * @dev Get the index of the observation corresponding to a given timestamp. * @param timestamp The timestamp for which to find the observation index. * @return index The index of the observation in the pairObservations array. */ function observationIndexOf(uint256 timestamp) public view returns (uint8 index) { uint256 epochPeriod = timestamp / periodSize; return uint8(epochPeriod % granularity); } /** * @dev Get all observations stored in the pairObservations array. * @return observations An array of observations. */ function getAllObservations() public view returns (Observation[] memory) { return pairObservations; } /** * @dev Get the first observation in the sliding time window. * @return firstObservation The first observation in the window. */ function getFirstObservationInWindow() public view returns (Observation memory firstObservation) { uint8 observationIndex = observationIndexOf(block.timestamp); uint8 firstObservationIndex = (observationIndex + 1) % granularity; firstObservation = pairObservations[firstObservationIndex]; } /** * @dev Consult the oracle for the amount out corresponding to the input amount. * @param tokenIn The input token address. * @param amountIn The input amount. * @param tokenOut The output token address. * @return amountOut The computed amount out. */ function consult(address tokenIn, uint256 amountIn, address tokenOut) public view returns (uint256 amountOut) { Observation memory firstObservation = getFirstObservationInWindow(); uint256 timeElapsed = block.timestamp - firstObservation.timestamp; if (timeElapsed > windowSize) revert MissingHistoricalObservation(); (uint256 price0Cumulative, uint256 price1Cumulative, ) = UniswapV2OracleLibrary.currentCumulativePrices( address(pair) ); address token0 = tokenIn < tokenOut ? tokenIn : tokenOut; if (token0 == tokenIn) { return computeAmountOut(firstObservation.price0Cumulative, price0Cumulative, timeElapsed, amountIn); } else { return computeAmountOut(firstObservation.price1Cumulative, price1Cumulative, timeElapsed, amountIn); } } /** * @dev Compute the amount out based on cumulative prices and time elapsed. * @param priceCumulativeStart The cumulative price at the start of the period. * @param priceCumulativeEnd The cumulative price at the end of the period. * @param timeElapsed The time elapsed in seconds. * @param amountIn The input amount. * @return amountOut The computed amount out. */ function computeAmountOut( uint256 priceCumulativeStart, uint256 priceCumulativeEnd, uint256 timeElapsed, uint256 amountIn ) private pure returns (uint256 amountOut) { // Overflow is desired. FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112( uint224((priceCumulativeEnd - priceCumulativeStart) / timeElapsed) ); amountOut = priceAverage.mul(amountIn).decode144(); } } /** * @title RFRMOracle * @notice An extension of SlidingWindowOracle to provide RFRM token price conversions in different currencies. */ contract RFRMOracle is Ownable, SlidingWindowOracle { AggregatorV3Interface public priceFeed; // RFRM/ETH bool internal isUsingChainlink; IERC20 public immutable token; address public immutable weth; AggregatorV3Interface public immutable ethusd; AggregatorV3Interface public immutable usdcusd; AggregatorV3Interface public immutable usdtusd; event OracleChanged(address feed, bool isUsing); error PriceNotUpdated(); /** * @dev Constructor to initialize the RFRMOracle. * @param _pair The address of the Uniswap pair contract for RFRM token. * @param _token The address of the RFRM token. * @param _weth The address of Wrapped Ether (WETH). * @param _ethusd The address of the ETH/USD Chainlink aggregator. * @param _usdcusd The address of the USDC/USD Chainlink aggregator. * @param _usdtusd The address of the USDT/USD Chainlink aggregator. * @param _windowSize The desired time window for computing the moving average. * @param _granularity The granularity of observations. */ constructor( address _pair, address _token, address _weth, address _ethusd, address _usdcusd, address _usdtusd, uint256 _windowSize, uint8 _granularity ) SlidingWindowOracle(_windowSize, _granularity, _pair) { if (_pair == address(0) || _token == address(0)) revert ZeroAddress(); weth = _weth; ethusd = AggregatorV3Interface(_ethusd); usdcusd = AggregatorV3Interface(_usdcusd); usdtusd = AggregatorV3Interface(_usdtusd); token = IERC20(_token); } /** * @dev Set the Chainlink aggregator and specify whether it is in use. * @param _feed The address of the Chainlink aggregator. * @param _isUsing True if Chainlink aggregator is in use, false otherwise. */ function setChainlink(address _feed, bool _isUsing) external onlyOwner { if (_isUsing) { if (_feed == address(0)) revert ZeroAddress(); } priceFeed = AggregatorV3Interface(_feed); isUsingChainlink = _isUsing; emit OracleChanged(_feed, _isUsing); } /** * @dev Get the price of RFRM token in USDC. * @param tokenAmount The amount of RFRM tokens to convert. * @return usdAmount The equivalent amount in USDC. */ function getPriceInUSDC(uint256 tokenAmount) external view returns (uint256 usdAmount) { uint256 ethAmount = getPriceInETH(tokenAmount); usdAmount = convertETHToUSDC(ethAmount); } /** * @dev Get the price of RFRM token in USDT. * @param tokenAmount The amount of RFRM tokens to convert. * @return usdAmount The equivalent amount in USDT. */ function getPriceInUSDT(uint256 tokenAmount) external view returns (uint256 usdAmount) { uint256 ethAmount = getPriceInETH(tokenAmount); usdAmount = convertETHToUSDT(ethAmount); } /** * @dev Convert USDC to Ether (ETH). * @param usdAmount The amount of USDC to convert. * @return ethAmount The equivalent amount in Ether. */ function convertUSDCToETH(uint256 usdAmount) external view returns (uint256 ethAmount) { (uint80 ethRoundId, int256 ethPrice, , uint256 updatedAtEth, uint80 ethAnsweredInRound) = ethusd .latestRoundData(); (uint80 usdcRoundId, int256 usdcPrice, , uint256 updatedAtUsdt, uint80 usdcAnsweredInRound) = usdcusd .latestRoundData(); if (ethRoundId != ethAnsweredInRound || usdcRoundId != usdcAnsweredInRound) revert PriceNotUpdated(); if (updatedAtEth == 0 || updatedAtUsdt == 0) revert PriceNotUpdated(); if (ethPrice == 0 || usdcPrice == 0) revert PriceNotUpdated(); ethAmount = (10 ** 18 * uint256(usdcPrice) * usdAmount) / (uint256(ethPrice) * 10 ** 6); } /** * @dev Convert USDT to Ether (ETH). * @param usdAmount The amount of USDT to convert. * @return ethAmount The equivalent amount in Ether. */ function convertUSDTToETH(uint256 usdAmount) external view returns (uint256 ethAmount) { (uint80 ethRoundId, int256 ethPrice, , uint256 updatedAtEth, uint80 ethAnsweredInRound) = ethusd .latestRoundData(); (uint80 usdtRoundId, int256 usdtPrice, , uint256 updatedAtUsdt, uint80 usdtAnsweredInRound) = usdtusd .latestRoundData(); if (ethRoundId != ethAnsweredInRound || usdtRoundId != usdtAnsweredInRound) revert PriceNotUpdated(); if (updatedAtEth == 0 || updatedAtUsdt == 0) revert PriceNotUpdated(); if (ethPrice == 0 || usdtPrice == 0) revert PriceNotUpdated(); ethAmount = (10 ** 18 * uint256(usdtPrice) * usdAmount) / (uint256(ethPrice) * 10 ** 6); } /** * @dev Convert USD to Ether (ETH). * @param usdAmount The amount of USD to convert (with 8 decimals). * @return ethAmount The equivalent amount in Ether. */ function convertUSDToETH(uint256 usdAmount) external view returns (uint256 ethAmount) { usdAmount = usdAmount * 100; //Converting to 8 decimals (uint80 ethRoundId, int256 ethPrice, , uint256 updatedAtEth, uint80 ethAnsweredInRound) = ethusd .latestRoundData(); if (ethRoundId != ethAnsweredInRound) revert PriceNotUpdated(); if (updatedAtEth == 0) revert PriceNotUpdated(); if (ethPrice == 0) revert PriceNotUpdated(); ethAmount = (usdAmount * 10 ** 18) / uint256(ethPrice); } /** * @dev Get the price of RFRM token in Ether (ETH). * @param tokenAmount The amount of RFRM tokens to convert. * @return ethAmount The equivalent amount in Ether. */ function getPriceInETH(uint256 tokenAmount) public view returns (uint256 ethAmount) { if (!isUsingChainlink) { ethAmount = consult(address(token), tokenAmount, weth); } else { // Price of 1 RFRM including decimals (uint80 roundId, int256 price, , uint256 updatedAt, uint80 answeredInRound) = priceFeed.latestRoundData(); if (roundId != answeredInRound) revert PriceNotUpdated(); if (updatedAt == 0) revert PriceNotUpdated(); if (price == 0) revert PriceNotUpdated(); ethAmount = (uint256(price) * tokenAmount) / 10 ** token.decimals(); } } /** * @dev Convert Ether (ETH) to USDC. * @param ethAmount The amount of Ether to convert. * @return usdAmount The equivalent amount in USDC. */ function convertETHToUSDC(uint256 ethAmount) public view returns (uint256 usdAmount) { (uint80 ethRoundId, int256 ethPrice, , uint256 updatedAtEth, uint80 ethAnsweredInRound) = ethusd .latestRoundData(); (uint80 usdcRoundId, int256 usdcPrice, , uint256 updatedAtUsdt, uint80 usdcAnsweredInRound) = usdcusd .latestRoundData(); if (ethRoundId != ethAnsweredInRound || usdcRoundId != usdcAnsweredInRound) revert PriceNotUpdated(); if (updatedAtEth == 0 || updatedAtUsdt == 0) revert PriceNotUpdated(); if (ethPrice == 0 || usdcPrice == 0) revert PriceNotUpdated(); // USDC has 6 decimals, ETH has 18 usdAmount = (uint256(ethPrice) * 10 ** 6 * ethAmount) / (10 ** 18 * uint256(usdcPrice)); } /** * @dev Convert Ether (ETH) to USDT. * @param ethAmount The amount of Ether to convert. * @return usdAmount The equivalent amount in USDT. */ function convertETHToUSDT(uint256 ethAmount) public view returns (uint256 usdAmount) { (uint80 ethRoundId, int256 ethPrice, , uint256 updatedAtEth, uint80 ethAnsweredInRound) = ethusd .latestRoundData(); (uint80 usdtRoundId, int256 usdtPrice, , uint256 updatedAtUsdt, uint80 usdtAnsweredInRound) = usdtusd .latestRoundData(); if (ethRoundId != ethAnsweredInRound || usdtRoundId != usdtAnsweredInRound) revert PriceNotUpdated(); if (updatedAtEth == 0 || updatedAtUsdt == 0) revert PriceNotUpdated(); if (ethPrice == 0 || usdtPrice == 0) revert PriceNotUpdated(); // USDT has 6 decimals, ETH has 18 usdAmount = (uint256(ethPrice) * 10 ** 6 * ethAmount) / (10 ** 18 * uint256(usdtPrice)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (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 Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { 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 pragma solidity ^0.8.0; interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); }
pragma solidity >=0.5.0; import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol'; import '@uniswap/lib/contracts/libraries/FixedPoint.sol'; // library with helper methods for oracles that are concerned with computing average prices library UniswapV2OracleLibrary { using FixedPoint for *; // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1] function currentBlockTimestamp() internal view returns (uint32) { return uint32(block.timestamp % 2 ** 32); } // produces the cumulative price using counterfactuals to save gas and avoid a call to sync. function currentCumulativePrices( address pair ) internal view returns (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) { blockTimestamp = currentBlockTimestamp(); price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast(); price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast(); // if time has elapsed since the last update on the pair, mock the accumulated price values (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves(); if (blockTimestampLast != blockTimestamp) { // subtraction overflow is desired uint32 timeElapsed = blockTimestamp - blockTimestampLast; // addition overflow is desired // counterfactual price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed; // counterfactual price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed; } } }
// 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; } }
pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; }
pragma solidity >=0.4.0; // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) library FixedPoint { // range: [0, 2**112 - 1] // resolution: 1 / 2**112 struct uq112x112 { uint224 _x; } // range: [0, 2**144 - 1] // resolution: 1 / 2**112 struct uq144x112 { uint _x; } uint8 private constant RESOLUTION = 112; // encode a uint112 as a UQ112x112 function encode(uint112 x) internal pure returns (uq112x112 memory) { return uq112x112(uint224(x) << RESOLUTION); } // encodes a uint144 as a UQ144x112 function encode144(uint144 x) internal pure returns (uq144x112 memory) { return uq144x112(uint256(x) << RESOLUTION); } // divide a UQ112x112 by a uint112, returning a UQ112x112 function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) { require(x != 0, 'FixedPoint: DIV_BY_ZERO'); return uq112x112(self._x / uint224(x)); } // multiply a UQ112x112 by a uint, returning a UQ144x112 // reverts on overflow function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) { uint z; require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW"); return uq144x112(z); } // returns a UQ112x112 which represents the ratio of the numerator to the denominator // equivalent to encode(numerator).div(denominator) function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) { require(denominator > 0, "FixedPoint: DIV_BY_ZERO"); return uq112x112((uint224(numerator) << RESOLUTION) / denominator); } // decode a UQ112x112 into a uint112 by truncating after the radix point function decode(uq112x112 memory self) internal pure returns (uint112) { return uint112(self._x >> RESOLUTION); } // decode a UQ144x112 into a uint144 by truncating after the radix point function decode144(uq144x112 memory self) internal pure returns (uint144) { return uint144(self._x >> RESOLUTION); } }
{ "remappings": [ "@prb/test/=lib/prb-test/src/", "forge-std/=lib/forge-std/src/", "@openzeppelin/=lib/openzeppelin-contracts/", "@uniswap/=node_modules/@uniswap/", "@chainlink/=lib/chainlink/", "chainlink/=lib/chainlink/integration-tests/contracts/ethereum/src/", "ds-test/=lib/forge-std/lib/ds-test/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "prb-test/=lib/prb-test/src/" ], "optimizer": { "enabled": true, "runs": 10000 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "none", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "libraries": {} }
[{"inputs":[{"internalType":"address","name":"_pair","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_weth","type":"address"},{"internalType":"address","name":"_ethusd","type":"address"},{"internalType":"address","name":"_usdcusd","type":"address"},{"internalType":"address","name":"_usdtusd","type":"address"},{"internalType":"uint256","name":"_windowSize","type":"uint256"},{"internalType":"uint8","name":"_granularity","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidGranularity","type":"error"},{"inputs":[],"name":"InvalidWindowSize","type":"error"},{"inputs":[],"name":"MissingHistoricalObservation","type":"error"},{"inputs":[],"name":"PriceNotUpdated","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"feed","type":"address"},{"indexed":false,"internalType":"bool","name":"isUsing","type":"bool"}],"name":"OracleChanged","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":"timestamp","type":"uint256"}],"name":"PriceUpdated","type":"event"},{"inputs":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"address","name":"tokenOut","type":"address"}],"name":"consult","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"ethAmount","type":"uint256"}],"name":"convertETHToUSDC","outputs":[{"internalType":"uint256","name":"usdAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"ethAmount","type":"uint256"}],"name":"convertETHToUSDT","outputs":[{"internalType":"uint256","name":"usdAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"usdAmount","type":"uint256"}],"name":"convertUSDCToETH","outputs":[{"internalType":"uint256","name":"ethAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"usdAmount","type":"uint256"}],"name":"convertUSDTToETH","outputs":[{"internalType":"uint256","name":"ethAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"usdAmount","type":"uint256"}],"name":"convertUSDToETH","outputs":[{"internalType":"uint256","name":"ethAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ethusd","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllObservations","outputs":[{"components":[{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint256","name":"price0Cumulative","type":"uint256"},{"internalType":"uint256","name":"price1Cumulative","type":"uint256"}],"internalType":"struct SlidingWindowOracle.Observation[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFirstObservationInWindow","outputs":[{"components":[{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint256","name":"price0Cumulative","type":"uint256"},{"internalType":"uint256","name":"price1Cumulative","type":"uint256"}],"internalType":"struct SlidingWindowOracle.Observation","name":"firstObservation","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"getPriceInETH","outputs":[{"internalType":"uint256","name":"ethAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"getPriceInUSDC","outputs":[{"internalType":"uint256","name":"usdAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"getPriceInUSDT","outputs":[{"internalType":"uint256","name":"usdAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"granularity","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"observationIndexOf","outputs":[{"internalType":"uint8","name":"index","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pairObservations","outputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint256","name":"price0Cumulative","type":"uint256"},{"internalType":"uint256","name":"price1Cumulative","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceFeed","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feed","type":"address"},{"internalType":"bool","name":"_isUsing","type":"bool"}],"name":"setChainlink","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"update","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usdcusd","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"usdtusd","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"windowSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
6101a06040523480156200001257600080fd5b506040516200247f3803806200247f8339810160408190526200003591620001c5565b818189620000433362000158565b60018260ff16116200006857604051630f4d94b560e21b815260040160405180910390fd5b8260ff83166200007981836200026d565b60e08190526200008a919062000290565b14620000a9576040516350a3ddc960e11b815260040160405180910390fd5b60a083905260ff821660c0526001600160a01b03811660805260005b60c05160ff16811015620000e7576001805481018155600081905201620000c5565b505050506001600160a01b03881615806200010957506001600160a01b038716155b15620001285760405163d92e233d60e01b815260040160405180910390fd5b50506001600160a01b039384166101205291831661014052821661016052811661018052166101005250620002bc565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b0381168114620001c057600080fd5b919050565b600080600080600080600080610100898b031215620001e357600080fd5b620001ee89620001a8565b9750620001fe60208a01620001a8565b96506200020e60408a01620001a8565b95506200021e60608a01620001a8565b94506200022e60808a01620001a8565b93506200023e60a08a01620001a8565b925060c0890151915060e089015160ff811681146200025c57600080fd5b809150509295985092959890939650565b6000826200028b57634e487b7160e01b600052601260045260246000fd5b500490565b8082028115828204841417620002b657634e487b7160e01b600052601160045260246000fd5b92915050565b60805160a05160c05160e05161010051610120516101405161016051610180516120cd620003b26000396000818161022201528181610aab015261138d01526000818161035e01528181610ebe015261111601526000818161033701528181610a0d01528181610c9401528181610e200152818161107801526112ef0152600081816102d701526105cb0152600081816104e0015281816105a9015261075c0152600081816104a60152818161145401526114fa0152600081816102fe0152818161094601526115280152600081816103e601526111be01526000818161046c0152818161121e015261148201526120cd6000f3fe608060405234801561001057600080fd5b50600436106101c45760003560e01c80637c9c2f8a116100f9578063907f238311610097578063dbaad32f11610071578063dbaad32f1461048e578063e4463eb2146104a1578063f2fde38b146104c8578063fc0c546a146104db57600080fd5b8063907f23831461044c578063a2e620451461045f578063a8aa1b311461046757600080fd5b80638a14117a116100d35780638a14117a146103e15780638c86f1e4146104085780638da5cb5b1461041b5780638e2141e61461043957600080fd5b80637c9c2f8a146103a8578063831cefa6146103bb57806388882205146103ce57600080fd5b80633be0dcb81161016657806361150aae1161014057806361150aae146103325780636a0b275414610359578063715018a614610380578063741bef1a1461038857600080fd5b80633be0dcb8146102bf5780633fc8cef3146102d2578063556f0dc7146102f957600080fd5b8063255b2d71116101a2578063255b2d711461021d5780632eb59ece14610269578063363ec28d1461027e57806339606a5c146102ac57600080fd5b806302b231d0146101c95780630441b220146101e7578063243948cf14610208575b600080fd5b6101d1610502565b6040516101de9190611b9e565b60405180910390f35b6101fa6101f5366004611c00565b61057f565b6040519081526020016101de565b61021b610216366004611c3d565b610814565b005b6102447f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101de565b610271610911565b6040516101de9190611c79565b61029161028c366004611c00565b6109d0565b604080519384526020840192909252908201526060016101de565b6101fa6102ba366004611c00565b610a03565b6101fa6102cd366004611c00565b610c7d565b6102447f000000000000000000000000000000000000000000000000000000000000000081565b6103207f000000000000000000000000000000000000000000000000000000000000000081565b60405160ff90911681526020016101de565b6102447f000000000000000000000000000000000000000000000000000000000000000081565b6102447f000000000000000000000000000000000000000000000000000000000000000081565b61021b610e02565b6002546102449073ffffffffffffffffffffffffffffffffffffffff1681565b6101fa6103b6366004611c00565b610e16565b6101fa6103c9366004611c00565b61106e565b6101fa6103dc366004611c00565b61117f565b6101fa7f000000000000000000000000000000000000000000000000000000000000000081565b6101fa610416366004611c9a565b61119d565b60005473ffffffffffffffffffffffffffffffffffffffff16610244565b6101fa610447366004611c00565b6112e5565b6101fa61045a366004611c00565b6113f6565b61021b61140d565b6102447f000000000000000000000000000000000000000000000000000000000000000081565b61032061049c366004611c00565b6114f2565b6101fa7f000000000000000000000000000000000000000000000000000000000000000081565b61021b6104d6366004611cd6565b61154e565b6102447f000000000000000000000000000000000000000000000000000000000000000081565b60606001805480602002602001604051908101604052809291908181526020016000905b828210156105765783829060005260206000209060030201604051806060016040529081600082015481526020016001820154815260200160028201548152505081526020019060010190610526565b50505050905090565b60025460009074010000000000000000000000000000000000000000900460ff166105f5576105ef7f0000000000000000000000000000000000000000000000000000000000000000837f000000000000000000000000000000000000000000000000000000000000000061119d565b92915050565b600080600080600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610668573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068c9190611d0b565b9450945050935093508069ffffffffffffffffffff168469ffffffffffffffffffff16146106e6576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81600003610720576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8260000361075a576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e99190611d5b565b6107f490600a611ecd565b6107fe8785611edc565b6108089190611f22565b9450505050505b919050565b61081c61160a565b801561086f5773ffffffffffffffffffffffffffffffffffffffff821661086f576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002805473ffffffffffffffffffffffffffffffffffffffff84167fffffffffffffffffffffff000000000000000000000000000000000000000000909116811774010000000000000000000000000000000000000000841515908102919091179092556040805191825260208201929092527fc839b5877f623b583686377df854b924d71e9243578fb187b95913417b4861fe910160405180910390a15050565b61093560405180606001604052806000815260200160008152602001600081525090565b6000610940426114f2565b905060007f0000000000000000000000000000000000000000000000000000000000000000610970836001611f36565b61097a9190611f4f565b905060018160ff168154811061099257610992611f71565b906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820154815250509250505090565b600181815481106109e057600080fd5b600091825260209091206003909102018054600182015460029092015490925083565b60008060008060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610a76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9a9190611d0b565b9450945050935093506000806000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610b14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b389190611d0b565b9450945050935093508469ffffffffffffffffffff168869ffffffffffffffffffff16141580610b8057508069ffffffffffffffffffff168469ffffffffffffffffffff1614155b15610bb7576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b851580610bc2575081155b15610bf9576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b861580610c04575082155b15610c3b576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610c4d83670de0b6b3a7640000611edc565b8a610c5b89620f4240611edc565b610c659190611edc565b610c6f9190611f22565b9a9950505050505050505050565b6000610c8a826064611edc565b91506000806000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610cfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d219190611d0b565b9450945050935093508069ffffffffffffffffffff168469ffffffffffffffffffff1614610d7b576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81600003610db5576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82600003610def576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b826107fe87670de0b6b3a7640000611edc565b610e0a61160a565b610e14600061168b565b565b60008060008060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610e89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ead9190611d0b565b9450945050935093506000806000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610f27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4b9190611d0b565b9450945050935093508469ffffffffffffffffffff168869ffffffffffffffffffff16141580610f9357508069ffffffffffffffffffff168469ffffffffffffffffffff1614155b15610fca576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b851580610fd5575081155b1561100c576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b861580611017575082155b1561104e576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61105b87620f4240611edc565b8a610c5b85670de0b6b3a7640000611edc565b60008060008060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa1580156110e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111059190611d0b565b9450945050935093506000806000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610b14573d6000803e3d6000fd5b60008061118b8361057f565b90506111968161106e565b9392505050565b6000806111a8610911565b80519091506000906111ba9042611fa0565b90507f0000000000000000000000000000000000000000000000000000000000000000811115611216576040517f2ecfede900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806112427f0000000000000000000000000000000000000000000000000000000000000000611700565b509150915060008673ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff16106112825786611284565b885b90508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036112d5576112c9856020015184868b611924565b95505050505050611196565b6112c9856040015183868b611924565b60008060008060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015611358573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061137c9190611d0b565b9450945050935093506000806000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610f27573d6000803e3d6000fd5b6000806114028361057f565b905061119681610a03565b6000611418426114f2565b9050600060018260ff168154811061143257611432611f71565b60009182526020822060039091020180549092506114509042611fa0565b90507f00000000000000000000000000000000000000000000000000000000000000008111156114ba576000806114a67f0000000000000000000000000000000000000000000000000000000000000000611700565b504286556001860191909155600285015550505b6040514281527f66cbca4f3c64fecf1dcb9ce094abcf7f68c3450a1d4e3a8e917dd621edb4ebe09060200160405180910390a1505050565b60008061151f7f000000000000000000000000000000000000000000000000000000000000000084611f22565b905061119660ff7f00000000000000000000000000000000000000000000000000000000000000001682611fb3565b61155661160a565b73ffffffffffffffffffffffffffffffffffffffff81166115fe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6116078161168b565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610e14576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016115f5565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080600061170d61199d565b90508373ffffffffffffffffffffffffffffffffffffffff16635909c0d56040518163ffffffff1660e01b8152600401602060405180830381865afa15801561175a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177e9190611fc7565b92508373ffffffffffffffffffffffffffffffffffffffff16635a3d54936040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ef9190611fc7565b915060008060008673ffffffffffffffffffffffffffffffffffffffff16630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015611841573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118659190611ffe565b9250925092508363ffffffff168163ffffffff161461191a57600061188a828661204e565b90508063ffffffff1661189d84866119b3565b516118c691907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16611edc565b6118d09088612072565b96508063ffffffff166118e385856119b3565b5161190c91907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16611edc565b6119169087612072565b9550505b5050509193909250565b600080604051806020016040528085888861193f9190611fa0565b6119499190611f22565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169052905061197f6119788285611aab565b5160701c90565b71ffffffffffffffffffffffffffffffffffff169695505050505050565b60006119ae64010000000042611fb3565b905090565b6040805160208101909152600081526000826dffffffffffffffffffffffffffff1611611a3c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4669786564506f696e743a204449565f42595f5a45524f00000000000000000060448201526064016115f5565b604080516020810190915280611a846dffffffffffffffffffffffffffff85167bffffffffffffffffffffffffffff0000000000000000000000000000607088901b16612085565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1690529392505050565b6040805160208101909152600081526000821580611afd575083517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1683611aef8183611edc565b9250611afb9083611f22565b145b611b89576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f4669786564506f696e743a204d554c5449504c49434154494f4e5f4f5645524660448201527f4c4f57000000000000000000000000000000000000000000000000000000000060648201526084016115f5565b60408051602081019091529081529392505050565b6020808252825182820181905260009190848201906040850190845b81811015611bf457611be18385518051825260208082015190830152604090810151910152565b9284019260609290920191600101611bba565b50909695505050505050565b600060208284031215611c1257600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461080f57600080fd5b60008060408385031215611c5057600080fd5b611c5983611c19565b915060208301358015158114611c6e57600080fd5b809150509250929050565b815181526020808301519082015260408083015190820152606081016105ef565b600080600060608486031215611caf57600080fd5b611cb884611c19565b925060208401359150611ccd60408501611c19565b90509250925092565b600060208284031215611ce857600080fd5b61119682611c19565b805169ffffffffffffffffffff8116811461080f57600080fd5b600080600080600060a08688031215611d2357600080fd5b611d2c86611cf1565b9450602086015193506040860151925060608601519150611d4f60808701611cf1565b90509295509295909350565b600060208284031215611d6d57600080fd5b815160ff8116811461119657600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600181815b80851115611e0657817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115611dec57611dec611d7e565b80851615611df957918102915b93841c9390800290611db2565b509250929050565b600082611e1d575060016105ef565b81611e2a575060006105ef565b8160018114611e405760028114611e4a57611e66565b60019150506105ef565b60ff841115611e5b57611e5b611d7e565b50506001821b6105ef565b5060208310610133831016604e8410600b8410161715611e89575081810a6105ef565b611e938383611dad565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115611ec557611ec5611d7e565b029392505050565b600061119660ff841683611e0e565b80820281158282048414176105ef576105ef611d7e565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082611f3157611f31611ef3565b500490565b60ff81811683821601908111156105ef576105ef611d7e565b600060ff831680611f6257611f62611ef3565b8060ff84160691505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b818103818111156105ef576105ef611d7e565b600082611fc257611fc2611ef3565b500690565b600060208284031215611fd957600080fd5b5051919050565b80516dffffffffffffffffffffffffffff8116811461080f57600080fd5b60008060006060848603121561201357600080fd5b61201c84611fe0565b925061202a60208501611fe0565b9150604084015163ffffffff8116811461204357600080fd5b809150509250925092565b63ffffffff82811682821603908082111561206b5761206b611d7e565b5092915050565b808201808211156105ef576105ef611d7e565b60007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff808416806120b4576120b4611ef3565b9216919091049291505056fea164736f6c6343000817000a000000000000000000000000a99a468c39d46eae2c4e12ffb8a8bb4faefc5f4d000000000000000000000000ea3eed8616877f5d3c4aebf5a799f2e8d6de9a5e000000000000000000000000fff9976782d46cc05630d1f6ebab18b2324d6b14000000000000000000000000694aa1769357215de4fac081bf1f309adc325306000000000000000000000000a2f78ab2355fe2f984d808b5cee7fd0a93d5270e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000151800000000000000000000000000000000000000000000000000000000000000004
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101c45760003560e01c80637c9c2f8a116100f9578063907f238311610097578063dbaad32f11610071578063dbaad32f1461048e578063e4463eb2146104a1578063f2fde38b146104c8578063fc0c546a146104db57600080fd5b8063907f23831461044c578063a2e620451461045f578063a8aa1b311461046757600080fd5b80638a14117a116100d35780638a14117a146103e15780638c86f1e4146104085780638da5cb5b1461041b5780638e2141e61461043957600080fd5b80637c9c2f8a146103a8578063831cefa6146103bb57806388882205146103ce57600080fd5b80633be0dcb81161016657806361150aae1161014057806361150aae146103325780636a0b275414610359578063715018a614610380578063741bef1a1461038857600080fd5b80633be0dcb8146102bf5780633fc8cef3146102d2578063556f0dc7146102f957600080fd5b8063255b2d71116101a2578063255b2d711461021d5780632eb59ece14610269578063363ec28d1461027e57806339606a5c146102ac57600080fd5b806302b231d0146101c95780630441b220146101e7578063243948cf14610208575b600080fd5b6101d1610502565b6040516101de9190611b9e565b60405180910390f35b6101fa6101f5366004611c00565b61057f565b6040519081526020016101de565b61021b610216366004611c3d565b610814565b005b6102447f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101de565b610271610911565b6040516101de9190611c79565b61029161028c366004611c00565b6109d0565b604080519384526020840192909252908201526060016101de565b6101fa6102ba366004611c00565b610a03565b6101fa6102cd366004611c00565b610c7d565b6102447f000000000000000000000000fff9976782d46cc05630d1f6ebab18b2324d6b1481565b6103207f000000000000000000000000000000000000000000000000000000000000000481565b60405160ff90911681526020016101de565b6102447f000000000000000000000000694aa1769357215de4fac081bf1f309adc32530681565b6102447f000000000000000000000000a2f78ab2355fe2f984d808b5cee7fd0a93d5270e81565b61021b610e02565b6002546102449073ffffffffffffffffffffffffffffffffffffffff1681565b6101fa6103b6366004611c00565b610e16565b6101fa6103c9366004611c00565b61106e565b6101fa6103dc366004611c00565b61117f565b6101fa7f000000000000000000000000000000000000000000000000000000000001518081565b6101fa610416366004611c9a565b61119d565b60005473ffffffffffffffffffffffffffffffffffffffff16610244565b6101fa610447366004611c00565b6112e5565b6101fa61045a366004611c00565b6113f6565b61021b61140d565b6102447f000000000000000000000000a99a468c39d46eae2c4e12ffb8a8bb4faefc5f4d81565b61032061049c366004611c00565b6114f2565b6101fa7f000000000000000000000000000000000000000000000000000000000000546081565b61021b6104d6366004611cd6565b61154e565b6102447f000000000000000000000000ea3eed8616877f5d3c4aebf5a799f2e8d6de9a5e81565b60606001805480602002602001604051908101604052809291908181526020016000905b828210156105765783829060005260206000209060030201604051806060016040529081600082015481526020016001820154815260200160028201548152505081526020019060010190610526565b50505050905090565b60025460009074010000000000000000000000000000000000000000900460ff166105f5576105ef7f000000000000000000000000ea3eed8616877f5d3c4aebf5a799f2e8d6de9a5e837f000000000000000000000000fff9976782d46cc05630d1f6ebab18b2324d6b1461119d565b92915050565b600080600080600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610668573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068c9190611d0b565b9450945050935093508069ffffffffffffffffffff168469ffffffffffffffffffff16146106e6576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81600003610720576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8260000361075a576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000ea3eed8616877f5d3c4aebf5a799f2e8d6de9a5e73ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e99190611d5b565b6107f490600a611ecd565b6107fe8785611edc565b6108089190611f22565b9450505050505b919050565b61081c61160a565b801561086f5773ffffffffffffffffffffffffffffffffffffffff821661086f576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002805473ffffffffffffffffffffffffffffffffffffffff84167fffffffffffffffffffffff000000000000000000000000000000000000000000909116811774010000000000000000000000000000000000000000841515908102919091179092556040805191825260208201929092527fc839b5877f623b583686377df854b924d71e9243578fb187b95913417b4861fe910160405180910390a15050565b61093560405180606001604052806000815260200160008152602001600081525090565b6000610940426114f2565b905060007f0000000000000000000000000000000000000000000000000000000000000004610970836001611f36565b61097a9190611f4f565b905060018160ff168154811061099257610992611f71565b906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820154815250509250505090565b600181815481106109e057600080fd5b600091825260209091206003909102018054600182015460029092015490925083565b60008060008060007f000000000000000000000000694aa1769357215de4fac081bf1f309adc32530673ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610a76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9a9190611d0b565b9450945050935093506000806000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610b14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b389190611d0b565b9450945050935093508469ffffffffffffffffffff168869ffffffffffffffffffff16141580610b8057508069ffffffffffffffffffff168469ffffffffffffffffffff1614155b15610bb7576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b851580610bc2575081155b15610bf9576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b861580610c04575082155b15610c3b576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610c4d83670de0b6b3a7640000611edc565b8a610c5b89620f4240611edc565b610c659190611edc565b610c6f9190611f22565b9a9950505050505050505050565b6000610c8a826064611edc565b91506000806000807f000000000000000000000000694aa1769357215de4fac081bf1f309adc32530673ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610cfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d219190611d0b565b9450945050935093508069ffffffffffffffffffff168469ffffffffffffffffffff1614610d7b576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81600003610db5576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82600003610def576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b826107fe87670de0b6b3a7640000611edc565b610e0a61160a565b610e14600061168b565b565b60008060008060007f000000000000000000000000694aa1769357215de4fac081bf1f309adc32530673ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610e89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ead9190611d0b565b9450945050935093506000806000807f000000000000000000000000a2f78ab2355fe2f984d808b5cee7fd0a93d5270e73ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610f27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4b9190611d0b565b9450945050935093508469ffffffffffffffffffff168869ffffffffffffffffffff16141580610f9357508069ffffffffffffffffffff168469ffffffffffffffffffff1614155b15610fca576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b851580610fd5575081155b1561100c576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b861580611017575082155b1561104e576040517f1f4bcb2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61105b87620f4240611edc565b8a610c5b85670de0b6b3a7640000611edc565b60008060008060007f000000000000000000000000694aa1769357215de4fac081bf1f309adc32530673ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa1580156110e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111059190611d0b565b9450945050935093506000806000807f000000000000000000000000a2f78ab2355fe2f984d808b5cee7fd0a93d5270e73ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610b14573d6000803e3d6000fd5b60008061118b8361057f565b90506111968161106e565b9392505050565b6000806111a8610911565b80519091506000906111ba9042611fa0565b90507f0000000000000000000000000000000000000000000000000000000000015180811115611216576040517f2ecfede900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806112427f000000000000000000000000a99a468c39d46eae2c4e12ffb8a8bb4faefc5f4d611700565b509150915060008673ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff16106112825786611284565b885b90508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036112d5576112c9856020015184868b611924565b95505050505050611196565b6112c9856040015183868b611924565b60008060008060007f000000000000000000000000694aa1769357215de4fac081bf1f309adc32530673ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015611358573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061137c9190611d0b565b9450945050935093506000806000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610f27573d6000803e3d6000fd5b6000806114028361057f565b905061119681610a03565b6000611418426114f2565b9050600060018260ff168154811061143257611432611f71565b60009182526020822060039091020180549092506114509042611fa0565b90507f00000000000000000000000000000000000000000000000000000000000054608111156114ba576000806114a67f000000000000000000000000a99a468c39d46eae2c4e12ffb8a8bb4faefc5f4d611700565b504286556001860191909155600285015550505b6040514281527f66cbca4f3c64fecf1dcb9ce094abcf7f68c3450a1d4e3a8e917dd621edb4ebe09060200160405180910390a1505050565b60008061151f7f000000000000000000000000000000000000000000000000000000000000546084611f22565b905061119660ff7f00000000000000000000000000000000000000000000000000000000000000041682611fb3565b61155661160a565b73ffffffffffffffffffffffffffffffffffffffff81166115fe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6116078161168b565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610e14576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016115f5565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080600061170d61199d565b90508373ffffffffffffffffffffffffffffffffffffffff16635909c0d56040518163ffffffff1660e01b8152600401602060405180830381865afa15801561175a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177e9190611fc7565b92508373ffffffffffffffffffffffffffffffffffffffff16635a3d54936040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ef9190611fc7565b915060008060008673ffffffffffffffffffffffffffffffffffffffff16630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015611841573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118659190611ffe565b9250925092508363ffffffff168163ffffffff161461191a57600061188a828661204e565b90508063ffffffff1661189d84866119b3565b516118c691907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16611edc565b6118d09088612072565b96508063ffffffff166118e385856119b3565b5161190c91907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16611edc565b6119169087612072565b9550505b5050509193909250565b600080604051806020016040528085888861193f9190611fa0565b6119499190611f22565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169052905061197f6119788285611aab565b5160701c90565b71ffffffffffffffffffffffffffffffffffff169695505050505050565b60006119ae64010000000042611fb3565b905090565b6040805160208101909152600081526000826dffffffffffffffffffffffffffff1611611a3c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4669786564506f696e743a204449565f42595f5a45524f00000000000000000060448201526064016115f5565b604080516020810190915280611a846dffffffffffffffffffffffffffff85167bffffffffffffffffffffffffffff0000000000000000000000000000607088901b16612085565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1690529392505050565b6040805160208101909152600081526000821580611afd575083517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1683611aef8183611edc565b9250611afb9083611f22565b145b611b89576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f4669786564506f696e743a204d554c5449504c49434154494f4e5f4f5645524660448201527f4c4f57000000000000000000000000000000000000000000000000000000000060648201526084016115f5565b60408051602081019091529081529392505050565b6020808252825182820181905260009190848201906040850190845b81811015611bf457611be18385518051825260208082015190830152604090810151910152565b9284019260609290920191600101611bba565b50909695505050505050565b600060208284031215611c1257600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461080f57600080fd5b60008060408385031215611c5057600080fd5b611c5983611c19565b915060208301358015158114611c6e57600080fd5b809150509250929050565b815181526020808301519082015260408083015190820152606081016105ef565b600080600060608486031215611caf57600080fd5b611cb884611c19565b925060208401359150611ccd60408501611c19565b90509250925092565b600060208284031215611ce857600080fd5b61119682611c19565b805169ffffffffffffffffffff8116811461080f57600080fd5b600080600080600060a08688031215611d2357600080fd5b611d2c86611cf1565b9450602086015193506040860151925060608601519150611d4f60808701611cf1565b90509295509295909350565b600060208284031215611d6d57600080fd5b815160ff8116811461119657600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600181815b80851115611e0657817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115611dec57611dec611d7e565b80851615611df957918102915b93841c9390800290611db2565b509250929050565b600082611e1d575060016105ef565b81611e2a575060006105ef565b8160018114611e405760028114611e4a57611e66565b60019150506105ef565b60ff841115611e5b57611e5b611d7e565b50506001821b6105ef565b5060208310610133831016604e8410600b8410161715611e89575081810a6105ef565b611e938383611dad565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115611ec557611ec5611d7e565b029392505050565b600061119660ff841683611e0e565b80820281158282048414176105ef576105ef611d7e565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082611f3157611f31611ef3565b500490565b60ff81811683821601908111156105ef576105ef611d7e565b600060ff831680611f6257611f62611ef3565b8060ff84160691505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b818103818111156105ef576105ef611d7e565b600082611fc257611fc2611ef3565b500690565b600060208284031215611fd957600080fd5b5051919050565b80516dffffffffffffffffffffffffffff8116811461080f57600080fd5b60008060006060848603121561201357600080fd5b61201c84611fe0565b925061202a60208501611fe0565b9150604084015163ffffffff8116811461204357600080fd5b809150509250925092565b63ffffffff82811682821603908082111561206b5761206b611d7e565b5092915050565b808201808211156105ef576105ef611d7e565b60007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff808416806120b4576120b4611ef3565b9216919091049291505056fea164736f6c6343000817000a
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000a99a468c39d46eae2c4e12ffb8a8bb4faefc5f4d000000000000000000000000ea3eed8616877f5d3c4aebf5a799f2e8d6de9a5e000000000000000000000000fff9976782d46cc05630d1f6ebab18b2324d6b14000000000000000000000000694aa1769357215de4fac081bf1f309adc325306000000000000000000000000a2f78ab2355fe2f984d808b5cee7fd0a93d5270e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000151800000000000000000000000000000000000000000000000000000000000000004
-----Decoded View---------------
Arg [0] : _pair (address): 0xa99A468c39D46EaE2c4E12ffb8a8BB4FaefC5F4D
Arg [1] : _token (address): 0xea3eed8616877F5d3c4aEbf5A799F2e8D6DE9A5E
Arg [2] : _weth (address): 0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14
Arg [3] : _ethusd (address): 0x694AA1769357215DE4FAC081bf1f309aDC325306
Arg [4] : _usdcusd (address): 0xA2F78ab2355fe2f984D808B5CeE7FD0A93D5270E
Arg [5] : _usdtusd (address): 0x0000000000000000000000000000000000000000
Arg [6] : _windowSize (uint256): 86400
Arg [7] : _granularity (uint8): 4
-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 000000000000000000000000a99a468c39d46eae2c4e12ffb8a8bb4faefc5f4d
Arg [1] : 000000000000000000000000ea3eed8616877f5d3c4aebf5a799f2e8d6de9a5e
Arg [2] : 000000000000000000000000fff9976782d46cc05630d1f6ebab18b2324d6b14
Arg [3] : 000000000000000000000000694aa1769357215de4fac081bf1f309adc325306
Arg [4] : 000000000000000000000000a2f78ab2355fe2f984d808b5cee7fd0a93d5270e
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [6] : 0000000000000000000000000000000000000000000000000000000000015180
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000004
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.