ExampleSlidingWindowOracle
State Variables
factory
address public immutable factory;
windowSize
uint256 public immutable windowSize;
granularity
uint8 public immutable granularity;
periodSize
uint256 public immutable periodSize;
pairObservations
mapping(address => Observation[]) public pairObservations;
Functions
constructor
constructor(address factory_, uint256 windowSize_, uint8 granularity_);
observationIndexOf
function observationIndexOf(uint256 timestamp) public view returns (uint8 index);
getFirstObservationInWindow
function getFirstObservationInWindow(address pair) private view returns (Observation storage firstObservation);
update
function update(address tokenA, address tokenB) external;
computeAmountOut
function computeAmountOut(
uint256 priceCumulativeStart,
uint256 priceCumulativeEnd,
uint256 timeElapsed,
uint256 amountIn
) private pure returns (uint256 amountOut);
consult
function consult(address tokenIn, uint256 amountIn, address tokenOut) external view returns (uint256 amountOut);
Structs
Observation
struct Observation {
uint256 timestamp;
uint256 price0Cumulative;
uint256 price1Cumulative;
}