Skip to content

Commit

Permalink
add rateUSD to armDailyStats
Browse files Browse the repository at this point in the history
  • Loading branch information
apexearth committed Oct 29, 2024
1 parent c3a67d5 commit e23472b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@ type ArmDailyStat @entity {
apy: Float!
yield: BigInt!
fees: BigInt!
rateUSD: Float!
}

type ArmWithdrawalRequest @entity {
Expand Down
1 change: 1 addition & 0 deletions schema/arm.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type ArmDailyStat @entity {
apy: Float!
yield: BigInt!
fees: BigInt!
rateUSD: Float!
}

type ArmWithdrawalRequest @entity {
Expand Down
3 changes: 3 additions & 0 deletions src/model/generated/armDailyStat.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@ export class ArmDailyStat {

@BigIntColumn_({nullable: false})
fees!: bigint

@FloatColumn_({nullable: false})
rateUSD!: number
}
4 changes: 4 additions & 0 deletions src/templates/origin-arm/origin-arm.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import dayjs from 'dayjs'
import { last } from 'lodash'
import { formatUnits } from 'viem'

import * as erc20Abi from '@abi/erc20'
import * as originLidoArmAbi from '@abi/origin-lido-arm'
import * as originLidoArmCapManagerAbi from '@abi/origin-lido-arm-cap-manager'
import { Arm, ArmDailyStat, ArmState, ArmWithdrawalRequest, TraderateChanged } from '@model'
import { Block, Context, Processor } from '@processor'
import { ensureExchangeRate } from '@shared/post-processors/exchange-rates'
import { EvmBatchProcessor } from '@subsquid/evm-processor'
import { createERC20SimpleTracker } from '@templates/erc20-simple'
import { createEventProcessor } from '@templates/events/createEventProcessor'
Expand Down Expand Up @@ -179,6 +181,7 @@ export const createOriginARMProcessors = ({
if (tracker(ctx, block)) {
// ArmState
const state = await getCurrentState(block)
const rateUSD = await ensureExchangeRate(ctx, block, 'ETH', 'USD')

// ArmDailyStat
const date = new Date(block.header.timestamp)
Expand Down Expand Up @@ -215,6 +218,7 @@ export const createOriginARMProcessors = ({
apy: armDayApy.apy,
fees: state.totalFees - (previousDailyStat?.fees ?? 0n),
yield: state.totalYield - (previousDailyStat?.yield ?? 0n),
rateUSD: +formatUnits(rateUSD?.rate ?? 0n, 8),
})
dailyStatsMap.set(currentDayId, armDailyStatEntity)
}
Expand Down

0 comments on commit e23472b

Please sign in to comment.