@across-protocol/sdk 4.2.16-alpha.0 → 4.2.16-alpha.3

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 (211) hide show
  1. package/dist/cjs/arch/evm/SpokeUtils.d.ts +6 -2
  2. package/dist/cjs/arch/evm/SpokeUtils.js +21 -6
  3. package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
  4. package/dist/cjs/arch/svm/SpokeUtils.d.ts +9 -5
  5. package/dist/cjs/arch/svm/SpokeUtils.js +70 -71
  6. package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
  7. package/dist/cjs/arch/svm/utils.d.ts +3 -5
  8. package/dist/cjs/arch/svm/utils.js +20 -28
  9. package/dist/cjs/arch/svm/utils.js.map +1 -1
  10. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  11. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
  12. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  13. package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
  14. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +60 -56
  15. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  16. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +13 -13
  17. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  18. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
  19. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +3 -2
  20. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  21. package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
  22. package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
  23. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +3 -3
  24. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
  25. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
  26. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +11 -8
  27. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  28. package/dist/cjs/clients/HubPoolClient.d.ts +21 -21
  29. package/dist/cjs/clients/HubPoolClient.js +83 -58
  30. package/dist/cjs/clients/HubPoolClient.js.map +1 -1
  31. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +1 -1
  32. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  33. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
  34. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +64 -45
  35. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  36. package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +9 -9
  37. package/dist/cjs/clients/mocks/MockHubPoolClient.js +15 -9
  38. package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
  39. package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +5 -3
  40. package/dist/cjs/clients/mocks/MockSpokePoolClient.js +40 -36
  41. package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
  42. package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
  43. package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js +3 -4
  44. package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
  45. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.d.ts +3 -3
  46. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +2 -2
  47. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
  48. package/dist/cjs/interfaces/HubPool.d.ts +19 -14
  49. package/dist/cjs/interfaces/SpokePool.d.ts +13 -13
  50. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
  51. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +10 -10
  52. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  53. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +5 -5
  54. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +42 -49
  55. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  56. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
  57. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +7 -7
  58. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  59. package/dist/cjs/utils/AddressUtils.d.ts +12 -13
  60. package/dist/cjs/utils/AddressUtils.js +44 -46
  61. package/dist/cjs/utils/AddressUtils.js.map +1 -1
  62. package/dist/cjs/utils/EventUtils.js +1 -1
  63. package/dist/cjs/utils/EventUtils.js.map +1 -1
  64. package/dist/cjs/utils/SpokeUtils.d.ts +3 -3
  65. package/dist/cjs/utils/SpokeUtils.js +4 -22
  66. package/dist/cjs/utils/SpokeUtils.js.map +1 -1
  67. package/dist/cjs/utils/TokenUtils.d.ts +4 -4
  68. package/dist/cjs/utils/TokenUtils.js +4 -6
  69. package/dist/cjs/utils/TokenUtils.js.map +1 -1
  70. package/dist/esm/arch/evm/SpokeUtils.d.ts +6 -2
  71. package/dist/esm/arch/evm/SpokeUtils.js +22 -7
  72. package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
  73. package/dist/esm/arch/svm/SpokeUtils.d.ts +9 -5
  74. package/dist/esm/arch/svm/SpokeUtils.js +74 -75
  75. package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
  76. package/dist/esm/arch/svm/utils.d.ts +6 -8
  77. package/dist/esm/arch/svm/utils.js +21 -27
  78. package/dist/esm/arch/svm/utils.js.map +1 -1
  79. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  80. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
  81. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  82. package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
  83. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +61 -57
  84. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  85. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +14 -14
  86. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  87. package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
  88. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +5 -3
  89. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  90. package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
  91. package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
  92. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +4 -4
  93. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
  94. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
  95. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +12 -9
  96. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  97. package/dist/esm/clients/HubPoolClient.d.ts +23 -22
  98. package/dist/esm/clients/HubPoolClient.js +97 -63
  99. package/dist/esm/clients/HubPoolClient.js.map +1 -1
  100. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
  101. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  102. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
  103. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +67 -47
  104. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  105. package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +9 -9
  106. package/dist/esm/clients/mocks/MockHubPoolClient.js +16 -10
  107. package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
  108. package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +5 -3
  109. package/dist/esm/clients/mocks/MockSpokePoolClient.js +42 -38
  110. package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
  111. package/dist/esm/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
  112. package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js +4 -5
  113. package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
  114. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.d.ts +3 -3
  115. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +3 -3
  116. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
  117. package/dist/esm/interfaces/HubPool.d.ts +19 -14
  118. package/dist/esm/interfaces/SpokePool.d.ts +13 -13
  119. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
  120. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +11 -11
  121. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  122. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +6 -6
  123. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +44 -51
  124. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  125. package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
  126. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +8 -8
  127. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  128. package/dist/esm/utils/AddressUtils.d.ts +13 -14
  129. package/dist/esm/utils/AddressUtils.js +50 -56
  130. package/dist/esm/utils/AddressUtils.js.map +1 -1
  131. package/dist/esm/utils/EventUtils.js +2 -2
  132. package/dist/esm/utils/EventUtils.js.map +1 -1
  133. package/dist/esm/utils/SpokeUtils.d.ts +3 -8
  134. package/dist/esm/utils/SpokeUtils.js +4 -26
  135. package/dist/esm/utils/SpokeUtils.js.map +1 -1
  136. package/dist/esm/utils/TokenUtils.d.ts +4 -16
  137. package/dist/esm/utils/TokenUtils.js +5 -7
  138. package/dist/esm/utils/TokenUtils.js.map +1 -1
  139. package/dist/types/arch/evm/SpokeUtils.d.ts +6 -2
  140. package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
  141. package/dist/types/arch/svm/SpokeUtils.d.ts +9 -5
  142. package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
  143. package/dist/types/arch/svm/utils.d.ts +6 -8
  144. package/dist/types/arch/svm/utils.d.ts.map +1 -1
  145. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  146. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
  147. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
  148. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  149. package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
  150. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
  151. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
  152. package/dist/types/clients/BundleDataClient/utils/MerkleTreeUtils.d.ts.map +1 -1
  153. package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts.map +1 -1
  154. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
  155. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
  156. package/dist/types/clients/HubPoolClient.d.ts +23 -22
  157. package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
  158. package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
  159. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
  160. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
  161. package/dist/types/clients/mocks/MockHubPoolClient.d.ts +9 -9
  162. package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
  163. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +5 -3
  164. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
  165. package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
  166. package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts.map +1 -1
  167. package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts +3 -3
  168. package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts.map +1 -1
  169. package/dist/types/interfaces/HubPool.d.ts +19 -14
  170. package/dist/types/interfaces/HubPool.d.ts.map +1 -1
  171. package/dist/types/interfaces/SpokePool.d.ts +13 -13
  172. package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
  173. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
  174. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
  175. package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +6 -6
  176. package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
  177. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
  178. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
  179. package/dist/types/utils/AddressUtils.d.ts +13 -14
  180. package/dist/types/utils/AddressUtils.d.ts.map +1 -1
  181. package/dist/types/utils/SpokeUtils.d.ts +3 -8
  182. package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
  183. package/dist/types/utils/TokenUtils.d.ts +4 -16
  184. package/dist/types/utils/TokenUtils.d.ts.map +1 -1
  185. package/package.json +2 -3
  186. package/src/arch/evm/SpokeUtils.ts +52 -12
  187. package/src/arch/svm/SpokeUtils.ts +108 -59
  188. package/src/arch/svm/utils.ts +11 -20
  189. package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -4
  190. package/src/clients/BundleDataClient/BundleDataClient.ts +57 -53
  191. package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +28 -13
  192. package/src/clients/BundleDataClient/utils/FillUtils.ts +10 -4
  193. package/src/clients/BundleDataClient/utils/MerkleTreeUtils.ts +7 -1
  194. package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +4 -4
  195. package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +13 -9
  196. package/src/clients/HubPoolClient.ts +126 -82
  197. package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +6 -0
  198. package/src/clients/SpokePoolClient/SpokePoolClient.ts +118 -35
  199. package/src/clients/mocks/MockHubPoolClient.ts +24 -19
  200. package/src/clients/mocks/MockSpokePoolClient.ts +39 -27
  201. package/src/clients/mocks/MockSvmCpiEventsClient.ts +3 -5
  202. package/src/clients/mocks/MockSvmSpokePoolClient.ts +12 -3
  203. package/src/interfaces/HubPool.ts +23 -14
  204. package/src/interfaces/SpokePool.ts +13 -13
  205. package/src/relayFeeCalculator/chain-queries/baseQuery.ts +14 -12
  206. package/src/relayFeeCalculator/chain-queries/svmQuery.ts +42 -46
  207. package/src/relayFeeCalculator/relayFeeCalculator.ts +20 -12
  208. package/src/utils/AddressUtils.ts +58 -60
  209. package/src/utils/EventUtils.ts +2 -2
  210. package/src/utils/SpokeUtils.ts +11 -33
  211. package/src/utils/TokenUtils.ts +10 -11
