@across-protocol/sdk 3.1.36 → 3.2.0

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 (83) hide show
  1. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +4 -4
  2. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +1 -2
  3. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  4. package/dist/cjs/clients/HubPoolClient.d.ts +7 -4
  5. package/dist/cjs/clients/HubPoolClient.js +37 -25
  6. package/dist/cjs/clients/HubPoolClient.js.map +1 -1
  7. package/dist/cjs/clients/SpokePoolClient.d.ts +7 -5
  8. package/dist/cjs/clients/SpokePoolClient.js +53 -90
  9. package/dist/cjs/clients/SpokePoolClient.js.map +1 -1
  10. package/dist/cjs/clients/mocks/MockConfigStoreClient.d.ts +4 -3
  11. package/dist/cjs/clients/mocks/MockConfigStoreClient.js +27 -44
  12. package/dist/cjs/clients/mocks/MockConfigStoreClient.js.map +1 -1
  13. package/dist/cjs/clients/mocks/MockEvents.d.ts +5 -5
  14. package/dist/cjs/clients/mocks/MockEvents.js +7 -44
  15. package/dist/cjs/clients/mocks/MockEvents.js.map +1 -1
  16. package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +5 -5
  17. package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
  18. package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +9 -19
  19. package/dist/cjs/clients/mocks/MockSpokePoolClient.js +22 -96
  20. package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
  21. package/dist/cjs/contracts/utils.d.ts +1 -1
  22. package/dist/cjs/contracts/utils.js.map +1 -1
  23. package/dist/cjs/interfaces/Common.d.ts +7 -0
  24. package/dist/cjs/utils/EventUtils.d.ts +7 -4
  25. package/dist/cjs/utils/EventUtils.js +9 -5
  26. package/dist/cjs/utils/EventUtils.js.map +1 -1
  27. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +4 -4
  28. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +2 -3
  29. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  30. package/dist/esm/clients/HubPoolClient.d.ts +19 -4
  31. package/dist/esm/clients/HubPoolClient.js +51 -27
  32. package/dist/esm/clients/HubPoolClient.js.map +1 -1
  33. package/dist/esm/clients/SpokePoolClient.d.ts +13 -12
  34. package/dist/esm/clients/SpokePoolClient.js +61 -104
  35. package/dist/esm/clients/SpokePoolClient.js.map +1 -1
  36. package/dist/esm/clients/mocks/MockConfigStoreClient.d.ts +4 -3
  37. package/dist/esm/clients/mocks/MockConfigStoreClient.js +33 -47
  38. package/dist/esm/clients/mocks/MockConfigStoreClient.js.map +1 -1
  39. package/dist/esm/clients/mocks/MockEvents.d.ts +5 -5
  40. package/dist/esm/clients/mocks/MockEvents.js +9 -50
  41. package/dist/esm/clients/mocks/MockEvents.js.map +1 -1
  42. package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +5 -5
  43. package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
  44. package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +9 -19
  45. package/dist/esm/clients/mocks/MockSpokePoolClient.js +30 -100
  46. package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
  47. package/dist/esm/contracts/utils.d.ts +1 -1
  48. package/dist/esm/contracts/utils.js.map +1 -1
  49. package/dist/esm/interfaces/Common.d.ts +7 -0
  50. package/dist/esm/utils/EventUtils.d.ts +7 -4
  51. package/dist/esm/utils/EventUtils.js +7 -4
  52. package/dist/esm/utils/EventUtils.js.map +1 -1
  53. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +4 -4
  54. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
  55. package/dist/types/clients/HubPoolClient.d.ts +19 -4
  56. package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
  57. package/dist/types/clients/SpokePoolClient.d.ts +13 -12
  58. package/dist/types/clients/SpokePoolClient.d.ts.map +1 -1
  59. package/dist/types/clients/mocks/MockConfigStoreClient.d.ts +4 -3
  60. package/dist/types/clients/mocks/MockConfigStoreClient.d.ts.map +1 -1
  61. package/dist/types/clients/mocks/MockEvents.d.ts +5 -5
  62. package/dist/types/clients/mocks/MockEvents.d.ts.map +1 -1
  63. package/dist/types/clients/mocks/MockHubPoolClient.d.ts +5 -5
  64. package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
  65. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +9 -19
  66. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
  67. package/dist/types/contracts/utils.d.ts +1 -1
  68. package/dist/types/contracts/utils.d.ts.map +1 -1
  69. package/dist/types/interfaces/Common.d.ts +7 -0
  70. package/dist/types/interfaces/Common.d.ts.map +1 -1
  71. package/dist/types/utils/EventUtils.d.ts +7 -4
  72. package/dist/types/utils/EventUtils.d.ts.map +1 -1
  73. package/package.json +3 -2
  74. package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +9 -10
  75. package/src/clients/HubPoolClient.ts +34 -24
  76. package/src/clients/SpokePoolClient.ts +55 -74
  77. package/src/clients/mocks/MockConfigStoreClient.ts +11 -11
  78. package/src/clients/mocks/MockEvents.ts +15 -65
  79. package/src/clients/mocks/MockHubPoolClient.ts +6 -6
  80. package/src/clients/mocks/MockSpokePoolClient.ts +26 -59
  81. package/src/contracts/utils.ts +2 -1
  82. package/src/interfaces/Common.ts +7 -0
  83. package/src/utils/EventUtils.ts +12 -7
