Skip to content

Commit e23472b

Browse files
committed
add rateUSD to armDailyStats
1 parent c3a67d5 commit e23472b

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

db/migrations/1730241139493-Data.js renamed to db/migrations/1730245853368-Data.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,7 @@ type ArmDailyStat @entity {
809809
apy: Float!
810810
yield: BigInt!
811811
fees: BigInt!
812+
rateUSD: Float!
812813
}
813814

814815
type ArmWithdrawalRequest @entity {

schema/arm.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ type ArmDailyStat @entity {
6060
apy: Float!
6161
yield: BigInt!
6262
fees: BigInt!
63+
rateUSD: Float!
6364
}
6465

6566
type ArmWithdrawalRequest @entity {

src/model/generated/armDailyStat.model.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,7 @@ export class ArmDailyStat {
6161

6262
@BigIntColumn_({nullable: false})
6363
fees!: bigint
64+
65+
@FloatColumn_({nullable: false})
66+
rateUSD!: number
6467
}

src/templates/origin-arm/origin-arm.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import dayjs from 'dayjs'
22
import { last } from 'lodash'
3+
import { formatUnits } from 'viem'
34

45
import * as erc20Abi from '@abi/erc20'
56
import * as originLidoArmAbi from '@abi/origin-lido-arm'
67
import * as originLidoArmCapManagerAbi from '@abi/origin-lido-arm-cap-manager'
78
import { Arm, ArmDailyStat, ArmState, ArmWithdrawalRequest, TraderateChanged } from '@model'
89
import { Block, Context, Processor } from '@processor'
10+
import { ensureExchangeRate } from '@shared/post-processors/exchange-rates'
911
import { EvmBatchProcessor } from '@subsquid/evm-processor'
1012
import { createERC20SimpleTracker } from '@templates/erc20-simple'
1113
import { createEventProcessor } from '@templates/events/createEventProcessor'
@@ -179,6 +181,7 @@ export const createOriginARMProcessors = ({
179181
if (tracker(ctx, block)) {
180182
// ArmState
181183
const state = await getCurrentState(block)
184+
const rateUSD = await ensureExchangeRate(ctx, block, 'ETH', 'USD')
182185

183186
// ArmDailyStat
184187
const date = new Date(block.header.timestamp)
@@ -215,6 +218,7 @@ export const createOriginARMProcessors = ({
215218
apy: armDayApy.apy,
216219
fees: state.totalFees - (previousDailyStat?.fees ?? 0n),
217220
yield: state.totalYield - (previousDailyStat?.yield ?? 0n),
221+
rateUSD: +formatUnits(rateUSD?.rate ?? 0n, 8),
218222
})
219223
dailyStatsMap.set(currentDayId, armDailyStatEntity)
220224
}

0 commit comments

Comments
 (0)