github.com/status-im/status-go@v1.1.0/contracts/uniswapV3/interfaces/pool/IUniswapV3PoolState.sol (about) 1 // SPDX-License-Identifier: GPL-2.0-or-later 2 pragma solidity >=0.5.0; 3 4 /// @title Pool state that can change 5 /// @notice These methods compose the pool's state, and can change with any frequency including multiple times 6 /// per transaction 7 interface IUniswapV3PoolState { 8 /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas 9 /// when accessed externally. 10 /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value 11 /// tick The current tick of the pool, i.e. according to the last tick transition that was run. 12 /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick 13 /// boundary. 14 /// observationIndex The index of the last oracle observation that was written, 15 /// observationCardinality The current maximum number of observations stored in the pool, 16 /// observationCardinalityNext The next maximum number of observations, to be updated when the observation. 17 /// feeProtocol The protocol fee for both tokens of the pool. 18 /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0 19 /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee. 20 /// unlocked Whether the pool is currently locked to reentrancy 21 function slot0() 22 external 23 view 24 returns ( 25 uint160 sqrtPriceX96, 26 int24 tick, 27 uint16 observationIndex, 28 uint16 observationCardinality, 29 uint16 observationCardinalityNext, 30 uint8 feeProtocol, 31 bool unlocked 32 ); 33 34 /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool 35 /// @dev This value can overflow the uint256 36 function feeGrowthGlobal0X128() external view returns (uint256); 37 38 /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool 39 /// @dev This value can overflow the uint256 40 function feeGrowthGlobal1X128() external view returns (uint256); 41 42 /// @notice The amounts of token0 and token1 that are owed to the protocol 43 /// @dev Protocol fees will never exceed uint128 max in either token 44 function protocolFees() external view returns (uint128 token0, uint128 token1); 45 46 /// @notice The currently in range liquidity available to the pool 47 /// @dev This value has no relationship to the total liquidity across all ticks 48 function liquidity() external view returns (uint128); 49 50 /// @notice Look up information about a specific tick in the pool 51 /// @param tick The tick to look up 52 /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or 53 /// tick upper, 54 /// liquidityNet how much liquidity changes when the pool price crosses the tick, 55 /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0, 56 /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1, 57 /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick 58 /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick, 59 /// secondsOutside the seconds spent on the other side of the tick from the current tick, 60 /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false. 61 /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0. 62 /// In addition, these values are only relative and must be used only in comparison to previous snapshots for 63 /// a specific position. 64 function ticks(int24 tick) 65 external 66 view 67 returns ( 68 uint128 liquidityGross, 69 int128 liquidityNet, 70 uint256 feeGrowthOutside0X128, 71 uint256 feeGrowthOutside1X128, 72 int56 tickCumulativeOutside, 73 uint160 secondsPerLiquidityOutsideX128, 74 uint32 secondsOutside, 75 bool initialized 76 ); 77 78 /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information 79 function tickBitmap(int16 wordPosition) external view returns (uint256); 80 81 /// @notice Returns the information about a position by the position's key 82 /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper 83 /// @return _liquidity The amount of liquidity in the position, 84 /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, 85 /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, 86 /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, 87 /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke 88 function positions(bytes32 key) 89 external 90 view 91 returns ( 92 uint128 _liquidity, 93 uint256 feeGrowthInside0LastX128, 94 uint256 feeGrowthInside1LastX128, 95 uint128 tokensOwed0, 96 uint128 tokensOwed1 97 ); 98 99 /// @notice Returns data about a specific observation index 100 /// @param index The element of the observations array to fetch 101 /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time 102 /// ago, rather than at a specific index in the array. 103 /// @return blockTimestamp The timestamp of the observation, 104 /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, 105 /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp, 106 /// Returns initialized whether the observation has been initialized and the values are safe to use 107 function observations(uint256 index) 108 external 109 view 110 returns ( 111 uint32 blockTimestamp, 112 int56 tickCumulative, 113 uint160 secondsPerLiquidityCumulativeX128, 114 bool initialized 115 ); 116 }