@across-protocol/sdk 4.3.0 → 4.3.2

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 (117) hide show
  1. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +6 -10
  2. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  3. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +6 -3
  4. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  5. package/dist/cjs/clients/HubPoolClient.js +4 -4
  6. package/dist/cjs/clients/HubPoolClient.js.map +1 -1
  7. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
  8. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  9. package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js +1 -3
  10. package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
  11. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +1 -0
  12. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +7 -1
  13. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  14. package/dist/cjs/clients/SpokePoolClient/index.d.ts +1 -0
  15. package/dist/cjs/clients/SpokePoolClient/index.js +3 -1
  16. package/dist/cjs/clients/SpokePoolClient/index.js.map +1 -1
  17. package/dist/cjs/clients/index.d.ts +1 -1
  18. package/dist/cjs/clients/index.js +2 -1
  19. package/dist/cjs/clients/index.js.map +1 -1
  20. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +2 -2
  21. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +4 -4
  22. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  23. package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
  24. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +8 -5
  25. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  26. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +5 -5
  27. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +26 -25
  28. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  29. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +14 -6
  30. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +5 -5
  31. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  32. package/dist/cjs/utils/DepositUtils.d.ts +2 -2
  33. package/dist/cjs/utils/DepositUtils.js +1 -1
  34. package/dist/cjs/utils/DepositUtils.js.map +1 -1
  35. package/dist/cjs/utils/SpokeUtils.d.ts +0 -2
  36. package/dist/cjs/utils/SpokeUtils.js +1 -5
  37. package/dist/cjs/utils/SpokeUtils.js.map +1 -1
  38. package/dist/cjs/utils/TokenUtils.d.ts +2 -2
  39. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +6 -10
  40. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  41. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +7 -4
  42. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  43. package/dist/esm/clients/HubPoolClient.js +7 -9
  44. package/dist/esm/clients/HubPoolClient.js.map +1 -1
  45. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +3 -3
  46. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  47. package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js +2 -4
  48. package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
  49. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +1 -0
  50. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +9 -2
  51. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  52. package/dist/esm/clients/SpokePoolClient/index.d.ts +1 -0
  53. package/dist/esm/clients/SpokePoolClient/index.js +1 -0
  54. package/dist/esm/clients/SpokePoolClient/index.js.map +1 -1
  55. package/dist/esm/clients/index.d.ts +1 -1
  56. package/dist/esm/clients/index.js +1 -1
  57. package/dist/esm/clients/index.js.map +1 -1
  58. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +2 -2
  59. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +5 -5
  60. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  61. package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
  62. package/dist/esm/relayFeeCalculator/chain-queries/factory.js +8 -5
  63. package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  64. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +5 -5
  65. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +27 -26
  66. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  67. package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +24 -7
  68. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +6 -6
  69. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  70. package/dist/esm/utils/DepositUtils.d.ts +2 -2
  71. package/dist/esm/utils/DepositUtils.js +2 -2
  72. package/dist/esm/utils/DepositUtils.js.map +1 -1
  73. package/dist/esm/utils/SpokeUtils.d.ts +0 -2
  74. package/dist/esm/utils/SpokeUtils.js +0 -4
  75. package/dist/esm/utils/SpokeUtils.js.map +1 -1
  76. package/dist/esm/utils/TokenUtils.d.ts +2 -18
  77. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  78. package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
  79. package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
  80. package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
  81. package/dist/types/clients/SpokePoolClient/SVMSpokePoolClient.d.ts.map +1 -1
  82. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +1 -0
  83. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
  84. package/dist/types/clients/SpokePoolClient/index.d.ts +1 -0
  85. package/dist/types/clients/SpokePoolClient/index.d.ts.map +1 -1
  86. package/dist/types/clients/index.d.ts +1 -1
  87. package/dist/types/clients/index.d.ts.map +1 -1
  88. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +2 -2
  89. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
  90. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
  91. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
  92. package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +5 -5
  93. package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
  94. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +24 -7
  95. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
  96. package/dist/types/utils/DepositUtils.d.ts +2 -2
  97. package/dist/types/utils/DepositUtils.d.ts.map +1 -1
  98. package/dist/types/utils/SpokeUtils.d.ts +0 -2
  99. package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
  100. package/dist/types/utils/TokenUtils.d.ts +2 -18
  101. package/dist/types/utils/TokenUtils.d.ts.map +1 -1
  102. package/package.json +1 -1
  103. package/src/clients/BundleDataClient/BundleDataClient.ts +6 -10
  104. package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +6 -4
  105. package/src/clients/HubPoolClient.ts +7 -9
  106. package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +2 -3
  107. package/src/clients/SpokePoolClient/SVMSpokePoolClient.ts +1 -4
  108. package/src/clients/SpokePoolClient/SpokePoolClient.ts +9 -2
  109. package/src/clients/SpokePoolClient/index.ts +1 -0
  110. package/src/clients/index.ts +1 -0
  111. package/src/relayFeeCalculator/chain-queries/baseQuery.ts +5 -6
  112. package/src/relayFeeCalculator/chain-queries/factory.ts +7 -4
  113. package/src/relayFeeCalculator/chain-queries/svmQuery.ts +25 -11
  114. package/src/relayFeeCalculator/relayFeeCalculator.ts +13 -13
  115. package/src/utils/DepositUtils.ts +4 -4
  116. package/src/utils/SpokeUtils.ts +0 -6
  117. package/src/utils/TokenUtils.ts +2 -2
