Skip to content

Commit

Permalink
Merge pull request #92 from nlordell/save-pool-on-initialize
Browse files Browse the repository at this point in the history
Save pool in `handleInitialize`
  • Loading branch information
ianlapham authored Mar 8, 2022
2 parents b6de75b + 2a2ac31 commit 9f09b04
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/mappings/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ import {
import { createTick, feeTierToTickSpacing } from '../utils/tick'

export function handleInitialize(event: Initialize): void {
// update pool sqrt price and tick
let pool = Pool.load(event.address.toHexString())
pool.sqrtPrice = event.params.sqrtPriceX96
pool.tick = BigInt.fromI32(event.params.tick)
pool.save()

// update token prices
let token0 = Token.load(pool.token0)
let token1 = Token.load(pool.token1)
Expand Down

0 comments on commit 9f09b04

Please sign in to comment.