@across-protocol/sdk 4.1.28 → 4.1.30

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 (47) hide show
  1. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +2 -2
  2. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  3. package/dist/cjs/clients/SpokePoolClient.d.ts +0 -3
  4. package/dist/cjs/clients/SpokePoolClient.js +5 -64
  5. package/dist/cjs/clients/SpokePoolClient.js.map +1 -1
  6. package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +9 -9
  7. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +9 -9
  8. package/dist/cjs/utils/CachingUtils.js +2 -2
  9. package/dist/cjs/utils/CachingUtils.js.map +1 -1
  10. package/dist/cjs/utils/DepositUtils.d.ts +14 -1
  11. package/dist/cjs/utils/DepositUtils.js +51 -3
  12. package/dist/cjs/utils/DepositUtils.js.map +1 -1
  13. package/dist/cjs/utils/SpokeUtils.d.ts +2 -18
  14. package/dist/cjs/utils/SpokeUtils.js +26 -130
  15. package/dist/cjs/utils/SpokeUtils.js.map +1 -1
  16. package/dist/cjs/utils/TokenUtils.d.ts +18 -18
  17. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +2 -2
  18. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  19. package/dist/esm/clients/SpokePoolClient.d.ts +0 -14
  20. package/dist/esm/clients/SpokePoolClient.js +7 -82
  21. package/dist/esm/clients/SpokePoolClient.js.map +1 -1
  22. package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +9 -9
  23. package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +9 -9
  24. package/dist/esm/utils/CachingUtils.js +1 -1
  25. package/dist/esm/utils/CachingUtils.js.map +1 -1
  26. package/dist/esm/utils/DepositUtils.d.ts +21 -1
  27. package/dist/esm/utils/DepositUtils.js +61 -2
  28. package/dist/esm/utils/DepositUtils.js.map +1 -1
  29. package/dist/esm/utils/SpokeUtils.d.ts +9 -36
  30. package/dist/esm/utils/SpokeUtils.js +32 -185
  31. package/dist/esm/utils/SpokeUtils.js.map +1 -1
  32. package/dist/esm/utils/TokenUtils.d.ts +18 -18
  33. package/dist/types/clients/SpokePoolClient.d.ts +0 -14
  34. package/dist/types/clients/SpokePoolClient.d.ts.map +1 -1
  35. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +9 -9
  36. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +9 -9
  37. package/dist/types/utils/DepositUtils.d.ts +21 -1
  38. package/dist/types/utils/DepositUtils.d.ts.map +1 -1
  39. package/dist/types/utils/SpokeUtils.d.ts +9 -36
  40. package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
  41. package/dist/types/utils/TokenUtils.d.ts +18 -18
  42. package/package.json +2 -2
  43. package/src/clients/BundleDataClient/BundleDataClient.ts +2 -2
  44. package/src/clients/SpokePoolClient.ts +14 -69
  45. package/src/utils/CachingUtils.ts +1 -1
  46. package/src/utils/DepositUtils.ts +73 -3
  47. package/src/utils/SpokeUtils.ts +22 -210
@@ -215,15 +215,6 @@ export declare class RelayFeeCalculator {
215
215
  };
216
216
  coingeckoId: string;
217
217
  };
218
- XYZ: {
219
- name: string;
220
- symbol: string;
221
- decimals: number;
222
- addresses: {
223
- [x: number]: string;
224
- };
225
- coingeckoId: string;
226
- };
227
218
  LSK: {
228
219
  name: string;
229
220
  symbol: string;
@@ -407,6 +398,15 @@ export declare class RelayFeeCalculator {
407
398
  };
408
399
  coingeckoId: string;
409
400
  };
401
+ XYZ: {
402
+ name: string;
403
+ symbol: string;
404
+ decimals: number;
405
+ addresses: {
406
+ [x: number]: string;
407
+ };
408
+ coingeckoId: string;
409
+ };
410
410
  }, gasPrice?: BigNumberish, gasLimit?: BigNumberish, _tokenGasCost?: BigNumberish, transport?: Transport): Promise<BigNumber>;