@@ -15,7 +15,6 @@ import {
15
15
  isDefined,
16
16
  getMessageHash,
17
17
  isSlowFill,
18
- isZeroAddress,
19
18
  validateFillForDeposit,
20
19
  chainIsProd,
21
20
  Address,
@@ -364,6 +363,14 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
364
363
  return this.depositHashesToFills[this.getDepositHash(deposit)];
365
364
  }
366
365
 
366
+ public isDepositFilled(deposit: Deposit): boolean {
367
+ const depositHash = this.getDepositHash(deposit);
368
+ const fills = this.depositHashesToFills[depositHash] ?? [];
369
+
370
+ return fills.some((fill) => validateFillForDeposit(fill, deposit).valid);
371
+ }
372
+
373
+ // @TODO: Remove this method after refactoring relayer repo.
367
374
  /**
368
375
  * Find the unfilled amount for a given deposit. This is the full deposit amount minus the total filled amount.
369
376
  * @param deposit The deposit to find the unfilled amount for.
@@ -558,7 +565,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
558
565
  deposit.fromLiteChain = this.isOriginLiteChain(deposit);
559
566
  deposit.toLiteChain = this.isDestinationLiteChain(deposit);
560
567
 
561
- if (isZeroAddress(deposit.outputToken)) {
568
+ if (deposit.outputToken.isZeroAddress()) {
562
569
  deposit.outputToken = this.getDestinationTokenForDeposit(deposit);
563
570
  }
564
571
 
@@ -5,6 +5,7 @@ import { SpokePoolClient } from "./SpokePoolClient";
5
5
  export { EVMSpokePoolClient } from "./EVMSpokePoolClient";
6
6
  export { SpokePoolClient, SpokePoolUpdate } from "./SpokePoolClient";
7
7
  export { SVMSpokePoolClient } from "./SVMSpokePoolClient";
8
+ export { SpokePoolManager } from "./SpokePoolClientManager";
8
9
 
9
10
  /**
10
11
  * Checks if a SpokePoolClient is an EVMSpokePoolClient.
@@ -13,6 +13,7 @@ export {
13
13
  SVMSpokePoolClient,
14
14
  isEVMSpokePoolClient,
15
15
  isSVMSpokePoolClient,
16
+ SpokePoolManager,
16
17
  } from "./SpokePoolClient";
17
18
  export * as BundleDataClient from "./BundleDataClient";
18
19
  export * as mocks from "./mocks";
@@ -15,7 +15,6 @@ import {
15
15
  bnZero,
16
16
  chainIsOPStack,
17
17
  fixedPointAdjustment,
18
- toAddressType,
19
18
  Address,
20
19
  } from "../../utils";
21
20
  import assert from "assert";
@@ -53,7 +52,7 @@ export class QueryBase implements QueryInterface {
53
52
  readonly provider: EvmProvider,
54
53
  readonly symbolMapping: SymbolMappingType,
55
54
  readonly spokePoolAddress: string,
56
- readonly simulatedRelayerAddress: string,
55
+ readonly simulatedRelayerAddress: EvmAddress,
57
56
  readonly logger: Logger,
58
57
  readonly coingeckoProApiKey?: string,
59
58
  readonly fixedGasPrice?: BigNumberish,
@@ -74,7 +73,7 @@ export class QueryBase implements QueryInterface {
74
73
  */
