@across-protocol/sdk 4.3.57 → 4.3.59-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +39 -39
  2. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  3. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +6 -4
  4. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  5. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +5 -0
  6. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  7. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts +1 -1
  8. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +4 -3
  9. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
  10. package/dist/cjs/clients/HubPoolClient.d.ts +3 -9
  11. package/dist/cjs/clients/HubPoolClient.js +44 -68
  12. package/dist/cjs/clients/HubPoolClient.js.map +1 -1
  13. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +1 -0
  14. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +48 -30
  15. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  16. package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js +7 -2
  17. package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
  18. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +4 -3
  19. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  20. package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +2 -2
  21. package/dist/cjs/clients/mocks/MockHubPoolClient.js +1 -1
  22. package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
  23. package/dist/cjs/interfaces/SpokePool.d.ts +5 -0
  24. package/dist/cjs/utils/SpokeUtils.d.ts +5 -1
  25. package/dist/cjs/utils/SpokeUtils.js +67 -0
  26. package/dist/cjs/utils/SpokeUtils.js.map +1 -1
  27. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +40 -40
  28. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  29. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +6 -4
  30. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  31. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +6 -1
  32. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  33. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts +1 -1
  34. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +3 -2
  35. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
  36. package/dist/esm/clients/HubPoolClient.d.ts +3 -9
  37. package/dist/esm/clients/HubPoolClient.js +48 -74
  38. package/dist/esm/clients/HubPoolClient.js.map +1 -1
  39. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +1 -0
  40. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +48 -30
  41. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  42. package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js +7 -2
  43. package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
  44. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +4 -3
  45. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  46. package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +2 -2
  47. package/dist/esm/clients/mocks/MockHubPoolClient.js +1 -1
  48. package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
  49. package/dist/esm/interfaces/SpokePool.d.ts +5 -0
  50. package/dist/esm/utils/SpokeUtils.d.ts +5 -1
  51. package/dist/esm/utils/SpokeUtils.js +72 -3
  52. package/dist/esm/utils/SpokeUtils.js.map +1 -1
  53. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  54. package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
  55. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
  56. package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts +1 -1
  57. package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts.map +1 -1
  58. package/dist/types/clients/HubPoolClient.d.ts +3 -9
  59. package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
  60. package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +1 -0
  61. package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
  62. package/dist/types/clients/SpokePoolClient/SVMSpokePoolClient.d.ts.map +1 -1
  63. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
  64. package/dist/types/clients/mocks/MockHubPoolClient.d.ts +2 -2
  65. package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
  66. package/dist/types/interfaces/SpokePool.d.ts +5 -0
  67. package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
  68. package/dist/types/utils/SpokeUtils.d.ts +5 -1
  69. package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
  70. package/package.json +2 -2
  71. package/src/clients/BundleDataClient/BundleDataClient.ts +12 -10
  72. package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +13 -20
  73. package/src/clients/BundleDataClient/utils/FillUtils.ts +7 -1
  74. package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +8 -2
  75. package/src/clients/HubPoolClient.ts +49 -80
  76. package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +54 -39
  77. package/src/clients/SpokePoolClient/SVMSpokePoolClient.ts +5 -0
  78. package/src/clients/SpokePoolClient/SpokePoolClient.ts +15 -11
  79. package/src/clients/mocks/MockHubPoolClient.ts +3 -3
  80. package/src/interfaces/SpokePool.ts +6 -0
  81. package/src/utils/SpokeUtils.ts +63 -2
@@ -6,6 +6,7 @@ import {
6
6
  Fill,
7
7
  FillWithBlock,
8
8
  FillType,
9
+ InvalidFill,
9
10
  RelayData,
10
11
  RelayExecutionEventInfo,
11
12
  SlowFillLeaf,
@@ -13,9 +14,10 @@ import {
13
14
  } from "../interfaces";
14
15
  import { svm } from "../arch";
15
16
  import { BigNumber } from "./BigNumberUtils";
16
- import { isMessageEmpty } from "./DepositUtils";
17
- import { chainIsSvm } from "./NetworkUtils";
17
+ import { isMessageEmpty, validateFillForDeposit } from "./DepositUtils";
18
+ import { chainIsSvm, getNetworkName } from "./NetworkUtils";
18
19
  import { toAddressType } from "./AddressUtils";
20
+ import { SpokePoolClient } from "../clients";
19
21
 
20
22
  export function isSlowFill(fill: Fill): boolean {
21
23
  return fill.relayExecutionInfo.fillType === FillType.SlowFill;
@@ -171,3 +173,62 @@ export function isUnsafeDepositId(depositId: BigNumber): boolean {
171
173
  export function getMessageHash(message: string): string {
172
174
  return isMessageEmpty(message) ? ZERO_BYTES : keccak256(message as Hex);
173
175
  }
176
+
177
+ export async function findInvalidFills(spokePoolClients: {
178
+ [chainId: number]: SpokePoolClient;
179
+ }): Promise<InvalidFill[]> {
180
+ const invalidFills: InvalidFill[] = [];
181
+
182
+ // Iterate through each spoke pool client
183
+ for (const spokePoolClient of Object.values(spokePoolClients)) {
184
+ // Get all fills for this client
185
+ const fills = spokePoolClient.getFills();
186
+
187
+ // Process fills in parallel for this client
188
+ const fillDepositPairs = await Promise.all(
189
+ fills.map(async (fill) => {
190
+ // Skip fills with unsafe deposit IDs
191
+ if (isUnsafeDepositId(fill.depositId)) {
192
+ return null; // Return null for unsafe deposits
193
+ }
194
+
195
+ // Get all deposits (including duplicates) for this fill's depositId, both in memory and on-chain
196
+ const depositResult = await spokePoolClients[fill.originChainId]?.findDeposit(fill.depositId);
197
+
198
+ // If no deposits found at all
199
+ if (!depositResult?.found) {
200
+ return {
201
+ fill,
202
+ deposit: null,
203
+ reason: `No ${getNetworkName(fill.originChainId)} deposit with depositId ${fill.depositId} found`,
204
+ };
205
+ }
206
+
207
+ // Check if fill is valid for deposit
208
+ const validationResult = validateFillForDeposit(fill, depositResult.deposit);
209
+ if (!validationResult.valid) {
210
+ return {
211
+ fill,
212
+ deposit: depositResult.deposit,
213
+ reason: validationResult.reason,
214
+ };
215
+ }
216
+
217
+ // Valid fill with deposit - return null to filter out
218
+ return null;
219
+ })
220
+ );
221
+
222
+ for (const pair of fillDepositPairs) {
223
+ if (pair) {
224
+ invalidFills.push({
225
+ fill: pair.fill,
226
+ reason: pair.reason,
227
+ deposit: pair.deposit || undefined,
228
+ });
229
+ }
230
+ }
231
+ }
232
+
233
+ return invalidFills;
234
+ }