411
411
  capitalFeePercent(_amountToRelay: BigNumberish, _tokenSymbol: string, _originRoute?: ChainIdAsString, _destinationRoute?: ChainIdAsString): BigNumber;
412
412
  /**
@@ -1,5 +1,5 @@
1
1
  import { SpokePoolClient } from "../clients";
2
- import { CachingMechanismInterface, Deposit, DepositWithBlock, Fill, SlowFillRequest } from "../interfaces";
2
+ import { CachingMechanismInterface, Deposit, DepositWithBlock, Fill, RelayData, SlowFillRequest } from "../interfaces";
3
3
  export declare enum InvalidFill {
4
4
  DepositIdInvalid = 0,
5
5
  DepositIdNotFound = 1,
@@ -27,6 +27,26 @@ export type DepositSearchResult = {
27
27
  * @throws If the spoke pool client has not been updated.
28
28
  */
29
29
  export declare function queryHistoricalDepositForFill(spokePoolClient: SpokePoolClient, fill: Fill | SlowFillRequest, cache?: CachingMechanismInterface): Promise<DepositSearchResult>;
30
+ /**
31
+ * Concatenate all fields from a Deposit, Fill or SlowFillRequest into a single string.
32
+ * This can be used to identify a bridge event in a mapping. This is used instead of the actual keccak256 hash
33
+ * (getRelayDataHash()) for two reasons: performance and the fact that only Deposit includes the `message` field, which
34
+ * is required to compute a complete RelayData hash.
35
+ * note: This function should _not_ be used to query the SpokePool.fillStatuses mapping.
36
+ */
37
+ export declare function getRelayEventKey(data: Omit<RelayData, "message"> & {
38
+ messageHash: string;
39
+ destinationChainId: number;
40
+ }): string;
41
+ export declare function validateFillForDeposit(relayData: Omit<RelayData, "message"> & {
42
+ messageHash: string;
43
+ destinationChainId: number;
44
+ }, deposit?: Omit<Deposit, "quoteTimestamp" | "fromLiteChain" | "toLiteChain">): {
45
+ valid: true;
46
+ } | {
47
+ valid: false;
48
+ reason: string;
49
+ };
30
50
  /**
31
51
  * Returns true if filling this deposit (as a slow or fast fill) or refunding it would not change any state
32
52
  * on-chain. The dataworker functions can use this to conveniently filter out useless deposits.
@@ -1 +1 @@
1
- {"version":3,"file":"DepositUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/DepositUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,Y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,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,CAAC,GAAG,OAAO,CAE7F;AAED,wBAAgB,gCAAgC,CAC9C,CAAC,EAAE,IAAI,CAAC,IAAI,GAAG,eAAe,EAAE,aAAa,GAAG,aAAa,CAAC,GAC7D,OAAO,CAET;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAgB,GAAG,OAAO,CAE/D;AAED,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE5E;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAI9D"}
@@ -1,6 +1,5 @@
1
1
  import { Contract, PopulatedTransaction, providers } from "ethers";
2
2
  import { Deposit, FillStatus, FillWithBlock, RelayData } from "../interfaces";
3
- import { SpokePoolClient } from "../clients";
4
3
  import { BigNumber } from "./BigNumberUtils";
5
4
  type BlockTag = providers.BlockTag;
6
5
  /**
@@ -11,44 +10,18 @@ type BlockTag = providers.BlockTag;
11
10
  */
12
11
  export declare function populateV3Relay(spokePool: Contract, deposit: Omit<Deposit, "messageHash">, relayer: string, repaymentChainId?: number): Promise<PopulatedTransaction>;
13
12
  /**
14
- * Concatenate all fields from a Deposit, Fill or SlowFillRequest into a single string.
15
- * This can be used to identify a bridge event in a mapping. This is used instead of the actual keccak256 hash
16
- * (getRelayDataHash()) for two reasons: performance and the fact that only Deposit includes the `message` field, which
17
- * is required to compute a complete RelayData hash.
18
- * note: This function should _not_ be used to query the SpokePool.fillStatuses mapping.
13
+ * Retrieves the time from the SpokePool contract at a particular block.
14
+ * @returns The time at the specified block tag.
19
15
  */