75
74
  async getGasCosts(
76
75
  relayData: RelayData & { destinationChainId: number },
77
- relayer = toAddressType(getDefaultRelayer(relayData.destinationChainId), relayData.destinationChainId),
76
+ relayer = getDefaultRelayer(relayData.destinationChainId),
78
77
  options: Partial<{
79
78
  gasPrice: BigNumberish;
80
79
  gasUnits: BigNumberish;
@@ -133,7 +132,7 @@ export class QueryBase implements QueryInterface {
133
132
  recipient: EvmAddress;
134
133
  outputToken: EvmAddress;
135
134
  },
136
- relayer = toAddressType(getDefaultRelayer(relayData.destinationChainId), relayData.destinationChainId)
135
+ relayer = getDefaultRelayer(relayData.destinationChainId)
137
136
  ): Promise<PopulatedTransaction> {
138
137
  return populateV3Relay(this.spokePool, relayData, relayer);
139
138
  }
@@ -146,7 +145,7 @@ export class QueryBase implements QueryInterface {
146
145
  */
147
146
  async getNativeGasCost(
148
147
  relayData: RelayData & { destinationChainId: number },
149
- relayer = toAddressType(getDefaultRelayer(relayData.destinationChainId), relayData.destinationChainId)
148
+ relayer = getDefaultRelayer(relayData.destinationChainId)
150
149
  ): Promise<BigNumber> {
151
150
  const { recipient, outputToken, exclusiveRelayer } = relayData;
152
151
  assert(recipient.isEVM(), `getNativeGasCost: recipient not an EVM address (${recipient})`);
@@ -171,7 +170,7 @@ export class QueryBase implements QueryInterface {
171
170
  */
172
171
  async getOpStackL1DataFee(
173
172
  unsignedTx: PopulatedTransaction,
174
- relayer = toAddressType(getDefaultRelayer(unsignedTx.chainId), CHAIN_IDs.MAINNET),
173
+ relayer = getDefaultRelayer(unsignedTx.chainId),
175
174
  options: Partial<{
176
175
  opStackL2GasUnits: BigNumberish;
177
176
  opStackL1DataFeeMultiplier: BigNumber;
@@ -25,7 +25,7 @@ export class QueryBase__factory {
25
25
  provider: providers.Provider | svmProvider,
26
26
  symbolMapping = TOKEN_SYMBOLS_MAP,
27
27
  spokePoolAddress = getDeployedAddress("SpokePool", chainId),
28
- simulatedRelayerAddress = getDefaultRelayer(chainId),
28
+ relayerAddress = getDefaultRelayer(chainId),
29
29
  coingeckoProApiKey?: string,
30
30
  logger: Logger = DEFAULT_LOGGER,
31
31
  coingeckoBaseCurrency = "eth"
@@ -34,12 +34,13 @@ export class QueryBase__factory {
34
34
 
35
35
  const customGasTokenSymbol = CUSTOM_GAS_TOKENS[chainId];
36
36
  if (customGasTokenSymbol) {
37
+ assert(relayerAddress.isEVM());
37
38
  return new CustomGasTokenQueries({
38
39
  queryBaseArgs: [
39
40
  provider as providers.Provider,
40
41
  symbolMapping,
41
42
  spokePoolAddress,
42
- simulatedRelayerAddress,
43
+ relayerAddress,
43
44
  logger,
44
45
  coingeckoProApiKey,
45
46
  fixedGasPrice[chainId],
@@ -49,11 +50,12 @@ export class QueryBase__factory {
49
50
  });
50
51
  }
51
52
  if (chainIsSvm(chainId)) {
53
+ assert(relayerAddress.isSVM());
52
54
  return new SvmQuery(
53
55
  provider as svmProvider,
54
56
  symbolMapping,
55
57
  SvmAddress.from(spokePoolAddress),
56
- SvmAddress.from(simulatedRelayerAddress),
58
+ relayerAddress,
57
59
  logger,
58
60
  coingeckoProApiKey,
59
61
  fixedGasPrice[chainId],
@@ -66,11 +68,12 @@ export class QueryBase__factory {
66
68
  ? asL2Provider(provider as providers.Provider)
67
69
  : (provider as providers.Provider);
68
70
 
71
+ assert(relayerAddress.isEVM());
69
72
  return new QueryBase(
70
73
  provider,
71
74
  symbolMapping,
72
75
  spokePoolAddress,
73
- simulatedRelayerAddress,
76
+ relayerAddress,
74
77
  logger,
75
78
  coingeckoProApiKey,
76
79
  fixedGasPrice[chainId],
@@ -20,12 +20,12 @@ import { CHAIN_IDs } from "../../constants";
20
20
  import { getGasPriceEstimate } from "../../gasPriceOracle";
21
21
  import { RelayData } from "../../interfaces";
22
22
  import {
23
+ Address,
23
24
  BigNumber,
24
25
  BigNumberish,
25
26
  SvmAddress,
26
27
  TransactionCostEstimate,
27
28
  getRelayDataHash,
28
- toAddressType,
29
29
  toBN,
30
30
  } from "../../utils";
31
31
  import { Logger, QueryInterface, getDefaultRelayer } from "../relayFeeCalculator";
@@ -76,7 +76,7 @@ export class SvmQuery implements QueryInterface {
76
76
  */
77
77
  async getGasCosts(
78
78
  relayData: RelayData & { destinationChainId: number },
79
- relayer = toAddressType(getDefaultRelayer(relayData.destinationChainId), relayData.destinationChainId),
79
+ relayer = getDefaultRelayer(relayData.destinationChainId),
80
80
  options: Partial<{
81
81
  gasPrice: BigNumberish;
82
82
  gasUnits: BigNumberish;
@@ -84,12 +84,19 @@ export class SvmQuery implements QueryInterface {
84
84
  priorityFeeMultiplier: BigNumber;
85
85
  }> = {}
86
86
  ): Promise<TransactionCostEstimate> {
87
- const { recipient, outputToken, exclusiveRelayer } = relayData;
87
+ const { destinationChainId, 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
+ assert(relayer.isSVM());
91
92
 
92
- const fillRelayTx = await this.getFillRelayTx({ ...relayData, recipient, outputToken, exclusiveRelayer }, relayer);
93
+ const [repaymentChainId, repaymentAddress] = [destinationChainId, relayer]; // These are not important for gas cost simulation.
94
+ const fillRelayTx = await this.getFillRelayTx(
95
+ { ...relayData, recipient, outputToken, exclusiveRelayer },
96
+ relayer,
97
+ repaymentChainId,
98
+ repaymentAddress
99
+ );
93
100
 
94
101
  const [computeUnitsConsumed, gasPriceEstimate] = await Promise.all([
95
102
  toBN(await this.computeUnitEstimator(fillRelayTx)),
@@ -121,14 +128,21 @@ export class SvmQuery implements QueryInterface {
121
128
  */
122
129
  async getNativeGasCost(
123
130
  deposit: RelayData & { destinationChainId: number },
124
- _relayer = toAddressType(getDefaultRelayer(deposit.destinationChainId), deposit.destinationChainId)
131
+ relayer = getDefaultRelayer(deposit.destinationChainId)
125
132
  ): Promise<BigNumber> {
126
- const { recipient, outputToken, exclusiveRelayer } = deposit;
133
+ const { destinationChainId, recipient, outputToken, exclusiveRelayer } = deposit;
127
134
  assert(recipient.isSVM(), `getNativeGasCost: recipient not an SVM address (${recipient})`);
128
135
  assert(outputToken.isSVM(), `getNativeGasCost: outputToken not an SVM address (${outputToken})`);
129
136
  assert(exclusiveRelayer.isSVM(), `getNativeGasCost: exclusiveRelayer not an SVM address (${exclusiveRelayer})`);
137
+ assert(relayer.isSVM());
130
138
 
131
- const fillRelayTx = await this.getFillRelayTx({ ...deposit, recipient, outputToken, exclusiveRelayer }, _relayer);
139
+ const [repaymentChainId, repaymentAddress] = [destinationChainId, relayer]; // These are not important for gas cost simulation.
140
+ const fillRelayTx = await this.getFillRelayTx(
141
+ { ...deposit, recipient, outputToken, exclusiveRelayer },
142
+ relayer,
143
+ repaymentChainId,
144
+ repaymentAddress
145
+ );
132
146
  return toBN(await this.computeUnitEstimator(fillRelayTx));
133
147
  }
134
148
 
@@ -138,15 +152,15 @@ export class SvmQuery implements QueryInterface {
138
152
  * @param relayer SVM address of the relayer
139
153
  * @returns FillRelay transaction
140
154
  */
141
- async getFillRelayTx(
155
+ protected async getFillRelayTx(
142
156
  relayData: Omit<RelayData, "recipent" | "outputToken"> & {
143
157
  destinationChainId: number;
144
158
  recipient: SvmAddress;
145
159
  outputToken: SvmAddress;
146
160
  },
147
- relayer = toAddressType(getDefaultRelayer(relayData.destinationChainId), relayData.destinationChainId),
148
- repaymentChainId = relayData.destinationChainId,
149
- repaymentAddress = toAddressType(getDefaultRelayer(relayData.destinationChainId), relayData.destinationChainId)
161
+ relayer: SvmAddress,
162
+ repaymentChainId: number,
163
+ repaymentAddress: Address
150
164
  ) {
151
165
  const { depositor, recipient, inputToken, outputToken, exclusiveRelayer, destinationChainId } = relayData;
152
166
 
@@ -5,7 +5,7 @@ import {
5
5
  DEFAULT_SIMULATED_RELAYER_ADDRESS_SVM,
6
6
  TOKEN_SYMBOLS_MAP,
7
7
  } from "../constants";
8
- import { Deposit } from "../interfaces";
8
+ import { RelayData } from "../interfaces";
9
9
  import {
10
10
  BigNumber,
11
11
  BigNumberish,
@@ -15,7 +15,6 @@ import {
15
15
  fixedPointAdjustment,
16
16
  getTokenInfo,
17
17
  isDefined,
18
- isZeroAddress,
19
18
  max,
20
19
  min,
21
20
  nativeToToken,
@@ -25,14 +24,15 @@ import {
25
24
  compareAddressesSimple,
26
25
  ConvertDecimals,
27
26
  chainIsSvm,
28
- toAddressType,
29
27
  Address,
28
+ EvmAddress,
29
+ SvmAddress,
30
30
  } from "../utils";
31
31
 
32
32
  // This needs to be implemented for every chain and passed into RelayFeeCalculator
33
33
  export interface QueryInterface {
34
34
  getGasCosts: (
35
- deposit: Omit<Deposit, "messageHash">,
35
+ deposit: RelayData & { destinationChainId: number },
36
36
  relayer: Address,
37
37
  options?: Partial<{
38
38
  gasPrice: BigNumberish;
@@ -44,7 +44,7 @@ export interface QueryInterface {
44
44
  }>
45
45
  ) => Promise<TransactionCostEstimate>;
46
46
  getTokenPrice: (tokenSymbol: string) => Promise<number>;
47
- getNativeGasCost: (deposit: Omit<Deposit, "messageHash">, relayer: Address) => Promise<BigNumber>;
47
+ getNativeGasCost: (deposit: RelayData & { destinationChainId: number }, relayer: Address) => Promise<BigNumber>;
48
48
  }
49
49
 
50
50
  export const expectedCapitalCostsKeys = ["lowerBound", "upperBound", "cutoff", "decimals"];
@@ -114,10 +114,10 @@ export const DEFAULT_LOGGER: Logger = {
114
114
  error: (...args) => console.error(args),
115
115
  };
116
116
 
117
- export function getDefaultRelayer(chainId?: number) {
117
+ export function getDefaultRelayer(chainId?: number): Address {
118
118
  return isDefined(chainId) && chainIsSvm(chainId)
119
- ? DEFAULT_SIMULATED_RELAYER_ADDRESS_SVM
120
- : DEFAULT_SIMULATED_RELAYER_ADDRESS;
119
+ ? SvmAddress.from(DEFAULT_SIMULATED_RELAYER_ADDRESS_SVM)
120
+ : EvmAddress.from(DEFAULT_SIMULATED_RELAYER_ADDRESS);
121
121
  }
122
122
 
123
123
  // Small amount to simulate filling with. Should be low enough to guarantee a successful fill.
@@ -253,10 +253,10 @@ export class RelayFeeCalculator {
253
253
  * the correct parameters to see a full fill.
254
254
  */
255
255
  async gasFeePercent(
256
- deposit: Deposit,
256
+ deposit: RelayData & { destinationChainId: number },
257
257
  outputAmount: BigNumberish,
258
258
  simulateZeroFill = false,
259
- relayerAddress = toAddressType(getDefaultRelayer(deposit.destinationChainId), deposit.destinationChainId),
259
+ relayerAddress = getDefaultRelayer(deposit.destinationChainId),
260
260
  _tokenPrice?: number,
261
261
  tokenMapping = TOKEN_SYMBOLS_MAP,
262
262
  gasPrice?: BigNumberish,
@@ -276,7 +276,7 @@ export class RelayFeeCalculator {
276
276
  compareAddressesSimple(details.addresses[originChainId], inputToken.toNative()) &&
277
277
  isDefined(details.addresses[destinationChainId])
278
278
  );
279
- const outputToken = isZeroAddress(deposit.outputToken)
279
+ const outputToken = deposit.outputToken.isZeroAddress()
280
280
  ? destinationChainTokenDetails!.addresses[destinationChainId]
281
281
  : deposit.outputToken.toNative();
282
282
  const outputTokenInfo = getTokenInfo(outputToken, destinationChainId, tokenMapping);
@@ -492,10 +492,10 @@ export class RelayFeeCalculator {
492
492
  * @returns A resulting `RelayerFeeDetails` object
493
493
  */
494
494
  async relayerFeeDetails(
495
- deposit: Deposit,
495
+ deposit: RelayData & { destinationChainId: number },
496
496
  outputAmount?: BigNumberish,
497
497
  simulateZeroFill = false,
498
- relayerAddress = toAddressType(getDefaultRelayer(deposit.destinationChainId), deposit.destinationChainId),
498
+ relayerAddress = getDefaultRelayer(deposit.destinationChainId),
499
499
  _tokenPrice?: number,
500
500
  gasPrice?: BigNumberish,
501
501
  gasUnits?: BigNumberish,
@@ -2,7 +2,7 @@ import assert from "assert";
2
2
  import { SpokePoolClient } from "../clients";
3
3
  import { DEFAULT_CACHING_TTL, EMPTY_MESSAGE, UNDEFINED_MESSAGE_HASH, ZERO_BYTES } from "../constants";
4
4
  import { CachingMechanismInterface, Deposit, DepositWithBlock, Fill, RelayData, SlowFillRequest } from "../interfaces";
5
- import { getMessageHash, isUnsafeDepositId, isZeroAddress } from "./SpokeUtils";
5
+ import { getMessageHash, isUnsafeDepositId } from "./SpokeUtils";
6
6
  import { getNetworkName } from "./NetworkUtils";
7
7
  import { bnZero } from "./BigNumberUtils";
8
8
  import { getDepositInCache, getDepositKey, setDepositInCache } from "./CachingUtils";
@@ -204,13 +204,13 @@ export function validateFillForDeposit(
204
204
  * @param deposit Deposit to check.
205
205
  * @returns True if deposit's input amount is 0 and message is empty.
206
206
  */
207
- export function isZeroValueDeposit(deposit: Pick<Deposit, "inputAmount" | "message">): boolean {
207
+ export function isZeroValueDeposit(deposit: Pick<RelayData, "inputAmount" | "message">): boolean {
208
208
  return deposit.inputAmount.eq(0) && isMessageEmpty(deposit.message);
209
209
  }
210
210
 
211
- export function invalidOutputToken(deposit: Pick<DepositWithBlock, "outputToken">): boolean {
211
+ export function invalidOutputToken(deposit: Pick<RelayData, "outputToken">): boolean {
212
212
  // If the output token is zero address, then it is invalid.
213
- return isZeroAddress(deposit.outputToken);
213
+ return deposit.outputToken.isZeroAddress();
214
214
  }
215
215
 
216
216
  export function isZeroValueFillOrSlowFillRequest(
@@ -3,7 +3,6 @@ import { fixedPointAdjustment as fixedPoint } from "./common";
3
3
  import { MAX_SAFE_DEPOSIT_ID, ZERO_BYTES } from "../constants";
4
4
  import { Fill, FillType, RelayData, SlowFillLeaf } from "../interfaces";
5
5
  import { BigNumber } from "./BigNumberUtils";
6
- import { Address } from "./AddressUtils";
7
6
  import { isMessageEmpty } from "./DepositUtils";
8
7
  import { chainIsSvm } from "./NetworkUtils";
9
8
  import { svm } from "../arch";
@@ -72,11 +71,6 @@ export function isUnsafeDepositId(depositId: BigNumber): boolean {
72
71
  return maxSafeDepositId.lt(depositId);
73
72
  }
74
73
 
75
- // Determines if the input address (either a bytes32 or bytes20) is the zero address.
76
- export function isZeroAddress(address: Address): boolean {
77
- return address.toBytes32() === ZERO_BYTES;
78
- }
79
-
80
74
  export function getMessageHash(message: string): string {
81
75
  return isMessageEmpty(message) ? ZERO_BYTES : keccak256(message as Hex);
82
76
  }
@@ -2,7 +2,7 @@ import assert from "assert";
2
2
  import { BlockTag } from "@ethersproject/abstract-provider";
3
3
  import { Contract, providers, Signer } from "ethers";
4
4
  import * as constants from "../constants";
5
- import { TokenInfo } from "../interfaces";
5
+ import { L1TokenInfo, TokenInfo } from "../interfaces";
6
6
  import { ERC20__factory } from "../typechain";
7
7
  import { BigNumber } from "./BigNumberUtils";
8
8
  import { getNetworkName, chainIsL1, chainIsProd } from "./NetworkUtils";
@@ -12,7 +12,7 @@ const { TOKEN_SYMBOLS_MAP, CHAIN_IDs, TOKEN_EQUIVALENCE_REMAPPING } = constants;
12
12
 
13
13
  type SignerOrProvider = providers.Provider | Signer;
14
14
 
15
- export async function fetchTokenInfo(address: string, signerOrProvider: SignerOrProvider): Promise<TokenInfo> {
15
+ export async function fetchTokenInfo(address: string, signerOrProvider: SignerOrProvider): Promise<L1TokenInfo> {
16
16
  const token = new Contract(address, ERC20__factory.abi, signerOrProvider);
17
17
  const [symbol, decimals] = await Promise.all([token.symbol(), token.decimals()]);
18
18
  return { address: EvmAddress.from(address), symbol, decimals };