@@ -1,7 +1,7 @@
1
1
  import winston from "winston";
2
- import { Contract, Event } from "ethers";
2
+ import { Contract } from "ethers";
3
3
  import { BigNumber } from "../../utils";
4
- import { L1Token, PendingRootBundle, RealizedLpFee } from "../../interfaces";
4
+ import { L1Token, Log, PendingRootBundle, RealizedLpFee } from "../../interfaces";
5
5
  import { AcrossConfigStoreClient as ConfigStoreClient } from "../AcrossConfigStoreClient";
6
6
  import { HubPoolClient, HubPoolUpdate, LpFeeRequest } from "../HubPoolClient";
7
7
  import { EventOverrides } from "./MockEvents";
@@ -30,8 +30,8 @@ export declare class MockHubPoolClient extends HubPoolClient {
30
30
  setTokenInfoToReturn(tokenInfo: L1Token): void;
31
31
  _update(eventNames: string[]): Promise<HubPoolUpdate>;
32
32
  readonly eventSignatures: Record<string, string>;
33
- setPoolRebalanceRoute(destinationChainId: number, l1Token: string, destinationToken: string, overrides?: EventOverrides): Event;
34
- proposeRootBundle(challengePeriodEndTimestamp: number, poolRebalanceLeafCount: number, bundleEvaluationBlockNumbers: BigNumber[], poolRebalanceRoot?: string, relayerRefundRoot?: string, slowRelayRoot?: string, proposer?: string, overrides?: EventOverrides): Event;
35
- executeRootBundle(groupIndex: BigNumber, leafId: number, chainId: BigNumber, l1Tokens: string[], bundleLpFees: BigNumber[], netSendAmounts: BigNumber[], runningBalances: BigNumber[], caller?: string, overrides?: EventOverrides): Event;
33
+ setPoolRebalanceRoute(destinationChainId: number, l1Token: string, destinationToken: string, overrides?: EventOverrides): Log;
34
+ proposeRootBundle(challengePeriodEndTimestamp: number, poolRebalanceLeafCount: number, bundleEvaluationBlockNumbers: BigNumber[], poolRebalanceRoot?: string, relayerRefundRoot?: string, slowRelayRoot?: string, proposer?: string, overrides?: EventOverrides): Log;
35
+ executeRootBundle(groupIndex: BigNumber, leafId: number, chainId: BigNumber, l1Tokens: string[], bundleLpFees: BigNumber[], netSendAmounts: BigNumber[], runningBalances: BigNumber[], caller?: string, overrides?: EventOverrides): Log;
36
36
  }
37
37
  //# sourceMappingURL=MockHubPoolClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MockHubPoolClient.d.ts","sourceRoot":"","sources":["../../../../src/clients/mocks/MockHubPoolClient.ts"],"names":[],"mappings":"AAAA,OAA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AAC,EAAE,MAAM,EACf,SAAS,GAAE,cAAmB,GAC7B,GAAG;CAyBP"}
@@ -1,28 +1,19 @@
1
- import { Contract, Event, providers } from "ethers";
1
+ import { Contract } from "ethers";
2
2
  import winston from "winston";
3
- import { DepositWithBlock, V3FundsDepositedEvent, RealizedLpFee, RelayerRefundExecutionWithBlock, SlowFillRequestWithBlock, FillWithBlock, SlowFillLeaf, SpeedUp } from "../../interfaces";
4
- import { BigNumber } from "../../utils";
3
+ import { Log, DepositWithBlock, RelayerRefundExecutionWithBlock, SlowFillRequestWithBlock, FillWithBlock, SlowFillLeaf, SpeedUp } from "../../interfaces";
5
4
  import { SpokePoolClient, SpokePoolUpdate } from "../SpokePoolClient";
6
5
  import { HubPoolClient } from "../HubPoolClient";
7
6
  import { EventManager, EventOverrides } from "./MockEvents";
8
7
  import { AcrossConfigStoreClient } from "../AcrossConfigStoreClient";
