Skip to content

Commit 96fdb82

Browse files
committed
add oeth portion of revenue to oethb and oethp
1 parent 1bc4c93 commit 96fdb82

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/mainnet/processors/protocol/protocol.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import dayjs from 'dayjs'
2-
import { uniq } from 'lodash'
2+
import { compact, uniq } from 'lodash'
33
import { In, LessThanOrEqual } from 'typeorm'
44

55
import {
@@ -145,9 +145,11 @@ const getOTokenDetails = async (
145145

146146
// Since we depend on superOETHb and superOETHp, we need to continue updating
147147
// our product's details until our dependencies are all caught up.
148+
const lastOETH = await getLatestProtocolDailyStatDetail(ctx, 'OETH')
148149
const lastSuperOETHb = await getLatestProtocolDailyStatDetail(ctx, 'superOETHb')
149150
const lastSuperOETHp = await getLatestProtocolDailyStatDetail(ctx, 'superOETHp')
150-
const lastDates = [last?.date ?? startDate, lastSuperOETHb?.date, lastSuperOETHp?.date].filter(Boolean) as string[]
151+
const lastDates = compact([last?.date ?? startDate, lastOETH?.date, lastSuperOETHb?.date, lastSuperOETHp?.date])
152+
151153
const oldestDate = lastDates.reduce((min, d) => (d < min ? d : min), lastDates[0])
152154

153155
const status = await ctx.store.findOne(ProcessingStatus, { where: { id: processorId } })
@@ -208,19 +210,25 @@ const getOTokenDetails = async (
208210
detail.earningTvl !== 0n ? (detail.revenue * detail.inheritedTvl) / detail.earningTvl : 0n
209211
detail.bridgedTvl = (superOETHbWrappedOETH?.balanceETH ?? 0n) + (superOETHpWrappedOETH?.balanceETH ?? 0n)
210212
} else if (detail.product === 'superOETHb') {
213+
const detailOETH = await getProtocolDailyStatDetail(ctx, date, 'OETH')
211214
const superOETHbWrappedOETH = await getLatestStrategyBalance(
212215
ctx,
213216
baseAddresses.superOETHb.strategies.bridgedWOETH,
214217
date,
215218
)
216-
detail.bridgedTvl = superOETHbWrappedOETH?.balanceETH ?? 0n
219+
const woethBalance = superOETHbWrappedOETH?.balanceETH ?? 0n
220+
detail.bridgedTvl = woethBalance
221+
detail.revenue += ((detailOETH?.revenue ?? 0n) * woethBalance) / detail.tvl
217222
} else if (detail.product === 'superOETHp') {
223+
const detailOETH = await getProtocolDailyStatDetail(ctx, date, 'OETH')
218224
const superOETHpWrappedOETH = await getLatestStrategyBalance(
219225
ctx,
220226
plumeAddresses.superOETHp.strategies.bridgedWOETH,
221227
date,
222228
)
223-
detail.bridgedTvl = superOETHpWrappedOETH?.balanceETH ?? 0n
229+
const woethBalance = superOETHpWrappedOETH?.balanceETH ?? 0n
230+
detail.bridgedTvl = woethBalance
231+
detail.revenue += ((detailOETH?.revenue ?? 0n) * woethBalance) / detail.tvl
224232
}
225233

226234
details.push(detail)
@@ -253,16 +261,14 @@ const getArmDetails = async (
253261
return details
254262
}
255263
const detail = await getProtocolDailyStatDetail(ctx, date, product)
264+
const eth = (value: bigint) => (value * BigInt(Math.round(armDailyStat.rateETH * 1e18))) / BigInt(10 ** 18)
256265
detail.rateUSD = BigInt(Math.round(armDailyStat.rateUSD * 1e18))
257-
detail.earningTvl = armDailyStat.totalAssets
258-
detail.tvl = armDailyStat.totalAssets
259-
detail.supply = armDailyStat.totalSupply
260-
detail.yield = armDailyStat.yield + armDailyStat.fees
261-
detail.revenue = armDailyStat.fees
266+
detail.earningTvl = eth(armDailyStat.totalAssets)
267+
detail.tvl = eth(armDailyStat.totalAssets)
268+
detail.supply = eth(armDailyStat.totalSupply)
269+
detail.yield = eth(armDailyStat.yield + armDailyStat.fees)
270+
detail.revenue = eth(armDailyStat.fees)
262271
detail.apy = armDailyStat.apy
263-
detail.inheritedTvl = 0n
264-
detail.inheritedYield = 0n
265-
detail.inheritedRevenue = 0n
266272
details.push(detail)
267273
}
268274
return details

0 commit comments

Comments
 (0)