@across-protocol/sdk 4.2.13 → 4.2.14-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/dist/cjs/arch/evm/SpokeUtils.d.ts +5 -2
  2. package/dist/cjs/arch/evm/SpokeUtils.js +22 -5
  3. package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
  4. package/dist/cjs/arch/svm/SpokeUtils.js +14 -11
  5. package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
  6. package/dist/cjs/arch/svm/utils.d.ts +1 -1
  7. package/dist/cjs/arch/svm/utils.js +15 -13
  8. package/dist/cjs/arch/svm/utils.js.map +1 -1
  9. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  10. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
  11. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  12. package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
  13. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +60 -56
  14. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  15. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +13 -13
  16. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  17. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
  18. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +3 -2
  19. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  20. package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
  21. package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
  22. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +3 -3
  23. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
  24. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
  25. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +11 -8
  26. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  27. package/dist/cjs/clients/HubPoolClient.d.ts +21 -21
  28. package/dist/cjs/clients/HubPoolClient.js +83 -59
  29. package/dist/cjs/clients/HubPoolClient.js.map +1 -1
  30. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +1 -1
  31. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  32. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
  33. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +52 -37
  34. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  35. package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +9 -9
  36. package/dist/cjs/clients/mocks/MockHubPoolClient.js +15 -9
  37. package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
  38. package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +5 -3
  39. package/dist/cjs/clients/mocks/MockSpokePoolClient.js +39 -36
  40. package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
  41. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
  42. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +2 -2
  43. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
  44. package/dist/cjs/interfaces/HubPool.d.ts +19 -14
  45. package/dist/cjs/interfaces/SpokePool.d.ts +13 -13
  46. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
  47. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +7 -7
  48. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  49. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +4 -4
  50. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +14 -15
  51. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  52. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
  53. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +7 -7
  54. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  55. package/dist/cjs/utils/AddressUtils.d.ts +6 -3
  56. package/dist/cjs/utils/AddressUtils.js +42 -14
  57. package/dist/cjs/utils/AddressUtils.js.map +1 -1
  58. package/dist/cjs/utils/SpokeUtils.d.ts +3 -3
  59. package/dist/cjs/utils/SpokeUtils.js +4 -22
  60. package/dist/cjs/utils/SpokeUtils.js.map +1 -1
  61. package/dist/cjs/utils/TokenUtils.d.ts +4 -4
  62. package/dist/cjs/utils/TokenUtils.js +3 -3
  63. package/dist/cjs/utils/TokenUtils.js.map +1 -1
  64. package/dist/esm/arch/evm/SpokeUtils.d.ts +5 -2
  65. package/dist/esm/arch/evm/SpokeUtils.js +23 -6
  66. package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
  67. package/dist/esm/arch/svm/SpokeUtils.js +15 -12
  68. package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
  69. package/dist/esm/arch/svm/utils.d.ts +1 -1
  70. package/dist/esm/arch/svm/utils.js +15 -13
  71. package/dist/esm/arch/svm/utils.js.map +1 -1
  72. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  73. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
  74. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  75. package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
  76. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +61 -57
  77. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  78. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +14 -14
  79. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  80. package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
  81. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +4 -3
  82. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  83. package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
  84. package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
  85. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +4 -4
  86. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
  87. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
  88. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +12 -9
  89. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  90. package/dist/esm/clients/HubPoolClient.d.ts +23 -22
  91. package/dist/esm/clients/HubPoolClient.js +96 -63
  92. package/dist/esm/clients/HubPoolClient.js.map +1 -1
  93. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
  94. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  95. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
  96. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +54 -38
  97. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  98. package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +9 -9
  99. package/dist/esm/clients/mocks/MockHubPoolClient.js +16 -10
  100. package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
  101. package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +5 -3
  102. package/dist/esm/clients/mocks/MockSpokePoolClient.js +41 -38
  103. package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
  104. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
  105. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +3 -3
  106. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
  107. package/dist/esm/interfaces/HubPool.d.ts +19 -14
  108. package/dist/esm/interfaces/SpokePool.d.ts +13 -13
  109. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
  110. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +8 -8
  111. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  112. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +4 -4
  113. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +15 -16
  114. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  115. package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
  116. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +8 -8
  117. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  118. package/dist/esm/utils/AddressUtils.d.ts +7 -3
  119. package/dist/esm/utils/AddressUtils.js +52 -19
  120. package/dist/esm/utils/AddressUtils.js.map +1 -1
  121. package/dist/esm/utils/SpokeUtils.d.ts +3 -8
  122. package/dist/esm/utils/SpokeUtils.js +4 -26
  123. package/dist/esm/utils/SpokeUtils.js.map +1 -1
  124. package/dist/esm/utils/TokenUtils.d.ts +18 -16
  125. package/dist/esm/utils/TokenUtils.js +3 -3
  126. package/dist/esm/utils/TokenUtils.js.map +1 -1
  127. package/dist/types/arch/evm/SpokeUtils.d.ts +5 -2
  128. package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
  129. package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
  130. package/dist/types/arch/svm/utils.d.ts +1 -1
  131. package/dist/types/arch/svm/utils.d.ts.map +1 -1
  132. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  133. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
  134. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
  135. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  136. package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
  137. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
  138. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
  139. package/dist/types/clients/BundleDataClient/utils/MerkleTreeUtils.d.ts.map +1 -1
  140. package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts.map +1 -1
  141. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
  142. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
  143. package/dist/types/clients/HubPoolClient.d.ts +23 -22
  144. package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
  145. package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
  146. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
  147. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
  148. package/dist/types/clients/mocks/MockHubPoolClient.d.ts +9 -9
  149. package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
  150. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +5 -3
  151. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
  152. package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
  153. package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts.map +1 -1
  154. package/dist/types/interfaces/HubPool.d.ts +19 -14
  155. package/dist/types/interfaces/HubPool.d.ts.map +1 -1
  156. package/dist/types/interfaces/SpokePool.d.ts +13 -13
  157. package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
  158. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
  159. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
  160. package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +4 -4
  161. package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
  162. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
  163. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
  164. package/dist/types/utils/AddressUtils.d.ts +7 -3
  165. package/dist/types/utils/AddressUtils.d.ts.map +1 -1
  166. package/dist/types/utils/SpokeUtils.d.ts +3 -8
  167. package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
  168. package/dist/types/utils/TokenUtils.d.ts +18 -16
  169. package/dist/types/utils/TokenUtils.d.ts.map +1 -1
  170. package/package.json +2 -3
  171. package/src/arch/evm/SpokeUtils.ts +53 -11
  172. package/src/arch/svm/SpokeUtils.ts +44 -11
  173. package/src/arch/svm/utils.ts +3 -3
  174. package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -4
  175. package/src/clients/BundleDataClient/BundleDataClient.ts +54 -52
  176. package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +28 -13
  177. package/src/clients/BundleDataClient/utils/FillUtils.ts +6 -4
  178. package/src/clients/BundleDataClient/utils/MerkleTreeUtils.ts +7 -1
  179. package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +4 -4
  180. package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +13 -9
  181. package/src/clients/HubPoolClient.ts +122 -82
  182. package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +6 -0
  183. package/src/clients/SpokePoolClient/SpokePoolClient.ts +109 -28
  184. package/src/clients/mocks/MockHubPoolClient.ts +24 -19
  185. package/src/clients/mocks/MockSpokePoolClient.ts +37 -26
  186. package/src/clients/mocks/MockSvmSpokePoolClient.ts +12 -3
  187. package/src/interfaces/HubPool.ts +23 -14
  188. package/src/interfaces/SpokePool.ts +13 -13
  189. package/src/relayFeeCalculator/chain-queries/baseQuery.ts +10 -8
  190. package/src/relayFeeCalculator/chain-queries/svmQuery.ts +16 -21
  191. package/src/relayFeeCalculator/relayFeeCalculator.ts +20 -12
  192. package/src/utils/AddressUtils.ts +56 -21
  193. package/src/utils/SpokeUtils.ts +11 -33
  194. package/src/utils/TokenUtils.ts +7 -7