9
- type Block = providers.Block;
10
8
  export declare class MockSpokePoolClient extends SpokePoolClient {
11
9
  eventManager: EventManager;
12
- private realizedLpFeePct;
13
- private realizedLpFeePctOverride;
14
10
  private destinationTokenForChainOverride;
15
11
  depositIdAtBlock: number[];
16
12
  numberOfDeposits: number;
17
- blocks: Record<number, Block>;
18
13
  constructor(logger: winston.Logger, spokePool: Contract, chainId: number, deploymentBlock: number, opts?: {
19
14
  hubPoolClient: HubPoolClient | null;
20
15
  });
21
- setDefaultRealizedLpFeePct(fee: BigNumber): void;
22
16
  setConfigStoreClient(configStore?: AcrossConfigStoreClient): void;
23
- clearDefaultRealizedLpFeePct(): void;
24
- computeRealizedLpFeePct(depositEvent: V3FundsDepositedEvent): Promise<RealizedLpFee>;
25
- batchComputeRealizedLpFeePct(depositEvents: V3FundsDepositedEvent[]): Promise<RealizedLpFee[]>;
26
17
  setDestinationTokenForChain(chainId: number, token: string): void;
27
18
  getDestinationTokenForDeposit(deposit: DepositWithBlock): string;
28
19
  setLatestBlockNumber(blockNumber: number): void;
@@ -30,13 +21,12 @@ export declare class MockSpokePoolClient extends SpokePoolClient {
30
21
  _getDepositIdAtBlock(blockTag: number): Promise<number>;
31
22
  _update(eventsToQuery: string[]): Promise<SpokePoolUpdate>;
32
23
  readonly eventSignatures: Record<string, string>;
33
- depositV3(deposit: DepositWithBlock): Event;
34
- fillV3Relay(fill: FillWithBlock): Event;
35
- speedUpV3Deposit(speedUp: SpeedUp): Event;
36
- requestV3SlowFill(request: SlowFillRequestWithBlock): Event;
37
- executeV3SlowRelayLeaf(leaf: SlowFillLeaf): Event;
38
- executeRelayerRefundLeaf(refund: RelayerRefundExecutionWithBlock): Event;
39
- setEnableRoute(originToken: string, destinationChainId: number, enabled: boolean, overrides?: EventOverrides): Event;
24
+ depositV3(deposit: DepositWithBlock): Log;
25
+ fillV3Relay(fill: FillWithBlock): Log;
26
+ speedUpV3Deposit(speedUp: SpeedUp): Log;
27
+ requestV3SlowFill(request: SlowFillRequestWithBlock): Log;
28
+ executeV3SlowRelayLeaf(leaf: SlowFillLeaf): Log;
29
+ executeRelayerRefundLeaf(refund: RelayerRefundExecutionWithBlock): Log;
30
+ setEnableRoute(originToken: string, destinationChainId: number, enabled: boolean, overrides?: EventOverrides): Log;
40
31
  }
41
- export {};
42
32
  //# sourceMappingURL=MockSpokePoolClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MockSpokePoolClient.d.ts","sourceRoot":"","sources":["../../../../src/clients/mocks/MockSpokePoolClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEpD,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EACL,gBAAgB,EAEhB,qBAAqB,EACrB,aAAa,EACb,+BAA+B,EAC/B,wBAAwB,EAExB,aAAa,EACb,YAAY,EACZ,OAAO,EACR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAsE,MAAM,aAAa,CAAC;AAC5G,OAAO,EAAE,eAAe,EAAE,eAAe,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AAmB,GAC7B,GAAG;CAcP"}
@@ -1,4 +1,4 @@
1
- import { Event } from "ethers";
1
+ import { Event } from "@ethersproject/contracts";
2
2
  import { BigNumberish } from "../utils";
3
3
  /**
4
4
  * @dev Originally imported from @uma/sdk.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/contracts/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAa,YAAY,EAAa,MAAM,UAAU,CAAC;AAE9D;;;;GAIG;AAEH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,KAAK,EACL,QAAQ,GAAG,gBAAgB,GAAG,UAAU,GAAG,gBAAgB,GAAG,uBAAuB,CACtF,CAAC;AAGF,MAAM,MAAM,QAAQ,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEjD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,GAAE,QAAa;iBAC1B,MAAM;cAcT,MAAM,UAAU,YAAY;cAI5B,MAAM,UAAU,YAAY;cAI5B,MAAM;;cAbN,MAAM,UAAU,MAAM;cAJtB,MAAM;sBAsBE,MAAM;EAMhC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/contracts/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAa,YAAY,EAAa,MAAM,UAAU,CAAC;AAE9D;;;;GAIG;AAEH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,KAAK,EACL,QAAQ,GAAG,gBAAgB,GAAG,UAAU,GAAG,gBAAgB,GAAG,uBAAuB,CACtF,CAAC;AAGF,MAAM,MAAM,QAAQ,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEjD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,GAAE,QAAa;iBAC1B,MAAM;cAcT,MAAM,UAAU,YAAY;cAI5B,MAAM,UAAU,YAAY;cAI5B,MAAM;;cAbN,MAAM,UAAU,MAAM;cAJtB,MAAM;sBAsBE,MAAM;EAMhC"}
@@ -1,4 +1,11 @@
1
+ import { Log as _Log } from "@ethersproject/abstract-provider";
1
2
  import { BigNumber } from "../utils";
3
+ export type Log = _Log & {
4
+ event: string;
5
+ args: {
6
+ [key: string]: any;
7
+ };
8
+ };
2
9
  export interface SortableEvent {
3
10
  blockNumber: number;
4
11
  transactionIndex: number;
@@ -1 +1 @@
1
- {"version":3,"file":"Common.d.ts","sourceRoot":"","sources":["../../../src/interfaces/Common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC"}
1
+ {"version":3,"file":"Common.d.ts","sourceRoot":"","sources":["../../../src/interfaces/Common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,MAAM,GAAG,GAAG,IAAI,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IAEd,IAAI,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CAC9B,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC"}
@@ -1,13 +1,16 @@
1
1
  import { Result } from "@ethersproject/abi";
2
- import { SortableEvent } from "../interfaces";
3
2
  import { Contract, Event, EventFilter } from "ethers";
4
- export declare function spreadEvent(args?: Result): any;
3
+ import { Log, SortableEvent } from "../interfaces";
4
+ export declare function spreadEvent(args: Result | Record<string, unknown>): {
5
+ [key: string]: any;
6
+ };
5
7
  export interface EventSearchConfig {
6
8
  fromBlock: number;
7
9
  toBlock: number;
8
10
  maxBlockLookBack?: number;
9
11
  }
10
- export declare function paginatedEventQuery(contract: Contract, filter: EventFilter, searchConfig: EventSearchConfig, retryCount?: number): Promise<Event[]>;
12
+ export declare const eventToLog: (event: Event) => Log;
13
+ export declare function paginatedEventQuery(contract: Contract, filter: EventFilter, searchConfig: EventSearchConfig, retryCount?: number): Promise<Log[]>;
11
14
  /**
12
15
  * @dev Warning: this is a specialized function!! Its functionality is not obvious.
13
16
  * This function attempts to return block ranges to repeat ranges as much as possible. To do so, it may include blocks that
@@ -23,7 +26,7 @@ export declare function paginatedEventQuery(contract: Contract, filter: EventFil
23
26
  * are ordered from smallest to largest.
24
27
  */
25
28
  export declare function getPaginatedBlockRanges({ fromBlock, toBlock, maxBlockLookBack, }: EventSearchConfig): [number, number][];
26
- export declare function spreadEventWithBlockNumber(event: Event): SortableEvent;
29
+ export declare function spreadEventWithBlockNumber(event: Log): SortableEvent;
27
30
  export declare function sortEventsAscending<T extends SortableEvent>(events: T[]): T[];
28
31
  export declare function sortEventsAscendingInPlace<T extends SortableEvent>(events: T[]): T[];
29
32
  export declare function sortEventsDescending<T extends SortableEvent>(events: T[]): T[];
@@ -1 +1 @@
1
- {"version":3,"file":"EventUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/EventUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE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E,CAAC,EAAE,GAAG,CAAC,EAAE,CAUpF;AAGD,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,aAAa,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAE9E;AAID,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,aAAa,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAUrF;AAGD,wBAAgB,YAAY,CAAC,CAAC,SAAS,aAAa,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,OAAO,CAQ3E;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,EAAE,CAEtE"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@across-protocol/sdk",
3
3
  "author": "UMA Team",
4
- "version": "3.1.36",
4
+ "version": "3.2.0",
5
5
  "license": "AGPL-3.0",
6
6
  "homepage": "https://docs.across.to/reference/sdk",
7
7
  "files": [
@@ -12,8 +12,9 @@
12
12
  "node": ">=16.18.0"
13
13
  },
14
14
  "scripts": {
15
- "start": "nodemon -e ts,tsx,json,js,jsx --watch ./src --ignore ./dist --exec 'yarn build'",
15
+ "start": "yarn typechain && nodemon -e ts,tsx,json,js,jsx --watch ./src --ignore ./dist --exec 'yarn dev'",
16
16
  "build": "yarn run clean && yarn typechain && yarn run build:cjs & yarn run build:esm & yarn run build:types; wait",
17
+ "dev": "yarn run build:cjs & yarn run build:esm & yarn run build:types; wait",
17
18
  "build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir ./dist/cjs --removeComments --verbatimModuleSyntax false && echo > ./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
18
19
  "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir ./dist/esm && echo > ./dist/esm/package.json '{\"type\":\"module\",\"sideEffects\":false}'",
19
20
  "build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
@@ -1,6 +1,6 @@
1
1
  import { utils, across } from "@uma/sdk";
2
2
  import assert from "assert";
3
- import { Contract, Event } from "ethers";
3
+ import { Contract } from "ethers";
4
4
  import winston from "winston";
5
5
  import { isError } from "../../typeguards";
6
6
  import {
@@ -14,7 +14,6 @@ import {
14
14
  paginatedEventQuery,
15
15
  sortEventsAscendingInPlace,
16
16
  sortEventsDescending,
17
- spreadEvent,
18
17
  spreadEventWithBlockNumber,
19
18
  toBN,
20
19
  utf8ToHex,
@@ -25,8 +24,10 @@ import {
25
24
  DisabledChainsUpdate,
26
25
  GlobalConfigUpdate,
27
26
  LiteChainsIdListUpdate,
27
+ Log,
28
28
  ParsedTokenConfig,
29
29
  RouteRateModelUpdate,
30
+ SortableEvent,
30
31
  SpokePoolTargetBalance,
31
32
  SpokeTargetBalanceUpdate,
32
33
  TokenConfig,
@@ -41,8 +42,8 @@ type ConfigStoreUpdateSuccess = {
41
42
  chainId: number;
42
43
  searchEndBlock: number;
43
44
  events: {
44
- updatedTokenConfigEvents: Event[];
45
- updatedGlobalConfigEvents: Event[];
45
+ updatedTokenConfigEvents: Log[];
46
+ updatedGlobalConfigEvents: Log[];
46
47
  globalConfigUpdateTimes: number[];
47
48
  };
48
49
  };
@@ -430,12 +431,10 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
430
431
 
431
432
  // Save new Global config updates.
432
433
  for (let i = 0; i < updatedGlobalConfigEvents.length; i++) {
433
- const event = updatedGlobalConfigEvents[i];
434
- const args = {
435
- blockNumber: event.blockNumber,
436
- transactionIndex: event.transactionIndex,
437
- logIndex: event.logIndex,
438
- ...spreadEvent(event.args),
434
+ const args = spreadEventWithBlockNumber(updatedGlobalConfigEvents[i]) as SortableEvent & {
435
+ key: string;
436
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
437
+ value: any;
439
438
  };
440
439
 
441
440
  if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.MAX_RELAYER_REPAYMENT_LEAF_SIZE)) {
@@ -1,5 +1,5 @@
1
1
  import assert from "assert";
2
- import { Contract, Event, EventFilter } from "ethers";
2
+ import { Contract, EventFilter } from "ethers";
3
3
  import _ from "lodash";
4
4
  import winston from "winston";
5
5
  import { DEFAULT_CACHING_SAFE_LAG, DEFAULT_CACHING_TTL } from "../constants";
@@ -13,6 +13,7 @@ import {
13
13
  DisputedRootBundle,
14
14
  ExecutedRootBundle,
15
15
  L1Token,
16
+ Log,
16
17
  LpToken,
17
18
  PendingRootBundle,
18
19
  ProposedRootBundle,
@@ -38,7 +39,6 @@ import {
38
39
  paginatedEventQuery,
39
40
  shouldCache,
40
41
  sortEventsDescending,
41
- spreadEvent,
42
42
  spreadEventWithBlockNumber,
43
43
  toBN,
44
44
  getTokenInfo,
@@ -52,7 +52,7 @@ type HubPoolUpdateSuccess = {
52
52
  success: true;
53
53
  currentTime: number;
54
54
  pendingRootBundleProposal: PendingRootBundle;
55
- events: Record<string, Event[]>;
55
+ events: Record<string, Log[]>;
56
56
  searchEndBlock: number;
57
57
  };
58
58
  type HubPoolUpdateFailure = {
@@ -291,11 +291,33 @@ export class HubPoolClient extends BaseAbstractClient {
291
291
  return getL1TokenInfo(tokenAddress, chain);
292
292
  }
293
293
 
294
- getBlockNumber(timestamp: number): Promise<number | undefined> {
294
+ /**
295
+ * Resolve a given timestamp to a block number on the HubPool chain.
296
+ * @param timestamp A single timestamp to be resolved to a block number on the HubPool chain.
297
+ * @returns The block number corresponding to the supplied timestamp.
298
+ */
299
+ getBlockNumber(timestamp: number): Promise<number> {
295
300
  const hints = { lowBlock: this.deploymentBlock };
296
301
  return getCachedBlockForTimestamp(this.chainId, timestamp, this.blockFinder, this.cachingMechanism, hints);
297
302
  }
298
303
 
304
+ /**
305
+ * For an array of timestamps, resolve each unique timestamp to a block number on the HubPool chain.
306
+ * @dev Inputs are filtered for uniqueness and sorted to improve BlockFinder efficiency.
307
+ * @dev Querying block numbers sequentially also improves BlockFinder efficiency.
308
+ * @param timestamps Array of timestamps to be resolved to a block number on the HubPool chain.
309
+ * @returns A mapping of quoteTimestamp -> HubPool block number.
310
+ */
311
+ async getBlockNumbers(timestamps: number[]): Promise<{ [quoteTimestamp: number]: number }> {
312
+ const sortedTimestamps = dedupArray(timestamps).sort((x, y) => x - y);
313
+ const blockNumbers: { [quoteTimestamp: number]: number } = {};
314
+ for (const timestamp of sortedTimestamps) {
315
+ blockNumbers[timestamp] = await this.getBlockNumber(timestamp);
316
+ }
317
+
318
+ return blockNumbers;
319
+ }
320
+
299
321
  async getCurrentPoolUtilization(l1Token: string): Promise<BigNumber> {
300
322
  const blockNumber = this.latestBlockSearched ?? (await this.hubPool.provider.getBlockNumber());
301
323
  return await this.getUtilization(l1Token, blockNumber, bnZero, getCurrentTime(), 0);
@@ -400,15 +422,6 @@ export class HubPoolClient extends BaseAbstractClient {
400
422
  }
401
423
  };
402
424
 
403
- // Helper to resolve a quoteTimestamp to a HubPool block number.
404
- const resolveTimestampsToBlocks = async (quoteTimestamp: number): Promise<[number, number]> => {
405
- const quoteBlock = await this.getBlockNumber(quoteTimestamp);
406
- if (!isDefined(quoteBlock)) {
407
- throw new Error(`Could not find block for timestamp ${quoteTimestamp}`);
408
- }
409
- return [quoteTimestamp, quoteBlock];
410
- };
411
-
412
425
  // Helper to resolve existing HubPool token utilisation for an array of unique block numbers.
413
426
  // Produces a mapping of blockNumber -> utilization for a specific token.
414
427
  const resolveUtilization = async (hubPoolToken: string): Promise<Record<number, BigNumber>> => {
@@ -462,14 +475,12 @@ export class HubPoolClient extends BaseAbstractClient {
462
475
  */
463
476
  const timeToCache = this.configOverride.timeToCache ?? DEFAULT_CACHING_SAFE_LAG;
464
477
 
465
- // Identify the unique hubPoolToken & quoteTimestamp mappings. This is used to optimise subsequent HubPool queries.
466
- deposits.forEach((deposit) => resolveUniqueQuoteTimestamps(deposit));
467
-
468
478
  // Filter all deposits for unique quoteTimestamps, to be resolved to a blockNumber in parallel.
469
479
  const quoteTimestamps = dedupArray(deposits.map(({ quoteTimestamp }) => quoteTimestamp));
470
- quoteBlocks = Object.fromEntries(
471
- await mapAsync(quoteTimestamps, (quoteTimestamp) => resolveTimestampsToBlocks(quoteTimestamp))
472
- );
480
+ quoteBlocks = await this.getBlockNumbers(quoteTimestamps);
481
+
482
+ // Identify the unique hubPoolToken & quoteTimestamp mappings. This is used to optimise subsequent HubPool queries.
483
+ deposits.forEach((deposit) => resolveUniqueQuoteTimestamps(deposit));
473
484
 
474
485
  // For each token / quoteBlock pair, resolve the utilisation for each quoted block.
475
486
  // This can be reused for each deposit with the same HubPool token and quoteTimestamp pair.
@@ -890,11 +901,10 @@ export class HubPoolClient extends BaseAbstractClient {
890
901
  // only run iff a new token has been enabled. Will only append iff the info is not there already.
891
902
  // Filter out any duplicate addresses. This might happen due to enabling, disabling and re-enabling a token.
892
903
  if (eventsToQuery.includes("L1TokenEnabledForLiquidityProvision")) {
893
- const uniqueL1Tokens = [
894
- ...Array.from(
895
- new Set(events["L1TokenEnabledForLiquidityProvision"].map((event) => spreadEvent(event.args).l1Token))
896
- ),
897
- ];
904
+ const uniqueL1Tokens = dedupArray(
905
+ events["L1TokenEnabledForLiquidityProvision"].map((event) => String(event.args["l1Token"]))
906
+ );
907
+
898
908
  const [tokenInfo, lpTokenInfo] = await Promise.all([
899
909
  Promise.all(uniqueL1Tokens.map((l1Token: string) => fetchTokenInfo(l1Token, this.hubPool.provider))),
900
910
  Promise.all(
@@ -1,4 +1,4 @@
1
- import { Contract, Event, EventFilter } from "ethers";
1
+ import { Contract, EventFilter } from "ethers";
2
2
  import winston from "winston";
3
3
  import {
4
4
  AnyObject,
@@ -20,7 +20,6 @@ import {
20
20
  spreadEventWithBlockNumber,
21
21
  } from "../utils/EventUtils";
22
22
  import { validateFillForDeposit } from "../utils/FlowUtils";
23
-
24
23
  import { ZERO_ADDRESS } from "../constants";
25
24
  import {
26
25
  Deposit,
@@ -28,15 +27,13 @@ import {
28
27
  Fill,
29
28
  FillStatus,
30
29
  FillWithBlock,
31
- FilledV3RelayEvent,
32
- RealizedLpFee,
30
+ Log,
33
31
  RelayData,
34
32
  RelayerRefundExecutionWithBlock,
35
33
  RootBundleRelayWithBlock,
36
34
  SlowFillRequestWithBlock,
37
35
  SpeedUpWithBlock,
38
36
  TokensBridged,
39
- V3FundsDepositedEvent,
40
37
  } from "../interfaces";
41
38
  import { SpokePool } from "../typechain";
42
39
  import { getNetworkName } from "../utils/NetworkUtils";
@@ -51,7 +48,7 @@ type SpokePoolUpdateSuccess = {
51
48
  oldestTime: number;
52
49
  firstDepositId: number;
53
50
  latestDepositId: number;
54
- events: Event[][];
51
+ events: Log[][];
55
52
  searchEndBlock: number;
56
53
  };
57
54
  type SpokePoolUpdateFailure = {
@@ -511,7 +508,7 @@ export class SpokePoolClient extends BaseAbstractClient {
511
508
  }
512
509
 
513
510
  // Sort all events to ensure they are stored in a consistent order.
514
- events.forEach((events: Event[]) => sortEventsAscendingInPlace(events));
511
+ events.forEach((events: Log[]) => sortEventsAscendingInPlace(events));
515
512
 
516
513
  return {
517
514
  success: true,
@@ -550,24 +547,34 @@ export class SpokePoolClient extends BaseAbstractClient {
550
547
  }
551
548
 
552
549
  if (eventsToQuery.includes("V3FundsDeposited")) {
553
- const depositEvents = [
554
- ...((queryResults[eventsToQuery.indexOf("V3FundsDeposited")] ?? []) as V3FundsDepositedEvent[]),
555
- ];
550
+ const depositEvents = queryResults[eventsToQuery.indexOf("V3FundsDeposited")] ?? [];
556
551
  if (depositEvents.length > 0) {
557
552
  this.log("debug", `Using ${depositEvents.length} newly queried deposit events for chain ${this.chainId}`, {
558
553
  earliestEvent: depositEvents[0].blockNumber,
559
554
  });
560
555
  }
561
556
 
562
- const dataForQuoteTime = await this.batchComputeRealizedLpFeePct(depositEvents);
563
- for (const [index, event] of Array.from(depositEvents.entries())) {
564
- const rawDeposit = spreadEventWithBlockNumber(event);
557
+ // For each deposit, resolve its quoteTimestamp to a block number on the HubPool.
558
+ // Don't bother filtering for uniqueness; the HubPoolClient handles this efficienctly.
559
+ const quoteBlockNumbers = await this.getBlockNumbers(
560
+ depositEvents.map(({ args }) => Number(args["quoteTimestamp"]))
561
+ );
562
+ for (const event of depositEvents) {
563
+ const quoteBlockNumber = quoteBlockNumbers[Number(event.args["quoteTimestamp"])];
565
564
 
566
565
  // Derive and append the common properties that are not part of the onchain event.
567
- const { quoteBlock: quoteBlockNumber } = dataForQuoteTime[index];
568
- const deposit = { ...(rawDeposit as DepositWithBlock), originChainId: this.chainId, quoteBlockNumber };
566
+ const deposit = {
567
+ ...spreadEventWithBlockNumber(event),
568
+ quoteBlockNumber,
569
+ originChainId: this.chainId,
570
+ // The following properties are placeholders to be updated immediately.
571
+ fromLiteChain: true,
572
+ toLiteChain: true,
573
+ } as DepositWithBlock;
574
+
569
575
  deposit.fromLiteChain = this.isOriginLiteChain(deposit);
570
576
  deposit.toLiteChain = this.isDestinationLiteChain(deposit);
577
+
571
578
  if (deposit.outputToken === ZERO_ADDRESS) {
572
579
  deposit.outputToken = this.getDestinationTokenForDeposit(deposit);
573
580
  }
@@ -586,16 +593,12 @@ export class SpokePoolClient extends BaseAbstractClient {
586
593
  }
587
594
  }
588
595
 
589
- // TODO: When validating fills with deposits for the purposes of UBA flows, do we need to consider
590
- // speed ups as well? For example, do we need to also consider that the speed up is before the fill
591
- // timestamp to be applied for the fill? My brain hurts.
592
596
  // Update deposits with speed up requests from depositor.
593
597
  if (eventsToQuery.includes("RequestedSpeedUpV3Deposit")) {
594
- const speedUpEvents = [...(queryResults[eventsToQuery.indexOf("RequestedSpeedUpV3Deposit")] ?? [])];
598
+ const speedUpEvents = queryResults[eventsToQuery.indexOf("RequestedSpeedUpV3Deposit")] ?? [];
595
599
 
596
600
  for (const event of speedUpEvents) {
597
- const rawEvent = spreadEventWithBlockNumber(event);
598
- const speedUp = { ...rawEvent, originChainId: this.chainId } as SpeedUpWithBlock;
601
+ const speedUp = { ...spreadEventWithBlockNumber(event), originChainId: this.chainId } as SpeedUpWithBlock;
599
602
  assign(this.speedUps, [speedUp.depositor, speedUp.depositId], [speedUp]);
600
603
 
601
604
  // Find deposit hash matching this speed up event and update the deposit data associated with the hash,
@@ -614,10 +617,11 @@ export class SpokePoolClient extends BaseAbstractClient {
614
617
  if (eventsToQuery.includes("RequestedV3SlowFill")) {
615
618
  const slowFillRequests = queryResults[eventsToQuery.indexOf("RequestedV3SlowFill")];
616
619
  for (const event of slowFillRequests) {
617
- const slowFillRequest: SlowFillRequestWithBlock = {
618
- ...(spreadEventWithBlockNumber(event) as SlowFillRequestWithBlock),
620
+ const slowFillRequest = {
621
+ ...spreadEventWithBlockNumber(event),
619
622
  destinationChainId: this.chainId,
620
- };
623
+ } as SlowFillRequestWithBlock;
624
+
621
625
  const relayDataHash = getRelayDataHash(slowFillRequest, this.chainId);
622
626
  if (this.slowFillRequests[relayDataHash] !== undefined) {
623
627
  continue;
@@ -627,7 +631,7 @@ export class SpokePoolClient extends BaseAbstractClient {
627
631
  }
628
632
 
629
633
  if (eventsToQuery.includes("FilledV3Relay")) {
630
- const fillEvents = [...((queryResults[eventsToQuery.indexOf("FilledV3Relay")] ?? []) as FilledV3RelayEvent[])];
634
+ const fillEvents = queryResults[eventsToQuery.indexOf("FilledV3Relay")] ?? [];
631
635
 
632
636
  if (fillEvents.length > 0) {
633
637
  this.log("debug", `Using ${fillEvents.length} newly queried fill events for chain ${this.chainId}`, {
@@ -639,9 +643,9 @@ export class SpokePoolClient extends BaseAbstractClient {
639
643
  // test that the types are complete. A broader change in strategy for safely unpacking events will be introduced.
640
644
  for (const event of fillEvents) {
641
645
  const fill = {
642
- ...(spreadEventWithBlockNumber(event) as FillWithBlock),
646
+ ...spreadEventWithBlockNumber(event),
643
647
  destinationChainId: this.chainId,
644
- };
648
+ } as FillWithBlock;
645
649
 
646
650
  assign(this.fills, [fill.originChainId], [fill]);
647
651
  assign(this.depositHashesToFills, [this.getDepositHash(fill)], [fill]);
@@ -719,46 +723,24 @@ export class SpokePoolClient extends BaseAbstractClient {
719
723
  }
720
724
 
721
725
  /**
722
- * Computes the realized LP fee percentage for a given deposit.
723
- * @param depositEvent The deposit event to compute the realized LP fee percentage for.
724
- * @returns The realized LP fee percentage.
726
+ * Resolve a given timestamp to a block number on the HubPool chain via the HubPoolClient.
727
+ * @param timestamp A single timestamp to be resolved via the HubPoolClient.
728
+ * @returns The block number on the HubPool chain corresponding to the supplied timestamp.
725
729
  */
726
- protected async computeRealizedLpFeePct(depositEvent: V3FundsDepositedEvent): Promise<RealizedLpFee> {
727
- const [lpFee] = await this.batchComputeRealizedLpFeePct([depositEvent]);
728
- return lpFee;
730
+ protected getBlockNumber(timestamp: number): Promise<number> {
731
+ return this.hubPoolClient?.getBlockNumber(timestamp) ?? Promise.resolve(MAX_BIG_INT.toNumber());
729
732
  }
730
733
 
731
734
  /**
732
- * Computes the realized LP fee percentage for a batch of deposits.
733
- * @dev Computing in batch opens up for efficiencies, e.g. in quoteTimestamp -> blockNumber resolution.
734
- * @param depositEvents The array of deposit events to compute the realized LP fee percentage for.
735
- * @returns The array of realized LP fee percentages and associated HubPool block numbers.
735
+ * For an array of timestamps, resolve each timestamp to a block number on the HubPool chain via the HubPoolClient.
736
+ * @param timestamps Array of timestamps to be resolved to a block number via the HubPoolClient.
737
+ * @returns A mapping of quoteTimestamp -> HubPool block number.
736
738
  */
737
- protected async batchComputeRealizedLpFeePct(depositEvents: V3FundsDepositedEvent[]): Promise<RealizedLpFee[]> {
738
- // If no hub pool client, we're using this for testing. Set quote block very high so that if it's ever
739
- // used to look up a configuration for a block, it will always match with the latest configuration.
740
- if (this.hubPoolClient === null) {
741
- const realizedLpFeePct = bnZero;
742
- const quoteBlock = MAX_BIG_INT.toNumber();
743
- return depositEvents.map(() => {
744
- return { realizedLpFeePct, quoteBlock };
745
- });
746
- }
747
-
748
- const deposits = depositEvents.map(({ args }) => {
749
- // For v3 deposits, leave payment chain ID undefined so we don't compute lp fee since we don't have the
750
- // payment chain ID until we match this deposit with a fill.
751
- const { inputToken, inputAmount, quoteTimestamp } = args;
752
- return {
753
- inputToken,
754
- inputAmount,
755
- originChainId: this.chainId,
756
- paymentChainId: undefined,
757
- quoteTimestamp,
758
- };
759
- });
760
-
761
- return deposits.length > 0 ? await this.hubPoolClient.batchComputeRealizedLpFeePct(deposits) : [];
739
+ protected getBlockNumbers(timestamps: number[]): Promise<{ [quoteTimestamp: number]: number }> {
740
+ return (
741
+ this.hubPoolClient?.getBlockNumbers(timestamps) ??
742
+ Promise.resolve(Object.fromEntries(timestamps.map((timestamp) => [timestamp, MAX_BIG_INT.toNumber()])))
743
+ );
762
744
  }
763
745
 
764
746
  /**
@@ -829,7 +811,7 @@ export class SpokePoolClient extends BaseAbstractClient {
829
811
  );
830
812
  const tStop = Date.now();
831
813
 
832
- const event = (query as V3FundsDepositedEvent[]).find((deposit) => deposit.args.depositId === depositId);
814
+ const event = query.find(({ args }) => args["depositId"] === depositId);
833
815
  if (event === undefined) {
834
816
  const srcChain = getNetworkName(this.chainId);
835
817
  const dstChain = getNetworkName(destinationChainId);
@@ -838,19 +820,18 @@ export class SpokePoolClient extends BaseAbstractClient {
838
820
  ` between ${srcChain} blocks [${searchBounds.low}, ${searchBounds.high}]`
839
821
  );
840
822
  }
841
- const partialDeposit = spreadEventWithBlockNumber(event) as DepositWithBlock;
842
- const { quoteBlock: quoteBlockNumber } = await this.computeRealizedLpFeePct(event);
843
823
 
844
- // Append destination token and realized lp fee to deposit.
845
- const deposit: DepositWithBlock = {
846
- ...partialDeposit,
824
+ const deposit = {
825
+ ...spreadEventWithBlockNumber(event),
847
826
  originChainId: this.chainId,
848
- quoteBlockNumber,
849
- outputToken:
850
- partialDeposit.outputToken === ZERO_ADDRESS
851
- ? this.getDestinationTokenForDeposit({ ...partialDeposit, originChainId: this.chainId })
852
- : partialDeposit.outputToken,
853
- };
827
+ quoteBlockNumber: await this.getBlockNumber(Number(event.args["quoteTimestamp"])),
828
+ fromLiteChain: true, // To be updated immediately afterwards.
829
+ toLiteChain: true, // To be updated immediately afterwards.
830
+ } as DepositWithBlock;
831
+
832
+ if (deposit.outputToken === ZERO_ADDRESS) {
833
+ deposit.outputToken = this.getDestinationTokenForDeposit(deposit);
834
+ }
854
835
  deposit.fromLiteChain = this.isOriginLiteChain(deposit);
855
836
  deposit.toLiteChain = this.isDestinationLiteChain(deposit);
856
837