@@ -201,8 +201,6 @@ export const createOTokenProcessor = (params: {
201
201
}
202
202
203
203
let owners : Map < string , OTokenAddress > | undefined = undefined
204
- let ownersHistorical : OTokenAddress [ ] = [ ]
205
-
206
204
let idMap : Map < string , number >
207
205
const getUniqueId = ( partialId : string ) => {
208
206
const nextId = ( idMap . get ( partialId ) ?? 0 ) + 1
@@ -220,7 +218,6 @@ export const createOTokenProcessor = (params: {
220
218
start = Date . now ( )
221
219
}
222
220
idMap = new Map < string , number > ( )
223
- ownersHistorical = [ ]
224
221
225
222
const transferFilter = logFilter ( {
226
223
address : [ params . otokenAddress ] ,
@@ -351,7 +348,6 @@ export const createOTokenProcessor = (params: {
351
348
if ( ! entity ) {
352
349
entity = await createAddress ( ctx , params . otokenAddress , address , block )
353
350
owners ! . set ( entity . address , entity )
354
- ownersHistorical . push ( entity )
355
351
}
356
352
entity . blockNumber = block . header . height
357
353
entity . lastUpdated = new Date ( block . header . timestamp )
@@ -606,7 +602,6 @@ export const createOTokenProcessor = (params: {
606
602
if ( ! owner ) {
607
603
owner = await createAddress ( ctx , params . otokenAddress , address , block )
608
604
owners ! . set ( address , owner )
609
- ownersHistorical . push ( owner )
610
605
}
611
606
const rebaseOption = new OTokenRebaseOption ( {
612
607
id : getUniqueId ( `${ ctx . chain . id } -${ params . otokenAddress } -${ hash } -${ owner . address } ` ) ,
@@ -651,7 +646,6 @@ export const createOTokenProcessor = (params: {
651
646
if ( ! sourceOwner ) {
652
647
sourceOwner = await createAddress ( ctx , params . otokenAddress , sourceAddress , block )
653
648
owners ! . set ( sourceAddress , sourceOwner )
654
- ownersHistorical . push ( sourceOwner )
655
649
}
656
650
sourceOwner . rebasingOption = RebasingOption . YieldDelegationSource
657
651
sourceOwner . delegatedTo = targetAddress
@@ -673,7 +667,6 @@ export const createOTokenProcessor = (params: {
673
667
if ( ! targetOwner ) {
674
668
targetOwner = await createAddress ( ctx , params . otokenAddress , targetAddress , block )
675
669
owners ! . set ( targetAddress , targetOwner )
676
- ownersHistorical . push ( targetOwner )
677
670
}
678
671
targetOwner . rebasingOption = RebasingOption . YieldDelegationTarget
679
672
targetOwner . delegatedTo = null
@@ -704,7 +697,6 @@ export const createOTokenProcessor = (params: {
704
697
if ( ! sourceOwner ) {
705
698
sourceOwner = await createAddress ( ctx , params . otokenAddress , sourceAddress , block )
706
699
owners ! . set ( sourceAddress , sourceOwner )
707
- ownersHistorical . push ( sourceOwner )
708
700
}
709
701
sourceOwner . rebasingOption = RebasingOption . OptOut
710
702
sourceOwner . delegatedTo = null
@@ -726,7 +718,6 @@ export const createOTokenProcessor = (params: {
726
718
if ( ! targetOwner ) {
727
719
targetOwner = await createAddress ( ctx , params . otokenAddress , targetAddress , block )
728
720
owners ! . set ( targetAddress , targetOwner )
729
- ownersHistorical . push ( targetOwner )
730
721
}
731
722
targetOwner . rebasingOption = RebasingOption . OptIn
732
723
targetOwner . delegatedTo = null
@@ -1158,17 +1149,18 @@ export const createOTokenProcessor = (params: {
1158
1149
result . erc20 . holders . set ( erc20Holder . id , erc20Holder )
1159
1150
}
1160
1151
}
1161
- for ( const owner of ownersHistorical ) {
1152
+ for ( const history of result . history ) {
1153
+ const id = `${ ctx . chain . id } -${ history . blockNumber } -${ history . otoken } -${ history . address } `
1162
1154
result . erc20 . balances . set (
1163
- owner . id ,
1155
+ id ,
1164
1156
new ERC20Balance ( {
1165
- id : ` ${ ctx . chain . id } - ${ owner . blockNumber } - ${ owner . otoken } - ${ owner . address } ` ,
1157
+ id,
1166
1158
chainId : ctx . chain . id ,
1167
- address : owner . otoken ,
1168
- account : owner . address ,
1169
- timestamp : owner . lastUpdated ,
1170
- blockNumber : owner . blockNumber ,
1171
- balance : owner . balance ,
1159
+ address : history . otoken ,
1160
+ account : history . address . address ,
1161
+ timestamp : history . timestamp ,
1162
+ blockNumber : history . blockNumber ,
1163
+ balance : history . balance ,
1172
1164
} ) ,
1173
1165
)
1174
1166
}
0 commit comments