1
1
import { BridgeAdapter , PartialContractEventParams } from "../../helpers/bridgeAdapter.type" ;
2
2
import { BigNumber } from "ethers" ;
3
3
import { getTxDataFromEVMEventLogsCustom } from "./processTransactionsCustom" ;
4
- import { ACTION_EXECUTOR_ADDRESSES , VAULT_TYPE_USDC , VAULT_TYPE_USDT , VAULT_ASSET_ADDRESSES } from "./constants" ;
4
+ import {
5
+ ACTION_EXECUTOR_ADDRESSES ,
6
+ ACTION_EXECUTOR_CCTP_ADDRESSES ,
7
+ VAULT_TYPE_USDC ,
8
+ VAULT_TYPE_USDT ,
9
+ VAULT_TYPE_CIRCLE_CCTP ,
10
+ VAULT_ASSET_ADDRESSES
11
+ } from "./constants" ;
5
12
6
13
type SupportedChains = keyof typeof ACTION_EXECUTOR_ADDRESSES ;
7
14
8
- const depositParams = ( chain : SupportedChains ) : PartialContractEventParams => {
9
- const actionExecutorAddress = ACTION_EXECUTOR_ADDRESSES [ chain ] ;
15
+ const depositParams = ( chain : SupportedChains , isCCTP = false ) : PartialContractEventParams => {
16
+ const actionExecutorAddress =
17
+ isCCTP ?
18
+ ACTION_EXECUTOR_CCTP_ADDRESSES [ chain ] :
19
+ ACTION_EXECUTOR_ADDRESSES [ chain ] ;
10
20
11
21
return {
12
22
target : actionExecutorAddress ,
@@ -33,8 +43,11 @@ const depositParams = (chain: SupportedChains): PartialContractEventParams => {
33
43
} ;
34
44
} ;
35
45
36
- const withdrawParams = ( chain : SupportedChains ) : PartialContractEventParams => {
37
- const actionExecutorAddress = ACTION_EXECUTOR_ADDRESSES [ chain ] ;
46
+ const withdrawParams = ( chain : SupportedChains , isCCTP = false ) : PartialContractEventParams => {
47
+ const actionExecutorAddress =
48
+ isCCTP ?
49
+ ACTION_EXECUTOR_CCTP_ADDRESSES [ chain ] :
50
+ ACTION_EXECUTOR_ADDRESSES [ chain ] ;
38
51
39
52
return {
40
53
target : actionExecutorAddress ,
@@ -114,9 +127,42 @@ const variableBalanceUsdtParams = (chain: SupportedChains): PartialContractEvent
114
127
} ;
115
128
} ;
116
129
130
+ const variableBalanceCctpParams = ( chain : SupportedChains ) : PartialContractEventParams => {
131
+ const actionExecutorAddress = ACTION_EXECUTOR_CCTP_ADDRESSES [ chain ] ;
132
+
133
+ return {
134
+ target : actionExecutorAddress ,
135
+ topic : "VariableBalanceAllocated(uint256,address,uint256,uint256)" ,
136
+ abi : [
137
+ "event VariableBalanceAllocated(uint256 indexed actionId, address indexed recipient, uint256 vaultType, uint256 amount)"
138
+ ] ,
139
+ isDeposit : false ,
140
+ logKeys : {
141
+ blockNumber : "blockNumber" ,
142
+ txHash : "transactionHash" ,
143
+ } ,
144
+ argKeys : {
145
+ amount : "amount" ,
146
+ to : "recipient" ,
147
+ } ,
148
+ fixedEventData : {
149
+ token : VAULT_ASSET_ADDRESSES [ VAULT_TYPE_CIRCLE_CCTP ] [ chain ] ,
150
+ from : actionExecutorAddress ,
151
+ } ,
152
+ filter : {
153
+ includeArg : [ { vaultType : BigNumber . from ( VAULT_TYPE_CIRCLE_CCTP ) as unknown as string } ] ,
154
+ } ,
155
+ } ;
156
+ } ;
157
+
117
158
const constructParams = ( chain : SupportedChains ) => {
118
159
const eventParams = [ depositParams ( chain ) , withdrawParams ( chain ) ] ;
119
160
161
+ if ( ACTION_EXECUTOR_CCTP_ADDRESSES [ chain ] ) {
162
+ eventParams . push ( depositParams ( chain , true ) ) ;
163
+ eventParams . push ( withdrawParams ( chain , true ) ) ;
164
+ }
165
+
120
166
if ( VAULT_ASSET_ADDRESSES [ VAULT_TYPE_USDC ] [ chain ] ) {
121
167
eventParams . push ( variableBalanceUsdcParams ( chain ) ) ;
122
168
}
@@ -125,6 +171,10 @@ const constructParams = (chain: SupportedChains) => {
125
171
eventParams . push ( variableBalanceUsdtParams ( chain ) ) ;
126
172
}
127
173
174
+ if ( VAULT_ASSET_ADDRESSES [ VAULT_TYPE_CIRCLE_CCTP ] [ chain ] ) {
175
+ eventParams . push ( variableBalanceCctpParams ( chain ) ) ;
176
+ }
177
+
128
178
return async ( fromBlock : number , toBlock : number ) =>
129
179
getTxDataFromEVMEventLogsCustom ( "interport" , chain , fromBlock , toBlock , eventParams ) ;
130
180
} ;
0 commit comments