@@ -1,7 +1,7 @@
1
1
  import { MerkleTree } from "@across-protocol/contracts/dist/utils/MerkleTree";
2
2
  import { RunningBalances, PoolRebalanceLeaf, Clients, SpokePoolTargetBalance } from "../../../interfaces";
3
3
  import { SpokePoolClient } from "../../SpokePoolClient";
4
- import { BigNumber, bnZero, compareAddresses } from "../../../utils";
4
+ import { BigNumber, bnZero, compareAddresses, EvmAddress } from "../../../utils";
5
5
  import { HubPoolClient } from "../../HubPoolClient";
6
6
  import { V3DepositWithBlock } from "./shims";
7
7
  import { AcrossConfigStoreClient } from "../../AcrossConfigStoreClient";
@@ -151,7 +151,7 @@ export function addLastRunningBalance(
151
151
  const { runningBalance } = hubPoolClient.getRunningBalanceBeforeBlockForChain(
152
152
  latestMainnetBlock,
153
153
  Number(repaymentChainId),
154
- l1TokenAddress
154
+ EvmAddress.from(l1TokenAddress)
155
155
  );
156
156
  if (!runningBalance.eq(bnZero)) {
157
157
  updateRunningBalance(runningBalances, Number(repaymentChainId), l1TokenAddress, runningBalance);
@@ -172,7 +172,7 @@ export function updateRunningBalanceForDeposit(
172
172
  deposit.originChainId,
173
173
  mainnetBundleEndBlock
174
174
  );
175
- updateRunningBalance(runningBalances, deposit.originChainId, l1TokenCounterpart, updateAmount);
175
+ updateRunningBalance(runningBalances, deposit.originChainId, l1TokenCounterpart.toEvmAddress(), updateAmount);
176
176
  }
177
177
 
178
178
  export function constructPoolRebalanceLeaves(
@@ -253,7 +253,7 @@ export function constructPoolRebalanceLeaves(
253
253
  runningBalances: leafRunningBalances,
254
254
  groupIndex: groupIndexForChainId++,
255
255
  leafId: leaves.length,
256
- l1Tokens: l1TokensToIncludeInThisLeaf,
256
+ l1Tokens: l1TokensToIncludeInThisLeaf.map((l1TokenAddr: string) => EvmAddress.from(l1TokenAddr)),
257
257
  });
258
258
  }
259
259
  });
@@ -15,7 +15,7 @@ import {
15
15
  type,
16
16
  } from "superstruct";
17
17
  import { UNDEFINED_MESSAGE_HASH } from "../../../constants";
18
- import { BigNumber } from "../../../utils";
18
+ import { BigNumber, toAddressType, Address } from "../../../utils";
19
19
 
20
20
  const PositiveIntegerStringSS = pattern(string(), /\d+/);
21
21
  const Web3AddressSS = pattern(string(), /^0x[a-fA-F0-9]{40}$/);
@@ -31,19 +31,23 @@ const BigNumberType = coerce(instance(BigNumber), union([string(), number()]), (
31
31
  }
32
32
  });
33
33
 
34
+ const AddressType = coerce(instance(Address), string(), (value) => {
35
+ return toAddressType(value);
36
+ });
37
+
34
38
  const FillTypeSS = number();
35
39
 
36
40
  const V3RelayDataSS = {
37
- inputToken: string(),
41
+ inputToken: AddressType,
38
42
  inputAmount: BigNumberType,
39
- outputToken: string(),
43
+ outputToken: AddressType,
40
44
  outputAmount: BigNumberType,
41
45
  fillDeadline: number(),
42
- exclusiveRelayer: string(),
46
+ exclusiveRelayer: AddressType,
43
47
  exclusivityDeadline: number(),
44
48
  originChainId: number(),
45
- depositor: string(),
46
- recipient: string(),
49
+ depositor: AddressType,
50
+ recipient: AddressType,
47
51
  depositId: BigNumberType,
48
52
  message: string(),
49
53
  };
@@ -67,7 +71,7 @@ const V3DepositSS = {
67
71
  quoteTimestamp: number(),
68
72
  relayerFeePct: optional(BigNumberType),
69
73
  speedUpSignature: optional(string()),
70
- updatedRecipient: optional(string()),
74
+ updatedRecipient: optional(AddressType),
71
75
  updatedOutputAmount: optional(BigNumberType),
72
76
  updatedMessage: optional(string()),
73
77
  };
