@@ -43,6 +43,11 @@ export const createOriginARMProcessors = ({
43
43
topic0 : [ originLidoArmAbi . events . RedeemRequested . topic ] ,
44
44
range : { from } ,
45
45
} )
46
+ const feeCollectedFilter = logFilter ( {
47
+ address : [ armAddress ] ,
48
+ topic0 : [ originLidoArmAbi . events . FeeCollected . topic ] ,
49
+ range : { from } ,
50
+ } )
46
51
const tracker = blockFrequencyTracker ( { from } )
47
52
let armEntity : Arm
48
53
let initialized = false
@@ -86,6 +91,7 @@ export const createOriginARMProcessors = ({
86
91
p . addLog ( redeemClaimedFilter . value )
87
92
p . addLog ( depositFilter . value )
88
93
p . addLog ( withdrawalFilter . value )
94
+ p . addLog ( feeCollectedFilter . value )
89
95
} ,
90
96
initialize,
91
97
process : async ( ctx : Context ) => {
@@ -106,7 +112,7 @@ export const createOriginARMProcessors = ({
106
112
} ) )
107
113
)
108
114
}
109
- const getCurrentState = async ( block : Block , extra ?: { deposit : bigint ; withdrawal : bigint } ) => {
115
+ const getCurrentState = async ( block : Block ) => {
110
116
const stateId = getStateId ( block )
111
117
if ( states [ states . length - 1 ] ?. id === stateId ) {
112
118
return states [ states . length - 1 ]
@@ -147,9 +153,9 @@ export const createOriginARMProcessors = ({
147
153
totalAssetsCap,
148
154
totalSupply,
149
155
assetsPerShare,
150
- totalDeposits : ( previousState ?. totalDeposits ?? 0n ) + ( extra ?. deposit ?? 0n ) ,
151
- totalWithdrawals : ( previousState ?. totalWithdrawals ?? 0n ) + ( extra ?. withdrawal ?? 0n ) ,
152
- totalFees : feesAccrued ,
156
+ totalDeposits : previousState ?. totalDeposits ?? 0n ,
157
+ totalWithdrawals : previousState ?. totalWithdrawals ?? 0n ,
158
+ totalFees : previousState ?. totalFees ?? 0n ,
153
159
totalYield : 0n ,
154
160
} )
155
161
armStateEntity . totalYield = calculateTotalYield ( armStateEntity )
@@ -159,7 +165,6 @@ export const createOriginARMProcessors = ({
159
165
const calculateTotalYield = ( state : ArmState ) =>
160
166
state . totalAssets - state . totalDeposits + state . totalWithdrawals
161
167
162
- // ArmWithdrawalRequest
163
168
for ( const block of ctx . blocks ) {
164
169
if ( tracker ( ctx , block ) ) {
165
170
// ArmState
@@ -204,6 +209,7 @@ export const createOriginARMProcessors = ({
204
209
dailyStatsMap . set ( currentDayId , armDailyStatEntity )
205
210
}
206
211
for ( const log of block . logs ) {
212
+ // ArmWithdrawalRequest
207
213
if ( redeemRequestedFilter . matches ( log ) ) {
208
214
const event = originLidoArmAbi . events . RedeemRequested . decode ( log )
209
215
const eventId = `${ ctx . chain . id } :${ armAddress } :${ event . requestId } `
@@ -243,6 +249,11 @@ export const createOriginARMProcessors = ({
243
249
state . totalWithdrawals += event . assets
244
250
state . totalYield = calculateTotalYield ( state )
245
251
}
252
+ if ( feeCollectedFilter . matches ( log ) ) {
253
+ const event = originLidoArmAbi . events . FeeCollected . decode ( log )
254
+ const state = await getCurrentState ( block )
255
+ state . totalFees += event . fee
256
+ }
246
257
}
247
258
}
248
259
await ctx . store . insert ( states )
0 commit comments