1/5
### Conversion to Tick Another useful math equation to keep in the back of our heads is the conversion between square root price x 96 and tick. The price ‘P’ is defined to be 1.0001 raised to the tick, which can also be written as: ``` P = 1.0001^tick ``` We also saw that given the square root price x 96 we can calculate the price by using this equation: ``` P = (sqrtPriceX96 / Q96)^2 ``` Now, we want to explain, given that we know the square root price x 96 how do we calculate the tick? This math is used inside of the smart contract for Uniswap V3 during a swap to calculate the current tick given the square root price x 96. So to calculate the tick given that we know the square root price x 96, we'll first take the log of both sides. So, we'll copy the equation and paste it here: Taking the log on both sides of the equation: ``` log(1.0001^tick) = log((sqrtPriceX96 / Q96)^2) ``` On the left side the tick comes out: ``` tick log(1.0001) = log((sqrtPriceX96 / Q96)^2) ``` On the right side the 2 comes out: ``` tick log(1.0001) = 2 log(sqrtPriceX96 / Q96) ``` Next we’ll divide both sides of the equation by log of 1.0001. Dividing the left side by log of 1.0001 results in 1: ``` tick = 2 log(sqrtPriceX96 / Q96) / log(1.0001) ``` And now we have the equation for the tick. You don’t have to remember this equation, but if you need to find the tick and given that you know the square root price x 96 you can use this equation to calculate the tick.
A simple math explanation to calculate Tick given the sqrtPriceX96 - This lesson uses basic math and logarithms to explain how to calculate the current tick given the square root price x 96. The explanation focuses on the logic of the formula.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Concentrated liquidity and derive its equations
Uniswap V3 math
How to calculate the spot price of tokens
Single and multi position swapping
Factory contract architecture
How to calculate liquidity requirements
Uniswap V3 fee algorithm
Flash loans
TWAP price oracle
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on May 15, 2025
DeFi Developer
Uniswap V3Duration: 3min
Duration: 35min
Duration: 25min
Duration: 22min
Duration: 1h 43min
Duration: 11min
Duration: 1h 03min
Duration: 12min
Duration: 51min
Duration: 41min
Duration: 10min
Duration: 7min
Course Overview
About the course
Concentrated liquidity and derive its equations
Uniswap V3 math
How to calculate the spot price of tokens
Single and multi position swapping
Factory contract architecture
How to calculate liquidity requirements
Uniswap V3 fee algorithm
Flash loans
TWAP price oracle
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on May 15, 2025