# How to get Uniswap V3 price range by given tickUpper and tickLower?

For example, there is an add uniswap v3 pool operation

The tickerUpper is `-115000`, the tickLower is `-138000`

What is the price range?

In Uniswap V3, the price range for a given tick range can be determined using the formula `P = 1.0001^T`, where P represents the price ratio of token1 to token0, denoted as token1/token0, which aligns with the representation used for `sqrtPriceX96` in the `UniswapV3Pool`, and `T` is the tick value. This formula was also correctly pointed out by @quentinadam

For the specific tick range in your question, `[-138_000, -115_000]`, the calculation can be performed as follows:

• For `tickLower` (-138,000), the price is calculated as `P_{lower} = 1.0001^{-138,000} = 1.016332451797928e-06`
• For `tickUpper` (-115,000), the price is calculated as `P_{upper} = 1.0001^{-115,000} = 1.0135919688900418e-05`

These calculations yield the price range in terms of `token1/token0`

If you'd like to get the price in the context of solidity you can use the OracleLibrary.getQuoteAtTick function from Uniswap's `v3-periphery`. The example contract below implements a `getPrice(int24 tick)` function that returns the price for a given tick with 18 decimal precision:

``````import "@uniswap/v3-periphery/contracts/libraries/OracleLibrary.sol";

contract Price {
function getPrice(int24 tick) external pure returns (uint256 priceU18) {
priceU18 = OracleLibrary.getQuoteAtTick(
tick,
1e18, // fixed point to 18 decimals
address(0), // since we want the price in terms of token1/token0
);
}
}
``````

Using this contract, the prices for the ticks `-138_000` and `-115_000` as returned by `getPrice` was found to be `1016332451796` and `10135919688887` respectively, which aligns very closely with the previously calculated values after decimal scaling.

You need to take 1.0001 to the power of the tick to get the price.

For instance, for the tick -115000, the price would be 1.0001^(-115000) = 0.0000101359.

Please note that you need to take into account the number of decimals of each token, because the Uniswap price is expressed in units of token.

For instance, if the pool was WETH/USDC, a price of USDC 2000 for WETH would actually be expressed as 2000 * 1e-18 * 1e6 = 0.000000002, because WETH has 18 decimals and USDC has 6 decimals.