@across-protocol/sdk 4.2.9-alpha.0 → 4.2.9-alpha.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 (193) hide show
  1. package/dist/cjs/arch/evm/SpokeUtils.d.ts +2 -2
  2. package/dist/cjs/arch/evm/SpokeUtils.js +3 -18
  3. package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
  4. package/dist/cjs/arch/svm/SpokeUtils.d.ts +16 -1
  5. package/dist/cjs/arch/svm/SpokeUtils.js +135 -34
  6. package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
  7. package/dist/cjs/arch/svm/utils.d.ts +5 -1
  8. package/dist/cjs/arch/svm/utils.js +26 -16
  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 +2 -4
  12. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  13. package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +2 -2
  14. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +53 -57
  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 +1 -2
  19. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +2 -3
  20. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  21. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +3 -3
  22. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
  23. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
  24. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +8 -11
  25. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  26. package/dist/cjs/clients/HubPoolClient.d.ts +20 -20
  27. package/dist/cjs/clients/HubPoolClient.js +57 -78
  28. package/dist/cjs/clients/HubPoolClient.js.map +1 -1
  29. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
  30. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  31. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +3 -5
  32. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +29 -35
  33. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  34. package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +9 -9
  35. package/dist/cjs/clients/mocks/MockHubPoolClient.js +9 -15
  36. package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
  37. package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +13 -9
  38. package/dist/cjs/clients/mocks/MockSpokePoolClient.js +56 -40
  39. package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
  40. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
  41. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +2 -2
  42. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
  43. package/dist/cjs/interfaces/HubPool.d.ts +13 -18
  44. package/dist/cjs/interfaces/SpokePool.d.ts +16 -14
  45. package/dist/cjs/interfaces/SpokePool.js.map +1 -1
  46. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
  47. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +7 -7
  48. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  49. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +7 -8
  50. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +73 -64
  51. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  52. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +6 -6
  53. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +7 -7
  54. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  55. package/dist/cjs/utils/AddressUtils.d.ts +4 -7
  56. package/dist/cjs/utils/AddressUtils.js +8 -21
  57. package/dist/cjs/utils/AddressUtils.js.map +1 -1
  58. package/dist/cjs/utils/SpokeUtils.d.ts +3 -3
  59. package/dist/cjs/utils/SpokeUtils.js +22 -4
  60. package/dist/cjs/utils/SpokeUtils.js.map +1 -1
  61. package/dist/cjs/utils/TokenUtils.d.ts +4 -4
  62. package/dist/cjs/utils/TokenUtils.js +3 -3
  63. package/dist/cjs/utils/TokenUtils.js.map +1 -1
  64. package/dist/esm/arch/evm/SpokeUtils.d.ts +2 -2
  65. package/dist/esm/arch/evm/SpokeUtils.js +4 -19
  66. package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
  67. package/dist/esm/arch/svm/SpokeUtils.d.ts +46 -6
  68. package/dist/esm/arch/svm/SpokeUtils.js +164 -43
  69. package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
  70. package/dist/esm/arch/svm/utils.d.ts +11 -1
  71. package/dist/esm/arch/svm/utils.js +31 -16
  72. package/dist/esm/arch/svm/utils.js.map +1 -1
  73. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  74. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +2 -4
  75. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  76. package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +2 -2
  77. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +54 -58
  78. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  79. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +14 -14
  80. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  81. package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +1 -2
  82. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +3 -4
  83. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  84. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +4 -4
  85. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
  86. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
  87. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +9 -12
  88. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  89. package/dist/esm/clients/HubPoolClient.d.ts +21 -22
  90. package/dist/esm/clients/HubPoolClient.js +61 -91
  91. package/dist/esm/clients/HubPoolClient.js.map +1 -1
  92. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +3 -3
  93. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  94. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +3 -5
  95. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +30 -37
  96. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  97. package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +9 -9
  98. package/dist/esm/clients/mocks/MockHubPoolClient.js +10 -16
  99. package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
  100. package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +13 -9
  101. package/dist/esm/clients/mocks/MockSpokePoolClient.js +60 -44
  102. package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
  103. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
  104. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +3 -3
  105. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
  106. package/dist/esm/interfaces/HubPool.d.ts +13 -18
  107. package/dist/esm/interfaces/SpokePool.d.ts +16 -14
  108. package/dist/esm/interfaces/SpokePool.js.map +1 -1
  109. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
  110. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +8 -8
  111. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  112. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +8 -9
  113. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +77 -66
  114. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  115. package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +6 -6
  116. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +8 -8
  117. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  118. package/dist/esm/utils/AddressUtils.d.ts +4 -7
  119. package/dist/esm/utils/AddressUtils.js +10 -25
  120. package/dist/esm/utils/AddressUtils.js.map +1 -1
  121. package/dist/esm/utils/SpokeUtils.d.ts +8 -3
  122. package/dist/esm/utils/SpokeUtils.js +26 -4
  123. package/dist/esm/utils/SpokeUtils.js.map +1 -1
  124. package/dist/esm/utils/TokenUtils.d.ts +16 -4
  125. package/dist/esm/utils/TokenUtils.js +3 -3
  126. package/dist/esm/utils/TokenUtils.js.map +1 -1
  127. package/dist/types/arch/evm/SpokeUtils.d.ts +2 -2
  128. package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
  129. package/dist/types/arch/svm/SpokeUtils.d.ts +46 -6
  130. package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
  131. package/dist/types/arch/svm/utils.d.ts +11 -1
  132. package/dist/types/arch/svm/utils.d.ts.map +1 -1
  133. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  134. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
  135. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +2 -2
  136. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  137. package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
  138. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +1 -2
  139. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
  140. package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts.map +1 -1
  141. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
  142. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
  143. package/dist/types/clients/HubPoolClient.d.ts +21 -22
  144. package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
  145. package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
  146. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +3 -5
  147. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
  148. package/dist/types/clients/mocks/MockHubPoolClient.d.ts +9 -9
  149. package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
  150. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +13 -9
  151. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
  152. package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
  153. package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts.map +1 -1
  154. package/dist/types/interfaces/HubPool.d.ts +13 -18
  155. package/dist/types/interfaces/HubPool.d.ts.map +1 -1
  156. package/dist/types/interfaces/SpokePool.d.ts +16 -14
  157. package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
  158. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
  159. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
  160. package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +8 -9
  161. package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
  162. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +6 -6
  163. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
  164. package/dist/types/utils/AddressUtils.d.ts +4 -7
  165. package/dist/types/utils/AddressUtils.d.ts.map +1 -1
  166. package/dist/types/utils/SpokeUtils.d.ts +8 -3
  167. package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
  168. package/dist/types/utils/TokenUtils.d.ts +16 -4
  169. package/dist/types/utils/TokenUtils.d.ts.map +1 -1
  170. package/package.json +2 -1
  171. package/src/arch/evm/SpokeUtils.ts +8 -22
  172. package/src/arch/svm/SpokeUtils.ts +156 -49
  173. package/src/arch/svm/utils.ts +22 -3
  174. package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +4 -7
  175. package/src/clients/BundleDataClient/BundleDataClient.ts +47 -49
  176. package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +13 -28
  177. package/src/clients/BundleDataClient/utils/FillUtils.ts +4 -6
  178. package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +4 -4
  179. package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +9 -13
  180. package/src/clients/HubPoolClient.ts +79 -113
  181. package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +1 -7
  182. package/src/clients/SpokePoolClient/SpokePoolClient.ts +37 -104
  183. package/src/clients/mocks/MockHubPoolClient.ts +19 -24
  184. package/src/clients/mocks/MockSpokePoolClient.ts +74 -53
  185. package/src/clients/mocks/MockSvmSpokePoolClient.ts +3 -12
  186. package/src/interfaces/HubPool.ts +13 -22
  187. package/src/interfaces/SpokePool.ts +17 -14
  188. package/src/relayFeeCalculator/chain-queries/baseQuery.ts +8 -10
  189. package/src/relayFeeCalculator/chain-queries/svmQuery.ts +92 -91
  190. package/src/relayFeeCalculator/relayFeeCalculator.ts +14 -16
  191. package/src/utils/AddressUtils.ts +14 -32
  192. package/src/utils/SpokeUtils.ts +33 -11
  193. package/src/utils/TokenUtils.ts +7 -7