@@ -1,4 +1,4 @@
1
- import { BigNumber } from "../utils";
1
+ import { Address, BigNumber, EvmAddress } from "../utils";
2
2
  import { SortableEvent } from "./Common";
3
3
 
4
4
  export interface PoolRebalanceLeaf {
@@ -8,7 +8,7 @@ export interface PoolRebalanceLeaf {
8
8
  netSendAmounts: BigNumber[];
9
9
  runningBalances: BigNumber[];
10
10
  leafId: number;
11
- l1Tokens: string[];
11
+ l1Tokens: EvmAddress[];
12
12
  }
13
13
 
14
14
  export interface RelayerRefundLeaf {
@@ -16,8 +16,8 @@ export interface RelayerRefundLeaf {
16
16
  chainId: number;
17
17
  refundAmounts: BigNumber[];
18
18
  leafId: number;
19
- l2TokenAddress: string;
20
- refundAddresses: string[];
19
+ l2TokenAddress: Address;
20
+ refundAddresses: Address[];
21
21
  }
22
22
 
23
23
  export interface ProposedRootBundle extends SortableEvent {
@@ -27,7 +27,7 @@ export interface ProposedRootBundle extends SortableEvent {
27
27
  poolRebalanceRoot: string;
28
28
  relayerRefundRoot: string;
29
29
  slowRelayRoot: string;
30
- proposer: string;
30
+ proposer: EvmAddress;
31
31
  }
32
32
 
33
33
  export type RealizedLpFee = {
@@ -55,7 +55,7 @@ export interface ExecutedRootBundle extends SortableEvent {
55
55
  netSendAmounts: BigNumber[];
56
56
  runningBalances: BigNumber[];
57
57
  leafId: number;
58
- l1Tokens: string[];
58
+ l1Tokens: EvmAddress[];
59
59
  proof: string[];
60
60
  }
61
61
 
@@ -76,8 +76,14 @@ export interface RelayerRefundLeafWithGroup extends RelayerRefundLeaf {
76
76
  groupIndex: number;
77
77
  }
78
78
 
79
- export interface L1Token {
80
- address: string;
79
+ export interface L1TokenInfo {
80
+ address: EvmAddress;
81
+ symbol: string;
82
+ decimals: number;
83
+ }
84
+
85
+ export interface TokenInfo {
86
+ address: Address;
81
87
  symbol: string;
82
88
  decimals: number;
83
89
  }
@@ -87,27 +93,30 @@ export interface LpToken {
87
93
  liquidReserves: BigNumber;
88
94
  }
89
95
 
96
+ // TODO: I think I don't change string -> Address in the Events. I change right after the event is read
90
97
  export interface CrossChainContractsSet extends SortableEvent {
91
98
  l2ChainId: number;
92
- spokePool: string;
99
+ spokePool: Address;
93
100
  }
94
101
 
102
+ // TODO: I think I don't change string -> Address in the Events. I change right after the event is read
95
103
  export interface DestinationTokenWithBlock extends SortableEvent {
96
- l2Token: string;
97
- l1Token: string;
104
+ l2Token: Address;
105
+ l1Token: EvmAddress;
98
106
  }
99
107
 
108
+ // TODO: I think I don't change string -> Address in the Events. I change right after the event is read
100
109
  export interface SetPoolRebalanceRoot extends SortableEvent {
101
110
  destinationChainId: number;
102
- l1Token: string;
103
- destinationToken: string;
111
+ l1Token: EvmAddress;
112
+ destinationToken: Address;
104
113
  }
105
114
 
106
115
  export interface PendingRootBundle {
107
116
  poolRebalanceRoot: string;
108
117
  relayerRefundRoot: string;
109
118
  slowRelayRoot: string;
110
- proposer: string;
119
+ proposer: EvmAddress;
111
120
  unclaimedPoolRebalanceLeafCount: number;
112
121
  challengePeriodEndTimestamp: number;
113
122
  bundleEvaluationBlockNumbers: number[];
@@ -1,20 +1,20 @@
1
1
  import { SortableEvent } from "./Common";
2
2
  import { SpokePoolClient } from "../clients";
3
- import { BigNumber } from "../utils";
3
+ import { BigNumber, Address, EvmAddress } from "../utils";
4
4
  import { RelayerRefundLeaf } from "./HubPool";
5
5
 
6
6
  export interface RelayData {
7
7
  originChainId: number;
8
- depositor: string;
9
- recipient: string;
8
+ depositor: Address;
9
+ recipient: Address;
10
10
  depositId: BigNumber;
11
- inputToken: string;
11
+ inputToken: Address;
12
12
  inputAmount: BigNumber;
13
- outputToken: string;
13
+ outputToken: Address;
14
14
  outputAmount: BigNumber;
15
15
  message: string;
16
16
  fillDeadline: number;
17
- exclusiveRelayer: string;
17
+ exclusiveRelayer: Address;
18
18
  exclusivityDeadline: number;
19
19
  }
20
20
 
@@ -23,7 +23,7 @@ export interface Deposit extends RelayData {
23
23
  destinationChainId: number;
24
24
  quoteTimestamp: number;
25
25
  speedUpSignature?: string;
26
- updatedRecipient?: string;
26
+ updatedRecipient?: Address;
27
27
  updatedOutputAmount?: BigNumber;
28
28
  updatedMessage?: string;
29
29
  fromLiteChain: boolean;
@@ -51,7 +51,7 @@ export enum FillType {
51
51
  }
52
52
 
53
53
  export interface RelayExecutionEventInfo {
54
- updatedRecipient: string;
54
+ updatedRecipient: Address;
55
55
  updatedOutputAmount: BigNumber;
56
56
  updatedMessage?: string;
57
57
  updatedMessageHash: string;
@@ -61,7 +61,7 @@ export interface RelayExecutionEventInfo {
61
61
  export interface Fill extends Omit<RelayData, "message"> {
62
62
  messageHash: string;
63
63
  destinationChainId: number;
64
- relayer: string;
64
+ relayer: Address;
65
65
  repaymentChainId: number;
66
66
  relayExecutionInfo: RelayExecutionEventInfo;
67
67
  }
@@ -72,18 +72,18 @@ export interface FillWithTime extends Fill, SortableEvent {
72
72
  }
73
73
 
74
74
  export interface EnabledDepositRoute {
75
- originToken: string;
75
+ originToken: Address;
76
76
  destinationChainId: number;
77
77
  enabled: boolean;
78
78
  }
79
79
 
80
80
  export interface EnabledDepositRouteWithBlock extends EnabledDepositRoute, SortableEvent {}
81
81
  export interface SpeedUp {
82
- depositor: string;
82
+ depositor: EvmAddress;
83
83
  depositorSignature: string;
84
84
  depositId: BigNumber;
85
85
  originChainId: number;
86
- updatedRecipient: string;
86
+ updatedRecipient: Address;
87
87
  updatedOutputAmount: BigNumber;
88
88
  updatedMessage: string;
89
89
  }
@@ -130,7 +130,7 @@ export interface TokensBridged extends SortableEvent {
130
130
  amountToReturn: BigNumber;
131
131
  chainId: number;
132
132
  leafId: number;
133
- l2TokenAddress: string;
133
+ l2TokenAddress: Address;
134
134
  }
135
135
 
136
136
  export interface ClaimedRelayerRefundWithBlock extends SortableEvent {
@@ -15,11 +15,13 @@ import {
15
15
  bnZero,
16
16
  chainIsOPStack,
17
17
  fixedPointAdjustment,
18
+ toAddressType,
19
+ Address,
18
20
  } from "../../utils";
19
21
  import assert from "assert";
20
22
  import { Logger, QueryInterface, getDefaultSimulatedRelayerAddress } from "../relayFeeCalculator";
21
23
  import { Transport } from "viem";
22
- import { getGasPriceEstimate, EvmGasPriceEstimate } from "../../gasPriceOracle";
24
+ import { getGasPriceEstimate } from "../../gasPriceOracle";
23
25
  import { EvmProvider } from "../../arch/evm/types";
24
26
 
25
27
  export type SymbolMappingType = Record<
@@ -72,7 +74,7 @@ export class QueryBase implements QueryInterface {
72
74
  */
73
75
  async getGasCosts(
74
76
  deposit: Omit<Deposit, "messageHash">,
75
- relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
77
+ relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId),
76
78
  options: Partial<{
77
79
  gasPrice: BigNumberish;
78
80
  gasUnits: BigNumberish;
@@ -122,7 +124,7 @@ export class QueryBase implements QueryInterface {
122
124
  */
123
125
  getUnsignedTxFromDeposit(
124
126
  deposit: Omit<Deposit, "messageHash">,
125
- relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
127
+ relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId)
126
128
  ): Promise<PopulatedTransaction> {
127
129
  return populateV3Relay(this.spokePool, deposit, relayer);
128
130
  }
@@ -135,10 +137,10 @@ export class QueryBase implements QueryInterface {
135
137
  */
136
138
  async getNativeGasCost(
137
139
  deposit: Omit<Deposit, "messageHash">,
138
- relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
140
+ relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId)
139
141
  ): Promise<BigNumber> {
140
142
  const unsignedTx = await this.getUnsignedTxFromDeposit(deposit, relayer);
141
- const voidSigner = new VoidSigner(relayer, this.provider);
143
+ const voidSigner = new VoidSigner(relayer.toEvmAddress(), this.provider);
142
144
  return voidSigner.estimateGas(unsignedTx);
143
145
  }
144
146
 
@@ -152,7 +154,7 @@ export class QueryBase implements QueryInterface {
152
154
  */
153
155
  async getOpStackL1DataFee(
154
156
  unsignedTx: PopulatedTransaction,
155
- relayer = getDefaultSimulatedRelayerAddress(unsignedTx.chainId),
157
+ relayer = toAddressType(getDefaultSimulatedRelayerAddress(unsignedTx.chainId), CHAIN_IDs.MAINNET),
156
158
  options: Partial<{
157
159
  opStackL2GasUnits: BigNumberish;
158
160
  opStackL1DataFeeMultiplier: BigNumber;
@@ -161,7 +163,7 @@ export class QueryBase implements QueryInterface {
161
163
  const { opStackL2GasUnits, opStackL1DataFeeMultiplier = toBNWei("1") } = options || {};
162
164
  const { chainId } = await this.provider.getNetwork();
163
165
  assert(isOptimismL2Provider(this.provider), `Unexpected provider for chain ID ${chainId}.`);
164
- const voidSigner = new VoidSigner(relayer, this.provider);
166
+ const voidSigner = new VoidSigner(relayer.toEvmAddress(), this.provider);
165
167
  const populatedTransaction = await voidSigner.populateTransaction({
166
168
  ...unsignedTx,
167
169
  gasLimit: opStackL2GasUnits, // prevents additional gas estimation call
@@ -183,7 +185,7 @@ export class QueryBase implements QueryInterface {
183
185
  */
184
186
  async estimateGas(
185
187
  unsignedTx: PopulatedTransaction,
186
- senderAddress: string,
188
+ senderAddress: Address,
187
189
  provider: providers.Provider | L2Provider<providers.Provider>,
188
190
  options: Partial<{
189
191
  gasPrice: BigNumberish;
@@ -204,7 +206,7 @@ export class QueryBase implements QueryInterface {
204
206
  } = options || {};
205
207
 
206
208
  const { chainId } = await provider.getNetwork();
207
- const voidSigner = new VoidSigner(senderAddress, provider);
209
+ const voidSigner = new VoidSigner(senderAddress.toEvmAddress(), provider);
208
210
 
209
211
  // Estimate the Gas units required to submit this transaction.
210
212
  const queries = [
@@ -213,9 +215,9 @@ export class QueryBase implements QueryInterface {
213
215
  ? Promise.resolve({ maxFeePerGas: _gasPrice })
214
216
  : getGasPriceEstimate(provider, { chainId, baseFeeMultiplier, priorityFeeMultiplier, transport, unsignedTx }),
215
217
  ] as const;
216
- const [nativeGasCost, _gasPriceEstimate] = await Promise.all(queries);
217
- // It should be safe to cast to an EvmGasPriceEstimate here since QueryBase is only used for EVM chains.
218
- const gasPrice = (_gasPriceEstimate as EvmGasPriceEstimate).maxFeePerGas;
218
+ const [nativeGasCost, gasPriceEstimate] = await Promise.all(queries);
219
+
220
+ const gasPrice = gasPriceEstimate.maxFeePerGas;
219
221
  assert(nativeGasCost.gt(bnZero), "Gas cost should not be 0");
220
222
  let tokenGasCost: BigNumber;
221
223
 
@@ -6,17 +6,17 @@ import { getComputeUnitEstimateForTransactionMessageFactory } from "@solana/kit"
6
6
  import {
7
7
  SVMProvider,
8
8
  SolanaVoidSigner,
9
- bigToU8a32,
10
9
  createFillInstruction,
11
10
  getAssociatedTokenAddress,
12
11
  getEventAuthority,
13
12
  getFillRelayDelegatePda,
14
13
  getFillStatusPda,
15
14
  getStatePda,
15
+ toAddress,
16
16
  } from "../../arch/svm";
17
17
  import { Coingecko } from "../../coingecko";
18
18
  import { CHAIN_IDs } from "../../constants";
19
- import { SvmGasPriceEstimate, getGasPriceEstimate } from "../../gasPriceOracle";
19
+ import { getGasPriceEstimate } from "../../gasPriceOracle";
20
20
  import { Deposit } from "../../interfaces";
21
21
  import {
22
22
  BigNumber,
@@ -41,7 +41,7 @@ export class SvmQuery implements QueryInterface {
41
41
  * Instantiates a SvmQuery instance
42
42
  * @param provider A valid solana/kit rpc client.
43
43
  * @param symbolMapping A mapping to valid ERC20 tokens and their respective characteristics
44
- * @param spokePoolAddress The valid address of the Spoke Pool deployment
44
+ * @param spokePool The valid address of the Spoke Pool deployment
45
45
  * @param simulatedRelayerAddress The address that these queries will reference as the sender. Note: This address must be approved for USDC
46
46
  * @param logger A logging utility to report logs
47
47
  * @param coingeckoProApiKey An optional CoinGecko API key that links to a PRO account
@@ -51,7 +51,7 @@ export class SvmQuery implements QueryInterface {
51
51
  constructor(
52
52
  readonly provider: SVMProvider,
53
53
  readonly symbolMapping: SymbolMappingType,
54
- readonly spokePoolAddress: SvmAddress,
54
+ readonly spokePool: SvmAddress,
55
55
  readonly simulatedRelayerAddress: SvmAddress,
56
56
  readonly logger: Logger,
57
57
  readonly coingeckoProApiKey?: string,
@@ -75,7 +75,7 @@ export class SvmQuery implements QueryInterface {
75
75
  */
76
76
  async getGasCosts(
77
77
  deposit: Omit<Deposit, "messageHash">,
78
- _relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
78
+ relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId),
79
79
  options: Partial<{
80
80
  gasPrice: BigNumberish;
81
81
  gasUnits: BigNumberish;
@@ -83,10 +83,9 @@ export class SvmQuery implements QueryInterface {
83
83
  priorityFeeMultiplier: BigNumber;
84
84
  }> = {}
85
85
  ): Promise<TransactionCostEstimate> {
86
- const relayer = _relayer ? toAddressType(_relayer).forceSvmAddress() : this.simulatedRelayerAddress;
87
- const fillRelayTx = await this.getFillRelayTx(deposit, relayer.toBase58());
86
+ const fillRelayTx = await this.getFillRelayTx(deposit, relayer);
88
87
 
89
- const [computeUnitsConsumed, _gasPriceEstimate] = await Promise.all([
88
+ const [computeUnitsConsumed, gasPriceEstimate] = await Promise.all([
90
89
  toBN(await this.computeUnitEstimator(fillRelayTx)),
91
90
  getGasPriceEstimate(this.provider, {
92
91
  unsignedTx: fillRelayTx,
@@ -97,7 +96,6 @@ export class SvmQuery implements QueryInterface {
97
96
 
98
97
  // We can cast the gas price estimate to an SvmGasPriceEstimate here since the oracle should always
99
98
  // query the Solana adapter.
100
- const gasPriceEstimate = _gasPriceEstimate as SvmGasPriceEstimate;
101
99
  const gasPrice = gasPriceEstimate.baseFee.add(
102
100
  gasPriceEstimate.microLamportsPerComputeUnit.mul(computeUnitsConsumed).div(toBN(1_000_000)) // 1_000_000 microLamports/lamport.
103
101
  );
@@ -117,7 +115,7 @@ export class SvmQuery implements QueryInterface {
117
115
  */
118
116
  async getNativeGasCost(
119
117
  deposit: Omit<Deposit, "messageHash">,
120
- _relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
118
+ _relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId)
121
119
  ): Promise<BigNumber> {
122
120
  const fillRelayTx = await this.getFillRelayTx(deposit, _relayer);
123
121
  return toBN(await this.computeUnitEstimator(fillRelayTx));
@@ -131,43 +129,41 @@ export class SvmQuery implements QueryInterface {
131
129
  */
132
130
  async getFillRelayTx(
133
131
  deposit: Omit<Deposit, "messageHash">,
134
- _relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
132
+ relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId),
135
133
  repaymentChainId = deposit.destinationChainId,
136
- repaymentAddress = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
134
+ repaymentAddress = toAddressType(
135
+ getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
136
+ deposit.destinationChainId
137
+ )
137
138
  ) {
138
- const toSvmAddress = (address: string) => toAddressType(address).forceSvmAddress().toV2Address();
139
- const relayer = _relayer ? toAddressType(_relayer).forceSvmAddress() : this.simulatedRelayerAddress;
140
- const state = await getStatePda(this.spokePoolAddress.toV2Address());
141
- const _relayDataHash = getRelayDataHash(deposit, deposit.destinationChainId);
139
+ const { depositor, recipient, inputToken, outputToken, exclusiveRelayer, destinationChainId } = deposit;
140
+
141
+ const program = toAddress(this.spokePool);
142
+ const _relayDataHash = getRelayDataHash(deposit, destinationChainId);
142
143
  const relayDataHash = new Uint8Array(Buffer.from(_relayDataHash.slice(2), "hex"));
143
- const delegate = await getFillRelayDelegatePda(
144
- relayDataHash,
145
- BigInt(repaymentChainId),
146
- toSvmAddress(repaymentAddress),
147
- this.spokePoolAddress.toV2Address()
148
- );
149
- const mint = toAddressType(deposit.outputToken).forceSvmAddress();
150
- const mintInfo = await fetchMint(this.provider, mint.toV2Address());
151
- const recipientAta = await getAssociatedTokenAddress(
152
- toAddressType(deposit.recipient).forceSvmAddress(),
153
- mint,
154
- mintInfo.programAddress
155
- );
156
- const relayerAta = await getAssociatedTokenAddress(
157
- SvmAddress.from(relayer.toBase58()),
158
- mint,
159
- mintInfo.programAddress
160
- );
161
- const fillStatus = await getFillStatusPda(this.spokePoolAddress.toV2Address(), deposit, deposit.destinationChainId);
162
- const eventAuthority = await getEventAuthority();
144
+
145
+ const [state, delegate] = await Promise.all([
146
+ getStatePda(program),
147
+ getFillRelayDelegatePda(relayDataHash, BigInt(repaymentChainId), toAddress(repaymentAddress), program),
148
+ ]);
149
+
150
+ const mint = toAddress(outputToken);
151
+ const mintInfo = await fetchMint(this.provider, mint);
152
+
153
+ const [recipientAta, relayerAta, fillStatus, eventAuthority] = await Promise.all([
154
+ getAssociatedTokenAddress(deposit.recipient, outputToken, mintInfo.programAddress),
155
+ getAssociatedTokenAddress(SvmAddress.from(relayer.toBase58()), outputToken, mintInfo.programAddress),
156
+ getFillStatusPda(program, deposit, destinationChainId),
157
+ getEventAuthority(program),
158
+ ]);
163
159
 
164
160
  const relayData: SvmSpokeClient.FillRelayInput["relayData"] = {
165
- depositor: toSvmAddress(deposit.depositor),
166
- recipient: toSvmAddress(deposit.recipient),
167
- exclusiveRelayer: toSvmAddress(deposit.exclusiveRelayer),
168
- inputToken: toSvmAddress(deposit.inputToken),
169
- outputToken: mint.toV2Address(),
170
- inputAmount: bigToU8a32(deposit.inputAmount),
161
+ depositor: toAddress(depositor),
162
+ recipient: toAddress(recipient),
163
+ exclusiveRelayer: toAddress(exclusiveRelayer),
164
+ inputToken: toAddress(inputToken),
165
+ outputToken: mint,
166
+ inputAmount: deposit.inputAmount.toBigInt(),
171
167
  outputAmount: deposit.outputAmount.toBigInt(),
172
168
  originChainId: deposit.originChainId,
173
169
  depositId: new Uint8Array(intToU8Array32(deposit.depositId.toNumber())),
@@ -181,19 +177,19 @@ export class SvmQuery implements QueryInterface {
181
177
  signer: simulatedSigner,
182
178
  state,
183
179
  delegate,
184
- mint: mint.toV2Address(),
180
+ mint,
185
181
  relayerTokenAccount: relayerAta,
186
182
  recipientTokenAccount: recipientAta,
187
183
  fillStatus,
188
184
  tokenProgram: mintInfo.programAddress,
189
185
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
190
186
  systemProgram: SYSTEM_PROGRAM_ADDRESS,
191
- eventAuthority: eventAuthority,
192
- program: this.spokePoolAddress.toV2Address(),
187
+ eventAuthority,
188
+ program,
193
189
  relayHash: relayDataHash,
194
190
  relayData,
195
191
  repaymentChainId: BigInt(repaymentChainId),
196
- repaymentAddress: toSvmAddress(repaymentAddress),
192
+ repaymentAddress: toAddress(repaymentAddress),
197
193
  };
198
194
  // Pass createRecipientAtaIfNeeded =true to the createFillInstruction function to create the recipient token account
199
195
  // if it doesn't exist.
@@ -9,12 +9,9 @@ import { Deposit } from "../interfaces";
9
9
  import {
10
10
  BigNumber,
11
11
  BigNumberish,
12
- ConvertDecimals,
13
12
  MAX_BIG_INT,
14
13
  TransactionCostEstimate,
15
14
  bnZero,
16
- chainIsSvm,
17
- compareAddressesSimple,
18
15
  fixedPointAdjustment,
19
16
  getTokenInfo,
20
17
  isDefined,
@@ -25,13 +22,18 @@ import {
25
22
  percent,
26
23
  toBN,
27
24
  toBNWei,
25
+ compareAddressesSimple,
26
+ ConvertDecimals,
27
+ chainIsSvm,
28
+ toAddressType,
29
+ Address,
28
30
  } from "../utils";
29
31
 
30
32
  // This needs to be implemented for every chain and passed into RelayFeeCalculator
31
33
  export interface QueryInterface {
32
34
  getGasCosts: (
33
35
  deposit: Omit<Deposit, "messageHash">,
34
- relayer: string,
36
+ relayer: Address,
35
37
  options?: Partial<{
36
38
  gasPrice: BigNumberish;
37
39
  gasUnits: BigNumberish;
@@ -42,7 +44,7 @@ export interface QueryInterface {
42
44
  }>
43
45
  ) => Promise<TransactionCostEstimate>;
44
46
  getTokenPrice: (tokenSymbol: string) => Promise<number>;
45
- getNativeGasCost: (deposit: Omit<Deposit, "messageHash">, relayer: string) => Promise<BigNumber>;
47
+ getNativeGasCost: (deposit: Omit<Deposit, "messageHash">, relayer: Address) => Promise<BigNumber>;
46
48
  }
47
49
 
48
50
  export const expectedCapitalCostsKeys = ["lowerBound", "upperBound", "cutoff", "decimals"];
@@ -254,7 +256,10 @@ export class RelayFeeCalculator {
254
256
  deposit: Deposit,
255
257
  outputAmount: BigNumberish,
256
258
  simulateZeroFill = false,
257
- relayerAddress = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
259
+ relayerAddress = toAddressType(
260
+ getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
261
+ deposit.destinationChainId
262
+ ),
258
263
  _tokenPrice?: number,
259
264
  tokenMapping = TOKEN_SYMBOLS_MAP,
260
265
  gasPrice?: BigNumberish,
@@ -271,14 +276,14 @@ export class RelayFeeCalculator {
271
276
  // undefined address on destination.
272
277
  const destinationChainTokenDetails = Object.values(tokenMapping).find(
273
278
  (details) =>
274
- compareAddressesSimple(details.addresses[originChainId], inputToken) &&
279
+ compareAddressesSimple(details.addresses[originChainId], inputToken.toNative()) &&
275
280
  isDefined(details.addresses[destinationChainId])
276
281
  );
277
282
  const outputToken = isZeroAddress(deposit.outputToken)
278
283
  ? destinationChainTokenDetails!.addresses[destinationChainId]
279
- : deposit.outputToken;
284
+ : deposit.outputToken.toNative();
280
285
  const outputTokenInfo = getTokenInfo(outputToken, destinationChainId, tokenMapping);
281
- const inputTokenInfo = getTokenInfo(inputToken, originChainId, tokenMapping);
286
+ const inputTokenInfo = getTokenInfo(inputToken.toNative(), originChainId, tokenMapping);
282
287
  if (!isDefined(outputTokenInfo) || !isDefined(inputTokenInfo)) {
283
288
  throw new Error(`Could not find token information for ${inputToken} or ${outputToken}`);
284
289
  }
@@ -493,7 +498,10 @@ export class RelayFeeCalculator {
493
498
  deposit: Deposit,
494
499
  outputAmount?: BigNumberish,
495
500
  simulateZeroFill = false,
496
- relayerAddress = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
501
+ relayerAddress = toAddressType(
502
+ getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
503
+ deposit.destinationChainId
504
+ ),
497
505
  _tokenPrice?: number,
498
506
  gasPrice?: BigNumberish,
499
507
  gasUnits?: BigNumberish,
@@ -505,8 +513,8 @@ export class RelayFeeCalculator {
505
513
  const { inputToken, originChainId, outputToken, destinationChainId } = deposit;
506
514
  // We can perform a simple lookup with `getTokenInfo` here without resolving the exact token to resolve since we only need to
507
515
  // resolve the L1 token symbol and not the L2 token decimals.
508
- const inputTokenInfo = getTokenInfo(inputToken, originChainId);
509
- const outputTokenInfo = getTokenInfo(outputToken, destinationChainId);
516
+ const inputTokenInfo = getTokenInfo(inputToken.toNative(), originChainId);
517
+ const outputTokenInfo = getTokenInfo(outputToken.toNative(), destinationChainId);
510
518
  if (!isDefined(inputTokenInfo) || !isDefined(outputTokenInfo)) {
511
519
  throw new Error(`Could not find token information for ${inputToken} or ${outputToken}`);
512
520
  }