Twap Math 4

A comprehensive guide to Uniswap V2 TWAP, or time-weighted average price. The lesson covers the formulas used to calculate the TWAP, how to calculate the TWAP from a previous time to the current time, and an example of how to calculate the TWAP.

Solidity Developer

Uniswap V2

1. Twap Spot Price Oracle
A detailed explanation of the dangers of using Uniswap V2 spot price as a price oracle. This lesson covers how an attacker can manipulate the price of a token on Uniswap to exploit a lending protocol that relies on Uniswap’s spot price for collateral valuation. You’ll see a step-by-step breakdown of how an attacker can manipulate the price of a token to their advantage. Duration: 5min
2. Twap Math 1
An introductory explanation of time weighted average price (TWAP) for Uniswap V2 - This lesson covers what TWAP is, what it means to take the TWAP of a Uniswap V2 pool over a particular time period, and how to calculate it. Duration: 9min
3. Twap Math 2
A simple guide to calculating TWAP (Time-weighted average price) using cumulative price. This lesson demonstrates how to calculate the TWAP from time tk to tn using cumulative prices. It is shown how to calculate the cumulative price and how to use it in the TWAP equation. Duration: 5min
4. Twap Math 3
A practical example of calculating the Time Weighted Average Price (TWAP). This lesson covers the TWAP equation and how to apply it to a sample set of token prices. Duration: 7min
5. Twap Math 4
A comprehensive guide to Uniswap V2 TWAP, or time-weighted average price. The lesson covers the formulas used to calculate the TWAP, how to calculate the TWAP from a previous time to the current time, and an example of how to calculate the TWAP. Duration: 5min
6. Twap Math 5
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. Duration: 2min
7. Twap Code Walk
A technical walkthrough of the Uniswap V2 code for TWAP - The video lesson walks through the TWAP implementation of the Uniswap V2 code, including an explanation of how the code calculates TWAP and why overflow in the calculations is considered desired. Duration: 8min
8. Twap Ex
A detailed guide to creating a TWAP price oracle using Uniswap V2. The lesson goes through the process of creating a contract that calculates the time-weighted average price of a pair of tokens, building on the example from the Uniswap V2 repository. The tutorial includes information on using fixed point libraries and how to create functions that calculate TWAP prices and determine the amount of one token for an equivalent amount of another. Duration: 13min
9. Twap Ex Sol
A complete guide to solving UniSwap V2 TWAP exercise - The lesson guides you through a practical implementation of calculating time-weighted average prices (TWAP) in UniSwap V2, covering the intricacies of using Fixed Point library for precise calculations and the logic behind the code. Duration: 9min

Course Overview

About the course

What you'll learn

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)

Course Description

Who is this course for?

  • Advanced smart contract engineers
  • Web3 developers
  • Smart Contract Security researchers

Potential Careers

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)

Meet your instructors

Tasuku Nakamura

Tasuku Nakamura

Founder at smartcontract.engineer

Smart contract engineer and educator.

Last updated on October 9, 2024

Testimonials

Students Reviews

Read what our students have to say about this course.

Chainlink

Chainlink

Chainlink

Gustavo Gonzalez

Gustavo Gonzalez

Solutions Engineer at OpenZeppelin

Francesco Andreoli

Francesco Andreoli

Lead Devrel at Metamask

Albert Hu

Albert Hu

DeForm Founding Engineer

Radek

Radek

Senior Developer Advocate at Ceramic

Boidushya

Boidushya

WalletConnect

Idris

Idris

Developer Relations Engineer at Axelar