1/5
This will be the last video about math for TWAP in Uniswap V2. Here, we want to explain about a misconception that if you know the TWAP of token X, then you can get the TWAP of token Y by doing 1 over the TWAP of token X. This is not true, and in this video, we want to quickly explain why this is not true. First of all, if we look at the spot price of token X in terms of token Y in Uniswap V2, we can write this as Y divided by X. And if we put this Y divided by X, we get X divided by Y, and this is spot price of token Y in terms of token X. In other words, if we know the spot price of token X in terms of token Y, let's call this P, then if we take 1 over P, then we get the spot price of token Y in terms of token X. However, we cannot apply this same logic to say that the TWAP of token Y is equal to 1 over the TWAP of token X. And here's why. As we discussed in the previous videos, the TWAP of token X from time tk to tn is given by this equation. ```javascript TWAP of X from tk to tn = Σ(i=k to n+1) Δt_i * p_i / (tn - tk) ``` The equation for the TWAP of token Y is almost similar to this equation. The only difference is that we need to take the spot price of token Y in terms of token X. This is given by 1 over P of Y. ```javascript TWAP of Y from tk to tn = Σ(i=k to n+1) Δt_i * (1 / p_i) / (tn - tk) ``` And it's hard to imagine that taking 1 over this equation will be equal to this equation. If you're curious, you can do the math and check that taking 1 over this equation will not be equal to this equation.
A simple explanation of why you cannot simply take the inverse of the TWAP of a token to get the TWAP of another token. The video covers the key concepts of spot price and TWAP, providing an illustrative example to show that taking the reciprocal of the TWAP does not equal the TWAP of the other token.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
How to use Uniswap v2 dex and contracts
Interacting with the Uniswap v2 router and factory
How to create Uniswap v2 liquidity pools
How to add liquidity to Uniswap v2 pools
Swaps, flash swaps, flash swap arbitrage, and time-weighted average price (TWAP)
Security researcher
$49,999 - $120,000 (avg. salary)
Smart Contract Auditor
$100,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 October 9, 2024
Solidity Developer
Uniswap V2Duration: 14min
Duration: 1h 20min
Duration: 10min
Duration: 54min
Duration: 25min
Duration: 26min
Duration: 1h 03min
Duration: 59min
Course Overview
About the course
How to use Uniswap v2 dex and contracts
Interacting with the Uniswap v2 router and factory
How to create Uniswap v2 liquidity pools
How to add liquidity to Uniswap v2 pools
Swaps, flash swaps, flash swap arbitrage, and time-weighted average price (TWAP)
Security researcher
$49,999 - $120,000 (avg. salary)
Smart Contract Auditor
$100,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 October 9, 2024
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar