@across-protocol/sdk 4.2.16-alpha.5 → 4.2.16-alpha.6

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 (62) hide show
  1. package/dist/cjs/arch/evm/SpokeUtils.d.ts +8 -3
  2. package/dist/cjs/arch/evm/SpokeUtils.js +21 -21
  3. package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
  4. package/dist/cjs/arch/svm/SpokeUtils.d.ts +8 -6
  5. package/dist/cjs/arch/svm/SpokeUtils.js +17 -17
  6. package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
  7. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +8 -8
  8. package/dist/cjs/interfaces/SpokePool.d.ts +7 -8
  9. package/dist/cjs/interfaces/SpokePool.js.map +1 -1
  10. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +9 -5
  11. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +12 -12
  12. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  13. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +1 -1
  14. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  15. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +9 -5
  16. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +22 -22
  17. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  18. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +1 -1
  19. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +5 -5
  20. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  21. package/dist/esm/arch/evm/SpokeUtils.d.ts +9 -4
  22. package/dist/esm/arch/evm/SpokeUtils.js +24 -24
  23. package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
  24. package/dist/esm/arch/svm/SpokeUtils.d.ts +9 -7
  25. package/dist/esm/arch/svm/SpokeUtils.js +19 -19
  26. package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
  27. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +8 -8
  28. package/dist/esm/interfaces/SpokePool.d.ts +7 -8
  29. package/dist/esm/interfaces/SpokePool.js.map +1 -1
  30. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +12 -8
  31. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +16 -16
  32. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  33. package/dist/esm/relayFeeCalculator/chain-queries/factory.js +2 -2
  34. package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  35. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +11 -8
  36. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +26 -27
  37. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  38. package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +1 -1
  39. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +3 -3
  40. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  41. package/dist/types/arch/evm/SpokeUtils.d.ts +9 -4
  42. package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
  43. package/dist/types/arch/svm/SpokeUtils.d.ts +9 -7
  44. package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
  45. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +8 -8
  46. package/dist/types/interfaces/SpokePool.d.ts +7 -8
  47. package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
  48. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +12 -8
  49. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
  50. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
  51. package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +11 -8
  52. package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
  53. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +1 -1
  54. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
  55. package/package.json +1 -1
  56. package/src/arch/evm/SpokeUtils.ts +42 -27
  57. package/src/arch/svm/SpokeUtils.ts +25 -33
  58. package/src/interfaces/SpokePool.ts +8 -8
  59. package/src/relayFeeCalculator/chain-queries/baseQuery.ts +18 -19
  60. package/src/relayFeeCalculator/chain-queries/factory.ts +2 -2
  61. package/src/relayFeeCalculator/chain-queries/svmQuery.ts +27 -30
  62. package/src/relayFeeCalculator/relayFeeCalculator.ts +3 -9
@@ -18,7 +18,7 @@ import {
18
18
  import { Coingecko } from "../../coingecko";
19
19
  import { CHAIN_IDs } from "../../constants";
20
20
  import { getGasPriceEstimate } from "../../gasPriceOracle";
21
- import { Deposit } from "../../interfaces";
21
+ import { RelayData } from "../../interfaces";
22
22
  import {
23
23
  BigNumber,
24
24
  BigNumberish,
@@ -28,7 +28,7 @@ import {
28
28
  toAddressType,
29
29
  toBN,
30
30
  } from "../../utils";
31
- import { Logger, QueryInterface, getDefaultSimulatedRelayerAddress } from "../relayFeeCalculator";
31
+ import { Logger, QueryInterface, getDefaultRelayer } from "../relayFeeCalculator";
32
32
  import { SymbolMappingType } from "./";
33
33
 
34
34
  /**
@@ -66,7 +66,7 @@ export class SvmQuery implements QueryInterface {
66
66
 
67
67
  /**
68
68
  * Retrieves the current gas costs of performing a fillRelay contract at the referenced SpokePool.
69
- * @param deposit V3 deposit instance.
69
+ * @param relayData RelayData instance, supplemented with destinationChainId
70
70
  * @param _relayer Relayer address to simulate with.
71
71
  * @param options
72
72
  * @param options.gasPrice Optional gas price to use for the simulation.
@@ -75,8 +75,8 @@ export class SvmQuery implements QueryInterface {
75
75
  * @returns The gas estimate for this function call (multiplied with the optional buffer).
76
76
  */
77
77
  async getGasCosts(
78
- deposit: Omit<Deposit, "messageHash">,
79
- relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId),
78
+ relayData: RelayData & { destinationChainId: number },
79
+ relayer = toAddressType(getDefaultRelayer(relayData.destinationChainId), relayData.destinationChainId),
80
80
  options: Partial<{
81
81
  gasPrice: BigNumberish;
82
82
  gasUnits: BigNumberish;
@@ -84,12 +84,12 @@ export class SvmQuery implements QueryInterface {
84
84
  priorityFeeMultiplier: BigNumber;
85
85
  }> = {}
86
86
  ): Promise<TransactionCostEstimate> {
87
- const { recipient, outputToken, exclusiveRelayer } = deposit;
87
+ const { recipient, outputToken, exclusiveRelayer } = relayData;
88
88
  assert(recipient.isSVM(), `getGasCosts: recipient not an SVM address (${recipient})`);
89
89
  assert(outputToken.isSVM(), `getGasCosts: outputToken not an SVM address (${outputToken})`);
90
90
  assert(exclusiveRelayer.isSVM(), `getGasCosts: exclusiveRelayer not an SVM address (${exclusiveRelayer})`);
91
91
 
92
- const fillRelayTx = await this.getFillRelayTx({ ...deposit, recipient, outputToken, exclusiveRelayer }, relayer);
92
+ const fillRelayTx = await this.getFillRelayTx({ ...relayData, recipient, outputToken, exclusiveRelayer }, relayer);
93
93
 
94
94
  const [computeUnitsConsumed, gasPriceEstimate] = await Promise.all([
95
95
  toBN(await this.computeUnitEstimator(fillRelayTx)),
@@ -120,8 +120,8 @@ export class SvmQuery implements QueryInterface {
120
120
  * @returns Estimated gas cost in compute units
121
121
  */
122
122
  async getNativeGasCost(
123
- deposit: Omit<Deposit, "messageHash">, // @todo Update interface to permit EvmAddress | SvmAddress
124
- _relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId)
123
+ deposit: RelayData & { destinationChainId: number },
124
+ _relayer = toAddressType(getDefaultRelayer(deposit.destinationChainId), deposit.destinationChainId)
125
125
  ): Promise<BigNumber> {
126
126
  const { recipient, outputToken, exclusiveRelayer } = deposit;
127
127
  assert(recipient.isSVM(), `getNativeGasCost: recipient not an SVM address (${recipient})`);
@@ -134,24 +134,21 @@ export class SvmQuery implements QueryInterface {
134
134
 
135
135
  /**
136
136
  * @notice Return the fillRelay transaction for a given deposit
137
- * @param deposit
137
+ * @param relayData RelayData instance, supplemented with destinationChainId
138
138
  * @param relayer SVM address of the relayer
139
139
  * @returns FillRelay transaction
140
140
  */
141
141
  async getFillRelayTx(
142
- deposit: Omit<Deposit, "recipent" | "outputToken" | "exclusiveRelayer" | "messageHash"> & {
142
+ relayData: Omit<RelayData, "recipent" | "outputToken"> & {
143
+ destinationChainId: number;
143
144
  recipient: SvmAddress;
144
145
  outputToken: SvmAddress;
145
- exclusiveRelayer: SvmAddress;
146
146
  },
147
- relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId),
148
- repaymentChainId = deposit.destinationChainId,
149
- repaymentAddress = toAddressType(
150
- getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
151
- deposit.destinationChainId
152
- )
147
+ relayer = toAddressType(getDefaultRelayer(relayData.destinationChainId), relayData.destinationChainId),
148
+ repaymentChainId = relayData.destinationChainId,
149
+ repaymentAddress = toAddressType(getDefaultRelayer(relayData.destinationChainId), relayData.destinationChainId)
153
150
  ) {
154
- const { depositor, recipient, inputToken, outputToken, exclusiveRelayer, destinationChainId } = deposit;
151
+ const { depositor, recipient, inputToken, outputToken, exclusiveRelayer, destinationChainId } = relayData;
155
152
 
156
153
  // tsc appeasement...should be unnecessary, but isn't. @todo Identify why.
157
154
  assert(recipient.isSVM(), `getFillRelayTx: recipient not an SVM address (${recipient})`);
@@ -161,7 +158,7 @@ export class SvmQuery implements QueryInterface {
161
158
  );
162
159
 
163
160
  const program = toAddress(this.spokePool);
164
- const _relayDataHash = getRelayDataHash(deposit, destinationChainId);
161
+ const _relayDataHash = getRelayDataHash(relayData, destinationChainId);
165
162
  const relayDataHash = new Uint8Array(Buffer.from(_relayDataHash.slice(2), "hex"));
166
163
 
167
164
  const [state, delegate] = await Promise.all([
@@ -175,23 +172,23 @@ export class SvmQuery implements QueryInterface {
175
172
  const [recipientAta, relayerAta, fillStatus, eventAuthority] = await Promise.all([
176
173
  getAssociatedTokenAddress(recipient, outputToken, mintInfo.programAddress),
177
174
  getAssociatedTokenAddress(SvmAddress.from(relayer.toBase58()), outputToken, mintInfo.programAddress),
178
- getFillStatusPda(program, deposit, destinationChainId),
175
+ getFillStatusPda(program, relayData, destinationChainId),
179
176
  getEventAuthority(program),
180
177
  ]);
181
178
 
182
- const relayData: SvmSpokeClient.FillRelayInput["relayData"] = {
179
+ const svmRelayData: SvmSpokeClient.FillRelayInput["relayData"] = {
183
180
  depositor: toAddress(depositor),
184
181
  recipient: toAddress(recipient),
185
182
  exclusiveRelayer: toAddress(exclusiveRelayer),
186
183
  inputToken: toAddress(inputToken),
187
184
  outputToken: mint,
188
- inputAmount: deposit.inputAmount.toBigInt(),
189
- outputAmount: deposit.outputAmount.toBigInt(),
190
- originChainId: deposit.originChainId,
191
- depositId: new Uint8Array(intToU8Array32(deposit.depositId.toNumber())),
192
- fillDeadline: deposit.fillDeadline,
193
- exclusivityDeadline: deposit.exclusivityDeadline,
194
- message: new Uint8Array(Buffer.from(deposit.message, "hex")),
185
+ inputAmount: relayData.inputAmount.toBigInt(),
186
+ outputAmount: relayData.outputAmount.toBigInt(),
187
+ originChainId: relayData.originChainId,
188
+ depositId: new Uint8Array(intToU8Array32(relayData.depositId.toNumber())),
189
+ fillDeadline: relayData.fillDeadline,
190
+ exclusivityDeadline: relayData.exclusivityDeadline,
191
+ message: new Uint8Array(Buffer.from(relayData.message, "hex")),
195
192
  };
196
193
 
197
194
  const simulatedSigner = SolanaVoidSigner(relayer.toBase58());
@@ -209,7 +206,7 @@ export class SvmQuery implements QueryInterface {
209
206
  eventAuthority,
210
207
  program,
211
208
  relayHash: relayDataHash,
212
- relayData,
209
+ relayData: svmRelayData,
213
210
  repaymentChainId: BigInt(repaymentChainId),
214
211
  repaymentAddress: toAddress(repaymentAddress),
215
212
  };
@@ -114,7 +114,7 @@ export const DEFAULT_LOGGER: Logger = {
114
114
  error: (...args) => console.error(args),
115
115
  };
116
116
 
117
- export function getDefaultSimulatedRelayerAddress(chainId?: number) {
117
+ export function getDefaultRelayer(chainId?: number) {
118
118
  return isDefined(chainId) && chainIsSvm(chainId)
119
119
  ? DEFAULT_SIMULATED_RELAYER_ADDRESS_SVM
120
120
  : DEFAULT_SIMULATED_RELAYER_ADDRESS;
@@ -256,10 +256,7 @@ export class RelayFeeCalculator {
256
256
  deposit: Deposit,
257
257
  outputAmount: BigNumberish,
258
258
  simulateZeroFill = false,
259
- relayerAddress = toAddressType(
260
- getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
261
- deposit.destinationChainId
262
- ),
259
+ relayerAddress = toAddressType(getDefaultRelayer(deposit.destinationChainId), deposit.destinationChainId),
263
260
  _tokenPrice?: number,
264
261
  tokenMapping = TOKEN_SYMBOLS_MAP,
265
262
  gasPrice?: BigNumberish,
@@ -498,10 +495,7 @@ export class RelayFeeCalculator {
498
495
  deposit: Deposit,
499
496
  outputAmount?: BigNumberish,
500
497
  simulateZeroFill = false,
501
- relayerAddress = toAddressType(
502
- getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
503
- deposit.destinationChainId
504
- ),
498
+ relayerAddress = toAddressType(getDefaultRelayer(deposit.destinationChainId), deposit.destinationChainId),
505
499
  _tokenPrice?: number,
506
500
  gasPrice?: BigNumberish,
507
501
  gasUnits?: BigNumberish,