1/5
### Calculating Price Using Square Root Price X96 In this lesson, we will explore how to use Square Root Price X96 to calculate the price P. Square root price X96 is defined as: ```javascript sqrtPriceX96 = sqrt(P) * Q96 ``` Where Q96 is defined as: ```javascript Q96 = 2^96 ``` To calculate the price P, when we know what Square root price X96 is, we first take this Square root price X96 and realize that sqrt(P) is multiplied by a factor of Q96, so we'll first divide this sqrtPriceX96 by Q96. ```javascript P = sqrtPriceX96 / Q96 ``` When we divide this, we're left with sqrt(P), so to get back P, we square this and we get back P. ```javascript P = (sqrtPriceX96 / Q96)^2 ``` This is how we calculate the price P, when we know the value of Square root price X96.
A quick guide to calculate the price of a token pair on Uniswap V3. This video explains what the variable sqrtPriceX96 represents and how it's used to calculate the price, as well as how to leverage this variable in your code to retrieve the price.
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