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
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; | |
import "@uniswap/v3-core/contracts/libraries/TickMath.sol"; | |
import "@uniswap/v3-core/contracts/libraries/FixedPoint96.sol"; | |
import "@uniswap/v3-core/contracts/libraries/FullMath.sol"; | |
contract TwapGetter { | |
function getSqrtTwapX96(address uniswapV3Pool, uint32 twapInterval) public view returns (uint160 sqrtPriceX96) { | |
if (twapInterval == 0) { | |
// return the current price if twapInterval == 0 | |
(sqrtPriceX96, , , , , , ) = IUniswapV3Pool(uniswapV3Pool).slot0(); |
OlderNewer