-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
4,174 additions
and
4,706 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity >=0.5.0; | ||
|
||
/// @title Interface defining the oracle contract used by Panoptic, which may be a Uniswap V3 pool or custom implementation | ||
/// @author Axicon Labs Inc, credit to Uniswap Labs [https://github.com/Uniswap/v3-core](https://github.com/Uniswap/v3-core) under GPL-2.0 license | ||
/// @notice This interface defines the set of functions called by Panoptic on its external oracle contract. | ||
/// @dev The interface is compatible with Uniswap V3 pools, but can also be implemented by a custom oracle contract. | ||
interface IV3CompatibleOracle { | ||
/// @notice The 0th storage slot in the oracle stores many values, and is exposed as a single method to save gas | ||
/// when accessed externally. | ||
/// @return sqrtPriceX96 The current price of the oracle as a sqrt(token1/token0) Q64.96 value | ||
/// @return tick The current tick of the oracle, i.e. according to the last tick transition that was run. | ||
/// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick | ||
/// boundary | ||
/// @return observationIndex The index of the last oracle observation that was written | ||
/// @return observationCardinality The current maximum number of observations stored in the oracle | ||
function slot0() | ||
external | ||
view | ||
returns ( | ||
uint160 sqrtPriceX96, | ||
int24 tick, | ||
uint16 observationIndex, | ||
uint16 observationCardinality, | ||
uint16, | ||
uint8, | ||
bool | ||
); | ||
|
||
/// @notice Returns data about a specific observation index | ||
/// @param index The element of the observations array to fetch | ||
/// @return blockTimestamp The timestamp of the observation | ||
/// @return tickCumulative The tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp | ||
/// @return secondsPerLiquidityCumulativeX128 The seconds per in range liquidity for the life of the pool as of the observation timestamp | ||
/// @return initialized Whether the observation has been initialized and the values are safe to use | ||
function observations( | ||
uint256 index | ||
) | ||
external | ||
view | ||
returns ( | ||
uint32 blockTimestamp, | ||
int56 tickCumulative, | ||
uint160 secondsPerLiquidityCumulativeX128, | ||
bool initialized | ||
); | ||
|
||
/// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp | ||
/// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing | ||
/// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, | ||
/// you must call it with secondsAgos = [3600, 0]. | ||
/// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in | ||
/// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio. | ||
/// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned | ||
/// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp | ||
/// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block | ||
/// timestamp | ||
function observe( | ||
uint32[] calldata secondsAgos | ||
) | ||
external | ||
view | ||
returns ( | ||
int56[] memory tickCumulatives, | ||
uint160[] memory secondsPerLiquidityCumulativeX128s | ||
); | ||
|
||
/// @notice Increase the maximum number of price and liquidity observations that this oracle will store | ||
/// @param observationCardinalityNext The desired minimum number of observations for the oracle to store | ||
function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.