1/5
## Getting the Spot Price from Uniswap V3: Slot0 To get the spot price from Uniswap V3, we need to look at the contract called `UniswapV3Pool`. Inside this contract there is a struct called `Slot0` that stores the data that we need, and it is stored as a state variable. Inside the struct there are a couple of data points we need to calculate the spot price: `sqrtPriceX96` and `tick`. Knowing either one of these pieces of data, we'll be able to calculate the spot price. The struct is called `Slot0` because all of the data contained goes into the zeroeth slot in the storage. In EVM when you declare a state variable, these state variables are stored in different slots. Each slot can store up to 32 bytes of data. In this case, all of the data for `Slot0` fits inside of 32 bytes and is stored in the zeroeth slot of storage. The state variable is named `slot0` ```javascript struct Slot0 { uint160 sqrtPriceX96; int24 tick; uint16 observationIndex; uint16 observationCardinality; uint16 observationCardinalityNext; uint8 feeProtocol; bool unlocked; } Slot0 public override slot0; ``` The main reason why the data is stored in `slot0` is to save gas. We will now take a look at a real world example of a square root price x96 and tick. We are going to look at the Uniswap V3 pool contract for `WETH`/`USDT`. Inside etherscan we will click on the read contracts tab, scroll down and find the function `slot0`. After clicking on this function, then clicking on `query`, we see that the tick is `-195301` and the square root price x96 is `4551852809367933182694918`. In the following videos, we'll explain how to use the `tick` and the `sqrtPriceX96` to calculate the price.
A basic explanation of Uniswap V3 Pool Slot0 and how it is used. This lesson covers the Slot0 data structure used within Uniswap V3 and how the data is used to calculate spot price. It also covers a quick overview of how the Slot0 struct is named and where the data is stored.
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