20
- export declare function getRelayEventKey(data: Omit<RelayData, "message"> & {
21
- messageHash: string;
22
- destinationChainId: number;
23
- }): string;
24
- export declare function validateFillForDeposit(relayData: Omit<RelayData, "message"> & {
25
- messageHash: string;
26
- destinationChainId: number;
27
- }, deposit?: Omit<Deposit, "quoteTimestamp" | "fromLiteChain" | "toLiteChain">): {
28
- valid: true;
29
- } | {
30
- valid: false;
31
- reason: string;
32
- };
16
+ export declare function getTimeAt(spokePool: Contract, blockNumber: number): Promise<number>;
33
17
  /**
34
- * Find the block range that contains the deposit ID. This is a binary search that searches for the block range
35
- * that contains the deposit ID.
36
- * @param targetDepositId The target deposit ID to search for.
37
- * @param initLow The initial lower bound of the block range to search.
38
- * @param initHigh The initial upper bound of the block range to search.
39
- * @param maxSearches The maximum number of searches to perform. This is used to prevent infinite loops.
40
- * @returns The block range that contains the deposit ID.
41
- * @note // We want to find the block range that satisfies these conditions:
42
- * // - the low block has deposit count <= targetDepositId
43
- * // - the high block has a deposit count > targetDepositId.
44
- * // This way the caller can search for a V3FundsDeposited event between [low, high] that will always
45
- * // contain the event emitted when deposit ID was incremented to targetDepositId + 1. This is the same transaction
46
- * // where the deposit with deposit ID = targetDepositId was created.
18
+ * Return maximum of fill deadline buffer at start and end of block range.
19
+ * @param spokePool SpokePool contract instance
20
+ * @param startBlock start block
21
+ * @param endBlock end block
22
+ * @returns maximum of fill deadline buffer at start and end block
47
23
  */
