File tree Expand file tree Collapse file tree 3 files changed +102
-79
lines changed
substreams/crates/tycho-substreams/src Expand file tree Collapse file tree 3 files changed +102
-79
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,6 @@ enum FinancialType{
55
55
PSM = 3 ;
56
56
}
57
57
58
-
59
58
enum ImplementationType {
60
59
VM = 0 ;
61
60
CUSTOM = 1 ;
@@ -128,6 +127,14 @@ message ContractSlot {
128
127
bytes value = 3 ;
129
128
}
130
129
130
+ // A struct for following the token balance changes for a contract.
131
+ message AccountBalanceChange {
132
+ // The address of the ERC20 token whose balance changed.
133
+ bytes token = 1 ;
134
+ // The new balance of the token. Note: it must be a big endian encoded int.
135
+ bytes balance = 2 ;
136
+ }
137
+
131
138
// Changes made to a single contract's state.
132
139
message ContractChange {
133
140
// The contract's address
@@ -140,6 +147,8 @@ message ContractChange {
140
147
repeated ContractSlot slots = 4 ;
141
148
// Whether this is an update, a creation or a deletion.
142
149
ChangeType change = 5 ;
150
+ // The new ERC20 balances of the contract.
151
+ repeated AccountBalanceChange token_balances = 6 ;
143
152
}
144
153
145
154
// Aggregate entities
Original file line number Diff line number Diff line change @@ -467,6 +467,7 @@ pub struct InterimContractChange {
467
467
code : Vec < u8 > ,
468
468
slots : HashMap < Vec < u8 > , SlotValue > ,
469
469
change : ChangeType ,
470
+ token_balances : HashMap < Vec < u8 > , Vec < u8 > > ,
470
471
}
471
472
472
473
impl InterimContractChange {
@@ -477,6 +478,7 @@ impl InterimContractChange {
477
478
code : vec ! [ ] ,
478
479
slots : Default :: default ( ) ,
479
480
change : if creation { ChangeType :: Creation } else { ChangeType :: Update } ,
481
+ token_balances : Default :: default ( ) ,
480
482
}
481
483
}
482
484
@@ -530,6 +532,11 @@ impl From<InterimContractChange> for Option<ContractChange> {
530
532
. map ( |( slot, value) | ContractSlot { slot, value : value. new_value } )
531
533
. collect ( ) ,
532
534
change : value. change . into ( ) ,
535
+ token_balances : value
536
+ . token_balances
537
+ . into_iter ( )
538
+ . map ( |( k, v) | AccountBalanceChange { token : k, balance : v } )
539
+ . collect ( ) ,
533
540
} ;
534
541
if contract_change. is_empty ( ) {
535
542
None
You can’t perform that action at this time.
0 commit comments