@across-protocol/sdk 4.2.16 → 4.3.1

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 (256) hide show
  1. package/dist/cjs/arch/evm/SpokeUtils.d.ts +8 -3
  2. package/dist/cjs/arch/evm/SpokeUtils.js +26 -11
  3. package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
  4. package/dist/cjs/arch/svm/SpokeUtils.d.ts +8 -2
  5. package/dist/cjs/arch/svm/SpokeUtils.js +41 -50
  6. package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
  7. package/dist/cjs/arch/svm/eventsClient.js +4 -2
  8. package/dist/cjs/arch/svm/eventsClient.js.map +1 -1
  9. package/dist/cjs/arch/svm/utils.d.ts +3 -3
  10. package/dist/cjs/arch/svm/utils.js +16 -14
  11. package/dist/cjs/arch/svm/utils.js.map +1 -1
  12. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  13. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
  14. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  15. package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
  16. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +59 -59
  17. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  18. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +16 -13
  19. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  20. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
  21. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +3 -2
  22. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  23. package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
  24. package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
  25. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +3 -3
  26. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
  27. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +71 -71
  28. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +13 -8
  29. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  30. package/dist/cjs/clients/HubPoolClient.d.ts +21 -21
  31. package/dist/cjs/clients/HubPoolClient.js +85 -58
  32. package/dist/cjs/clients/HubPoolClient.js.map +1 -1
  33. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
  34. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  35. package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js +1 -3
  36. package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
  37. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
  38. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +66 -46
  39. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  40. package/dist/cjs/clients/SpokePoolClient/index.d.ts +1 -0
  41. package/dist/cjs/clients/SpokePoolClient/index.js +3 -1
  42. package/dist/cjs/clients/SpokePoolClient/index.js.map +1 -1
  43. package/dist/cjs/clients/index.d.ts +1 -1
  44. package/dist/cjs/clients/index.js +2 -1
  45. package/dist/cjs/clients/index.js.map +1 -1
  46. package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +9 -9
  47. package/dist/cjs/clients/mocks/MockHubPoolClient.js +15 -9
  48. package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
  49. package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +5 -3
  50. package/dist/cjs/clients/mocks/MockSpokePoolClient.js +40 -36
  51. package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
  52. package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
  53. package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js +6 -4
  54. package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
  55. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
  56. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +2 -2
  57. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
  58. package/dist/cjs/interfaces/HubPool.d.ts +19 -14
  59. package/dist/cjs/interfaces/SpokePool.d.ts +18 -19
  60. package/dist/cjs/interfaces/SpokePool.js.map +1 -1
  61. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +17 -9
  62. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +24 -15
  63. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  64. package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
  65. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +8 -5
  66. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  67. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +13 -5
  68. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +61 -58
  69. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  70. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +15 -7
  71. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +13 -13
  72. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  73. package/dist/cjs/utils/AddressUtils.d.ts +12 -8
  74. package/dist/cjs/utils/AddressUtils.js +33 -36
  75. package/dist/cjs/utils/AddressUtils.js.map +1 -1
  76. package/dist/cjs/utils/DepositUtils.d.ts +2 -2
  77. package/dist/cjs/utils/DepositUtils.js +1 -1
  78. package/dist/cjs/utils/DepositUtils.js.map +1 -1
  79. package/dist/cjs/utils/SpokeUtils.d.ts +1 -3
  80. package/dist/cjs/utils/SpokeUtils.js +3 -25
  81. package/dist/cjs/utils/SpokeUtils.js.map +1 -1
  82. package/dist/cjs/utils/TokenUtils.d.ts +4 -4
  83. package/dist/cjs/utils/TokenUtils.js +5 -3
  84. package/dist/cjs/utils/TokenUtils.js.map +1 -1
  85. package/dist/esm/arch/evm/SpokeUtils.d.ts +9 -4
  86. package/dist/esm/arch/evm/SpokeUtils.js +29 -14
  87. package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
  88. package/dist/esm/arch/svm/SpokeUtils.d.ts +9 -3
  89. package/dist/esm/arch/svm/SpokeUtils.js +42 -55
  90. package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
  91. package/dist/esm/arch/svm/eventsClient.js +5 -3
  92. package/dist/esm/arch/svm/eventsClient.js.map +1 -1
  93. package/dist/esm/arch/svm/utils.d.ts +3 -3
  94. package/dist/esm/arch/svm/utils.js +17 -15
  95. package/dist/esm/arch/svm/utils.js.map +1 -1
  96. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  97. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
  98. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  99. package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
  100. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +60 -60
  101. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  102. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +18 -15
  103. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  104. package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
  105. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +7 -7
  106. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  107. package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
  108. package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
  109. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +4 -4
  110. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
  111. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +71 -71
  112. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +20 -10
  113. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  114. package/dist/esm/clients/HubPoolClient.d.ts +22 -22
  115. package/dist/esm/clients/HubPoolClient.js +93 -66
  116. package/dist/esm/clients/HubPoolClient.js.map +1 -1
  117. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +3 -3
  118. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  119. package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js +2 -4
  120. package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
  121. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
  122. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +69 -48
  123. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  124. package/dist/esm/clients/SpokePoolClient/index.d.ts +1 -0
  125. package/dist/esm/clients/SpokePoolClient/index.js +1 -0
  126. package/dist/esm/clients/SpokePoolClient/index.js.map +1 -1
  127. package/dist/esm/clients/index.d.ts +1 -1
  128. package/dist/esm/clients/index.js +1 -1
  129. package/dist/esm/clients/index.js.map +1 -1
  130. package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +9 -9
  131. package/dist/esm/clients/mocks/MockHubPoolClient.js +16 -10
  132. package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
  133. package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +5 -3
  134. package/dist/esm/clients/mocks/MockSpokePoolClient.js +42 -38
  135. package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
  136. package/dist/esm/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
  137. package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js +7 -5
  138. package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
  139. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
  140. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +3 -3
  141. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
  142. package/dist/esm/interfaces/HubPool.d.ts +19 -14
  143. package/dist/esm/interfaces/SpokePool.d.ts +18 -19
  144. package/dist/esm/interfaces/SpokePool.js.map +1 -1
  145. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +20 -12
  146. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +28 -19
  147. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  148. package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
  149. package/dist/esm/relayFeeCalculator/chain-queries/factory.js +9 -6
  150. package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  151. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +15 -7
  152. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +67 -63
  153. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  154. package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +25 -8
  155. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +12 -12
  156. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  157. package/dist/esm/utils/AddressUtils.d.ts +12 -8
  158. package/dist/esm/utils/AddressUtils.js +36 -38
  159. package/dist/esm/utils/AddressUtils.js.map +1 -1
  160. package/dist/esm/utils/DepositUtils.d.ts +2 -2
  161. package/dist/esm/utils/DepositUtils.js +2 -2
  162. package/dist/esm/utils/DepositUtils.js.map +1 -1
  163. package/dist/esm/utils/SpokeUtils.d.ts +1 -8
  164. package/dist/esm/utils/SpokeUtils.js +3 -29
  165. package/dist/esm/utils/SpokeUtils.js.map +1 -1
  166. package/dist/esm/utils/TokenUtils.d.ts +6 -18
  167. package/dist/esm/utils/TokenUtils.js +6 -4
  168. package/dist/esm/utils/TokenUtils.js.map +1 -1
  169. package/dist/types/arch/evm/SpokeUtils.d.ts +9 -4
  170. package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
  171. package/dist/types/arch/svm/SpokeUtils.d.ts +9 -3
  172. package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
  173. package/dist/types/arch/svm/eventsClient.d.ts.map +1 -1
  174. package/dist/types/arch/svm/utils.d.ts +3 -3
  175. package/dist/types/arch/svm/utils.d.ts.map +1 -1
  176. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  177. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
  178. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
  179. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  180. package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
  181. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
  182. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
  183. package/dist/types/clients/BundleDataClient/utils/MerkleTreeUtils.d.ts.map +1 -1
  184. package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts.map +1 -1
  185. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +71 -71
  186. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
  187. package/dist/types/clients/HubPoolClient.d.ts +22 -22
  188. package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
  189. package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
  190. package/dist/types/clients/SpokePoolClient/SVMSpokePoolClient.d.ts.map +1 -1
  191. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
  192. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
  193. package/dist/types/clients/SpokePoolClient/index.d.ts +1 -0
  194. package/dist/types/clients/SpokePoolClient/index.d.ts.map +1 -1
  195. package/dist/types/clients/index.d.ts +1 -1
  196. package/dist/types/clients/index.d.ts.map +1 -1
  197. package/dist/types/clients/mocks/MockHubPoolClient.d.ts +9 -9
  198. package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
  199. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +5 -3
  200. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
  201. package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
  202. package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts.map +1 -1
  203. package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
  204. package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts.map +1 -1
  205. package/dist/types/interfaces/HubPool.d.ts +19 -14
  206. package/dist/types/interfaces/HubPool.d.ts.map +1 -1
  207. package/dist/types/interfaces/SpokePool.d.ts +18 -19
  208. package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
  209. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +20 -12
  210. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
  211. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
  212. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
  213. package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +15 -7
  214. package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
  215. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +25 -8
  216. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
  217. package/dist/types/utils/AddressUtils.d.ts +12 -8
  218. package/dist/types/utils/AddressUtils.d.ts.map +1 -1
  219. package/dist/types/utils/DepositUtils.d.ts +2 -2
  220. package/dist/types/utils/DepositUtils.d.ts.map +1 -1
  221. package/dist/types/utils/SpokeUtils.d.ts +1 -8
  222. package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
  223. package/dist/types/utils/TokenUtils.d.ts +6 -18
  224. package/dist/types/utils/TokenUtils.d.ts.map +1 -1
  225. package/package.json +1 -2
  226. package/src/arch/evm/SpokeUtils.ts +72 -22
  227. package/src/arch/svm/SpokeUtils.ts +67 -53
  228. package/src/arch/svm/eventsClient.ts +40 -8
  229. package/src/arch/svm/utils.ts +6 -6
  230. package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -4
  231. package/src/clients/BundleDataClient/BundleDataClient.ts +56 -56
  232. package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +32 -15
  233. package/src/clients/BundleDataClient/utils/FillUtils.ts +12 -8
  234. package/src/clients/BundleDataClient/utils/MerkleTreeUtils.ts +7 -1
  235. package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +4 -4
  236. package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +22 -10
  237. package/src/clients/HubPoolClient.ts +125 -86
  238. package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +7 -2
  239. package/src/clients/SpokePoolClient/SVMSpokePoolClient.ts +1 -4
  240. package/src/clients/SpokePoolClient/SpokePoolClient.ts +122 -37
  241. package/src/clients/SpokePoolClient/index.ts +1 -0
  242. package/src/clients/index.ts +1 -0
  243. package/src/clients/mocks/MockHubPoolClient.ts +24 -19
  244. package/src/clients/mocks/MockSpokePoolClient.ts +39 -27
  245. package/src/clients/mocks/MockSvmCpiEventsClient.ts +8 -5
  246. package/src/clients/mocks/MockSvmSpokePoolClient.ts +12 -3
  247. package/src/interfaces/HubPool.ts +20 -14
  248. package/src/interfaces/SpokePool.ts +19 -19
  249. package/src/relayFeeCalculator/chain-queries/baseQuery.ts +39 -21
  250. package/src/relayFeeCalculator/chain-queries/factory.ts +8 -5
  251. package/src/relayFeeCalculator/chain-queries/svmQuery.ts +73 -58
  252. package/src/relayFeeCalculator/relayFeeCalculator.ts +23 -21
  253. package/src/utils/AddressUtils.ts +39 -51
  254. package/src/utils/DepositUtils.ts +4 -4
  255. package/src/utils/SpokeUtils.ts +8 -36
  256. package/src/utils/TokenUtils.ts +10 -8