48
- export declare function getBlockRangeForDepositId(targetDepositId: BigNumber, initLow: number, initHigh: number, maxSearches: number, spokePool: SpokePoolClient): Promise<{
49
- low: number;
50
- high: number;
51
- }>;
24
+ export declare function getMaxFillDeadlineInRange(spokePool: Contract, startBlock: number, endBlock: number): Promise<number>;
52
25
  /**
53
26
  * Finds the deposit id at a specific block number.
54
27
  * @param blockTag The block number to search for the deposit ID at.
@@ -1 +1 @@
1
- {"version":3,"file":"SpokeUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/SpokeUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,QAAQ,EAAE,oBAAoB,EAAE,SAAS,EAAwB,MAAM,QAAQ,CAAC;AAEpG,OAAO,EAAE,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AAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD"}
@@ -113,15 +113,6 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
113
113
  };
114
114
  coingeckoId: string;
115
115
  };
116
- XYZ: {
117
- name: string;
118
- symbol: string;
119
- decimals: number;
120
- addresses: {
121
- [x: number]: string;
122
- };
123
- coingeckoId: string;
124
- };
125
116
  LSK: {
126
117
  name: string;
127
118
  symbol: string;
@@ -305,6 +296,15 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
305
296
  };
306
297
  coingeckoId: string;
307
298
  };
299
+ XYZ: {
300
+ name: string;
301
+ symbol: string;
302
+ decimals: number;
303
+ addresses: {
304
+ [x: number]: string;
305
+ };
306
+ coingeckoId: string;
307
+ };
308
308
  }) => string | undefined;
309
309
  export declare function getTokenInformationFromAddress(address: string, tokenMapping?: {
310
310
  ACX: {
@@ -397,15 +397,6 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
397
397
  };
398
398
  coingeckoId: string;
399
399
  };
400
- XYZ: {
401
- name: string;
402
- symbol: string;
403
- decimals: number;
404
- addresses: {
405
- [x: number]: string;
406
- };
407
- coingeckoId: string;
408
- };
409
400
  LSK: {
410
401
  name: string;
411
402
  symbol: string;
@@ -589,6 +580,15 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
589
580
  };
590
581
  coingeckoId: string;
591
582
  };
583
+ XYZ: {
584
+ name: string;
585
+ symbol: string;
586
+ decimals: number;
587
+ addresses: {
588
+ [x: number]: string;
589
+ };
590
+ coingeckoId: string;
591
+ };
592
592
  }): L1Token | undefined;
593
593
  export declare function getCoingeckoTokenIdByAddress(contractAddress: string): string;
594
594
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@across-protocol/sdk",
3
3
  "author": "UMA Team",
4
- "version": "4.1.28",
4
+ "version": "4.1.30",
5
5
  "license": "AGPL-3.0",
6
6
  "homepage": "https://docs.across.to/reference/sdk",
7
7
  "files": [
@@ -103,7 +103,7 @@
103
103
  },
104
104
  "dependencies": {
105
105
  "@across-protocol/across-token": "^1.0.0",
106
- "@across-protocol/constants": "^3.1.40",
106
+ "@across-protocol/constants": "^3.1.43",
107
107
  "@across-protocol/contracts": "^4.0.4",
108
108
  "@coral-xyz/anchor": "^0.30.1",
109
109
  "@eth-optimism/sdk": "^3.3.1",
@@ -1551,8 +1551,8 @@ export class BundleDataClient {
1551
1551
  // there are no gaps in block timestamps between bundles.
1552
1552
  const endBlockForChain = Math.min(_endBlockForChain + 1, spokePoolClient.latestBlockSearched);
1553
1553
  const [startTime, _endTime] = [
1554
- await spokePoolClient.getTimestampForBlock(startBlockForChain),
1555
- await spokePoolClient.getTimestampForBlock(endBlockForChain),
1554
+ await spokePoolClient.getTimeAt(startBlockForChain),
1555
+ await spokePoolClient.getTimeAt(endBlockForChain),
1556
1556
  ];
1557
1557
  // @dev similar to reasoning above to ensure no gaps between bundle block range timestamps and also
1558
1558
  // no overlap, subtract 1 from the end time.
@@ -1,11 +1,9 @@
1
- import assert from "assert";
2
1
  import { Contract, EventFilter } from "ethers";
3
2
  import winston from "winston";
4
3
  import {
5
4
  AnyObject,
6
5
  BigNumber,
7
6
  bnZero,
8
- bnUint32Max,
9
7
  DefaultLogLevels,
10
8
  DepositSearchResult,
11
9
  EventSearchConfig,
@@ -45,9 +43,13 @@ import {
45
43
  SpeedUpWithBlock,
46
44
  TokensBridged,
47
45
  } from "../interfaces";
48
- import { SpokePool } from "../typechain";
49
46
  import { getNetworkName } from "../utils/NetworkUtils";
50
- import { findDepositBlock, getDepositIdAtBlock, relayFillStatus } from "../utils/SpokeUtils";
47
+ import {
48
+ findDepositBlock,
49
+ getMaxFillDeadlineInRange as getMaxFillDeadline,
50
+ getTimeAt as _getTimeAt,
51
+ relayFillStatus,
52
+ } from "../utils/SpokeUtils";
51
53
  import { BaseAbstractClient, isUpdateFailureReason, UpdateFailureReason } from "./BaseAbstractClient";
52
54
  import { HubPoolClient } from "./HubPoolClient";
53
55
  import { AcrossConfigStoreClient } from "./AcrossConfigStoreClient";
@@ -334,9 +336,7 @@ export class SpokePoolClient extends BaseAbstractClient {
334
336
  * @returns A list of slow fill requests.
335
337
  */
336
338
  public getSlowFillRequestsForOriginChain(originChainId: number): SlowFillRequestWithBlock[] {
337
- return Object.values(this.slowFillRequests).filter(
338
- (e: SlowFillRequestWithBlock) => e.originChainId === originChainId
339
- );
339
+ return Object.values(this.slowFillRequests).filter((e) => e.originChainId === originChainId);
340
340
  }
341
341
 