@@ -88,7 +92,7 @@ const V3DepositWithBlockLpFeeSS = object({
88
92
  const V3RelayExecutionEventInfoSS = object({
89
93
  updatedOutputAmount: BigNumberType,
90
94
  fillType: FillTypeSS,
91
- updatedRecipient: string(),
95
+ updatedRecipient: AddressType,
92
96
  updatedMessage: optional(string()),
93
97
  updatedMessageHash: defaulted(string(), UNDEFINED_MESSAGE_HASH),
94
98
  });
@@ -98,7 +102,7 @@ const V3FillSS = {
98
102
  message: optional(string()),
99
103
  messageHash: defaulted(string(), UNDEFINED_MESSAGE_HASH),
100
104
  destinationChainId: number(),
101
- relayer: string(),
105
+ relayer: AddressType,
102
106
  repaymentChainId: number(),
103
107
  relayExecutionInfo: V3RelayExecutionEventInfoSS,
104
108
  quoteTimestamp: number(),
@@ -12,7 +12,7 @@ import {
12
12
  DestinationTokenWithBlock,
13
13
  DisputedRootBundle,
14
14
  ExecutedRootBundle,
15
- L1Token,
15
+ TokenInfo,
16
16
  Log,
17
17
  LpToken,
18
18
  PendingRootBundle,
@@ -20,6 +20,7 @@ import {
20
20
  RealizedLpFee,
21
21
  SetPoolRebalanceRoot,
22
22
  TokenRunningBalance,
23
+ L1TokenInfo,
23
24
  } from "../interfaces";
24
25
  import * as lpFeeCalculator from "../lpFeeCalculator";
25
26
  import { EVMBlockFinder } from "../arch/evm";
@@ -43,10 +44,12 @@ import {
43
44
  toBN,
44
45
  getTokenInfo,
45
46
  getUsdcSymbol,
46
- compareAddressesSimple,
47
47
  chainIsSvm,
48
48
  getDeployedAddress,
49
49
  SvmAddress,
50
+ EvmAddress,
51
+ Address,
52
+ toAddressType,
50
53
  } from "../utils";
51
54
  import { AcrossConfigStoreClient as ConfigStoreClient } from "./AcrossConfigStoreClient/AcrossConfigStoreClient";
52
55
  import { BaseAbstractClient, isUpdateFailureReason, UpdateFailureReason } from "./BaseAbstractClient";
@@ -84,7 +87,8 @@ export type LpFeeRequest = Pick<Deposit, "originChainId" | "inputToken" | "input
84
87
  export class HubPoolClient extends BaseAbstractClient {
85
88
  // L1Token -> destinationChainId -> destinationToken
86
89
  protected l1TokensToDestinationTokens: L1TokensToDestinationTokens = {};
87
- protected l1Tokens: L1Token[] = []; // L1Tokens and their associated info.
90
+ protected l1Tokens: L1TokenInfo[] = []; // L1Tokens and their associated info.
91
+ // @dev `token` here is a 20-byte hex sting
88
92
  protected lpTokens: { [token: string]: LpToken } = {};
89
93
  protected proposedRootBundles: ProposedRootBundle[] = [];
90
94
  protected canceledRootBundles: CancelledRootBundle[] = [];
@@ -92,6 +96,7 @@ export class HubPoolClient extends BaseAbstractClient {
92
96
  protected executedRootBundles: ExecutedRootBundle[] = [];
93
97
  protected crossChainContracts: { [l2ChainId: number]: CrossChainContractsSet[] } = {};
94
98
  protected l1TokensToDestinationTokensWithBlock: {
99
+ // @dev `l1Token` here is a 20-byte hex sting
95
100
  [l1Token: string]: { [destinationChainId: number]: DestinationTokenWithBlock[] };
96
101
  } = {};
97
102
  protected pendingRootBundle: PendingRootBundle | undefined;
@@ -160,7 +165,7 @@ export class HubPoolClient extends BaseAbstractClient {
160
165
  return this.executedRootBundles;
161
166
  }
162
167
 
163
- getSpokePoolForBlock(chain: number, block: number = Number.MAX_SAFE_INTEGER): string {
168
+ getSpokePoolForBlock(chain: number, block: number = Number.MAX_SAFE_INTEGER): Address {
164
169
  if (!this.crossChainContracts[chain]) {
165
170
  throw new Error(`No cross chain contracts set for ${chain}`);
166
171
  }
@@ -174,33 +179,33 @@ export class HubPoolClient extends BaseAbstractClient {
174
179
  }
175
180
  }
176
181
 
177
- getSpokePoolActivationBlock(chain: number, spokePool: string): number | undefined {
182
+ getSpokePoolActivationBlock(chain: number, spokePool: Address): number | undefined {
178
183
  // Return first time that this spoke pool was registered in the HubPool as a cross chain contract. We can use
179
184
  // this block as the oldest block that we should query for SpokePoolClient purposes.
180
- const mostRecentSpokePoolUpdateBeforeBlock = this.crossChainContracts[chain].find(
181
- (crossChainContract) => crossChainContract.spokePool === spokePool
185
+ const mostRecentSpokePoolUpdateBeforeBlock = this.crossChainContracts[chain].find((crossChainContract) =>
186
+ crossChainContract.spokePool.eq(spokePool)
182
187
  );
183
188
  return mostRecentSpokePoolUpdateBeforeBlock?.blockNumber;
184
189
  }
185
190
 
186
191
  // Returns the latest L2 token to use for an L1 token as of the input hub block.
187
192
  getL2TokenForL1TokenAtBlock(
188
- l1Token: string,
193
+ l1Token: EvmAddress,
189
194
  destinationChainId: number,
190
195
  latestHubBlock = Number.MAX_SAFE_INTEGER
191
- ): string {
192
- if (!this.l1TokensToDestinationTokensWithBlock?.[l1Token]?.[destinationChainId]) {
196
+ ): Address {
197
+ if (!this.l1TokensToDestinationTokensWithBlock?.[l1Token.toEvmAddress()]?.[destinationChainId]) {
193
198
  const chain = getNetworkName(destinationChainId);
194
- const { symbol } = this.l1Tokens.find(({ address }) => address === l1Token) ?? { symbol: l1Token };
199
+ const { symbol } = this.l1Tokens.find(({ address }) => address.eq(l1Token)) ?? { symbol: l1Token.toString() };
195
200
  throw new Error(`Could not find SpokePool mapping for ${symbol} on ${chain} and L1 token ${l1Token}`);
196
201
  }
197
202
  // Find the last mapping published before the target block.
198
203
  const l2Token: DestinationTokenWithBlock | undefined = sortEventsDescending(
199
- this.l1TokensToDestinationTokensWithBlock[l1Token][destinationChainId]
204
+ this.l1TokensToDestinationTokensWithBlock[l1Token.toEvmAddress()][destinationChainId]
200
205
  ).find((mapping: DestinationTokenWithBlock) => mapping.blockNumber <= latestHubBlock);
201
206
  if (!l2Token) {
202
207
  const chain = getNetworkName(destinationChainId);
203
- const { symbol } = this.l1Tokens.find(({ address }) => address === l1Token) ?? { symbol: l1Token };
208
+ const { symbol } = this.l1Tokens.find(({ address }) => address.eq(l1Token)) ?? { symbol: l1Token.toString() };
204
209
  throw new Error(
205
210
  `Could not find SpokePool mapping for ${symbol} on ${chain} at or before HubPool block ${latestHubBlock}!`
206
211
  );
@@ -208,18 +213,23 @@ export class HubPoolClient extends BaseAbstractClient {
208
213
  return l2Token.l2Token;
209
214
  }
210
215
 
216
+ // TODO: this might have to deal with truncated Solana addresses? Depends on what input is given actually
217
+ // TODO: might craete `getL1TokenForL2EVMTokenAtBlock` and some other fn
211
218
  // Returns the latest L1 token to use for an L2 token as of the input hub block.
212
219
  getL1TokenForL2TokenAtBlock(
213
- l2Token: string,
220
+ l2Token: Address, // ! TODO: assuming that for Svm token, we'll have a proper full SvmAddress in this var
214
221
  destinationChainId: number,
215
222
  latestHubBlock = Number.MAX_SAFE_INTEGER
216
- ): string {
223
+ ): EvmAddress {
217
224
  const l2Tokens = Object.keys(this.l1TokensToDestinationTokensWithBlock)
218
- .filter((l1Token) => this.l2TokenEnabledForL1Token(l1Token, destinationChainId))
225
+ .filter((l1Token) => this.l2TokenEnabledForL1Token(EvmAddress.from(l1Token), destinationChainId))
219
226
  .map((l1Token) => {
220
227
  // Return all matching L2 token mappings that are equal to or earlier than the target block.
221
228
  return this.l1TokensToDestinationTokensWithBlock[l1Token][destinationChainId].filter(
222
- (mapping) => mapping.l2Token === l2Token && mapping.blockNumber <= latestHubBlock
229
+ // ! TODO: Okay. Here, in `l1TokensToDestinationTokensWithBlock`, we might be saving truncated solana addresses (as `l1TokensToDestinationTokensWithBlock` is probably generated from events)
230
+ // ! TODO: Considering this, this filtering should be a bit different. If .isSvmAddress => check not for equality, but for *truncated equality*. If .isEvmAddress, check for equality
231
+ (dstTokenWithBlock) =>
232
+ dstTokenWithBlock.l2Token.eq(l2Token) && dstTokenWithBlock.blockNumber <= latestHubBlock
223
233
  );
224
234
  })
225
235
  .flat();
@@ -235,32 +245,33 @@ export class HubPoolClient extends BaseAbstractClient {
235
245
 
236
246
  protected getL1TokenForDeposit(
237
247
  deposit: Pick<DepositWithBlock, "originChainId" | "inputToken" | "quoteBlockNumber">
238
- ): string {
248
+ ): EvmAddress {
239
249
  // L1-->L2 token mappings are set via PoolRebalanceRoutes which occur on mainnet,
240
250
  // so we use the latest token mapping. This way if a very old deposit is filled, the relayer can use the
241
251
  // latest L2 token mapping to find the L1 token counterpart.
242
252
  return this.getL1TokenForL2TokenAtBlock(deposit.inputToken, deposit.originChainId, deposit.quoteBlockNumber);
243
253
  }
244
254
 
245
- l2TokenEnabledForL1Token(l1Token: string, destinationChainId: number): boolean {
246
- return this.l1TokensToDestinationTokens?.[l1Token]?.[destinationChainId] != undefined;
255
+ l2TokenEnabledForL1Token(l1Token: EvmAddress, destinationChainId: number): boolean {
256
+ return this.l1TokensToDestinationTokens?.[l1Token.toEvmAddress()]?.[destinationChainId] != undefined;
247
257
  }
248
258
 
249
- l2TokenEnabledForL1TokenAtBlock(l1Token: string, destinationChainId: number, hubBlockNumber: number): boolean {
259
+ l2TokenEnabledForL1TokenAtBlock(l1Token: EvmAddress, destinationChainId: number, hubBlockNumber: number): boolean {
250
260
  // Find the last mapping published before the target block.
251
261
  const l2Token: DestinationTokenWithBlock | undefined = sortEventsDescending(
252
- this.l1TokensToDestinationTokensWithBlock?.[l1Token]?.[destinationChainId] ?? []
262
+ this.l1TokensToDestinationTokensWithBlock?.[l1Token.toEvmAddress()]?.[destinationChainId] ?? []
253
263
  ).find((mapping: DestinationTokenWithBlock) => mapping.blockNumber <= hubBlockNumber);
254
264
  return l2Token !== undefined;
255
265
  }
256
266
 
257
- l2TokenHasPoolRebalanceRoute(l2Token: string, l2ChainId: number, hubPoolBlock = this.latestHeightSearched): boolean {
267
+ l2TokenHasPoolRebalanceRoute(l2Token: Address, l2ChainId: number, hubPoolBlock = this.latestHeightSearched): boolean {
258
268
  return Object.values(this.l1TokensToDestinationTokensWithBlock).some((destinationTokenMapping) => {
259
269
  return Object.entries(destinationTokenMapping).some(([_l2ChainId, setPoolRebalanceRouteEvents]) => {
260
270
  return setPoolRebalanceRouteEvents.some((e) => {
261
271
  return (
262
272
  e.blockNumber <= hubPoolBlock &&
263
- compareAddressesSimple(e.l2Token, l2Token) &&
273
+ // TODO: compare the last 20 bytes of l2Token only. Solana workaround, is this correct?
274
+ e.l2Token.eq(l2Token) &&
264
275
  Number(_l2ChainId) === l2ChainId
265
276
  );
266
277
  });
@@ -271,15 +282,16 @@ export class HubPoolClient extends BaseAbstractClient {
271
282
  /**
272
283
  * @dev If tokenAddress + chain do not exist in TOKEN_SYMBOLS_MAP then this will throw.
273
284
  * @param tokenAddress Token address on `chain`
274
- * @param chain Chain where the `tokenAddress` exists in TOKEN_SYMBOLS_MAP.
285
+ * @param chainId Chain where the `tokenAddress` exists in TOKEN_SYMBOLS_MAP.
275
286
  * @returns Token info for the given token address on the L2 chain including symbol and decimal.
276
287
  */
277
- getTokenInfoForAddress(tokenAddress: string, chain: number): L1Token {
278
- const tokenInfo = getTokenInfo(tokenAddress, chain);
288
+ // TODO: didn't change `tokenAddress` here to Address because of downstream getTokenInfo impl
289
+ getTokenInfoForAddress(tokenAddress: string, chainId: number): TokenInfo {
290
+ const tokenInfo = getTokenInfo(tokenAddress, chainId);
279
291
  // @dev Temporarily handle case where an L2 token for chain ID can map to more than one TOKEN_SYMBOLS_MAP
280
292
  // entry. For example, L2 Bridged USDC maps to both the USDC and USDC.e/USDbC entries in TOKEN_SYMBOLS_MAP.
281
- if (tokenInfo.symbol.toLowerCase() === "usdc" && chain !== this.chainId) {
282
- tokenInfo.symbol = getUsdcSymbol(tokenAddress, chain) ?? "UNKNOWN";
293
+ if (tokenInfo.symbol.toLowerCase() === "usdc" && chainId !== this.chainId) {
294
+ tokenInfo.symbol = getUsdcSymbol(tokenAddress, chainId) ?? "UNKNOWN";
283
295
  }
284
296
  return tokenInfo;
285
297
  }
@@ -311,7 +323,7 @@ export class HubPoolClient extends BaseAbstractClient {
311
323
  return blockNumbers;
312
324
  }
313
325
 
314
- async getCurrentPoolUtilization(l1Token: string): Promise<BigNumber> {
326
+ async getCurrentPoolUtilization(l1Token: EvmAddress): Promise<BigNumber> {
315
327
  const blockNumber = this.latestHeightSearched ?? (await this.hubPool.provider.getBlockNumber());
316
328
  return await this.getUtilization(l1Token, blockNumber, bnZero, getCurrentTime(), 0);
317
329
  }
@@ -326,7 +338,7 @@ export class HubPoolClient extends BaseAbstractClient {
326
338
  * @returns HubPool utilization at `blockNumber` after optional `amount` increase in utilization.
327
339
  */
328
340
  protected async getUtilization(
329
- hubPoolToken: string,
341
+ hubPoolToken: EvmAddress,
330
342
  blockNumber: number,
331
343
  depositAmount: BigNumber,
332
344
  timestamp: number,
@@ -337,10 +349,14 @@ export class HubPoolClient extends BaseAbstractClient {
337
349
  const overrides = { blockTag: blockNumber };
338
350
  if (depositAmount.eq(0)) {
339
351
  // For zero amount, just get the utilisation at `blockNumber`.
340
- return await this.hubPool.callStatic.liquidityUtilizationCurrent(hubPoolToken, overrides);
352
+ return await this.hubPool.callStatic.liquidityUtilizationCurrent(hubPoolToken.toEvmAddress(), overrides);
341
353
  }
342
354
 
343
- return await this.hubPool.callStatic.liquidityUtilizationPostRelay(hubPoolToken, depositAmount, overrides);
355
+ return await this.hubPool.callStatic.liquidityUtilizationPostRelay(
356
+ hubPoolToken.toEvmAddress(),
357
+ depositAmount,
358
+ overrides
359
+ );
344
360
  };
345
361
 
346
362
  // Resolve the cache locally so that we can appease typescript
@@ -355,8 +371,8 @@ export class HubPoolClient extends BaseAbstractClient {
355
371
  // @note Avoid collisions with pre-existing cache keys by appending an underscore (_) for post-relay utilization.
356
372
  // @fixme This can be removed once the existing keys have been ejected from the cache (i.e. 7 days).
357
373
  const key = depositAmount.eq(0)
358
- ? `utilization_${hubPoolToken}_${blockNumber}`
359
- : `utilization_${hubPoolToken}_${blockNumber}_${depositAmount.toString()}_`;
374
+ ? `utilization_${hubPoolToken.toEvmAddress()}_${blockNumber}`
375
+ : `utilization_${hubPoolToken.toEvmAddress()}_${blockNumber}_${depositAmount.toString()}_`;
360
376
  const result = await cache.get<string>(key);
361
377
  if (isDefined(result)) {
362
378
  return BigNumber.from(result);
@@ -393,14 +409,14 @@ export class HubPoolClient extends BaseAbstractClient {
393
409
 
394
410
  // Map SpokePool token addresses to HubPool token addresses.
395
411
  // Note: Should only be accessed via `getHubPoolToken()` or `getHubPoolTokens()`.
396
- const hubPoolTokens: { [k: string]: string } = {};
397
- const getHubPoolToken = (deposit: LpFeeRequest, quoteBlockNumber: number): string | undefined => {
412
+ const hubPoolTokens: { [k: string]: EvmAddress } = {};
413
+ const getHubPoolToken = (deposit: LpFeeRequest, quoteBlockNumber: number): EvmAddress | undefined => {
398
414
  const tokenKey = `${deposit.originChainId}-${deposit.inputToken}`;
399
415
  if (this.l2TokenHasPoolRebalanceRoute(deposit.inputToken, deposit.originChainId, quoteBlockNumber)) {
400
416
  return (hubPoolTokens[tokenKey] ??= this.getL1TokenForDeposit({ ...deposit, quoteBlockNumber }));
401
417
  } else return undefined;
402
418
  };
403
- const getHubPoolTokens = (): string[] => dedupArray(Object.values(hubPoolTokens).filter(isDefined));
419
+ const getHubPoolTokens = (): EvmAddress[] => dedupArray(Object.values(hubPoolTokens).filter(isDefined));
404
420
 
405
421
  // Helper to resolve the unqiue hubPoolToken & quoteTimestamp mappings.
406
422
  const resolveUniqueQuoteTimestamps = (deposit: LpFeeRequest): void => {
@@ -414,17 +430,17 @@ export class HubPoolClient extends BaseAbstractClient {
414
430
  }
415
431
 
416
432
  // Append the quoteTimestamp for this HubPool token, if it isn't already enqueued.
417
- utilizationTimestamps[hubPoolToken] ??= [];
418
- if (!utilizationTimestamps[hubPoolToken].includes(quoteTimestamp)) {
419
- utilizationTimestamps[hubPoolToken].push(quoteTimestamp);
433
+ utilizationTimestamps[hubPoolToken.toEvmAddress()] ??= [];
434
+ if (!utilizationTimestamps[hubPoolToken.toEvmAddress()].includes(quoteTimestamp)) {
435
+ utilizationTimestamps[hubPoolToken.toEvmAddress()].push(quoteTimestamp);
420
436
  }
421
437
  };
422
438
 
423
439
  // Helper to resolve existing HubPool token utilisation for an array of unique block numbers.
424
440
  // Produces a mapping of blockNumber -> utilization for a specific token.
425
- const resolveUtilization = async (hubPoolToken: string): Promise<Record<number, BigNumber>> => {
441
+ const resolveUtilization = async (hubPoolToken: EvmAddress): Promise<Record<number, BigNumber>> => {
426
442
  return Object.fromEntries(
427
- await mapAsync(utilizationTimestamps[hubPoolToken], async (quoteTimestamp) => {
443
+ await mapAsync(utilizationTimestamps[hubPoolToken.toEvmAddress()], async (quoteTimestamp) => {
428
444
  const blockNumber = quoteBlocks[quoteTimestamp];
429
445
  const utilization = await this.getUtilization(
430
446
  hubPoolToken,
@@ -460,7 +476,7 @@ export class HubPoolClient extends BaseAbstractClient {
460
476
  quoteBlock
461
477
  );
462
478
 
463
- const preUtilization = utilization[hubPoolToken][quoteBlock];
479
+ const preUtilization = utilization[hubPoolToken.toEvmAddress()][quoteBlock];
464
480
  const postUtilization = await this.getUtilization(
465
481
  hubPoolToken,
466
482
  quoteBlock,
@@ -488,7 +504,10 @@ export class HubPoolClient extends BaseAbstractClient {
488
504
  // For each token / quoteBlock pair, resolve the utilisation for each quoted block.
489
505
  // This can be reused for each deposit with the same HubPool token and quoteTimestamp pair.
490
506
  utilization = Object.fromEntries(
491
- await mapAsync(getHubPoolTokens(), async (hubPoolToken) => [hubPoolToken, await resolveUtilization(hubPoolToken)])
507
+ await mapAsync(getHubPoolTokens(), async (hubPoolToken) => [
508
+ hubPoolToken.toEvmAddress(),
509
+ await resolveUtilization(hubPoolToken),
510
+ ])
492
511
  );
493
512
 
494
513
  // For each deposit, compute the post-relay HubPool utilisation independently.
@@ -506,22 +525,22 @@ export class HubPoolClient extends BaseAbstractClient {
506
525
  });
507
526
  }
508
527
 
509
- getL1Tokens(): L1Token[] {
528
+ getL1Tokens(): L1TokenInfo[] {
510
529
  return this.l1Tokens;
511
530
  }
512
531
 
513
- getTokenInfoForL1Token(l1Token: string): L1Token | undefined {
514
- return this.l1Tokens.find((token) => token.address === l1Token);
532
+ getTokenInfoForL1Token(l1Token: EvmAddress): L1TokenInfo | undefined {
533
+ return this.l1Tokens.find((token) => token.address.eq(l1Token));
515
534
  }
516
535
 
517
- getLpTokenInfoForL1Token(l1Token: string): LpToken | undefined {
518
- return this.lpTokens[l1Token];
536
+ getLpTokenInfoForL1Token(l1Token: EvmAddress): LpToken | undefined {
537
+ return this.lpTokens[l1Token.toEvmAddress()];
519
538
  }
520
539
 
521
540
  areTokensEquivalent(
522
- tokenA: string,
541
+ tokenA: Address,
523
542
  chainIdA: number,
524
- tokenB: string,
543
+ tokenB: Address,
525
544
  chainIdB: number,
526
545
  hubPoolBlock = this.latestHeightSearched
527
546
  ): boolean {
@@ -534,14 +553,14 @@ export class HubPoolClient extends BaseAbstractClient {
534
553
  // Resolve both SpokePool tokens back to their respective HubPool tokens and verify that they match.
535
554
  const l1TokenA = this.getL1TokenForL2TokenAtBlock(tokenA, chainIdA, hubPoolBlock);
536
555
  const l1TokenB = this.getL1TokenForL2TokenAtBlock(tokenB, chainIdB, hubPoolBlock);
537
- if (l1TokenA !== l1TokenB) {
556
+ if (!l1TokenA.eq(l1TokenB)) {
538
557
  return false;
539
558
  }
540
559
 
541
560
  // Resolve both HubPool tokens back to a current SpokePool token and verify that they match.
542
561
  const _tokenA = this.getL2TokenForL1TokenAtBlock(l1TokenA, chainIdA, hubPoolBlock);
543
562
  const _tokenB = this.getL2TokenForL1TokenAtBlock(l1TokenB, chainIdB, hubPoolBlock);
544
- return tokenA === _tokenA && tokenB === _tokenB;
563
+ return tokenA.eq(_tokenA) && tokenB.eq(_tokenB);
545
564
  }
546
565
 
547
566
  getSpokeActivationBlockForChain(chainId: number): number {
@@ -778,34 +797,35 @@ export class HubPoolClient extends BaseAbstractClient {
778
797
  getLatestExecutedRootBundleContainingL1Token(
779
798
  block: number,
780
799
  chain: number,
781
- l1Token: string
800
+ l1Token: EvmAddress
782
801
  ): ExecutedRootBundle | undefined {
783
802
  // Search ExecutedRootBundles in descending block order to find the most recent event before the target block.
784
803
  return sortEventsDescending(this.executedRootBundles).find((executedLeaf: ExecutedRootBundle) => {
785
804
  return (
786
805
  executedLeaf.blockNumber <= block &&
787
806
  executedLeaf.chainId === chain &&
788
- executedLeaf.l1Tokens.some((token) => token.toLowerCase() === l1Token.toLowerCase())
807
+ executedLeaf.l1Tokens.some((token) => token.eq(l1Token))
789
808
  );
790
809
  });
791
810
  }
792
811
 
793
- getRunningBalanceBeforeBlockForChain(block: number, chain: number, l1Token: string): TokenRunningBalance {
812
+ getRunningBalanceBeforeBlockForChain(block: number, chain: number, l1Token: EvmAddress): TokenRunningBalance {
794
813
  const executedRootBundle = this.getLatestExecutedRootBundleContainingL1Token(block, chain, l1Token);
795
814
 
796
815
  return this.getRunningBalanceForToken(l1Token, executedRootBundle);
797
816
  }
798
817
 
799
818
  public getRunningBalanceForToken(
800
- l1Token: string,
819
+ l1Token: EvmAddress,
801
820
  executedRootBundle: ExecutedRootBundle | undefined
802
821
  ): TokenRunningBalance {
803
822
  let runningBalance = toBN(0);
804
823
  if (executedRootBundle) {
805
- const indexOfL1Token = executedRootBundle.l1Tokens
806
- .map((l1Token) => l1Token.toLowerCase())
807
- .indexOf(l1Token.toLowerCase());
808
- runningBalance = executedRootBundle.runningBalances[indexOfL1Token];
824
+ const indexOfL1Token = executedRootBundle.l1Tokens.findIndex((tokenInBundle) => tokenInBundle.eq(l1Token));
825
+ // TODO: not sure this if is required. Wasn't here before. Probably `getRunningBalanceForToken` is used on checked tokens only
826
+ if (indexOfL1Token !== -1) {
827
+ runningBalance = executedRootBundle.runningBalances[indexOfL1Token];
828
+ }
809
829
  }
810
830
 
811
831
  return { runningBalance };
@@ -898,9 +918,9 @@ export class HubPoolClient extends BaseAbstractClient {
898
918
 
899
919
  if (eventsToQuery.includes("CrossChainContractsSet")) {
900
920
  for (const event of events["CrossChainContractsSet"]) {
901
- const args = spreadEventWithBlockNumber(event) as CrossChainContractsSet;
921
+ const args = spreadEventWithBlockNumber(event) as CrossChainContractsSet & { spokePool: string };
902
922
  const dataToAdd: CrossChainContractsSet = {
903
- spokePool: args.spokePool,
923
+ spokePool: toAddressType(args.spokePool, this.chainId),
904
924
  blockNumber: args.blockNumber,
905
925
  txnRef: args.txnRef,
906
926
  logIndex: args.logIndex,
@@ -916,16 +936,15 @@ export class HubPoolClient extends BaseAbstractClient {
916
936
  if (!solanaSpokePool) {
917
937
  throw new Error(`SVM spoke pool not found for chain ${args.l2ChainId}`);
918
938
  }
919
- const truncatedAddress = SvmAddress.from(solanaSpokePool).toEvmAddress();
939
+ const svmSpoke = SvmAddress.from(solanaSpokePool);
920
940
  // Verify the event address matches our expected truncated address
921
- if (args.spokePool.toLowerCase() !== truncatedAddress.toLowerCase()) {
941
+ if (args.spokePool.toLowerCase() !== svmSpoke.truncateToBytes20().toLowerCase()) {
922
942
  throw new Error(
923
943
  `SVM spoke pool address mismatch for chain ${args.l2ChainId}. ` +
924
- `Expected ${truncatedAddress}, got ${args.spokePool}`
944
+ `Expected ${svmSpoke.truncateToBytes20()}, got ${args.spokePool}`
925
945
  );
926
946
  }
927
- // Store the full Solana address
928
- dataToAdd.spokePool = SvmAddress.from(solanaSpokePool).toBytes32();
947
+ dataToAdd.spokePool = svmSpoke;
929
948
  }
930
949
  assign(this.crossChainContracts, [args.l2ChainId], [dataToAdd]);
931
950
  }
@@ -933,34 +952,37 @@ export class HubPoolClient extends BaseAbstractClient {
933
952
 
934
953
  if (eventsToQuery.includes("SetPoolRebalanceRoute")) {
935
954
  for (const event of events["SetPoolRebalanceRoute"]) {
936
- const args = spreadEventWithBlockNumber(event) as SetPoolRebalanceRoot;
955
+ const args = spreadEventWithBlockNumber(event) as SetPoolRebalanceRoot & {
956
+ l1Token: string;
957
+ destinationToken: string;
958
+ };
937
959
 
938
960
  // If the destination chain is SVM, then we need to convert the destination token to the Solana address.
939
961
  // This is because the HubPool contract only holds a truncated address for the USDC token and currently
940
962
  // only supports USDC as a destination token for Solana.
941
- let destinationToken = args.destinationToken;
963
+ let destinationToken = toAddressType(args.destinationToken, this.chainId);
942
964
  if (chainIsSvm(args.destinationChainId)) {
943
965
  const usdcTokenSol = TOKEN_SYMBOLS_MAP.USDC.addresses[args.destinationChainId];
944
- const truncatedAddress = SvmAddress.from(usdcTokenSol).toEvmAddress();
945
- if (destinationToken.toLowerCase() !== truncatedAddress.toLowerCase()) {
966
+ const svmUsdc = SvmAddress.from(usdcTokenSol);
967
+ if (destinationToken.truncateToBytes20() !== svmUsdc.truncateToBytes20()) {
946
968
  throw new Error(
947
969
  `SVM USDC address mismatch for chain ${args.destinationChainId}. ` +
948
- `Expected ${truncatedAddress}, got ${destinationToken}`
970
+ `Expected ${svmUsdc.truncateToBytes20()}, got ${destinationToken}`
949
971
  );
950
972
  }
951
- destinationToken = SvmAddress.from(usdcTokenSol).toBytes32();
973
+ destinationToken = svmUsdc;
952
974
  }
953
975
 
954
976
  // If the destination token is set to the zero address in an event, then this means Across should no longer
955
977
  // rebalance to this chain.
956
- if (destinationToken !== ZERO_ADDRESS) {
978
+ if (destinationToken.toAddress() !== ZERO_ADDRESS) {
957
979
  assign(this.l1TokensToDestinationTokens, [args.l1Token, args.destinationChainId], destinationToken);
958
980
  assign(
959
981
  this.l1TokensToDestinationTokensWithBlock,
960
982
  [args.l1Token, args.destinationChainId],
961
983
  [
962
984
  {
963
- l1Token: args.l1Token,
985
+ l1Token: toAddressType(args.l1Token, this.chainId),
964
986
  l2Token: destinationToken,
965
987
  blockNumber: args.blockNumber,
966
988
  txnIndex: args.txnIndex,
@@ -982,7 +1004,15 @@ export class HubPoolClient extends BaseAbstractClient {
982
1004
  );
983
1005
 
984
1006
  const [tokenInfo, lpTokenInfo] = await Promise.all([
985
- Promise.all(uniqueL1Tokens.map((l1Token: string) => fetchTokenInfo(l1Token, this.hubPool.provider))),
1007
+ Promise.all(
1008
+ uniqueL1Tokens.map(async (l1Token: string) => {
1009
+ const tokenInfo: L1TokenInfo = await fetchTokenInfo(l1Token, this.hubPool.provider);
1010
+ return {
1011
+ ...tokenInfo,
1012
+ address: EvmAddress.from(l1Token),
1013
+ };
1014
+ })
1015
+ ),
986
1016
  Promise.all(
987
1017
  uniqueL1Tokens.map(
988
1018
  async (l1Token: string) => await this.hubPool.pooledTokens(l1Token, { blockTag: update.searchEndBlock })
@@ -990,7 +1020,7 @@ export class HubPoolClient extends BaseAbstractClient {
990
1020
  ),
991
1021
  ]);
992
1022
  for (const info of tokenInfo) {
993
- if (!this.l1Tokens.find((token) => compareAddressesSimple(token.address, info.address))) {
1023
+ if (!this.l1Tokens.find((token) => token.address.eq(info.address))) {
994
1024
  if (info.decimals > 0 && info.decimals <= 18) {
995
1025
  this.l1Tokens.push(info);
996
1026
  } else {
@@ -1011,7 +1041,13 @@ export class HubPoolClient extends BaseAbstractClient {
1011
1041
  this.proposedRootBundles.push(
1012
1042
  ...events["ProposeRootBundle"]
1013
1043
  .filter((event) => !this.configOverride.ignoredHubProposedBundles.includes(event.blockNumber))
1014
- .map((event) => spreadEventWithBlockNumber(event) as ProposedRootBundle)
1044
+ .map((_event) => {
1045
+ const args = spreadEventWithBlockNumber(_event) as ProposedRootBundle & { proposer: string };
1046
+ return {
1047
+ ...args,
1048
+ proposer: toAddressType(args.proposer, this.chainId),
1049
+ };
1050
+ })
1015
1051
  );
1016
1052
  }
1017
1053
 
@@ -1034,7 +1070,7 @@ export class HubPoolClient extends BaseAbstractClient {
1034
1070
  }
1035
1071
 
1036
1072
  // Set running balances and incentive balances for this bundle.
1037
- const executedRootBundle = spreadEventWithBlockNumber(event) as ExecutedRootBundle;
1073
+ const executedRootBundle = spreadEventWithBlockNumber(event) as ExecutedRootBundle & { l1Tokens: string[] };
1038
1074
  const { l1Tokens, runningBalances } = executedRootBundle;
1039
1075
  const nTokens = l1Tokens.length;
1040
1076
 
@@ -1046,7 +1082,11 @@ export class HubPoolClient extends BaseAbstractClient {
1046
1082
  );
1047
1083
  }
1048
1084
  executedRootBundle.runningBalances = runningBalances.slice(0, nTokens);
1049
- this.executedRootBundles.push(executedRootBundle);
1085
+ const executedRootBundleWithL1Tokens = {
1086
+ ...executedRootBundle,
1087
+ l1Tokens: executedRootBundle.l1Tokens.map(toAddressType, this.chainId),
1088
+ };
1089
+ this.executedRootBundles.push(executedRootBundleWithL1Tokens);
1050
1090
  }
1051
1091
  }
1052
1092
 
@@ -17,6 +17,7 @@ import {
17
17
  MakeOptional,
18
18
  toBN,
19
19
  EvmAddress,
20
+ toAddressType,
20
21
  } from "../../utils";
21
22
  import {
22
23
  EventSearchConfig,
@@ -194,6 +195,11 @@ export class EVMSpokePoolClient extends SpokePoolClient {
194
195
 
195
196
  deposit = {
196
197
  ...spreadEventWithBlockNumber(event),
198
+ inputToken: toAddressType(event.args.inputToken, this.chainId),
199
+ outputToken: toAddressType(event.args.outputToken, event.args.destinationChainId),
200
+ depositor: toAddressType(event.args.depositor, this.chainId),
201
+ recipient: toAddressType(event.args.recipient, event.args.destinationChainId),
202
+ exclusiveRelayer: toAddressType(event.args.exclusiveRelayer, event.args.destinationChainId),
197
203
  originChainId: this.chainId,
198
204
  quoteBlockNumber: await this.getBlockNumber(Number(event.args["quoteTimestamp"])),
199
205
  fromLiteChain: true, // To be updated immediately afterwards.