1+ import * as feeAccumulatorAbi from '@abi/fee-accumulator'
2+ import * as nativeStakingAbi from '@abi/strategy-native-staking'
3+ import { AccountingConsensusRewards , ExecutionRewardsCollected } from '@model'
14import { Context } from '@processor'
25import { mainnetCurrencies } from '@shared/post-processors/exchange-rates/mainnetCurrencies'
36import { EvmBatchProcessor } from '@subsquid/evm-processor'
7+ import { createEventProcessor } from '@templates/events/createEventProcessor'
48import { IStrategyData , createStrategyProcessor , createStrategySetup } from '@templates/strategy'
59import { createStrategyRewardProcessor , createStrategyRewardSetup } from '@templates/strategy-rewards'
610import {
@@ -163,11 +167,50 @@ export const oethStrategies: readonly IStrategyData[] = [
163167
164168const strategies = oethStrategies
165169
170+ const eventProcessors = [
171+ ...OETH_NATIVE_STRATEGY_ADDRESSES . map ( ( address ) =>
172+ createEventProcessor ( {
173+ address,
174+ eventName : 'AccountingConsensusRewards' ,
175+ event : nativeStakingAbi . events . AccountingConsensusRewards ,
176+ from : 20046251 ,
177+ Entity : AccountingConsensusRewards ,
178+ mapEntity : ( ctx , block , log , decoded ) =>
179+ new AccountingConsensusRewards ( {
180+ id : `${ ctx . chain . id } :${ log . id } ` ,
181+ chainId : ctx . chain . id ,
182+ timestamp : new Date ( block . header . timestamp ) ,
183+ blockNumber : block . header . height ,
184+ address,
185+ rewards : decoded . amount ,
186+ } ) ,
187+ } ) ,
188+ ) ,
189+ createEventProcessor ( {
190+ address : addresses . oeth . nativeStakingFeeAccumulator ,
191+ eventName : 'ExecutionRewardsCollected' ,
192+ event : feeAccumulatorAbi . events . ExecutionRewardsCollected ,
193+ from : 20046238 ,
194+ Entity : ExecutionRewardsCollected ,
195+ mapEntity : ( ctx , block , log , decoded ) =>
196+ new ExecutionRewardsCollected ( {
197+ id : `${ ctx . chain . id } :${ log . id } ` ,
198+ chainId : ctx . chain . id ,
199+ timestamp : new Date ( block . header . timestamp ) ,
200+ blockNumber : block . header . height ,
201+ address : addresses . oeth . nativeStakingFeeAccumulator ,
202+ strategy : decoded . strategy ,
203+ amount : decoded . amount ,
204+ } ) ,
205+ } ) ,
206+ ]
207+
166208export const from = Math . min ( ...strategies . map ( ( s ) => s . from ) )
167209
168210export const setup = ( processor : EvmBatchProcessor ) => {
169211 strategies . forEach ( ( s ) => createStrategySetup ( s ) ( processor ) )
170212 strategies . filter ( ( s ) => s . kind !== 'Vault' ) . forEach ( ( s ) => createStrategyRewardSetup ( s ) ( processor ) )
213+ eventProcessors . forEach ( ( p ) => p . setup ( processor ) )
171214}
172215
173216const processors = [
@@ -176,5 +219,5 @@ const processors = [
176219]
177220
178221export const process = async ( ctx : Context ) => {
179- await Promise . all ( processors . map ( ( p ) => p ( ctx ) ) )
222+ await Promise . all ( [ ... processors . map ( ( p ) => p ( ctx ) ) , ... eventProcessors . map ( ( p ) => p . process ( ctx ) ) ] )
180223}
0 commit comments