@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
@@ -1,5 +1,5 @@
1
1
  // Create a combined `refunds` object containing refunds for V2 + V3 fills
2
-
2
+ import assert from "assert";
3
3
  import {
4
4
  BundleDepositsV3,
5
5
  BundleExcessSlowFills,
@@ -17,6 +17,7 @@ import {
17
17
  fixedPointAdjustment,
18
18
  count2DDictionaryValues,
19
19
  count3DDictionaryValues,
20
+ toAddressType,
20
21
  } from "../../../utils";
21
22
  import {
22
23
  addLastRunningBalance,
@@ -65,10 +66,10 @@ export function getRefundsFromBundle(
65
66
  Object.entries(depositsForChain).forEach(([l2TokenAddress, deposits]) => {
66
67
  deposits.forEach((deposit) => {
67
68
  if (combinedRefunds[originChainId][l2TokenAddress] === undefined) {
68
- combinedRefunds[originChainId][l2TokenAddress] = { [deposit.depositor]: deposit.inputAmount };
69
+ combinedRefunds[originChainId][l2TokenAddress] = { [deposit.depositor.toBytes32()]: deposit.inputAmount };
69
70
  } else {
70
- const existingRefundAmount = combinedRefunds[originChainId][l2TokenAddress][deposit.depositor];
71
- combinedRefunds[originChainId][l2TokenAddress][deposit.depositor] = deposit.inputAmount.add(
71
+ const existingRefundAmount = combinedRefunds[originChainId][l2TokenAddress][deposit.depositor.toBytes32()];
72
+ combinedRefunds[originChainId][l2TokenAddress][deposit.depositor.toBytes32()] = deposit.inputAmount.add(
72
73
  existingRefundAmount ?? bnZero
73
74
  );
74
75
  }
@@ -153,19 +154,25 @@ export function _buildPoolRebalanceRoot(
153
154
  // If the repayment token and repayment chain ID do not map to a PoolRebalanceRoute graph, then
154
155
  // there are no relevant L1 running balances.
155
156
  if (
156
- !clients.hubPoolClient.l2TokenHasPoolRebalanceRoute(l2TokenAddress, repaymentChainId, mainnetBundleEndBlock)
157
+ !clients.hubPoolClient.l2TokenHasPoolRebalanceRoute(
158
+ toAddressType(l2TokenAddress, repaymentChainId),
159
+ repaymentChainId,
160
+ mainnetBundleEndBlock
161
+ )
157
162
  ) {
158
163
  chainWithRefundsOnly.add(repaymentChainId);
159
164
  return;
160
165
  }
161
- const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
162
- l2TokenAddress,
166
+ const l1Token = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
167
+ toAddressType(l2TokenAddress, repaymentChainId),
163
168
  repaymentChainId,
164
169
  mainnetBundleEndBlock
165
170
  );
171
+ const l1TokenAddr = l1Token.toNative();
172
+ assert(l1Token.isEVM(), `Expected an EVM address: ${l1TokenAddr}`);
166
173
 
167
- updateRunningBalance(runningBalances, repaymentChainId, l1TokenCounterpart, totalRefundAmount);
168
- updateRunningBalance(realizedLpFees, repaymentChainId, l1TokenCounterpart, totalRealizedLpFee);
174
+ updateRunningBalance(runningBalances, repaymentChainId, l1TokenAddr, totalRefundAmount);
175
+ updateRunningBalance(realizedLpFees, repaymentChainId, l1TokenAddr, totalRealizedLpFee);
169
176
  }
170
177
  );
171
178
  });
@@ -182,12 +189,17 @@ export function _buildPoolRebalanceRoot(
182
189
  Object.entries(depositsForChain).forEach(([outputToken, deposits]) => {
183
190
  deposits.forEach((deposit) => {
184
191
  const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
185
- outputToken,
192
+ toAddressType(outputToken, destinationChainId),
186
193
  destinationChainId,
187
194
  mainnetBundleEndBlock
188
195
  );
189
196
  const lpFee = deposit.lpFeePct.mul(deposit.inputAmount).div(fixedPointAdjustment);
190
- updateRunningBalance(runningBalances, destinationChainId, l1TokenCounterpart, deposit.inputAmount.sub(lpFee));
197
+ updateRunningBalance(
198
+ runningBalances,
199
+ destinationChainId,
200
+ l1TokenCounterpart.toEvmAddress(),
201
+ deposit.inputAmount.sub(lpFee)
202
+ );
191
203
  // Slow fill LP fees are accounted for when the slow fill executes and a V3FilledRelay is emitted. i.e. when
192
204
  // the slow fill execution is included in bundleFillsV3.
193
205
  });
@@ -206,12 +218,17 @@ export function _buildPoolRebalanceRoot(
206
218
  Object.entries(slowFilledDepositsForChain).forEach(([outputToken, slowFilledDeposits]) => {
207
219
  slowFilledDeposits.forEach((deposit) => {
208
220
  const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
209
- outputToken,
221
+ toAddressType(outputToken, destinationChainId),
210
222
  destinationChainId,
211
223
  mainnetBundleEndBlock
212
224
  );
213
225
  const lpFee = deposit.lpFeePct.mul(deposit.inputAmount).div(fixedPointAdjustment);
214
- updateRunningBalance(runningBalances, destinationChainId, l1TokenCounterpart, lpFee.sub(deposit.inputAmount));
226
+ updateRunningBalance(
227
+ runningBalances,
228
+ destinationChainId,
229
+ l1TokenCounterpart.toEvmAddress(),
230
+ lpFee.sub(deposit.inputAmount)
231
+ );
215
232
  // Slow fills don't add to lpFees, only when the slow fill is executed and a V3FilledRelay is emitted, so
216
233
  // we don't need to subtract it here. Moreover, the HubPoole expects bundleLpFees to be > 0.
217
234
  });
@@ -271,11 +288,11 @@ export function _buildPoolRebalanceRoot(
271
288
  return;
272
289
  }
273
290
  const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
274
- inputToken,
291
+ toAddressType(inputToken, originChainId),
275
292
  originChainId,
276
293
  mainnetBundleEndBlock
277
294
  );
278
- updateRunningBalance(runningBalances, originChainId, l1TokenCounterpart, deposit.inputAmount);
295
+ updateRunningBalance(runningBalances, originChainId, l1TokenCounterpart.toEvmAddress(), deposit.inputAmount);
279
296
  });
280
297
  });
281
298
  });
@@ -2,7 +2,7 @@ import _ from "lodash";
2
2
  import assert from "assert";
3
3
  import { providers } from "ethers";
4
4
  import { DepositWithBlock, Fill, FillWithBlock } from "../../../interfaces";
5
- import { isSlowFill, isValidEvmAddress, isDefined, chainIsEvm } from "../../../utils";
5
+ import { isSlowFill, isValidEvmAddress, isDefined, chainIsEvm, Address, toAddressType } from "../../../utils";
6
6
  import { HubPoolClient } from "../../HubPoolClient";
7
7
  import { SVMProvider } from "../../../arch/svm";
8
8
 
@@ -25,7 +25,7 @@ export function getRefundInformationFromFill(
25
25
  bundleEndBlockForMainnet: number
26
26
  ): {
27
27
  chainToSendRefundTo: number;
28
- repaymentToken: string;
28
+ repaymentToken: Address;
29
29
  } {
30
30
  const chainToSendRefundTo = _getRepaymentChainId(relayData, hubPoolClient, bundleEndBlockForMainnet);
31
31
  if (chainToSendRefundTo === relayData.originChainId) {
@@ -49,6 +49,7 @@ export function getRefundInformationFromFill(
49
49
  chainToSendRefundTo,
50
50
  bundleEndBlockForMainnet
51
51
  );
52
+
52
53
  return {
53
54
  chainToSendRefundTo,
54
55
  repaymentToken,
@@ -125,7 +126,11 @@ export async function verifyFillRepayment(
125
126
  return undefined;
126
127
  }
127
128
  }
128
- fill.relayer = destinationRelayer;
129
+ fill.relayer = toAddressType(destinationRelayer, fill.destinationChainId);
130
+ assert(
131
+ fill.relayer.isValidOn(fill.destinationChainId),
132
+ `Cannot re-assign fill to msg.sender: ${destinationRelayer}`
133
+ );
129
134
  } else {
130
135
  return undefined;
131
136
  }
@@ -196,9 +201,8 @@ function _repaymentAddressNeedsToBeOverwritten(fill: Fill): boolean {
196
201
  return false;
197
202
  }
198
203
 
199
- // @todo add Solana logic here:
200
- // - i.e. If chainIsSvm && !isValidSvmAddress(fill.relayer) then return false
201
- // If chainIsEvm && !isValidEvmAddress(fill.relayer) then return false
202
- // If chainIsEvm && isValidEvmAddress(fill.relayer) then return true
203
- return !isValidEvmAddress(fill.relayer);
204
+ // @dev If the repayment chain is EVM, the repayment address is valid if the address is 20 bytes.
205
+ // If the repayment chain is SVM, the repayment address is valid if the address is strictly greater than
206
+ // 20 bytes.
207
+ return !fill.relayer.isValidOn(fill.repaymentChainId);
204
208
  }
@@ -21,6 +21,12 @@ export function buildPoolRebalanceLeafTree(poolRebalanceLeaves: PoolRebalanceLea
21
21
  }
22
22
 
23
23
  const paramType = getParamType("MerkleLibTest", "verifyPoolRebalance", "rebalance");
24
- const hashFn = (input: PoolRebalanceLeaf) => utils.keccak256(utils.defaultAbiCoder.encode([paramType], [input]));
24
+ const hashFn = (input: PoolRebalanceLeaf) => {
25
+ const ethersLeaf = {
26
+ ...input,
27
+ l1Tokens: input.l1Tokens.map((l1Token) => l1Token.toEvmAddress()),
28
+ };
29
+ return utils.keccak256(utils.defaultAbiCoder.encode([paramType], [ethersLeaf]));
30
+ };
25
31
  return new MerkleTree<PoolRebalanceLeaf>(poolRebalanceLeaves, hashFn);
26
32
  }
