@across-protocol/sdk 4.1.10-beta.0 → 4.1.10
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.
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +0 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +77 -79
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/HubPoolClient.d.ts +2 -2
- package/dist/cjs/clients/HubPoolClient.js +2 -6
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient.d.ts +1 -3
- package/dist/cjs/clients/SpokePoolClient.js +20 -15
- package/dist/cjs/clients/SpokePoolClient.js.map +1 -1
- package/dist/cjs/interfaces/HubPool.d.ts +1 -4
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +3 -2
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/utils/CachingUtils.js +3 -3
- package/dist/cjs/utils/CachingUtils.js.map +1 -1
- package/dist/cjs/utils/LogUtils.d.ts +0 -1
- package/dist/cjs/utils/LogUtils.js +1 -7
- package/dist/cjs/utils/LogUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +0 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +70 -73
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +2 -2
- package/dist/esm/clients/HubPoolClient.js +2 -6
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient.d.ts +3 -5
- package/dist/esm/clients/SpokePoolClient.js +23 -18
- package/dist/esm/clients/SpokePoolClient.js.map +1 -1
- package/dist/esm/interfaces/HubPool.d.ts +1 -4
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +2 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/utils/CachingUtils.js +1 -1
- package/dist/esm/utils/CachingUtils.js.map +1 -1
- package/dist/esm/utils/LogUtils.d.ts +0 -7
- package/dist/esm/utils/LogUtils.js +0 -11
- package/dist/esm/utils/LogUtils.js.map +1 -1
- package/dist/esm/utils/abi/typechain/Multicall3.d.ts +4 -1
- package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.js.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +0 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/HubPoolClient.d.ts +2 -2
- package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient.d.ts +3 -5
- package/dist/types/clients/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/interfaces/HubPool.d.ts +1 -4
- package/dist/types/interfaces/HubPool.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/utils/LogUtils.d.ts +0 -7
- package/dist/types/utils/LogUtils.d.ts.map +1 -1
- package/dist/types/utils/abi/typechain/Multicall3.d.ts +4 -1
- package/dist/types/utils/abi/typechain/Multicall3.d.ts.map +1 -1
- package/dist/types/utils/abi/typechain/common.d.ts.map +1 -1
- package/dist/types/utils/abi/typechain/factories/Multicall3__factory.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/clients/BundleDataClient/BundleDataClient.ts +104 -107
- package/src/clients/HubPoolClient.ts +12 -9
- package/src/clients/SpokePoolClient.ts +11 -16
- package/src/interfaces/HubPool.ts +1 -4
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +1 -1
- package/src/utils/CachingUtils.ts +1 -1
- package/src/utils/LogUtils.ts +0 -12
|
@@ -776,15 +776,19 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
776
776
|
return endBlock > 0 ? endBlock + 1 : 0;
|
|
777
777
|
}
|
|
778
778
|
|
|
779
|
-
getLatestExecutedRootBundleContainingL1Token(
|
|
779
|
+
getLatestExecutedRootBundleContainingL1Token(
|
|
780
|
+
block: number,
|
|
781
|
+
chain: number,
|
|
782
|
+
l1Token: string
|
|
783
|
+
): ExecutedRootBundle | undefined {
|
|
780
784
|
// Search ExecutedRootBundles in descending block order to find the most recent event before the target block.
|
|
781
785
|
return sortEventsDescending(this.executedRootBundles).find((executedLeaf: ExecutedRootBundle) => {
|
|
782
786
|
return (
|
|
783
787
|
executedLeaf.blockNumber <= block &&
|
|
784
788
|
executedLeaf.chainId === chain &&
|
|
785
|
-
executedLeaf.l1Tokens.
|
|
789
|
+
executedLeaf.l1Tokens.some((token) => token.toLowerCase() === l1Token.toLowerCase())
|
|
786
790
|
);
|
|
787
|
-
})
|
|
791
|
+
});
|
|
788
792
|
}
|
|
789
793
|
|
|
790
794
|
getRunningBalanceBeforeBlockForChain(block: number, chain: number, l1Token: string): TokenRunningBalance {
|
|
@@ -793,18 +797,19 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
793
797
|
return this.getRunningBalanceForToken(l1Token, executedRootBundle);
|
|
794
798
|
}
|
|
795
799
|
|
|
796
|
-
public getRunningBalanceForToken(
|
|
800
|
+
public getRunningBalanceForToken(
|
|
801
|
+
l1Token: string,
|
|
802
|
+
executedRootBundle: ExecutedRootBundle | undefined
|
|
803
|
+
): TokenRunningBalance {
|
|
797
804
|
let runningBalance = toBN(0);
|
|
798
|
-
let incentiveBalance = toBN(0);
|
|
799
805
|
if (executedRootBundle) {
|
|
800
806
|
const indexOfL1Token = executedRootBundle.l1Tokens
|
|
801
807
|
.map((l1Token) => l1Token.toLowerCase())
|
|
802
808
|
.indexOf(l1Token.toLowerCase());
|
|
803
809
|
runningBalance = executedRootBundle.runningBalances[indexOfL1Token];
|
|
804
|
-
incentiveBalance = executedRootBundle.incentiveBalances[indexOfL1Token];
|
|
805
810
|
}
|
|
806
811
|
|
|
807
|
-
return { runningBalance
|
|
812
|
+
return { runningBalance };
|
|
808
813
|
}
|
|
809
814
|
|
|
810
815
|
async _update(eventNames: HubPoolEvent[]): Promise<HubPoolUpdate> {
|
|
@@ -1009,8 +1014,6 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
1009
1014
|
);
|
|
1010
1015
|
}
|
|
1011
1016
|
executedRootBundle.runningBalances = runningBalances.slice(0, nTokens);
|
|
1012
|
-
executedRootBundle.incentiveBalances =
|
|
1013
|
-
runningBalances.length > nTokens ? runningBalances.slice(nTokens) : runningBalances.map(() => toBN(0));
|
|
1014
1017
|
this.executedRootBundles.push(executedRootBundle);
|
|
1015
1018
|
}
|
|
1016
1019
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import assert from "assert";
|
|
1
2
|
import { Contract, EventFilter } from "ethers";
|
|
2
3
|
import winston from "winston";
|
|
3
4
|
import {
|
|
4
5
|
AnyObject,
|
|
5
6
|
BigNumber,
|
|
6
7
|
bnZero,
|
|
8
|
+
bnUint32Max,
|
|
7
9
|
DefaultLogLevels,
|
|
8
10
|
EventSearchConfig,
|
|
9
11
|
MAX_BIG_INT,
|
|
@@ -54,7 +56,6 @@ import { getRepaymentChainId, forceDestinationRepayment } from "./BundleDataClie
|
|
|
54
56
|
type SpokePoolUpdateSuccess = {
|
|
55
57
|
success: true;
|
|
56
58
|
currentTime: number;
|
|
57
|
-
oldestTime: number;
|
|
58
59
|
firstDepositId: BigNumber;
|
|
59
60
|
latestDepositId: BigNumber;
|
|
60
61
|
events: Log[][];
|
|
@@ -72,7 +73,6 @@ export type SpokePoolUpdate = SpokePoolUpdateSuccess | SpokePoolUpdateFailure;
|
|
|
72
73
|
*/
|
|
73
74
|
export class SpokePoolClient extends BaseAbstractClient {
|
|
74
75
|
protected currentTime = 0;
|
|
75
|
-
protected oldestTime = 0;
|
|
76
76
|
protected depositHashes: { [depositHash: string]: DepositWithBlock } = {};
|
|
77
77
|
protected duplicateDepositHashes: { [depositHash: string]: DepositWithBlock[] } = {};
|
|
78
78
|
protected depositHashesToFills: { [depositHash: string]: FillWithBlock[] } = {};
|
|
@@ -543,12 +543,11 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
543
543
|
|
|
544
544
|
const timerStart = Date.now();
|
|
545
545
|
const multicallFunctions = ["getCurrentTime", "numberOfDeposits"];
|
|
546
|
-
const [multicallOutput,
|
|
546
|
+
const [multicallOutput, ...events] = await Promise.all([
|
|
547
547
|
spokePool.callStatic.multicall(
|
|
548
548
|
multicallFunctions.map((f) => spokePool.interface.encodeFunctionData(f)),
|
|
549
549
|
{ blockTag: searchConfig.toBlock }
|
|
550
550
|
),
|
|
551
|
-
this.spokePool.getCurrentTime({ blockTag: Math.max(searchConfig.fromBlock, this.deploymentBlock) }),
|
|
552
551
|
...eventSearchConfigs.map((config) => paginatedEventQuery(this.spokePool, config.filter, config.searchConfig)),
|
|
553
552
|
]);
|
|
554
553
|
this.log("debug", `Time to query new events from RPC for ${this.chainId}: ${Date.now() - timerStart} ms`);
|
|
@@ -571,7 +570,6 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
571
570
|
return {
|
|
572
571
|
success: true,
|
|
573
572
|
currentTime: currentTime.toNumber(), // uint32
|
|
574
|
-
oldestTime: oldestTime.toNumber(),
|
|
575
573
|
firstDepositId,
|
|
576
574
|
latestDepositId: _latestDepositId.gt(bnZero) ? _latestDepositId : bnZero,
|
|
577
575
|
searchEndBlock: searchConfig.toBlock,
|
|
@@ -597,7 +595,7 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
597
595
|
if (!update.success) {
|
|
598
596
|
return;
|
|
599
597
|
}
|
|
600
|
-
const { events: queryResults, currentTime,
|
|
598
|
+
const { events: queryResults, currentTime, searchEndBlock } = update;
|
|
601
599
|
|
|
602
600
|
if (eventsToQuery.includes("TokensBridged")) {
|
|
603
601
|
// Temporarily query old spoke pool events as well to ease migration:
|
|
@@ -660,11 +658,7 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
660
658
|
if (this.depositHashes[getRelayEventKey(deposit)] !== undefined) {
|
|
661
659
|
// Sanity check that this event is not a duplicate, even though the relay data hash is a duplicate.
|
|
662
660
|
const allDeposits = this._getDuplicateDeposits(deposit).concat(this.depositHashes[getRelayEventKey(deposit)]);
|
|
663
|
-
if (
|
|
664
|
-
allDeposits.some((e) => {
|
|
665
|
-
return duplicateEvent(deposit, e);
|
|
666
|
-
})
|
|
667
|
-
) {
|
|
661
|
+
if (allDeposits.some((e) => duplicateEvent(deposit, e))) {
|
|
668
662
|
duplicateEvents.push(event);
|
|
669
663
|
continue;
|
|
670
664
|
}
|
|
@@ -830,7 +824,6 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
830
824
|
|
|
831
825
|
// Next iteration should start off from where this one ended.
|
|
832
826
|
this.currentTime = currentTime;
|
|
833
|
-
if (this.oldestTime === 0) this.oldestTime = oldestTime; // Set oldest time only after the first update.
|
|
834
827
|
this.firstDepositIdForSpokePool = update.firstDepositId;
|
|
835
828
|
this.latestBlockSearched = searchEndBlock;
|
|
836
829
|
this.lastDepositIdForSpokePool = update.latestDepositId;
|
|
@@ -920,11 +913,13 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
920
913
|
}
|
|
921
914
|
|
|
922
915
|
/**
|
|
923
|
-
* Retrieves the
|
|
924
|
-
* @returns The
|
|
916
|
+
* Retrieves the time from the SpokePool contract at a particular block.
|
|
917
|
+
* @returns The time at the specified block tag.
|
|
925
918
|
*/
|
|
926
|
-
public
|
|
927
|
-
|
|
919
|
+
public async getTimeAt(blockNumber: number): Promise<number> {
|
|
920
|
+
const currentTime = await this.spokePool.getCurrentTime({ blockTag: blockNumber });
|
|
921
|
+
assert(BigNumber.isBigNumber(currentTime) && currentTime.lt(bnUint32Max));
|
|
922
|
+
return currentTime.toNumber();
|
|
928
923
|
}
|
|
929
924
|
|
|
930
925
|
async findDeposit(depositId: BigNumber, destinationChainId: number): Promise<DepositWithBlock> {
|
|
@@ -54,7 +54,6 @@ export interface ExecutedRootBundle extends SortableEvent {
|
|
|
54
54
|
bundleLpFees: BigNumber[];
|
|
55
55
|
netSendAmounts: BigNumber[];
|
|
56
56
|
runningBalances: BigNumber[];
|
|
57
|
-
incentiveBalances: BigNumber[];
|
|
58
57
|
leafId: number;
|
|
59
58
|
l1Tokens: string[];
|
|
60
59
|
proof: string[];
|
|
@@ -62,17 +61,15 @@ export interface ExecutedRootBundle extends SortableEvent {
|
|
|
62
61
|
|
|
63
62
|
export type ExecutedRootBundleStringified = Omit<
|
|
64
63
|
ExecutedRootBundle,
|
|
65
|
-
"bundleLpFees" | "netSendAmounts" | "runningBalances"
|
|
64
|
+
"bundleLpFees" | "netSendAmounts" | "runningBalances"
|
|
66
65
|
> & {
|
|
67
66
|
bundleLpFees: string[];
|
|
68
67
|
netSendAmounts: string[];
|
|
69
68
|
runningBalances: string[];
|
|
70
|
-
incentiveBalances: string[];
|
|
71
69
|
};
|
|
72
70
|
|
|
73
71
|
export type TokenRunningBalance = {
|
|
74
72
|
runningBalance: BigNumber;
|
|
75
|
-
incentiveBalance: BigNumber;
|
|
76
73
|
};
|
|
77
74
|
|
|
78
75
|
export interface RelayerRefundLeafWithGroup extends RelayerRefundLeaf {
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
BigNumber,
|
|
14
14
|
toBNWei,
|
|
15
15
|
bnZero,
|
|
16
|
-
assert,
|
|
17
16
|
chainIsOPStack,
|
|
18
17
|
fixedPointAdjustment,
|
|
19
18
|
} from "../../utils";
|
|
19
|
+
import assert from "assert";
|
|
20
20
|
import { Logger, QueryInterface } from "../relayFeeCalculator";
|
|
21
21
|
import { Transport } from "viem";
|
|
22
22
|
import { getGasPriceEstimate } from "../../gasPriceOracle/oracle";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_CACHING_SAFE_LAG, DEFAULT_CACHING_TTL } from "../constants";
|
|
2
2
|
import { CachingMechanismInterface, Deposit, Fill, SlowFillRequest } from "../interfaces";
|
|
3
|
-
import
|
|
3
|
+
import assert from "assert";
|
|
4
4
|
import { composeRevivers, objectWithBigNumberReviver } from "./ReviverUtils";
|
|
5
5
|
import { getRelayEventKey } from "./SpokeUtils";
|
|
6
6
|
import { getCurrentTime } from "./TimeUtils";
|
package/src/utils/LogUtils.ts
CHANGED
|
@@ -24,15 +24,3 @@ export function formattedLog(
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Asserts the truth of a condition. If the condition is false, an error is thrown with the provided message.
|
|
30
|
-
* @param condition The condition to assert.
|
|
31
|
-
* @param message The message to throw if the condition is false.
|
|
32
|
-
* @throws Error if the condition is false.
|
|
33
|
-
*/
|
|
34
|
-
export function assert(condition: boolean, message: string): void {
|
|
35
|
-
if (!condition) {
|
|
36
|
-
throw new Error(message);
|
|
37
|
-
}
|
|
38
|
-
}
|