1/5
# Calculating Tick From Square Root Price X96 In this lesson, we will be calculating the tick, given the square root price X96, using Python code. We will be using the USDC / WETH 0.05% pool. First, we will define a constant Q96: ```javascript Q96 = 2 ** 96 ``` Next, we will copy and paste the square root price X96 and the tick which we got from the contract address: ```javascript sqrt_p_x96 = 1386025840740905446350612632896904 tick = 195402 ``` Next, we will calculate the tick from the square root price X96, and double check to make sure it matches the tick from the contract address. We will define variable t as: ```javascript t = 2 * math.log(sqrt_p_x96 / Q96) / math.log(1.0001) ``` And then print out variable t: ```javascript print(t) ``` The result we calculated was 195402.155, and the actual tick was 195402, so we know we have successfully calculated the tick from the square root price X96.
A technical tutorial on how to calculate the tick given the sqrtPriceX96 - How to calculate the tick, given that we know the sqrtPriceX96, using the USDC WETH 0.05% pool.
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