@@ -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
  });
@@ -14,8 +14,8 @@ import {
14
14
  union,
15
15
  type,
16
16
  } from "superstruct";
17
- import { UNDEFINED_MESSAGE_HASH } from "../../../constants";
18
- import { BigNumber } from "../../../utils";
17
+ import { CHAIN_IDs, UNDEFINED_MESSAGE_HASH } from "../../../constants";
18
+ import { BigNumber, EvmAddress, RawAddress, SvmAddress, toAddressType } 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,31 @@ const BigNumberType = coerce(instance(BigNumber), union([string(), number()]), (
31
31
  }
32
32
  });
33
33
 
34
+ // Accept any concrete implementation of `Address` (Evm, Svm, or Raw) but avoid using the
35
+ // abstract `Address` class directly to keep TypeScript happy.
36
+ const AddressInstanceSS = union([instance(EvmAddress), instance(SvmAddress), instance(RawAddress)]);
37
+
38
+ const AddressType = coerce(AddressInstanceSS, string(), (value) => {
39
+ // Addresses are posted to arweave in their native format (base16 for EVM, base58 for SVM). The chainId for
40
+ // for the event data is not directly available, so infer it based on the shape of the address. RawAddress
41
+ // will be instantiated if the address format does not match the expected family.
42
+ const chainId = value.startsWith("0x") ? CHAIN_IDs.MAINNET : CHAIN_IDs.SOLANA;
43
+ return toAddressType(value, chainId);
44
+ });
45
+
34
46
  const FillTypeSS = number();