@@ -2,15 +2,7 @@ import winston from "winston";
2
2
  import { SvmSpokeClient } from "@across-protocol/contracts";
3
3
  import { Address } from "@solana/kit";
4
4
  import { DepositWithBlock, RelayerRefundExecution, SortableEvent, SlowFillLeaf, Log } from "../../interfaces";
5
- import {
6
- getCurrentTime,
7
- bnZero,
8
- MakeOptional,
9
- EventSearchConfig,
10
- Address as SDKAddress,
11
- toAddressType,
12
- isDefined,
13
- } from "../../utils";
5
+ import { getCurrentTime, bnZero, MakeOptional, EventSearchConfig } from "../../utils";
14
6
  import { SpokePoolUpdate, SVMSpokePoolClient } from "../SpokePoolClient";
15
7
  import { HubPoolClient } from "../HubPoolClient";
16
8
  import { EventOverrides } from "./MockEvents";
@@ -54,9 +46,8 @@ export class MockSvmSpokePoolClient extends SVMSpokePoolClient {
54
46
  this.destinationTokenForChainOverride[chainId] = token;
55
47
  }
56
48
 
57
- getDestinationTokenForDeposit(deposit: DepositWithBlock): SDKAddress {
58
- const override = this.destinationTokenForChainOverride[deposit.originChainId];
59
- return isDefined(override) ? toAddressType(override) : super.getDestinationTokenForDeposit(deposit);
49
+ getDestinationTokenForDeposit(deposit: DepositWithBlock): string {
50
+ return this.destinationTokenForChainOverride[deposit.originChainId] ?? super.getDestinationTokenForDeposit(deposit);
60
51
  }
61
52
 
62
53
  setLatestBlockNumber(blockNumber: number): void {
@@ -1,4 +1,4 @@
1
- import { Address, BigNumber, EvmAddress } from "../utils";
1
+ import { BigNumber } 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: EvmAddress[];
11
+ l1Tokens: string[];
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: Address;
20
- refundAddresses: Address[];
19
+ l2TokenAddress: string;
20
+ refundAddresses: string[];
21
21
  }
22
22
 
23
23
  export interface ProposedRootBundle extends SortableEvent {
@@ -55,7 +55,7 @@ export interface ExecutedRootBundle extends SortableEvent {
55
55
  netSendAmounts: BigNumber[];
56
56
  runningBalances: BigNumber[];
57
57
  leafId: number;
58
- l1Tokens: EvmAddress[];
58
+ l1Tokens: string[];
59
59
  proof: string[];
60
60
  }
61
61
 
@@ -76,14 +76,8 @@ export interface RelayerRefundLeafWithGroup extends RelayerRefundLeaf {
76
76
  groupIndex: number;
77
77
  }
78
78
 
79
- export interface L1TokenInfo {
80
- address: EvmAddress;
81
- symbol: string;
82
- decimals: number;
83
- }
84
-
85
- export interface TokenInfo {
86
- address: Address;
79
+ export interface L1Token {
80
+ address: string;
87
81
  symbol: string;
88
82
  decimals: number;
89
83
  }
@@ -93,30 +87,27 @@ export interface LpToken {
93
87
  liquidReserves: BigNumber;
94
88
  }
95
89
 
96
- // TODO: I think I don't change string -> Address in the Events. I change right after the event is read
97
90
  export interface CrossChainContractsSet extends SortableEvent {
98
91
  l2ChainId: number;
99
- spokePool: Address;
92
+ spokePool: string;
100
93
  }
101
94
 
102
- // TODO: I think I don't change string -> Address in the Events. I change right after the event is read
103
95
  export interface DestinationTokenWithBlock extends SortableEvent {
104
- l2Token: Address;
105
- l1Token: EvmAddress;
96
+ l2Token: string;
97
+ l1Token: string;
106
98
  }
107
99
 
108
- // TODO: I think I don't change string -> Address in the Events. I change right after the event is read
109
100
  export interface SetPoolRebalanceRoot extends SortableEvent {
110
101
  destinationChainId: number;
111
- l1Token: EvmAddress;
112
- destinationToken: Address;
102
+ l1Token: string;
103
+ destinationToken: string;
113
104
  }
114
105
 
115
106
  export interface PendingRootBundle {
116
107
  poolRebalanceRoot: string;
117
108
  relayerRefundRoot: string;
118
109
  slowRelayRoot: string;
119
- proposer: EvmAddress;
110
+ proposer: string;
120
111
  unclaimedPoolRebalanceLeafCount: number;
121
112
  challengePeriodEndTimestamp: number;
122
113
  bundleEvaluationBlockNumbers: number[];
@@ -1,20 +1,23 @@
1
1
  import { SortableEvent } from "./Common";
2
+ import { FilledV3RelayEvent, V3FundsDepositedEvent } from "../typechain";
2
3
  import { SpokePoolClient } from "../clients";
3
- import { BigNumber, Address, EvmAddress } from "../utils";
4
+ import { BigNumber } from "../utils";
4
5
  import { RelayerRefundLeaf } from "./HubPool";
5
6
 
7
+ export type { FilledV3RelayEvent, V3FundsDepositedEvent };
8
+
6
9
  export interface RelayData {
7
10
  originChainId: number;
8
- depositor: Address;
9
- recipient: Address;
11
+ depositor: string;
12
+ recipient: string;
10
13
  depositId: BigNumber;
11
- inputToken: Address;
14
+ inputToken: string;
12
15
  inputAmount: BigNumber;
13
- outputToken: Address;
16
+ outputToken: string;
14
17
  outputAmount: BigNumber;
15
18
  message: string;
16
19
  fillDeadline: number;
17
- exclusiveRelayer: Address;
20
+ exclusiveRelayer: string;
18
21
  exclusivityDeadline: number;
19
22
  }
20
23
 
@@ -23,7 +26,7 @@ export interface Deposit extends RelayData {
23
26
  destinationChainId: number;
24
27
  quoteTimestamp: number;
25
28
  speedUpSignature?: string;
26
- updatedRecipient?: Address;
29
+ updatedRecipient?: string;
27
30
  updatedOutputAmount?: BigNumber;
28
31
  updatedMessage?: string;
29
32
  fromLiteChain: boolean;
@@ -51,7 +54,7 @@ export enum FillType {
51
54
  }
52
55
 
53
56
  export interface RelayExecutionEventInfo {
54
- updatedRecipient: Address;
57
+ updatedRecipient: string;
55
58
  updatedOutputAmount: BigNumber;
56
59
  updatedMessage?: string;
57
60
  updatedMessageHash: string;
@@ -61,7 +64,7 @@ export interface RelayExecutionEventInfo {
61
64
  export interface Fill extends Omit<RelayData, "message"> {
62
65
  messageHash: string;
63
66
  destinationChainId: number;
64
- relayer: Address;
67
+ relayer: string;
65
68
  repaymentChainId: number;
66
69
  relayExecutionInfo: RelayExecutionEventInfo;
67
70
  }
@@ -72,25 +75,25 @@ export interface FillWithTime extends Fill, SortableEvent {
72
75
  }
73
76
 
74
77
  export interface EnabledDepositRoute {
75
- originToken: Address;
78
+ originToken: string;
76
79
  destinationChainId: number;
77
80
  enabled: boolean;
78
81
  }
79
82
 
80
83
  export interface EnabledDepositRouteWithBlock extends EnabledDepositRoute, SortableEvent {}
81
84
  export interface SpeedUp {
82
- depositor: EvmAddress;
85
+ depositor: string;
83
86
  depositorSignature: string;
84
87
  depositId: BigNumber;
85
88
  originChainId: number;
86
- updatedRecipient: Address;
89
+ updatedRecipient: string;
87
90
  updatedOutputAmount: BigNumber;
88
91
  updatedMessage: string;
89
92
  }
90
93
 
91
94
  export interface SpeedUpWithBlock extends SpeedUp, SortableEvent {}
92
95
 
93
- export interface SlowFillRequest extends Omit<RelayData, "message"> {
96
+ export interface SlowFillRequest extends RelayData {
94
97
  messageHash: string;
95
98
  destinationChainId: number;
96
99
  }
@@ -130,7 +133,7 @@ export interface TokensBridged extends SortableEvent {
130
133
  amountToReturn: BigNumber;
131
134
  chainId: number;
132
135
  leafId: number;
133
- l2TokenAddress: Address;
136
+ l2TokenAddress: string;
134
137
  }
135
138
 
136
139
  export interface SpokePoolClientsByChain {
@@ -15,8 +15,6 @@ import {
15
15
  bnZero,
16
16
  chainIsOPStack,
17
17
  fixedPointAdjustment,
18
- toAddressType,
19
- Address,
20
18
  } from "../../utils";
21
19
  import assert from "assert";
22
20
  import { Logger, QueryInterface, getDefaultSimulatedRelayerAddress } from "../relayFeeCalculator";
@@ -74,7 +72,7 @@ export class QueryBase implements QueryInterface {
74
72
  */
75
73
  async getGasCosts(
76
74
  deposit: Omit<Deposit, "messageHash">,
77
- relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId)),
75
+ relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
78
76
  options: Partial<{
79
77
  gasPrice: BigNumberish;
80
78
  gasUnits: BigNumberish;
@@ -124,7 +122,7 @@ export class QueryBase implements QueryInterface {
124
122
  */
125
123
  getUnsignedTxFromDeposit(
126
124
  deposit: Omit<Deposit, "messageHash">,
127
- relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId))
125
+ relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
128
126
  ): Promise<PopulatedTransaction> {
129
127
  return populateV3Relay(this.spokePool, deposit, relayer);
130
128
  }
@@ -137,10 +135,10 @@ export class QueryBase implements QueryInterface {
137
135
  */
138
136
  async getNativeGasCost(
139
137
  deposit: Omit<Deposit, "messageHash">,
140
- relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId))
138
+ relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
141
139
  ): Promise<BigNumber> {
142
140
  const unsignedTx = await this.getUnsignedTxFromDeposit(deposit, relayer);
143
- const voidSigner = new VoidSigner(relayer.toEvmAddress(), this.provider);
141
+ const voidSigner = new VoidSigner(relayer, this.provider);
144
142
  return voidSigner.estimateGas(unsignedTx);
145
143
  }
146
144
 
@@ -154,7 +152,7 @@ export class QueryBase implements QueryInterface {
154
152
  */
155
153
  async getOpStackL1DataFee(
156
154
  unsignedTx: PopulatedTransaction,
157
- relayer = toAddressType(getDefaultSimulatedRelayerAddress(unsignedTx.chainId)),
155
+ relayer = getDefaultSimulatedRelayerAddress(unsignedTx.chainId),
158
156
  options: Partial<{
159
157
  opStackL2GasUnits: BigNumberish;
160
158
  opStackL1DataFeeMultiplier: BigNumber;
@@ -163,7 +161,7 @@ export class QueryBase implements QueryInterface {
163
161
  const { opStackL2GasUnits, opStackL1DataFeeMultiplier = toBNWei("1") } = options || {};
164
162
  const { chainId } = await this.provider.getNetwork();
165
163
  assert(isOptimismL2Provider(this.provider), `Unexpected provider for chain ID ${chainId}.`);
166
- const voidSigner = new VoidSigner(relayer.toEvmAddress(), this.provider);
164
+ const voidSigner = new VoidSigner(relayer, this.provider);
167
165
  const populatedTransaction = await voidSigner.populateTransaction({
168
166
  ...unsignedTx,
169
167
  gasLimit: opStackL2GasUnits, // prevents additional gas estimation call
@@ -185,7 +183,7 @@ export class QueryBase implements QueryInterface {
185
183
  */
186
184
  async estimateGas(
187
185
  unsignedTx: PopulatedTransaction,
188
- senderAddress: Address,
186
+ senderAddress: string,
189
187
  provider: providers.Provider | L2Provider<providers.Provider>,
190
188
  options: Partial<{
191
189
  gasPrice: BigNumberish;
@@ -206,7 +204,7 @@ export class QueryBase implements QueryInterface {
206
204
  } = options || {};
207
205
 
208
206
  const { chainId } = await provider.getNetwork();
209
- const voidSigner = new VoidSigner(senderAddress.toEvmAddress(), provider);
207
+ const voidSigner = new VoidSigner(senderAddress, provider);
210
208
 
211
209
  // Estimate the Gas units required to submit this transaction.
212
210
  const queries = [
@@ -1,38 +1,33 @@
1
- import { pipe } from "@solana/functional";
1
+ import { SvmSpokeClient } from "@across-protocol/contracts";
2
+ import { intToU8Array32 } from "@across-protocol/contracts/dist/src/svm/web3-v1/conversionUtils";
3
+ import { SYSTEM_PROGRAM_ADDRESS } from "@solana-program/system";
4
+ import { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, fetchMint } from "@solana-program/token";
5
+ import { getComputeUnitEstimateForTransactionMessageFactory } from "@solana/kit";
6
+ import {
7
+ SVMProvider,
8
+ SolanaVoidSigner,
9
+ createFillInstruction,
10
+ getAssociatedTokenAddress,
11
+ getEventAuthority,
12
+ getFillRelayDelegatePda,
13
+ getFillStatusPda,
14
+ getStatePda,
15
+ } from "../../arch/svm";
2
16
  import { Coingecko } from "../../coingecko";
3
- import { SymbolMappingType } from "./";
4
17
  import { CHAIN_IDs } from "../../constants";
18
+ import { SvmGasPriceEstimate, getGasPriceEstimate } from "../../gasPriceOracle";
5
19
  import { Deposit } from "../../interfaces";
6
- import { getGasPriceEstimate, SvmGasPriceEstimate } from "../../gasPriceOracle";
7
20
  import {
8
- BigNumberish,
9
- TransactionCostEstimate,
10
21
  BigNumber,
22
+ BigNumberish,
11
23
  SvmAddress,
12
- toBN,
13
- isDefined,
24
+ TransactionCostEstimate,
25
+ getRelayDataHash,
14
26
  toAddressType,
27
+ toBN,
15
28
  } from "../../utils";
16
- import { getDefaultSimulatedRelayerAddress, Logger, QueryInterface } from "../relayFeeCalculator";
17
- import {
18
- fillRelayInstruction,
19
- createApproveInstruction,
20
- createTokenAccountsInstruction,
21
- SVMProvider,
22
- SolanaVoidSigner,
23
- getAssociatedTokenAddress,
24
- } from "../../arch/svm";
25
- import {
26
- createTransactionMessage,
27
- setTransactionMessageFeePayer,
28
- setTransactionMessageLifetimeUsingBlockhash,
29
- appendTransactionMessageInstructions,
30
- getComputeUnitEstimateForTransactionMessageFactory,
31
- fetchEncodedAccount,
32
- IInstruction,
33
- } from "@solana/kit";
34
- import { TOKEN_PROGRAM_ADDRESS, getMintSize, getInitializeMintInstruction, fetchMint } from "@solana-program/token";
35
- import { getCreateAccountInstruction } from "@solana-program/system";
29
+ import { Logger, QueryInterface, getDefaultSimulatedRelayerAddress } from "../relayFeeCalculator";
30
+ import { SymbolMappingType } from "./";
36
31
 
37
32
  /**
38
33
  * A special QueryBase implementation for SVM used for querying gas costs, token prices, and decimals of various tokens
@@ -70,7 +65,7 @@ export class SvmQuery implements QueryInterface {
70
65
  /**
71
66
  * Retrieves the current gas costs of performing a fillRelay contract at the referenced SpokePool.
72
67
  * @param deposit V3 deposit instance.
73
- * @param relayerAddress Relayer address to simulate with.
68
+ * @param _relayer Relayer address to simulate with.
74
69
  * @param options
75
70
  * @param options.gasPrice Optional gas price to use for the simulation.
76
71
  * @param options.gasUnits Optional gas units to use for the simulation.
@@ -79,7 +74,7 @@ export class SvmQuery implements QueryInterface {
79
74
  */
80
75
  async getGasCosts(
81
76
  deposit: Omit<Deposit, "messageHash">,
82
- _relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId)),
77
+ _relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
83
78
  options: Partial<{
84
79
  gasPrice: BigNumberish;
85
80
  gasUnits: BigNumberish;
@@ -87,9 +82,8 @@ export class SvmQuery implements QueryInterface {
87
82
  priorityFeeMultiplier: BigNumber;
88
83
  }> = {}
89
84
  ): Promise<TransactionCostEstimate> {
90
- const relayer = _relayer ? _relayer.forceSvmAddress() : this.simulatedRelayerAddress;
91
-
92
- const fillRelayTx = await this.getFillRelayTx(deposit, relayer);
85
+ const relayer = _relayer ? toAddressType(_relayer).forceSvmAddress() : this.simulatedRelayerAddress;
86
+ const fillRelayTx = await this.getFillRelayTx(deposit, relayer.toBase58());
93
87
 
94
88
  const [computeUnitsConsumed, _gasPriceEstimate] = await Promise.all([
95
89
  toBN(await this.computeUnitEstimator(fillRelayTx)),
@@ -122,11 +116,10 @@ export class SvmQuery implements QueryInterface {
122
116
  */
123
117
  async getNativeGasCost(
124
118
  deposit: Omit<Deposit, "messageHash">,
125
- _relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId))
119
+ _relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
126
120
  ): Promise<BigNumber> {
127
121
  const fillRelayTx = await this.getFillRelayTx(deposit, _relayer);
128
- const computeUnitsConsumed = toBN(await this.computeUnitEstimator(fillRelayTx));
129
- return computeUnitsConsumed;
122
+ return toBN(await this.computeUnitEstimator(fillRelayTx));
130
123
  }
131
124
 
132
125
  /**
@@ -137,65 +130,73 @@ export class SvmQuery implements QueryInterface {
137
130
  */
138
131
  async getFillRelayTx(
139
132
  deposit: Omit<Deposit, "messageHash">,
140
- _relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId))
133
+ _relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
134
+ repaymentChainId = deposit.destinationChainId,
135
+ repaymentAddress = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
141
136
  ) {
142
- const relayer = isDefined(_relayer) ? _relayer : this.simulatedRelayerAddress;
143
- // If the user did not have a token account created on destination, then we need to include this as a gas cost.
144
- const mint = deposit.outputToken.forceSvmAddress();
145
- const owner = deposit.recipient.forceSvmAddress();
146
- const associatedToken = await getAssociatedTokenAddress(owner, mint);
147
- const simulatedSigner = SolanaVoidSigner(relayer.toBase58());
148
-
149
- // If the recipient has an associated token account on destination, then skip generating the instruction for creating a new token account.
150
- let recipientCreateTokenAccountInstructions: IInstruction[] | undefined = undefined;
151
- const [associatedTokenAccountExists, mintInfo] = await Promise.all([
152
- (await fetchEncodedAccount(this.provider, associatedToken)).exists,
153
- fetchMint(this.provider, mint.toV2Address()),
154
- ]);
155
- if (!associatedTokenAccountExists) {
156
- const space = BigInt(getMintSize());
157
- const rent = await this.provider.getMinimumBalanceForRentExemption(space).send();
158
- const createAccountIx = getCreateAccountInstruction({
159
- payer: simulatedSigner,
160
- newAccount: SolanaVoidSigner(mint.toBase58()),
161
- lamports: rent,
162
- space,
163
- programAddress: TOKEN_PROGRAM_ADDRESS,
164
- });
165
-
166
- const initializeMintIx = getInitializeMintInstruction({
167
- mint: mint.toV2Address(),
168
- decimals: mintInfo.data.decimals,
169
- mintAuthority: owner.toV2Address(),
170
- });
171
- recipientCreateTokenAccountInstructions = [createAccountIx, initializeMintIx];
172
- }
137
+ const toSvmAddress = (address: string) => toAddressType(address).forceSvmAddress().toV2Address();
138
+ const relayer = _relayer ? toAddressType(_relayer).forceSvmAddress() : this.simulatedRelayerAddress;
139
+ const state = await getStatePda(this.spokePoolAddress.toV2Address());
140
+ const _relayDataHash = getRelayDataHash(deposit, deposit.destinationChainId);
141
+ const relayDataHash = new Uint8Array(Buffer.from(_relayDataHash.slice(2), "hex"));
142
+ const delegate = await getFillRelayDelegatePda(
143
+ relayDataHash,
144
+ BigInt(repaymentChainId),
145
+ toSvmAddress(repaymentAddress),
146
+ this.spokePoolAddress.toV2Address()
147
+ );
148
+ const mint = toAddressType(deposit.outputToken).forceSvmAddress();
149
+ const mintInfo = await fetchMint(this.provider, mint.toV2Address());
150
+ const recipientAta = await getAssociatedTokenAddress(
151
+ toAddressType(deposit.recipient).forceSvmAddress(),
152
+ mint,
153
+ mintInfo.programAddress
154
+ );
155
+ const relayerAta = await getAssociatedTokenAddress(
156
+ SvmAddress.from(relayer.toBase58()),
157
+ mint,
158
+ mintInfo.programAddress
159
+ );
160
+ const fillStatus = await getFillStatusPda(this.spokePoolAddress.toV2Address(), deposit, deposit.destinationChainId);
161
+ const eventAuthority = await getEventAuthority();
173
162
 
174
- const [createTokenAccountsIx, approveIx, fillIx] = await Promise.all([
175
- createTokenAccountsInstruction(mint, simulatedSigner),
176
- createApproveInstruction(
177
- mint.forceSvmAddress(),
178
- deposit.outputAmount,
179
- this.simulatedRelayerAddress,
180
- this.spokePoolAddress,
181
- mintInfo.data.decimals
182
- ),
183
- fillRelayInstruction(this.spokePoolAddress, deposit, simulatedSigner, associatedToken),
184
- ]);
163
+ const relayData: SvmSpokeClient.FillRelayInput["relayData"] = {
164
+ depositor: toSvmAddress(deposit.depositor),
165
+ recipient: toSvmAddress(deposit.recipient),
166
+ exclusiveRelayer: toSvmAddress(deposit.exclusiveRelayer),
167
+ inputToken: toSvmAddress(deposit.inputToken),
168
+ outputToken: mint.toV2Address(),
169
+ inputAmount: deposit.inputAmount.toBigInt(),
170
+ outputAmount: deposit.outputAmount.toBigInt(),
171
+ originChainId: deposit.originChainId,
172
+ depositId: new Uint8Array(intToU8Array32(deposit.depositId.toNumber())),
173
+ fillDeadline: deposit.fillDeadline,
174
+ exclusivityDeadline: deposit.exclusivityDeadline,
175
+ message: new Uint8Array(Buffer.from(deposit.message, "hex")),
176
+ };
185
177
 
186
- // Get the most recent confirmed blockhash.
187
- const recentBlockhash = await this.provider.getLatestBlockhash().send();
188
- const fillRelayTx = pipe(
189
- createTransactionMessage({ version: 0 }),
190
- (tx) => setTransactionMessageFeePayer(relayer.forceSvmAddress().toV2Address(), tx),
191
- (tx) => setTransactionMessageLifetimeUsingBlockhash(recentBlockhash.value, tx),
192
- (tx) =>
193
- isDefined(recipientCreateTokenAccountInstructions)
194
- ? appendTransactionMessageInstructions(recipientCreateTokenAccountInstructions, tx)
195
- : tx,
196
- (tx) => appendTransactionMessageInstructions([createTokenAccountsIx, approveIx, fillIx], tx)
197
- );
198
- return fillRelayTx;
178
+ const simulatedSigner = SolanaVoidSigner(relayer.toBase58());
179
+ const fillInput: SvmSpokeClient.FillRelayInput = {
180
+ signer: simulatedSigner,
181
+ state,
182
+ delegate,
183
+ mint: mint.toV2Address(),
184
+ relayerTokenAccount: relayerAta,
185
+ recipientTokenAccount: recipientAta,
186
+ fillStatus,
187
+ tokenProgram: mintInfo.programAddress,
188
+ associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
189
+ systemProgram: SYSTEM_PROGRAM_ADDRESS,
190
+ eventAuthority: eventAuthority,
191
+ program: this.spokePoolAddress.toV2Address(),
192
+ relayHash: relayDataHash,
193
+ relayData,
194
+ repaymentChainId: BigInt(repaymentChainId),
195
+ repaymentAddress: toSvmAddress(repaymentAddress),
196
+ };
197
+ // Pass createRecipientAtaIfNeeded =true to the createFillInstruction function to create the recipient token account
198
+ // if it doesn't exist.
199
+ return createFillInstruction(simulatedSigner, this.provider, fillInput, mintInfo.data.decimals, true);
199
200
  }
200
201
 
201
202
  /**
@@ -1,4 +1,5 @@
1
1
  import assert from "assert";
2
+ import { Transport } from "viem";
2
3
  import {
3
4
  DEFAULT_SIMULATED_RELAYER_ADDRESS,
4
5
  DEFAULT_SIMULATED_RELAYER_ADDRESS_SVM,
@@ -8,32 +9,29 @@ import { Deposit } from "../interfaces";
8
9
  import {
9
10
  BigNumber,
10
11
  BigNumberish,
12
+ ConvertDecimals,
11
13
  MAX_BIG_INT,
12
14
  TransactionCostEstimate,
13
15
  bnZero,
16
+ chainIsSvm,
17
+ compareAddressesSimple,
14
18
  fixedPointAdjustment,
15
19
  getTokenInfo,
16
20
  isDefined,
21
+ isZeroAddress,
17
22
  max,
18
23
  min,
19
24
  nativeToToken,
20
25
  percent,
21
26
  toBN,
22
27
  toBNWei,
23
- isZeroAddress,
24
- compareAddressesSimple,
25
- ConvertDecimals,
26
- chainIsSvm,
27
- toAddressType,
28
- Address,
29
28
  } from "../utils";
30
- import { Transport } from "viem";
31
29
 
32
30
  // This needs to be implemented for every chain and passed into RelayFeeCalculator
33
31
  export interface QueryInterface {
34
32
  getGasCosts: (
35
33
  deposit: Omit<Deposit, "messageHash">,
36
- relayer: Address,
34
+ relayer: string,
37
35
  options?: Partial<{
38
36
  gasPrice: BigNumberish;
39
37
  gasUnits: BigNumberish;
@@ -44,7 +42,7 @@ export interface QueryInterface {
44
42
  }>
45
43
  ) => Promise<TransactionCostEstimate>;
46
44
  getTokenPrice: (tokenSymbol: string) => Promise<number>;
47
- getNativeGasCost: (deposit: Omit<Deposit, "messageHash">, relayer: Address) => Promise<BigNumber>;
45
+ getNativeGasCost: (deposit: Omit<Deposit, "messageHash">, relayer: string) => Promise<BigNumber>;
48
46
  }
49
47
 
50
48
  export const expectedCapitalCostsKeys = ["lowerBound", "upperBound", "cutoff", "decimals"];
@@ -256,7 +254,7 @@ export class RelayFeeCalculator {
256
254
  deposit: Deposit,
257
255
  outputAmount: BigNumberish,
258
256
  simulateZeroFill = false,
259
- relayerAddress = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId)),
257
+ relayerAddress = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
260
258
  _tokenPrice?: number,
261
259
  tokenMapping = TOKEN_SYMBOLS_MAP,
262
260
  gasPrice?: BigNumberish,
@@ -273,14 +271,14 @@ export class RelayFeeCalculator {
273
271
  // undefined address on destination.
274
272
  const destinationChainTokenDetails = Object.values(tokenMapping).find(
275
273
  (details) =>
276
- compareAddressesSimple(details.addresses[originChainId], inputToken.toAddress()) &&
274
+ compareAddressesSimple(details.addresses[originChainId], inputToken) &&
277
275
  isDefined(details.addresses[destinationChainId])
278
276
  );
279
277
  const outputToken = isZeroAddress(deposit.outputToken)
280
278
  ? destinationChainTokenDetails!.addresses[destinationChainId]
281
- : deposit.outputToken.toAddress();
279
+ : deposit.outputToken;
282
280
  const outputTokenInfo = getTokenInfo(outputToken, destinationChainId, tokenMapping);
283
- const inputTokenInfo = getTokenInfo(inputToken.toAddress(), originChainId, tokenMapping);
281
+ const inputTokenInfo = getTokenInfo(inputToken, originChainId, tokenMapping);
284
282
  if (!isDefined(outputTokenInfo) || !isDefined(inputTokenInfo)) {
285
283
  throw new Error(`Could not find token information for ${inputToken} or ${outputToken}`);
286
284
  }
@@ -495,7 +493,7 @@ export class RelayFeeCalculator {
495
493
  deposit: Deposit,
496
494
  outputAmount?: BigNumberish,
497
495
  simulateZeroFill = false,
498
- relayerAddress = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId)),
496
+ relayerAddress = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
499
497
  _tokenPrice?: number,
500
498
  gasPrice?: BigNumberish,
501
499
  gasUnits?: BigNumberish,
@@ -507,8 +505,8 @@ export class RelayFeeCalculator {
507
505
  const { inputToken, originChainId, outputToken, destinationChainId } = deposit;
508
506
  // We can perform a simple lookup with `getTokenInfo` here without resolving the exact token to resolve since we only need to
509
507
  // resolve the L1 token symbol and not the L2 token decimals.
510
- const inputTokenInfo = getTokenInfo(inputToken.toAddress(), originChainId);
511
- const outputTokenInfo = getTokenInfo(outputToken.toAddress(), destinationChainId);
508
+ const inputTokenInfo = getTokenInfo(inputToken, originChainId);
509
+ const outputTokenInfo = getTokenInfo(outputToken, destinationChainId);
512
510
  if (!isDefined(inputTokenInfo) || !isDefined(outputTokenInfo)) {
513
511
  throw new Error(`Could not find token information for ${inputToken} or ${outputToken}`);
514
512
  }