@@ -24,13 +24,13 @@ import {
24
24
  import assert from "assert";
25
25
  import { arrayify, hexZeroPad, hexlify } from "ethers/lib/utils";
26
26
  import { Logger } from "winston";
27
-
28
27
  import { SYSTEM_PROGRAM_ADDRESS } from "@solana-program/system";
29
- import { Deposit, DepositWithBlock, FillStatus, FillWithBlock, RelayData } from "../../interfaces";
28
+ import { DepositWithBlock, FillStatus, FillWithBlock, RelayData, RelayExecutionEventInfo } from "../../interfaces";
30
29
  import {
31
30
  BigNumber,
32
31
  EvmAddress,
33
32
  SvmAddress,
33
+ Address as SdkAddress,
34
34
  chainIsSvm,
35
35
  chunk,
36
36
  isUnsafeDepositId,
@@ -46,6 +46,7 @@ import {
46
46
  toAddress,
47
47
  unwrapEventData,
48
48
  } from "./";
49
+ import { CHAIN_IDs } from "../../constants";
49
50
  import { SVMEventNames, SVMProvider } from "./types";
50
51
 
51
52
  /**
@@ -54,6 +55,12 @@ import { SVMEventNames, SVMProvider } from "./types";
54
55
  */
55
56
  export const SLOT_DURATION_MS = 400;
56
57
 
58
+ type ProtoFill = Omit<RelayData, "recipient" | "outputToken"> & {
59
+ destinationChainId: number;
60
+ recipient: SvmAddress;
61
+ outputToken: SvmAddress;
62
+ };
63
+
57
64
  /**
58
65
  * Retrieves the chain time at a particular slot.
59
66
  */
@@ -145,13 +152,20 @@ export async function findDeposit(
145
152
  return undefined;
146
153
  }
147
154
 
155
+ const unwrappedDepositEvent = unwrapEventData(depositEvent.data) as Record<string, unknown>;
156
+ const destinationChainId = unwrappedDepositEvent.destinationChainId as number;
148
157
  // Return the deposit event with block info
149
158
  return {
150
159
  txnRef: depositEvent.signature.toString(),
151
160
  blockNumber: Number(depositEvent.slot),
152
161
  txnIndex: 0,
153
162
  logIndex: 0,
154
- ...(unwrapEventData(depositEvent.data) as Record<string, unknown>),
163
+ ...unwrappedDepositEvent,
164
+ depositor: toAddressType(unwrappedDepositEvent.depositor as string, CHAIN_IDs.SOLANA),
165
+ recipient: toAddressType(unwrappedDepositEvent.recipient as string, destinationChainId),
166
+ inputToken: toAddressType(unwrappedDepositEvent.inputToken as string, CHAIN_IDs.SOLANA),
167
+ outputToken: toAddressType(unwrappedDepositEvent.outputToken as string, destinationChainId),
168
+ exclusiveRelayer: toAddressType(unwrappedDepositEvent.exclusiveRelayer as string, destinationChainId),
155
169
  } as DepositWithBlock;
156
170
  }
157
171
 
@@ -327,14 +341,34 @@ export async function findFillEvent(
327
341
 
328
342
  if (fillEvents.length > 0) {
329
343
  const rawFillEvent = fillEvents[0];
344
+ const eventData = unwrapEventData(rawFillEvent.data) as FillWithBlock & {
345
+ depositor: string;
346
+ recipient: string;
347
+ inputToken: string;
348
+ outputToken: string;
349
+ exclusiveRelayer: string;
350
+ relayer: string;
351
+ relayExecutionInfo: RelayExecutionEventInfo & { updatedRecipient: string };
352
+ };
353
+ const originChainId = eventData.originChainId;
330
354
  const parsedFillEvent = {
355
+ ...eventData,
331
356
  transactionHash: rawFillEvent.signature,
332
357
  blockNumber: Number(rawFillEvent.slot),
333
358
  transactionIndex: 0,
334
359
  logIndex: 0,
335
360
  destinationChainId,
336
- ...(unwrapEventData(rawFillEvent.data) as Record<string, unknown>),
337
- } as unknown as FillWithBlock;
361
+ inputToken: toAddressType(eventData.inputToken, originChainId),
362
+ outputToken: toAddressType(eventData.outputToken, destinationChainId),
363
+ relayer: toAddressType(eventData.relayer, destinationChainId),
364
+ exclusiveRelayer: toAddressType(eventData.exclusiveRelayer, destinationChainId),
365
+ depositor: toAddressType(eventData.depositor, originChainId),
366
+ recipient: toAddressType(eventData.recipient, destinationChainId),
367
+ relayExecutionInfo: {
368
+ ...eventData.relayExecutionInfo,
369
+ updatedRecipient: eventData.relayExecutionInfo.updatedRecipient,
370
+ },
371
+ } as FillWithBlock;
338
372
  return parsedFillEvent;
339
373
  }
340
374
 
@@ -343,18 +377,18 @@ export async function findFillEvent(
343
377
 
344
378
  /**
345
379
  * @param spokePool Address (program ID) of the SvmSpoke.
346
- * @param deposit V3Deopsit instance.
380
+ * @param relayData RelayData instance, supplemented with destinationChainId
347
381
  * @param relayer Address of the relayer filling the deposit.
348
382
  * @param repaymentChainId Optional repaymentChainId (defaults to destinationChainId).
349
383
  * @returns An Ethers UnsignedTransaction instance.
350
384
  */
351
385
  export async function fillRelayInstruction(
352
386
  spokePool: SvmAddress,
353
- deposit: Omit<Deposit, "messageHash" | "fromLiteChain" | "toLiteChain">,
387
+ relayData: ProtoFill,
354
388
  signer: TransactionSigner<string>,
355
389
  recipientTokenAccount: Address<string>,
356
390
  repaymentAddress: EvmAddress | SvmAddress = SvmAddress.from(signer.address),
357
- repaymentChainId = deposit.destinationChainId
391
+ repaymentChainId = relayData.destinationChainId
358
392
  ) {
359
393
  const program = toAddress(spokePool);
360
394
 
@@ -363,25 +397,22 @@ export async function fillRelayInstruction(
363
397
  `Invalid repayment address for chain ${repaymentChainId}: ${repaymentAddress.toNative()}.`
364
398
  );
365
399
 
366
- const _relayDataHash = getRelayDataHash(deposit, deposit.destinationChainId);
400
+ const _relayDataHash = getRelayDataHash(relayData, relayData.destinationChainId);
367
401
  const relayDataHash = new Uint8Array(Buffer.from(_relayDataHash.slice(2), "hex"));
368
402
 
369
403
  const relayer = SvmAddress.from(signer.address);
370
- const outputTokenAddress = toAddressType(deposit.outputToken, deposit.destinationChainId);
371
- if (!(outputTokenAddress instanceof SvmAddress)) {
372
- return undefined;
373
- }
374
404
 
375
405
  // Create ATA for the relayer and recipient token accounts
376
- const relayerTokenAccount = await getAssociatedTokenAddress(relayer, outputTokenAddress);
406
+ const relayerTokenAccount = await getAssociatedTokenAddress(relayer, relayData.outputToken);
377
407
 
378
408
  const [statePda, fillStatusPda, eventAuthority] = await Promise.all([
379
409
  getStatePda(program),
380
- getFillStatusPda(program, deposit, deposit.destinationChainId),
381
- getEventAuthority(),
410
+ getFillStatusPda(program, relayData, relayData.destinationChainId),
411
+ getEventAuthority(program),
382
412
  ]);
413
+
383
414
  const depositIdBuffer = new Uint8Array(32);
384
- const shortenedBuffer = new Uint8Array(Buffer.from(deposit.depositId.toHexString().slice(2), "hex"));
415
+ const shortenedBuffer = new Uint8Array(Buffer.from(relayData.depositId.toHexString().slice(2), "hex"));
385
416
  depositIdBuffer.set(shortenedBuffer, 32 - shortenedBuffer.length);
386
417
 
387
418
  const delegatePda = await getFillRelayDelegatePda(
@@ -391,26 +422,14 @@ export async function fillRelayInstruction(
391
422
  program
392
423
  );
393
424
 
394
- // @todo we need to convert the deposit's relayData to svm-like since the interface assumes the data originates
395
- // from an EVM Spoke pool. Once we migrate to `Address` types, this can be modified/removed.
396
- const [depositor, inputToken] = [deposit.depositor, deposit.inputToken].map((addr: string) => {
397
- const addressObj = toAddressType(addr, deposit.originChainId);
398
- // @dev we don't really care for correctness of format of depositor / inputToken, so we're fine converting to Solana
399
- // SDK `Address<string>` type even if our `toAddressType` function returned a raw address.
400
- return addressObj.toBase58() as Address<string>;
401
- });
402
-
403
- const [recipient, exclusiveRelayer] = [deposit.recipient, deposit.exclusiveRelayer].map((addr) => {
404
- const addressObj = toAddressType(addr, deposit.originChainId);
405
- if (!(addressObj instanceof SvmAddress)) {
406
- return undefined;
407
- }
408
- return toAddress(addressObj);
409
- });
410
-
411
- if (!recipient || !exclusiveRelayer) return undefined;
425
+ const [recipient, outputToken, exclusiveRelayer, depositor, inputToken] = [
426
+ relayData.recipient,
427
+ relayData.outputToken,
428
+ relayData.exclusiveRelayer,
429
+ relayData.depositor,
430
+ relayData.inputToken,
431
+ ].map(toAddress);
412
432
 
413
- const outputToken = toAddress(outputTokenAddress);
414
433
  return SvmSpokeClient.getFillRelayInstruction({
415
434
  signer,
416
435
  state: statePda,
@@ -428,13 +447,13 @@ export async function fillRelayInstruction(
428
447
  exclusiveRelayer,
429
448
  inputToken,
430
449
  outputToken,
431
- inputAmount: deposit.inputAmount.toBigInt(),
432
- outputAmount: deposit.outputAmount.toBigInt(),
433
- originChainId: BigInt(deposit.originChainId),
434
- fillDeadline: deposit.fillDeadline,
435
- exclusivityDeadline: deposit.exclusivityDeadline,
450
+ inputAmount: relayData.inputAmount.toBigInt(),
451
+ outputAmount: relayData.outputAmount.toBigInt(),
452
+ originChainId: BigInt(relayData.originChainId),
453
+ fillDeadline: relayData.fillDeadline,
454
+ exclusivityDeadline: relayData.exclusivityDeadline,
436
455
  depositId: depositIdBuffer,
437
- message: new Uint8Array(Buffer.from(deposit.message.slice(2), "hex")),
456
+ message: new Uint8Array(Buffer.from(relayData.message.slice(2), "hex")),
438
457
  }),
439
458
  repaymentChainId: some(BigInt(repaymentChainId)),
440
459
  repaymentAddress: toAddress(repaymentAddress),
@@ -616,19 +635,14 @@ export function getRelayDataHash(relayData: RelayData, destinationChainId: numbe
616
635
  const uint32Encoder = getU32Encoder();
617
636
 
618
637
  assert(relayData.message.startsWith("0x"), "Message must be a hex string");
619
- const encodeAddress = (addr: string, chainId: number) => {
620
- const addrObj = toAddressType(addr, chainId);
621
- // @dev even if `addrObj` is of type `Address` here, we still want to calculate the relayHash
622
- // based on `base58` representation of the `Address`
623
- return Uint8Array.from(addressEncoder.encode(addrObj.toBase58() as Address<string>));
624
- };
638
+ const encodeAddress = (data: SdkAddress) => Uint8Array.from(addressEncoder.encode(toAddress(data)));
625
639
 
626
640
  const contentToHash = Buffer.concat([
627
- encodeAddress(relayData.depositor, relayData.originChainId),
628
- encodeAddress(relayData.recipient, destinationChainId),
629
- encodeAddress(relayData.exclusiveRelayer, destinationChainId),
630
- encodeAddress(relayData.inputToken, relayData.originChainId),
631
- encodeAddress(relayData.outputToken, destinationChainId),
641
+ encodeAddress(relayData.depositor),
642
+ encodeAddress(relayData.recipient),
643
+ encodeAddress(relayData.exclusiveRelayer),
644
+ encodeAddress(relayData.inputToken),
645
+ encodeAddress(relayData.outputToken),
632
646
  Uint8Array.from(uint64Encoder.encode(BigInt(relayData.inputAmount.toString()))),
633
647
  Uint8Array.from(uint64Encoder.encode(BigInt(relayData.outputAmount.toString()))),
634
648
  Uint8Array.from(uint64Encoder.encode(BigInt(relayData.originChainId.toString()))),
@@ -10,7 +10,7 @@ import {
10
10
  GetTransactionApi,
11
11
  Signature,
12
12
  } from "@solana/kit";
13
- import { bs58, chainIsSvm, getMessageHash } from "../../utils";
13
+ import { bs58, chainIsSvm, getMessageHash, toAddressType } from "../../utils";
14
14
  import { EventName, EventWithData, SVMProvider } from "./types";
15
15
  import { decodeEvent, isDevnet } from "./utils";
16
16
  import { Deposit, DepositWithTime, Fill, FillWithTime } from "../../interfaces";
@@ -252,7 +252,6 @@ export class SvmCpiEventsClient {
252
252
 
253
253
  // Filter for FundsDeposited events only
254
254
  const depositEvents = events?.filter((event) => event?.name === "FundsDeposited");
255
-
256
255
  if (!txDetails || !depositEvents?.length) {
257
256
  return;
258
257
  }
@@ -261,13 +260,29 @@ export class SvmCpiEventsClient {
261
260
  const unwrappedEventArgs = unwrapEventData(event as Record<string, unknown>, ["depositId"]) as Record<
262
261
  "data",
263
262
  Deposit
264
- >;
265
-
263
+ > &
264
+ Record<
265
+ "data",
266
+ {
267
+ depositor: string;
268
+ recipient: string;
269
+ exclusiveRelayer: string;
270
+ inputToken: string;
271
+ outputToken: string;
272
+ }
273
+ >;
274
+
275
+ const { data } = unwrappedEventArgs;
266
276
  return {
267
- ...unwrappedEventArgs.data,
277
+ ...data,
278
+ depositor: toAddressType(data.depositor, data.originChainId),
279
+ recipient: toAddressType(data.recipient, data.destinationChainId),
280
+ exclusiveRelayer: toAddressType(data.exclusiveRelayer, data.destinationChainId),
281
+ inputToken: toAddressType(data.inputToken, data.originChainId),
282
+ outputToken: toAddressType(data.outputToken, data.destinationChainId),
268
283
  depositTimestamp: Number(txDetails.blockTime),
269
284
  originChainId,
270
- messageHash: getMessageHash(unwrappedEventArgs.data.message),
285
+ messageHash: getMessageHash(data.message),
271
286
  blockNumber: Number(txDetails.slot),
272
287
  txnIndex: 0,
273
288
  txnRef: txSignature,
@@ -309,9 +324,26 @@ export class SvmCpiEventsClient {
309
324
  }
310
325
 
311
326
  return fillEvents.map((event) => {
312
- const unwrappedEventData = unwrapEventData(event as Record<string, unknown>) as Record<"data", Fill>;
327
+ const unwrappedEventData = unwrapEventData(event as Record<string, unknown>) as Record<"data", Fill> &
328
+ Record<
329
+ "data",
330
+ {
331
+ depositor: string;
332
+ recipient: string;
333
+ exclusiveRelayer: string;
334
+ inputToken: string;
335
+ outputToken: string;
336
+ }
337
+ >;
338
+
339
+ const { data } = unwrappedEventData;
313
340
  return {
314
- ...unwrappedEventData.data,
341
+ ...data,
342
+ depositor: toAddressType(data.depositor, data.originChainId),
343
+ recipient: toAddressType(data.recipient, data.destinationChainId),
344
+ exclusiveRelayer: toAddressType(data.exclusiveRelayer, data.destinationChainId),
345
+ inputToken: toAddressType(data.inputToken, data.originChainId),
346
+ outputToken: toAddressType(data.outputToken, data.destinationChainId),
315
347
  fillTimestamp: Number(txDetails.blockTime),
316
348
  blockNumber: Number(txDetails.slot),
317
349
  txnRef: txSignature,
@@ -17,7 +17,7 @@ import {
17
17
  } from "@solana/kit";
18
18
  import { SvmSpokeClient } from "@across-protocol/contracts";
19
19
  import { FillType, RelayData } from "../../interfaces";
20
- import { BigNumber, EvmAddress, SvmAddress, getRelayDataHash, isUint8Array } from "../../utils";
20
+ import { BigNumber, getRelayDataHash, isUint8Array, Address as SdkAddress } from "../../utils";
21
21
  import { EventName, SVMEventNames, SVMProvider } from "./types";
22
22
 
23
23
  /**
@@ -45,7 +45,7 @@ export async function isDevnet(rpc: SVMProvider): Promise<boolean> {
45
45
  /**
46
46
  * Small utility to convert an Address to a Solana Kit branded type.
47
47
  */
48
- export function toAddress(address: EvmAddress | SvmAddress): Address<string> {
48
+ export function toAddress(address: SdkAddress): Address<string> {
49
49
  return address.toBase58() as Address<string>;
50
50
  }
51
51
 
@@ -144,7 +144,7 @@ export function unwrapEventData(
144
144
  }
145
145
  // Handle strings (potential addresses)
146
146
  if (typeof data === "string" && isAddress(data)) {
147
- return SvmAddress.from(data).toBytes32();
147
+ return ethers.utils.hexlify(bs58.decode(data));
148
148
  }
149
149
  // Handle objects
150
150
  if (typeof data === "object") {
@@ -280,13 +280,13 @@ export async function getInstructionParamsPda(programId: Address, signer: Addres
280
280
  * Returns the PDA for the Event Authority.
281
281
  * @returns The PDA for the Event Authority.
282
282
  */
283
- export const getEventAuthority = async () => {
283
+ export async function getEventAuthority(programId: Address): Promise<Address> {
284
284
  const [eventAuthority] = await getProgramDerivedAddress({
285
- programAddress: address(SvmSpokeClient.SVM_SPOKE_PROGRAM_ADDRESS),
285
+ programAddress: programId,
286
286
  seeds: ["__event_authority"],
287
287
  });
288
288
  return eventAuthority;
289
- };
289
+ }
290
290
 
291
291
  /**
292
292
  * Returns a random SVM address.
@@ -5,6 +5,7 @@ import winston from "winston";
5
5
  import { isError } from "../../typeguards";
6
6
  import {
7
7
  EventSearchConfig,
8
+ EvmAddress,
8
9
  MakeOptional,
9
10
  isArrayOf,
10
11
  isDefined,
@@ -107,7 +108,7 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
107
108
  }
108
109
 
109
110
  getRateModelForBlockNumber(
110
- l1Token: string,
111
+ l1Token: EvmAddress,
111
112
  originChainId: number | string,
112
113
  destinationChainId: number | string,
113
114
  blockNumber: number | undefined = undefined
@@ -121,7 +122,9 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
121
122
 
122
123
  const defaultRateModelUpdate = sortEventsDescending(this.cumulativeRateModelUpdates).find(
123
124
  (config) =>
124
- config.blockNumber <= (blockNumber ?? 0) && config.l1Token === l1Token && config.rateModel !== undefined
125
+ config.blockNumber <= (blockNumber ?? 0) &&
126
+ config.l1Token === l1Token.toEvmAddress() &&
127
+ config.rateModel !== undefined
125
128
  );
126
129
  if (!defaultRateModelUpdate) {
127
130
  throw new Error(`Could not find TokenConfig update for ${l1Token} at block ${blockNumber}`);
@@ -130,12 +133,12 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
130
133
  }
131
134
 
132
135
  getRouteRateModelForBlockNumber(
133
- l1Token: string,
136
+ l1Token: EvmAddress,
134
137
  route: string,
135
138
  blockNumber: number | undefined = undefined
136
139
  ): RateModel | undefined {
137
140
  const config = (sortEventsDescending(this.cumulativeRouteRateModelUpdates) as RouteRateModelUpdate[]).find(
138
- (config) => config.blockNumber <= (blockNumber ?? 0) && config.l1Token === l1Token
141
+ (config) => config.blockNumber <= (blockNumber ?? 0) && config.l1Token === l1Token.toEvmAddress()
139
142
  );
140
143
  if (config?.routeRateModel[route] === undefined) {
141
144
  return undefined;
@@ -39,10 +39,9 @@ import {
39
39
  bnUint32Max,
40
40
  isZeroValueDeposit,
41
41
  isZeroValueFillOrSlowFillRequest,
42
- chainIsEvm,
43
- isValidEvmAddress,
44
42
  duplicateEvent,
45
43
  invalidOutputToken,
44
+ Address,
46
45
  getNetworkName,
47
46
  } from "../../utils";
48
47
  import winston from "winston";
@@ -69,22 +68,21 @@ type DataCache = Record<string, Promise<LoadDataReturnValue>>;
69
68
  // V3 dictionary helper functions
70
69
  function updateExpiredDepositsV3(dict: ExpiredDepositsToRefundV3, deposit: V3DepositWithBlock): void {
71
70
  // A deposit refund for a deposit is invalid if the depositor has a bytes32 address input for an EVM chain. It is valid otherwise.
72
- if (chainIsEvm(deposit.originChainId) && !isValidEvmAddress(deposit.depositor)) {
71
+ if (!deposit.depositor.isValidOn(deposit.originChainId)) {
73
72
  return;
74
73
  }
74
+
75
75
  const { originChainId, inputToken } = deposit;
76
- if (!dict?.[originChainId]?.[inputToken]) {
77
- assign(dict, [originChainId, inputToken], []);
78
- }
79
- dict[originChainId][inputToken].push(deposit);
76
+ dict[originChainId] ??= {};
77
+ dict[originChainId][inputToken.toBytes32()] ??= [];
78
+ dict[originChainId][inputToken.toBytes32()].push(deposit);
80
79
  }
81
80
 
82
81
  function updateBundleDepositsV3(dict: BundleDepositsV3, deposit: V3DepositWithBlock): void {
83
82
  const { originChainId, inputToken } = deposit;
84
- if (!dict?.[originChainId]?.[inputToken]) {
85
- assign(dict, [originChainId, inputToken], []);
86
- }
87
- dict[originChainId][inputToken].push(deposit);
83
+ dict[originChainId] ??= {};
84
+ dict[originChainId][inputToken.toBytes32()] ??= [];
85
+ dict[originChainId][inputToken.toBytes32()].push(deposit);
88
86
  }
89
87
 
90
88
  function updateBundleFillsV3(
@@ -92,29 +90,29 @@ function updateBundleFillsV3(
92
90
  fill: V3FillWithBlock,
93
91
  lpFeePct: BigNumber,
94
92
  repaymentChainId: number,
95
- repaymentToken: string,
96
- repaymentAddress: string
93
+ repaymentToken: Address,
94
+ repaymentAddress: Address
97
95
  ): void {
98
96
  // We shouldn't pass any unrepayable fills into this function, so we perform an extra safety check.
99
- if (chainIsEvm(repaymentChainId) && !isValidEvmAddress(fill.relayer)) {
97
+ if (!fill.relayer.isValidOn(repaymentChainId)) {
100
98
  return;
101
99
  }
102
- if (!dict?.[repaymentChainId]?.[repaymentToken]) {
103
- assign(dict, [repaymentChainId, repaymentToken], {
104
- fills: [],
105
- totalRefundAmount: bnZero,
106
- realizedLpFees: bnZero,
107
- refunds: {},
108
- });
109
- }
100
+
101
+ dict[repaymentChainId] ??= {};
102
+ dict[repaymentChainId][repaymentToken.toBytes32()] ??= {
103
+ fills: [],
104
+ totalRefundAmount: bnZero,
105
+ realizedLpFees: bnZero,
106
+ refunds: {},
107
+ };
110
108
 
111
109
  const bundleFill: BundleFillV3 = { ...fill, lpFeePct, relayer: repaymentAddress };
112
110
 
113
111
  // Add all fills, slow and fast, to dictionary.
114
- assign(dict, [repaymentChainId, repaymentToken, "fills"], [bundleFill]);
112
+ assign(dict, [repaymentChainId, repaymentToken.toBytes32(), "fills"], [bundleFill]);
115
113
 
116
114
  // All fills update the bundle LP fees.
117
- const refundObj = dict[repaymentChainId][repaymentToken];
115
+ const refundObj = dict[repaymentChainId][repaymentToken.toBytes32()];
118
116
  const realizedLpFee = bundleFill.inputAmount.mul(bundleFill.lpFeePct).div(fixedPointAdjustment);
119
117
  refundObj.realizedLpFees = refundObj.realizedLpFees ? refundObj.realizedLpFees.add(realizedLpFee) : realizedLpFee;
120
118
 
@@ -128,10 +126,11 @@ function updateBundleFillsV3(
128
126
  // Instantiate dictionary if it doesn't exist.
129
127
  refundObj.refunds ??= {};
130
128
 
131
- if (refundObj.refunds[bundleFill.relayer]) {
132
- refundObj.refunds[bundleFill.relayer] = refundObj.refunds[bundleFill.relayer].add(refundAmount);
129
+ if (refundObj.refunds[bundleFill.relayer.toBytes32()]) {
130
+ refundObj.refunds[bundleFill.relayer.toBytes32()] =
131
+ refundObj.refunds[bundleFill.relayer.toBytes32()].add(refundAmount);
133
132
  } else {
134
- refundObj.refunds[bundleFill.relayer] = refundAmount;
133
+ refundObj.refunds[bundleFill.relayer.toBytes32()] = refundAmount;
135
134
  }
136
135
  }
137
136
  }
@@ -141,21 +140,20 @@ function updateBundleExcessSlowFills(
141
140
  deposit: V3DepositWithBlock & { lpFeePct: BigNumber }
142
141
  ): void {
143
142
  const { destinationChainId, outputToken } = deposit;
144
- if (!dict?.[destinationChainId]?.[outputToken]) {
145
- assign(dict, [destinationChainId, outputToken], []);
146
- }
147
- dict[destinationChainId][outputToken].push(deposit);
143
+ dict[destinationChainId] ??= {};
144
+ dict[destinationChainId][outputToken.toBytes32()] ??= [];
145
+ dict[destinationChainId][outputToken.toBytes32()].push(deposit);
148
146
  }
149
147
 
150
148
  function updateBundleSlowFills(dict: BundleSlowFills, deposit: V3DepositWithBlock & { lpFeePct: BigNumber }): void {
151
- if (chainIsEvm(deposit.destinationChainId) && !isValidEvmAddress(deposit.recipient)) {
149
+ if (!deposit.recipient.isValidOn(deposit.destinationChainId)) {
152
150
  return;
153
151
  }
152
+
154
153
  const { destinationChainId, outputToken } = deposit;
155
- if (!dict?.[destinationChainId]?.[outputToken]) {
156
- assign(dict, [destinationChainId, outputToken], []);
157
- }
158
- dict[destinationChainId][outputToken].push(deposit);
154
+ dict[destinationChainId] ??= {};
155
+ dict[destinationChainId][outputToken.toBytes32()] ??= [];
156
+ dict[destinationChainId][outputToken.toBytes32()].push(deposit);
159
157
  }
160
158
 
161
159
  // @notice Shared client for computing data needed to construct or validate a bundle.
@@ -507,22 +505,24 @@ export class BundleDataClient {
507
505
  // worst from the relayer's perspective.
508
506
  const { relayer, inputAmount: refundAmount } = fill;
509
507
  refundsForChain[chainToSendRefundTo] ??= {};
510
- refundsForChain[chainToSendRefundTo][repaymentToken] ??= {};
511
- const existingRefundAmount = refundsForChain[chainToSendRefundTo][repaymentToken][relayer] ?? bnZero;
512
- refundsForChain[chainToSendRefundTo][repaymentToken][relayer] = existingRefundAmount.add(refundAmount);
508
+ refundsForChain[chainToSendRefundTo][repaymentToken.toBytes32()] ??= {};
509
+ const existingRefundAmount =
510
+ refundsForChain[chainToSendRefundTo][repaymentToken.toBytes32()][relayer.toBytes32()] ?? bnZero;
511
+ refundsForChain[chainToSendRefundTo][repaymentToken.toBytes32()][relayer.toBytes32()] =
512
+ existingRefundAmount.add(refundAmount);
513
513
  });
514
514
  }
515
515
  return refundsForChain;
516
516
  }
517
517
 
518
- getUpcomingDepositAmount(chainId: number, l2Token: string, latestBlockToSearch: number): BigNumber {
518
+ getUpcomingDepositAmount(chainId: number, l2Token: Address, latestBlockToSearch: number): BigNumber {
519
519
  const spokePoolClient = this.spokePoolClientManager.getClient(chainId);
520
520
  if (!isDefined(spokePoolClient)) {
521
521
  return toBN(0);
522
522
  }
523
523
  return spokePoolClient
524
524
  .getDeposits()
525
- .filter((deposit) => deposit.blockNumber > latestBlockToSearch && deposit.inputToken === l2Token)
525
+ .filter((deposit) => deposit.blockNumber > latestBlockToSearch && deposit.inputToken.eq(l2Token))
526
526
  .reduce((acc, deposit) => {
527
527
  return acc.add(deposit.inputAmount);
528
528
  }, toBN(0));
@@ -644,18 +644,14 @@ export class BundleDataClient {
644
644
  .filter((leaf) => leaf.rootBundleId === bundle.rootBundleId);
645
645
  const executedRefunds: { [tokenAddress: string]: { [relayer: string]: BigNumber } } = {};
646
646
  for (const refundLeaf of executedRefundLeaves) {
647
- const tokenAddress = refundLeaf.l2TokenAddress;
648
- if (executedRefunds[tokenAddress] === undefined) {
649
- executedRefunds[tokenAddress] = {};
650
- }
651
- const executedTokenRefunds = executedRefunds[tokenAddress];
647
+ const tokenAddress = refundLeaf.l2TokenAddress.toBytes32();
648
+ const executedTokenRefunds = (executedRefunds[tokenAddress] ??= {});
652
649
 
653
650
  for (let i = 0; i < refundLeaf.refundAddresses.length; i++) {
654
- const relayer = refundLeaf.refundAddresses[i];
651
+ const relayer = refundLeaf.refundAddresses[i].toBytes32();
655
652
  const refundAmount = refundLeaf.refundAmounts[i];
656
- if (executedTokenRefunds[relayer] === undefined) {
657
- executedTokenRefunds[relayer] = bnZero;
658
- }
653
+
654
+ executedTokenRefunds[relayer] ??= bnZero;
659
655
  executedTokenRefunds[relayer] = executedTokenRefunds[relayer].add(refundAmount);
660
656
  }
661
657
  }
@@ -695,15 +691,15 @@ export class BundleDataClient {
695
691
  return allRefunds;
696
692
  }
697
693
 
698
- getRefundsFor(bundleRefunds: CombinedRefunds, relayer: string, chainId: number, token: string): BigNumber {
699
- if (!bundleRefunds[chainId] || !bundleRefunds[chainId][token]) {
694
+ getRefundsFor(bundleRefunds: CombinedRefunds, relayer: Address, chainId: number, token: Address): BigNumber {
695
+ if (!bundleRefunds[chainId] || !bundleRefunds[chainId][token.toBytes32()]) {
700
696
  return BigNumber.from(0);
701
697
  }
702
- const allRefunds = bundleRefunds[chainId][token];
703
- return allRefunds && allRefunds[relayer] ? allRefunds[relayer] : BigNumber.from(0);
698
+ const allRefunds = bundleRefunds[chainId][token.toBytes32()];
699
+ return allRefunds && allRefunds[relayer.toBytes32()] ? allRefunds[relayer.toBytes32()] : BigNumber.from(0);
704
700
  }
705
701
 
706
- getTotalRefund(refunds: CombinedRefunds[], relayer: string, chainId: number, refundToken: string): BigNumber {
702
+ getTotalRefund(refunds: CombinedRefunds[], relayer: Address, chainId: number, refundToken: Address): BigNumber {
707
703
  return refunds.reduce((totalRefund, refunds) => {
708
704
  return totalRefund.add(this.getRefundsFor(refunds, relayer, chainId, refundToken));
709
705
  }, bnZero);
@@ -916,7 +912,11 @@ export class BundleDataClient {
916
912
  "Not using correct bundle deposit hash key"
917
913
  );
918
914
  if (deposit.blockNumber >= originChainBlockRange[0]) {
919
- if (bundleDepositsV3?.[originChainId]?.[deposit.inputToken]?.find((d) => duplicateEvent(deposit, d))) {
915
+ if (
916
+ bundleDepositsV3?.[originChainId]?.[deposit.inputToken.toBytes32()]?.find((d) =>
917
+ duplicateEvent(deposit, d)
918
+ )
919
+ ) {
920
920
  this.logger.debug({
921
921
  at: "BundleDataClient#loadData",
922
922
  message: "Duplicate deposit detected",