342
342
  /**
@@ -355,10 +355,7 @@ export class SpokePoolClient extends BaseAbstractClient {
355
355
  public getDepositForFill(fill: Fill): DepositWithBlock | undefined {
356
356
  const deposit = this.depositHashes[getRelayEventKey(fill)];
357
357
  const match = validateFillForDeposit(fill, deposit);
358
- if (match.valid) {
359
- return deposit;
360
- }
361
- return undefined;
358
+ return match.valid ? deposit : undefined;
362
359
  }
363
360
 
364
361
  public getFillsForDeposit(deposit: Deposit): FillWithBlock[] {
@@ -475,15 +472,6 @@ export class SpokePoolClient extends BaseAbstractClient {
475
472
  return `${event.depositId.toString()}-${event.originChainId}`;
476
473
  }
477
474
 
478
- /**
479
- * Finds the deposit id at a specific block number.
480
- * @param blockTag The block number to search for the deposit ID at.
481
- * @returns The deposit ID.
482
- */
483
- public _getDepositIdAtBlock(blockTag: number): Promise<BigNumber> {
484
- return getDepositIdAtBlock(this.spokePool as SpokePool, blockTag);
485
- }
486
-
487
475
  /**
488
476
  * @notice Return maximum of fill deadline buffer at start and end of block range. This is a contract
489
477
  * immutable state variable so we can't query other events to find its updates.
@@ -497,12 +485,8 @@ export class SpokePoolClient extends BaseAbstractClient {
497
485
  * @param endBlock end block
498
486
  * @returns maximum of fill deadline buffer at start and end block
499
487
  */
