Skip to content

Commit

Permalink
implement updateAnalyticsHourData
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasCImach committed Jul 3, 2024
1 parent f6a1f1e commit d2f98ed
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { loadMarket, loadPosition, loadFactory, loadTransaction, loadAccount, lo
import { updateReferralRewards } from "./referral";
import { updateTraderEpochVolume } from "./trading-mining";
import { updateMarketHourData } from "./temporal-data-logger";
import { updateMarketState } from "./utils/helpers";
import { updateAnalyticsHourData, updateMarketState } from "./utils/helpers";

// TODO: rename or separate this file into multiple files

Expand Down Expand Up @@ -233,6 +233,8 @@ export function handleBuild(event: BuildEvent): void {
analytics.totalVolumeBuilds = analytics.totalVolumeBuilds.plus(initialNotional)
analytics.totalVolume = analytics.totalVolume.plus(initialNotional)

updateAnalyticsHourData(analytics, event.block.timestamp)

sender.numberOfOpenPositions = sender.numberOfOpenPositions.plus(ONE_BI)

updateReferralRewards(event, event.params.sender, transferFeeAmount)
Expand Down Expand Up @@ -396,6 +398,8 @@ export function handleUnwind(event: UnwindEvent): void {
analytics.totalVolumeUnwinds = analytics.totalVolumeUnwinds.plus(unwind.volume)
analytics.totalVolume = analytics.totalVolume.plus(unwind.volume)

updateAnalyticsHourData(analytics, event.block.timestamp)

// position.currentOi = stateContract.oi(marketAddress, senderAddress, positionId)
position.currentDebt = position.currentDebt.times(ONE_18DEC_BI.minus(unwind.fraction)).div(ONE_18DEC_BI)

Expand Down Expand Up @@ -650,6 +654,8 @@ export function handleLiquidate(event: LiquidateEvent): void {
analytics.totalVolumeLiquidations = analytics.totalVolumeLiquidations.plus(liquidate.volume)
analytics.totalVolume = analytics.totalVolume.plus(liquidate.volume)

updateAnalyticsHourData(analytics, event.block.timestamp)

market.totalVolume = market.totalVolume.plus(liquidate.volume)
market.totalMint = market.totalMint.plus(event.params.mint)

Expand Down

0 comments on commit d2f98ed

Please sign in to comment.