35
47
 
36
48
  const V3RelayDataSS = {
37
- inputToken: string(),
49
+ inputToken: AddressType,
38
50
  inputAmount: BigNumberType,
39
- outputToken: string(),
51
+ outputToken: AddressType,
40
52
  outputAmount: BigNumberType,
41
53
  fillDeadline: number(),
42
- exclusiveRelayer: string(),
54
+ exclusiveRelayer: AddressType,
43
55
  exclusivityDeadline: number(),
44
56
  originChainId: number(),
45
- depositor: string(),
46
- recipient: string(),
57
+ depositor: AddressType,
58
+ recipient: AddressType,
47
59
  depositId: BigNumberType,
48
60
  message: string(),
49
61
  };
@@ -67,7 +79,7 @@ const V3DepositSS = {
67
79
  quoteTimestamp: number(),
68
80
  relayerFeePct: optional(BigNumberType),
69
81
  speedUpSignature: optional(string()),
70
- updatedRecipient: optional(string()),
82
+ updatedRecipient: optional(AddressType),
71
83
  updatedOutputAmount: optional(BigNumberType),
72
84
  updatedMessage: optional(string()),
73
85
  };
@@ -88,7 +100,7 @@ const V3DepositWithBlockLpFeeSS = object({
88
100
  const V3RelayExecutionEventInfoSS = object({
89
101
  updatedOutputAmount: BigNumberType,
90
102
  fillType: FillTypeSS,
91
- updatedRecipient: string(),
103
+ updatedRecipient: AddressType,
92
104
  updatedMessage: optional(string()),
93
105
  updatedMessageHash: defaulted(string(), UNDEFINED_MESSAGE_HASH),
94
106
  });
@@ -98,7 +110,7 @@ const V3FillSS = {
98
110
  message: optional(string()),
99
111
  messageHash: defaulted(string(), UNDEFINED_MESSAGE_HASH),
100
112
  destinationChainId: number(),
101
- relayer: string(),
113
+ relayer: AddressType,
102
114
  repaymentChainId: number(),
103
115
  relayExecutionInfo: V3RelayExecutionEventInfoSS,
104
116
  quoteTimestamp: number(),