Skip to content

Commit

Permalink
feat: add latest timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorvin committed Mar 21, 2024
1 parent 4110296 commit a4a76c9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Book @entity {
openOrders: [OpenOrder!]! @derivedFrom(field: "book")
latestTick: BigInt!
latestPrice: BigInt!
latestTimestamp: BigInt!
}

type Depth @entity {
Expand Down
2 changes: 2 additions & 0 deletions src/book-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function handleOpen(event: Open): void {
book.hooks = event.params.hooks.toHexString()
book.latestTick = BigInt.zero()
book.latestPrice = BigInt.zero()
book.latestTimestamp = BigInt.zero()
book.save()
}

Expand Down Expand Up @@ -124,6 +125,7 @@ export function handleTake(event: Take): void {
const price = controller.toPrice(tick.toI32())
book.latestTick = tick
book.latestPrice = price
book.latestTimestamp = event.block.timestamp
book.save()

// update depth & open order
Expand Down

0 comments on commit a4a76c9

Please sign in to comment.