This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ethers } from 'ethers' | |
// To use this you need to read the Uniswap v2 contract for a pair/ | |
// PRICE pulled from priceXCumulativeLast | |
// TIMESTAMPS pulled from _blockTimestampLast in getReserves() | |
// Mock Data | |
// In a real scenario you would fetch and store price & timestamp at an interval | |
// to mirror the contract calculating the TWAP on chain | |
const price0 = '529527205677379158060966860839' |