Skip to content

Commit

Permalink
add unit tests for intervalUpdates
Browse files Browse the repository at this point in the history
  • Loading branch information
mzywang committed May 22, 2024
1 parent da02652 commit a87ba7b
Show file tree
Hide file tree
Showing 2 changed files with 490 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils/intervalUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { FACTORY_ADDRESS } from './constants'
* Tracks global aggregate data over daily windows
* @param event
*/
export function updateUniswapDayData(event: ethereum.Event): UniswapDayData {
const uniswap = Factory.load(FACTORY_ADDRESS)!
export function updateUniswapDayData(event: ethereum.Event, factoryAddress: string = FACTORY_ADDRESS): UniswapDayData {
const uniswap = Factory.load(factoryAddress)!
const timestamp = event.block.timestamp.toI32()
const dayID = timestamp / 86400 // rounded
const dayStartTimestamp = dayID * 86400
Expand Down Expand Up @@ -72,6 +72,7 @@ export function updatePoolDayData(event: ethereum.Event): PoolDayData {
poolDayData.sqrtPrice = pool.sqrtPrice
poolDayData.token0Price = pool.token0Price
poolDayData.token1Price = pool.token1Price
poolDayData.close = pool.token0Price
poolDayData.tick = pool.tick
poolDayData.tvlUSD = pool.totalValueLockedUSD
poolDayData.txCount = poolDayData.txCount.plus(ONE_BI)
Expand Down
Loading

0 comments on commit a87ba7b

Please sign in to comment.