500
- public async getMaxFillDeadlineInRange(startBlock: number, endBlock: number): Promise<number> {
501
- const fillDeadlineBuffers: number[] = await Promise.all([
502
- this.spokePool.fillDeadlineBuffer({ blockTag: startBlock }),
503
- this.spokePool.fillDeadlineBuffer({ blockTag: endBlock }),
504
- ]);
505
- return Math.max(fillDeadlineBuffers[0], fillDeadlineBuffers[1]);
488
+ public getMaxFillDeadlineInRange(startBlock: number, endBlock: number): Promise<number> {
489
+ return getMaxFillDeadline(this.spokePool, startBlock, endBlock);
506
490
  }
507
491
 
508
492
  /**
@@ -568,7 +552,7 @@ export class SpokePoolClient extends BaseAbstractClient {
568
552
  }
569
553
 
570
554
  // Sort all events to ensure they are stored in a consistent order.
571
- events.forEach((events: Log[]) => sortEventsAscendingInPlace(events));
555
+ events.forEach((events) => sortEventsAscendingInPlace(events));
572
556
 
573
557
  return {
574
558
  success: true,
@@ -788,10 +772,6 @@ export class SpokePoolClient extends BaseAbstractClient {
788
772
  const refundEvents = queryResults[eventsToQuery.indexOf("ExecutedRelayerRefundRoot")];
789
773
  for (const event of refundEvents) {
790
774
  const executedRefund = spreadEventWithBlockNumber(event) as RelayerRefundExecutionWithBlock;
791
- executedRefund.l2TokenAddress = SpokePoolClient.getExecutedRefundLeafL2Token(
792
- executedRefund.chainId,
793
- executedRefund.l2TokenAddress
794
- );
795
775
  this.relayerRefundExecutions.push(executedRefund);
796
776
  }
797
777
  }
@@ -814,30 +794,6 @@ export class SpokePoolClient extends BaseAbstractClient {
814
794
  });
815
795
  }
816
796
 
817
- /**
818
- * Retrieves the l2TokenAddress for a given executed refund leaf.
819
- * @param chainId The chain ID of the executed refund leaf.
820
- * @param eventL2Token The l2TokenAddress of the executed refund leaf.
821
- * @returns The l2TokenAddress of the executed refund leaf.
822
- */
823
- public static getExecutedRefundLeafL2Token(chainId: number, eventL2Token: string): string {
824
- // If execution of WETH refund leaf occurred on an OVM spoke pool, then we'll convert its l2Token from the native
825
- // token address to the wrapped token address. This is because the OVM_SpokePool modifies the l2TokenAddress prop
826
- // in _bridgeTokensToHubPool before emitting the ExecutedRelayerRefundLeaf event.
827
- // Here is the contract code referenced:
828
- // - https://github.com/across-protocol/contracts/blob/954528a4620863d1c868e54a370fd8556d5ed05c/contracts/Ovm_SpokePool.sol#L142
829
- if (
830
- (chainId === 10 || chainId === 8453) &&
831
- eventL2Token.toLowerCase() === "0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000"
832
- ) {
833
- return "0x4200000000000000000000000000000000000006";
834
- } else if (chainId === 288 && eventL2Token.toLowerCase() === "0x4200000000000000000000000000000000000006") {
835
- return "0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000";
836
- } else {
837
- return eventL2Token;
838
- }
839
- }
840
-
841
797
  /**
842
798
  * Resolve a given timestamp to a block number on the HubPool chain via the HubPoolClient.
843
799
  * @param timestamp A single timestamp to be resolved via the HubPoolClient.
@@ -866,11 +822,7 @@ export class SpokePoolClient extends BaseAbstractClient {
866
822
  */
867
823
  protected getDestinationTokenForDeposit(deposit: DepositWithBlock): string {
868
824
  // If there is no rate model client return address(0).
869
- if (!this.hubPoolClient) {
870
- return ZERO_ADDRESS;
871
- }
872
-
873
- return this.hubPoolClient.getL2TokenForDeposit(deposit);
825
+ return this.hubPoolClient?.getL2TokenForDeposit(deposit) ?? ZERO_ADDRESS;
874
826
  }
875
827
 
876
828
  /**
@@ -895,10 +847,8 @@ export class SpokePoolClient extends BaseAbstractClient {
895
847
  * Retrieves the time from the SpokePool contract at a particular block.
896
848
  * @returns The time at the specified block tag.
897
849
  */
898
- public async getTimeAt(blockNumber: number): Promise<number> {
899
- const currentTime = await this.spokePool.getCurrentTime({ blockTag: blockNumber });
900
- assert(BigNumber.isBigNumber(currentTime) && currentTime.lt(bnUint32Max));
901
- return currentTime.toNumber();
850
+ public getTimeAt(blockNumber: number): Promise<number> {
851
+ return _getTimeAt(this.spokePool, blockNumber);
902
852
  }
903
853
 
904
854
  /**
@@ -999,11 +949,6 @@ export class SpokePoolClient extends BaseAbstractClient {
999
949
  );
1000
950
  }
1001
951
 
1002
- public async getTimestampForBlock(blockTag: number): Promise<number> {
1003
- const block = await this.spokePool.provider.getBlock(blockTag);
1004
- return Number(block.timestamp);
1005
- }
1006
-
1007
952
  /**
1008
953
  * Find the amount filled for a deposit at a particular block.
1009
954
  * @param relayData Deposit information that is used to complete a fill.
@@ -2,7 +2,7 @@ import { DEFAULT_CACHING_SAFE_LAG, DEFAULT_CACHING_TTL } from "../constants";
2
2
  import { CachingMechanismInterface, Deposit, Fill, SlowFillRequest } from "../interfaces";
3
3
  import assert from "assert";
4
4
  import { composeRevivers, objectWithBigNumberReviver } from "./ReviverUtils";
5
- import { getRelayEventKey } from "./SpokeUtils";
5
+ import { getRelayEventKey } from "./DepositUtils";
6
6
  import { getCurrentTime } from "./TimeUtils";
7
7
  import { isDefined } from "./TypeGuards";
8
8
 
@@ -1,11 +1,11 @@
1
1
  import assert from "assert";
2
2
  import { SpokePoolClient } from "../clients";
3
- import { DEFAULT_CACHING_TTL, EMPTY_MESSAGE, ZERO_BYTES } from "../constants";
4
- import { CachingMechanismInterface, Deposit, DepositWithBlock, Fill, SlowFillRequest } from "../interfaces";
3
+ import { DEFAULT_CACHING_TTL, EMPTY_MESSAGE, UNDEFINED_MESSAGE_HASH, ZERO_BYTES } from "../constants";
4
+ import { CachingMechanismInterface, Deposit, DepositWithBlock, Fill, RelayData, SlowFillRequest } from "../interfaces";
5
5
  import { getNetworkName } from "./NetworkUtils";
6
6
  import { bnZero } from "./BigNumberUtils";
7
7
  import { getDepositInCache, getDepositKey, setDepositInCache } from "./CachingUtils";
8
- import { getMessageHash, isUnsafeDepositId, validateFillForDeposit } from "./SpokeUtils";
8
+ import { getMessageHash, isUnsafeDepositId } from "./SpokeUtils";
9
9
  import { getCurrentTime } from "./TimeUtils";
10
10
  import { isDefined } from "./TypeGuards";
11
11
  import { isDepositFormedCorrectly } from "./ValidatorUtils";
@@ -125,6 +125,76 @@ export async function queryHistoricalDepositForFill(
125
125
  };
126
126
  }
127
127
 
128
+ /**
129
+ * Concatenate all fields from a Deposit, Fill or SlowFillRequest into a single string.
130
+ * This can be used to identify a bridge event in a mapping. This is used instead of the actual keccak256 hash
131
+ * (getRelayDataHash()) for two reasons: performance and the fact that only Deposit includes the `message` field, which
132
+ * is required to compute a complete RelayData hash.
133
+ * note: This function should _not_ be used to query the SpokePool.fillStatuses mapping.
134
+ */
135
+ export function getRelayEventKey(
136
+ data: Omit<RelayData, "message"> & { messageHash: string; destinationChainId: number }
137
+ ): string {
138
+ return [
139
+ data.depositor,
140
+ data.recipient,
141
+ data.exclusiveRelayer,
142
+ data.inputToken,
143
+ data.outputToken,
144
+ data.inputAmount,
145
+ data.outputAmount,
146
+ data.originChainId,
147
+ data.destinationChainId,
148
+ data.depositId,
149
+ data.fillDeadline,
150
+ data.exclusivityDeadline,
151
+ data.messageHash,
152
+ ]
153
+ .map(String)
154
+ .join("-");
155
+ }
156
+
157
+ const RELAYDATA_KEYS = [
158
+ "depositId",
159
+ "originChainId",
160
+ "destinationChainId",
161
+ "depositor",
162
+ "recipient",
163
+ "inputToken",
164
+ "inputAmount",
165
+ "outputToken",
166
+ "outputAmount",
167
+ "fillDeadline",
168
+ "exclusivityDeadline",
169
+ "exclusiveRelayer",
170
+ "messageHash",
171
+ ] as const;
172
+
173
+ // Ensure that each deposit element is included with the same value in the fill. This includes all elements defined
174
+ // by the depositor as well as destinationToken, which are pulled from other clients.
175
+ export function validateFillForDeposit(
176
+ relayData: Omit<RelayData, "message"> & { messageHash: string; destinationChainId: number },
177
+ deposit?: Omit<Deposit, "quoteTimestamp" | "fromLiteChain" | "toLiteChain">
178
+ ): { valid: true } | { valid: false; reason: string } {
179
+ if (deposit === undefined) {
180
+ return { valid: false, reason: "Deposit is undefined" };
181
+ }
182
+
183
+ // Note: this short circuits when a key is found where the comparison doesn't match.
184
+ // TODO: if we turn on "strict" in the tsconfig, the elements of FILL_DEPOSIT_COMPARISON_KEYS will be automatically
185
+ // validated against the fields in Fill and Deposit, generating an error if there is a discrepency.
186
+ let invalidKey = RELAYDATA_KEYS.find((key) => relayData[key].toString() !== deposit[key].toString());
187
+
188
+ // There should be no paths for `messageHash` to be unset, but mask it off anyway.
189
+ if (!isDefined(invalidKey) && [relayData.messageHash, deposit.messageHash].includes(UNDEFINED_MESSAGE_HASH)) {
190
+ invalidKey = "messageHash";
191
+ }
192
+
193
+ return isDefined(invalidKey)
194
+ ? { valid: false, reason: `${invalidKey} mismatch (${relayData[invalidKey]} != ${deposit[invalidKey]})` }
195
+ : { valid: true };
196
+ }
197
+
128
198
  /**
129
199
  * Returns true if filling this deposit (as a slow or fast fill) or refunding it would not change any state
130
200
  * on-chain. The dataworker functions can use this to conveniently filter out useless deposits.