@across-protocol/sdk 4.2.16-alpha.6 → 4.2.16
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/arch/evm/SpokeUtils.d.ts +3 -8
- package/dist/cjs/arch/evm/SpokeUtils.js +11 -26
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.d.ts +2 -8
- package/dist/cjs/arch/svm/SpokeUtils.js +50 -41
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/eventsClient.js +2 -4
- package/dist/cjs/arch/svm/eventsClient.js.map +1 -1
- package/dist/cjs/arch/svm/utils.d.ts +3 -3
- package/dist/cjs/arch/svm/utils.js +14 -16
- package/dist/cjs/arch/svm/utils.js.map +1 -1
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +2 -4
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +6 -7
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +83 -78
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +13 -13
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +1 -2
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +2 -3
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +1 -5
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +3 -3
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +71 -71
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +8 -13
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/cjs/clients/HubPoolClient.d.ts +21 -21
- package/dist/cjs/clients/HubPoolClient.js +58 -84
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +45 -65
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClientManager.d.ts +13 -0
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClientManager.js +18 -0
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClientManager.js.map +1 -0
- package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +9 -15
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +3 -5
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +36 -40
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js +4 -6
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +2 -2
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/cjs/interfaces/HubPool.d.ts +14 -19
- package/dist/cjs/interfaces/SpokePool.d.ts +19 -18
- package/dist/cjs/interfaces/SpokePool.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +7 -15
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +15 -24
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +4 -12
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +44 -46
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +6 -6
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +10 -10
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +8 -12
- package/dist/cjs/utils/AddressUtils.js +36 -33
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/NetworkUtils.js +1 -1
- package/dist/cjs/utils/NetworkUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.d.ts +3 -3
- package/dist/cjs/utils/SpokeUtils.js +22 -4
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.d.ts +4 -4
- package/dist/cjs/utils/TokenUtils.js +3 -5
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.d.ts +4 -9
- package/dist/esm/arch/evm/SpokeUtils.js +14 -29
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.d.ts +3 -9
- package/dist/esm/arch/svm/SpokeUtils.js +55 -42
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/eventsClient.js +3 -5
- package/dist/esm/arch/svm/eventsClient.js.map +1 -1
- package/dist/esm/arch/svm/utils.d.ts +3 -3
- package/dist/esm/arch/svm/utils.js +15 -17
- package/dist/esm/arch/svm/utils.js.map +1 -1
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +2 -4
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +6 -7
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +84 -79
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +14 -14
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +1 -2
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +3 -5
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +1 -5
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +4 -4
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +71 -71
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +10 -20
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +22 -23
- package/dist/esm/clients/HubPoolClient.js +63 -98
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +47 -68
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClientManager.d.ts +28 -0
- package/dist/esm/clients/SpokePoolClient/SpokePoolClientManager.js +30 -0
- package/dist/esm/clients/SpokePoolClient/SpokePoolClientManager.js.map +1 -0
- package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/esm/clients/mocks/MockHubPoolClient.js +10 -16
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +3 -5
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +38 -42
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js +5 -7
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +3 -3
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/esm/interfaces/HubPool.d.ts +14 -19
- package/dist/esm/interfaces/SpokePool.d.ts +19 -18
- package/dist/esm/interfaces/SpokePool.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +10 -18
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +20 -29
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js +2 -2
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +6 -14
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +48 -51
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +6 -6
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +9 -9
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +8 -12
- package/dist/esm/utils/AddressUtils.js +38 -36
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/NetworkUtils.js +1 -1
- package/dist/esm/utils/NetworkUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +8 -3
- package/dist/esm/utils/SpokeUtils.js +26 -4
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.d.ts +18 -22
- package/dist/esm/utils/TokenUtils.js +4 -6
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/types/arch/evm/SpokeUtils.d.ts +4 -9
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts +3 -9
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/eventsClient.d.ts.map +1 -1
- package/dist/types/arch/svm/utils.d.ts +3 -3
- package/dist/types/arch/svm/utils.d.ts.map +1 -1
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +6 -7
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +1 -2
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/MerkleTreeUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +71 -71
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
- package/dist/types/clients/HubPoolClient.d.ts +22 -23
- package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/SpokePoolClientManager.d.ts +29 -0
- package/dist/types/clients/SpokePoolClient/SpokePoolClientManager.d.ts.map +1 -0
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +3 -5
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts.map +1 -1
- package/dist/types/interfaces/HubPool.d.ts +14 -19
- package/dist/types/interfaces/HubPool.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +19 -18
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +10 -18
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +6 -14
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +6 -6
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +8 -12
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts +8 -3
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts +18 -22
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/arch/evm/SpokeUtils.ts +22 -72
- package/src/arch/svm/SpokeUtils.ts +53 -67
- package/src/arch/svm/eventsClient.ts +8 -40
- package/src/arch/svm/utils.ts +6 -6
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +4 -7
- package/src/clients/BundleDataClient/BundleDataClient.ts +90 -77
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +13 -28
- package/src/clients/BundleDataClient/utils/FillUtils.ts +4 -10
- package/src/clients/BundleDataClient/utils/MerkleTreeUtils.ts +1 -7
- package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +4 -4
- package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +10 -22
- package/src/clients/HubPoolClient.ts +82 -127
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +0 -6
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +35 -121
- package/src/clients/SpokePoolClient/SpokePoolClientManager.ts +36 -0
- package/src/clients/mocks/MockHubPoolClient.ts +19 -24
- package/src/clients/mocks/MockSpokePoolClient.ts +27 -39
- package/src/clients/mocks/MockSvmCpiEventsClient.ts +5 -8
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +3 -12
- package/src/interfaces/HubPool.ts +14 -23
- package/src/interfaces/SpokePool.ts +19 -19
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +20 -39
- package/src/relayFeeCalculator/chain-queries/factory.ts +2 -2
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +56 -57
- package/src/relayFeeCalculator/relayFeeCalculator.ts +13 -15
- package/src/utils/AddressUtils.ts +51 -39
- package/src/utils/NetworkUtils.ts +1 -1
- package/src/utils/SpokeUtils.ts +33 -11
- package/src/utils/TokenUtils.ts +8 -10
|
@@ -5,7 +5,6 @@ import winston from "winston";
|
|
|
5
5
|
import { isError } from "../../typeguards";
|
|
6
6
|
import {
|
|
7
7
|
EventSearchConfig,
|
|
8
|
-
EvmAddress,
|
|
9
8
|
MakeOptional,
|
|
10
9
|
isArrayOf,
|
|
11
10
|
isDefined,
|
|
@@ -108,7 +107,7 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
getRateModelForBlockNumber(
|
|
111
|
-
l1Token:
|
|
110
|
+
l1Token: string,
|
|
112
111
|
originChainId: number | string,
|
|
113
112
|
destinationChainId: number | string,
|
|
114
113
|
blockNumber: number | undefined = undefined
|
|
@@ -122,9 +121,7 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
122
121
|
|
|
123
122
|
const defaultRateModelUpdate = sortEventsDescending(this.cumulativeRateModelUpdates).find(
|
|
124
123
|
(config) =>
|
|
125
|
-
config.blockNumber <= (blockNumber ?? 0) &&
|
|
126
|
-
config.l1Token === l1Token.toEvmAddress() &&
|
|
127
|
-
config.rateModel !== undefined
|
|
124
|
+
config.blockNumber <= (blockNumber ?? 0) && config.l1Token === l1Token && config.rateModel !== undefined
|
|
128
125
|
);
|
|
129
126
|
if (!defaultRateModelUpdate) {
|
|
130
127
|
throw new Error(`Could not find TokenConfig update for ${l1Token} at block ${blockNumber}`);
|
|
@@ -133,12 +130,12 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
133
130
|
}
|
|
134
131
|
|
|
135
132
|
getRouteRateModelForBlockNumber(
|
|
136
|
-
l1Token:
|
|
133
|
+
l1Token: string,
|
|
137
134
|
route: string,
|
|
138
135
|
blockNumber: number | undefined = undefined
|
|
139
136
|
): RateModel | undefined {
|
|
140
137
|
const config = (sortEventsDescending(this.cumulativeRouteRateModelUpdates) as RouteRateModelUpdate[]).find(
|
|
141
|
-
(config) => config.blockNumber <= (blockNumber ?? 0) && config.l1Token === l1Token
|
|
138
|
+
(config) => config.blockNumber <= (blockNumber ?? 0) && config.l1Token === l1Token
|
|
142
139
|
);
|
|
143
140
|
if (config?.routeRateModel[route] === undefined) {
|
|
144
141
|
return undefined;
|
|
@@ -39,9 +39,11 @@ import {
|
|
|
39
39
|
bnUint32Max,
|
|
40
40
|
isZeroValueDeposit,
|
|
41
41
|
isZeroValueFillOrSlowFillRequest,
|
|
42
|
+
chainIsEvm,
|
|
43
|
+
isValidEvmAddress,
|
|
42
44
|
duplicateEvent,
|
|
43
45
|
invalidOutputToken,
|
|
44
|
-
|
|
46
|
+
getNetworkName,
|
|
45
47
|
} from "../../utils";
|
|
46
48
|
import winston from "winston";
|
|
47
49
|
import {
|
|
@@ -57,6 +59,7 @@ import {
|
|
|
57
59
|
verifyFillRepayment,
|
|
58
60
|
} from "./utils";
|
|
59
61
|
import { isEVMSpokePoolClient, isSVMSpokePoolClient } from "../SpokePoolClient";
|
|
62
|
+
import { SpokePoolManager } from "../SpokePoolClient/SpokePoolClientManager";
|
|
60
63
|
|
|
61
64
|
// max(uint256) - 1
|
|
62
65
|
export const INFINITE_FILL_DEADLINE = bnUint32Max;
|
|
@@ -66,21 +69,22 @@ type DataCache = Record<string, Promise<LoadDataReturnValue>>;
|
|
|
66
69
|
// V3 dictionary helper functions
|
|
67
70
|
function updateExpiredDepositsV3(dict: ExpiredDepositsToRefundV3, deposit: V3DepositWithBlock): void {
|
|
68
71
|
// A deposit refund for a deposit is invalid if the depositor has a bytes32 address input for an EVM chain. It is valid otherwise.
|
|
69
|
-
if (
|
|
72
|
+
if (chainIsEvm(deposit.originChainId) && !isValidEvmAddress(deposit.depositor)) {
|
|
70
73
|
return;
|
|
71
74
|
}
|
|
72
|
-
|
|
73
75
|
const { originChainId, inputToken } = deposit;
|
|
74
|
-
dict[originChainId]
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
if (!dict?.[originChainId]?.[inputToken]) {
|
|
77
|
+
assign(dict, [originChainId, inputToken], []);
|
|
78
|
+
}
|
|
79
|
+
dict[originChainId][inputToken].push(deposit);
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
function updateBundleDepositsV3(dict: BundleDepositsV3, deposit: V3DepositWithBlock): void {
|
|
80
83
|
const { originChainId, inputToken } = deposit;
|
|
81
|
-
dict[originChainId]
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
if (!dict?.[originChainId]?.[inputToken]) {
|
|
85
|
+
assign(dict, [originChainId, inputToken], []);
|
|
86
|
+
}
|
|
87
|
+
dict[originChainId][inputToken].push(deposit);
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
function updateBundleFillsV3(
|
|
@@ -88,29 +92,29 @@ function updateBundleFillsV3(
|
|
|
88
92
|
fill: V3FillWithBlock,
|
|
89
93
|
lpFeePct: BigNumber,
|
|
90
94
|
repaymentChainId: number,
|
|
91
|
-
repaymentToken:
|
|
92
|
-
repaymentAddress:
|
|
95
|
+
repaymentToken: string,
|
|
96
|
+
repaymentAddress: string
|
|
93
97
|
): void {
|
|
94
98
|
// We shouldn't pass any unrepayable fills into this function, so we perform an extra safety check.
|
|
95
|
-
if (!fill.relayer
|
|
99
|
+
if (chainIsEvm(repaymentChainId) && !isValidEvmAddress(fill.relayer)) {
|
|
96
100
|
return;
|
|
97
101
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
102
|
+
if (!dict?.[repaymentChainId]?.[repaymentToken]) {
|
|
103
|
+
assign(dict, [repaymentChainId, repaymentToken], {
|
|
104
|
+
fills: [],
|
|
105
|
+
totalRefundAmount: bnZero,
|
|
106
|
+
realizedLpFees: bnZero,
|
|
107
|
+
refunds: {},
|
|
108
|
+
});
|
|
109
|
+
}
|
|
106
110
|
|
|
107
111
|
const bundleFill: BundleFillV3 = { ...fill, lpFeePct, relayer: repaymentAddress };
|
|
108
112
|
|
|
109
113
|
// Add all fills, slow and fast, to dictionary.
|
|
110
|
-
assign(dict, [repaymentChainId, repaymentToken
|
|
114
|
+
assign(dict, [repaymentChainId, repaymentToken, "fills"], [bundleFill]);
|
|
111
115
|
|
|
112
116
|
// All fills update the bundle LP fees.
|
|
113
|
-
const refundObj = dict[repaymentChainId][repaymentToken
|
|
117
|
+
const refundObj = dict[repaymentChainId][repaymentToken];
|
|
114
118
|
const realizedLpFee = bundleFill.inputAmount.mul(bundleFill.lpFeePct).div(fixedPointAdjustment);
|
|
115
119
|
refundObj.realizedLpFees = refundObj.realizedLpFees ? refundObj.realizedLpFees.add(realizedLpFee) : realizedLpFee;
|
|
116
120
|
|
|
@@ -124,11 +128,10 @@ function updateBundleFillsV3(
|
|
|
124
128
|
// Instantiate dictionary if it doesn't exist.
|
|
125
129
|
refundObj.refunds ??= {};
|
|
126
130
|
|
|
127
|
-
if (refundObj.refunds[bundleFill.relayer
|
|
128
|
-
refundObj.refunds[bundleFill.relayer.
|
|
129
|
-
refundObj.refunds[bundleFill.relayer.toBytes32()].add(refundAmount);
|
|
131
|
+
if (refundObj.refunds[bundleFill.relayer]) {
|
|
132
|
+
refundObj.refunds[bundleFill.relayer] = refundObj.refunds[bundleFill.relayer].add(refundAmount);
|
|
130
133
|
} else {
|
|
131
|
-
refundObj.refunds[bundleFill.relayer
|
|
134
|
+
refundObj.refunds[bundleFill.relayer] = refundAmount;
|
|
132
135
|
}
|
|
133
136
|
}
|
|
134
137
|
}
|
|
@@ -138,20 +141,21 @@ function updateBundleExcessSlowFills(
|
|
|
138
141
|
deposit: V3DepositWithBlock & { lpFeePct: BigNumber }
|
|
139
142
|
): void {
|
|
140
143
|
const { destinationChainId, outputToken } = deposit;
|
|
141
|
-
dict[destinationChainId]
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
if (!dict?.[destinationChainId]?.[outputToken]) {
|
|
145
|
+
assign(dict, [destinationChainId, outputToken], []);
|
|
146
|
+
}
|
|
147
|
+
dict[destinationChainId][outputToken].push(deposit);
|
|
144
148
|
}
|
|
145
149
|
|
|
146
150
|
function updateBundleSlowFills(dict: BundleSlowFills, deposit: V3DepositWithBlock & { lpFeePct: BigNumber }): void {
|
|
147
|
-
if (
|
|
151
|
+
if (chainIsEvm(deposit.destinationChainId) && !isValidEvmAddress(deposit.recipient)) {
|
|
148
152
|
return;
|
|
149
153
|
}
|
|
150
|
-
|
|
151
154
|
const { destinationChainId, outputToken } = deposit;
|
|
152
|
-
dict[destinationChainId]
|
|
153
|
-
|
|
154
|
-
|
|
155
|
+
if (!dict?.[destinationChainId]?.[outputToken]) {
|
|
156
|
+
assign(dict, [destinationChainId, outputToken], []);
|
|
157
|
+
}
|
|
158
|
+
dict[destinationChainId][outputToken].push(deposit);
|
|
155
159
|
}
|
|
156
160
|
|
|
157
161
|
// @notice Shared client for computing data needed to construct or validate a bundle.
|
|
@@ -160,15 +164,18 @@ export class BundleDataClient {
|
|
|
160
164
|
private arweaveDataCache: Record<string, Promise<LoadDataReturnValue | undefined>> = {};
|
|
161
165
|
|
|
162
166
|
private bundleTimestampCache: Record<string, { [chainId: number]: number[] }> = {};
|
|
167
|
+
readonly spokePoolClientManager: SpokePoolManager;
|
|
163
168
|
|
|
164
169
|
// eslint-disable-next-line no-useless-constructor
|
|
165
170
|
constructor(
|
|
166
171
|
readonly logger: winston.Logger,
|
|
167
172
|
readonly clients: Clients,
|
|
168
|
-
|
|
173
|
+
spokePoolClients: { [chainId: number]: SpokePoolClient },
|
|
169
174
|
readonly chainIdListForBundleEvaluationBlockNumbers: number[],
|
|
170
175
|
readonly blockRangeEndBlockBuffer: { [chainId: number]: number } = {}
|
|
171
|
-
) {
|
|
176
|
+
) {
|
|
177
|
+
this.spokePoolClientManager = new SpokePoolManager(logger, spokePoolClients);
|
|
178
|
+
}
|
|
172
179
|
|
|
173
180
|
// This should be called whenever it's possible that the loadData information for a block range could have changed.
|
|
174
181
|
// For instance, if the spoke or hub clients have been updated, it probably makes sense to clear this to be safe.
|
|
@@ -398,7 +405,7 @@ export class BundleDataClient {
|
|
|
398
405
|
// expiries here so we can skip some steps. We also don't need to compute LP fees as they should be small enough
|
|
399
406
|
// so as not to affect this approximate refund count.
|
|
400
407
|
const arweaveData = await this.loadArweaveData(bundleEvaluationBlockRanges);
|
|
401
|
-
if (arweaveData
|
|
408
|
+
if (!isDefined(arweaveData)) {
|
|
402
409
|
combinedRefunds = await this.getApproximateRefundsForBlockRange(chainIds, bundleEvaluationBlockRanges);
|
|
403
410
|
} else {
|
|
404
411
|
const { bundleFillsV3, expiredDepositsToRefundV3 } = arweaveData;
|
|
@@ -408,7 +415,7 @@ export class BundleDataClient {
|
|
|
408
415
|
// a reasonable assumption. This empty refund chain also matches what the alternative
|
|
409
416
|
// `getApproximateRefundsForBlockRange` would return.
|
|
410
417
|
Object.keys(combinedRefunds).forEach((chainId) => {
|
|
411
|
-
if (this.
|
|
418
|
+
if (!this.spokePoolClientManager.getClient(Number(chainId))) {
|
|
412
419
|
delete combinedRefunds[Number(chainId)];
|
|
413
420
|
}
|
|
414
421
|
});
|
|
@@ -424,7 +431,8 @@ export class BundleDataClient {
|
|
|
424
431
|
const refundsForChain: CombinedRefunds = {};
|
|
425
432
|
const bundleEndBlockForMainnet = blockRanges[0][1];
|
|
426
433
|
for (const chainId of chainIds) {
|
|
427
|
-
|
|
434
|
+
const spokePoolClient = this.spokePoolClientManager.getClient(chainId);
|
|
435
|
+
if (!isDefined(spokePoolClient)) {
|
|
428
436
|
continue;
|
|
429
437
|
}
|
|
430
438
|
const chainIndex = chainIds.indexOf(chainId);
|
|
@@ -433,7 +441,7 @@ export class BundleDataClient {
|
|
|
433
441
|
// and then query the FillStatus on-chain, but that might slow this function down too much. For now, we
|
|
434
442
|
// will live with this expected inaccuracy as it should be small. The pre-fill would have to precede the deposit
|
|
435
443
|
// by more than the caller's event lookback window which is expected to be unlikely.
|
|
436
|
-
const fillsToCount =
|
|
444
|
+
const fillsToCount = spokePoolClient.getFills().filter((fill) => {
|
|
437
445
|
if (
|
|
438
446
|
fill.blockNumber < blockRanges[chainIndex][0] ||
|
|
439
447
|
fill.blockNumber > blockRanges[chainIndex][1] ||
|
|
@@ -443,20 +451,32 @@ export class BundleDataClient {
|
|
|
443
451
|
return false;
|
|
444
452
|
}
|
|
445
453
|
|
|
454
|
+
const originSpokePoolClient = this.spokePoolClientManager.getClient(fill.originChainId);
|
|
446
455
|
// If origin spoke pool client isn't defined, we can't validate it.
|
|
447
|
-
if (
|
|
456
|
+
if (!isDefined(originSpokePoolClient)) {
|
|
448
457
|
return false;
|
|
449
458
|
}
|
|
450
|
-
const matchingDeposit =
|
|
459
|
+
const matchingDeposit = originSpokePoolClient.getDeposit(fill.depositId);
|
|
451
460
|
const hasMatchingDeposit =
|
|
452
461
|
matchingDeposit !== undefined && getRelayEventKey(fill) === getRelayEventKey(matchingDeposit);
|
|
453
462
|
return hasMatchingDeposit;
|
|
454
463
|
});
|
|
455
464
|
await forEachAsync(fillsToCount, async (_fill) => {
|
|
456
|
-
const
|
|
457
|
-
|
|
465
|
+
const originChain = getNetworkName(_fill.originChainId);
|
|
466
|
+
const originSpokePoolClient = this.spokePoolClientManager.getClient(_fill.originChainId);
|
|
467
|
+
assert(isDefined(originSpokePoolClient), `No SpokePoolClient for chain ${originChain}`);
|
|
468
|
+
const matchingDeposit = originSpokePoolClient.getDeposit(_fill.depositId);
|
|
469
|
+
assert(
|
|
470
|
+
isDefined(matchingDeposit),
|
|
471
|
+
`No ${originChain} deposit found for ${getNetworkName(_fill.destinationChainId)} fill ${_fill.depositId}`
|
|
472
|
+
);
|
|
473
|
+
|
|
474
|
+
const spokeClient = this.spokePoolClientManager.getClient(_fill.destinationChainId);
|
|
475
|
+
assert(
|
|
476
|
+
isDefined(spokeClient),
|
|
477
|
+
`SpokePoolClient for ${getNetworkName(_fill.destinationChainId)} not found for fill.`
|
|
478
|
+
);
|
|
458
479
|
|
|
459
|
-
const spokeClient = this.spokePoolClients[_fill.destinationChainId];
|
|
460
480
|
let provider;
|
|
461
481
|
if (isEVMSpokePoolClient(spokeClient)) {
|
|
462
482
|
provider = spokeClient.spokePool.provider;
|
|
@@ -487,23 +507,22 @@ export class BundleDataClient {
|
|
|
487
507
|
// worst from the relayer's perspective.
|
|
488
508
|
const { relayer, inputAmount: refundAmount } = fill;
|
|
489
509
|
refundsForChain[chainToSendRefundTo] ??= {};
|
|
490
|
-
refundsForChain[chainToSendRefundTo][repaymentToken
|
|
491
|
-
const existingRefundAmount =
|
|
492
|
-
|
|
493
|
-
refundsForChain[chainToSendRefundTo][repaymentToken.toBytes32()][relayer.toBytes32()] =
|
|
494
|
-
existingRefundAmount.add(refundAmount);
|
|
510
|
+
refundsForChain[chainToSendRefundTo][repaymentToken] ??= {};
|
|
511
|
+
const existingRefundAmount = refundsForChain[chainToSendRefundTo][repaymentToken][relayer] ?? bnZero;
|
|
512
|
+
refundsForChain[chainToSendRefundTo][repaymentToken][relayer] = existingRefundAmount.add(refundAmount);
|
|
495
513
|
});
|
|
496
514
|
}
|
|
497
515
|
return refundsForChain;
|
|
498
516
|
}
|
|
499
517
|
|
|
500
|
-
getUpcomingDepositAmount(chainId: number, l2Token:
|
|
501
|
-
|
|
518
|
+
getUpcomingDepositAmount(chainId: number, l2Token: string, latestBlockToSearch: number): BigNumber {
|
|
519
|
+
const spokePoolClient = this.spokePoolClientManager.getClient(chainId);
|
|
520
|
+
if (!isDefined(spokePoolClient)) {
|
|
502
521
|
return toBN(0);
|
|
503
522
|
}
|
|
504
|
-
return
|
|
523
|
+
return spokePoolClient
|
|
505
524
|
.getDeposits()
|
|
506
|
-
.filter((deposit) => deposit.blockNumber > latestBlockToSearch && deposit.inputToken
|
|
525
|
+
.filter((deposit) => deposit.blockNumber > latestBlockToSearch && deposit.inputToken === l2Token)
|
|
507
526
|
.reduce((acc, deposit) => {
|
|
508
527
|
return acc.add(deposit.inputAmount);
|
|
509
528
|
}, toBN(0));
|
|
@@ -529,7 +548,7 @@ export class BundleDataClient {
|
|
|
529
548
|
// should be handled gracefully and effectively cause this function to ignore refunds for the chain.
|
|
530
549
|
let widestBundleBlockRanges = getWidestPossibleExpectedBlockRange(
|
|
531
550
|
chainIds,
|
|
532
|
-
this.
|
|
551
|
+
this.spokePoolClientManager.getSpokePoolClients(),
|
|
533
552
|
getEndBlockBuffers(chainIds, this.blockRangeEndBlockBuffer),
|
|
534
553
|
this.clients,
|
|
535
554
|
this.clients.hubPoolClient.latestHeightSearched,
|
|
@@ -572,7 +591,7 @@ export class BundleDataClient {
|
|
|
572
591
|
// data is undefined and use the much faster approximation method which doesn't consider LP fees which is
|
|
573
592
|
// ok for this use case.
|
|
574
593
|
const arweaveData = await this.loadArweaveData(pendingBundleBlockRanges);
|
|
575
|
-
if (arweaveData
|
|
594
|
+
if (!isDefined(arweaveData)) {
|
|
576
595
|
combinedRefunds.push(await this.getApproximateRefundsForBlockRange(chainIds, pendingBundleBlockRanges));
|
|
577
596
|
} else {
|
|
578
597
|
const { bundleFillsV3, expiredDepositsToRefundV3 } = arweaveData;
|
|
@@ -626,18 +645,18 @@ export class BundleDataClient {
|
|
|
626
645
|
const executedRefunds: { [tokenAddress: string]: { [relayer: string]: BigNumber } } = {};
|
|
627
646
|
for (const refundLeaf of executedRefundLeaves) {
|
|
628
647
|
const tokenAddress = refundLeaf.l2TokenAddress;
|
|
629
|
-
if (executedRefunds[tokenAddress
|
|
630
|
-
executedRefunds[tokenAddress
|
|
648
|
+
if (executedRefunds[tokenAddress] === undefined) {
|
|
649
|
+
executedRefunds[tokenAddress] = {};
|
|
631
650
|
}
|
|
632
|
-
const executedTokenRefunds = executedRefunds[tokenAddress
|
|
651
|
+
const executedTokenRefunds = executedRefunds[tokenAddress];
|
|
633
652
|
|
|
634
653
|
for (let i = 0; i < refundLeaf.refundAddresses.length; i++) {
|
|
635
654
|
const relayer = refundLeaf.refundAddresses[i];
|
|
636
655
|
const refundAmount = refundLeaf.refundAmounts[i];
|
|
637
|
-
if (executedTokenRefunds[relayer
|
|
638
|
-
executedTokenRefunds[relayer
|
|
656
|
+
if (executedTokenRefunds[relayer] === undefined) {
|
|
657
|
+
executedTokenRefunds[relayer] = bnZero;
|
|
639
658
|
}
|
|
640
|
-
executedTokenRefunds[relayer
|
|
659
|
+
executedTokenRefunds[relayer] = executedTokenRefunds[relayer].add(refundAmount);
|
|
641
660
|
}
|
|
642
661
|
}
|
|
643
662
|
return executedRefunds;
|
|
@@ -650,13 +669,11 @@ export class BundleDataClient {
|
|
|
650
669
|
): CombinedRefunds {
|
|
651
670
|
for (const chainIdStr of Object.keys(allRefunds)) {
|
|
652
671
|
const chainId = Number(chainIdStr);
|
|
653
|
-
|
|
672
|
+
const spokePoolClient = this.spokePoolClientManager.getClient(chainId);
|
|
673
|
+
if (!isDefined(spokePoolClient)) {
|
|
654
674
|
continue;
|
|
655
675
|
}
|
|
656
|
-
const executedRefunds = this.getExecutedRefunds(
|
|
657
|
-
this.spokePoolClients[chainId],
|
|
658
|
-
bundleContainingRefunds.relayerRefundRoot
|
|
659
|
-
);
|
|
676
|
+
const executedRefunds = this.getExecutedRefunds(spokePoolClient, bundleContainingRefunds.relayerRefundRoot);
|
|
660
677
|
|
|
661
678
|
for (const tokenAddress of Object.keys(allRefunds[chainId])) {
|
|
662
679
|
const refunds = allRefunds[chainId][tokenAddress];
|
|
@@ -678,15 +695,15 @@ export class BundleDataClient {
|
|
|
678
695
|
return allRefunds;
|
|
679
696
|
}
|
|
680
697
|
|
|
681
|
-
getRefundsFor(bundleRefunds: CombinedRefunds, relayer:
|
|
682
|
-
if (!bundleRefunds[chainId] || !bundleRefunds[chainId][token
|
|
698
|
+
getRefundsFor(bundleRefunds: CombinedRefunds, relayer: string, chainId: number, token: string): BigNumber {
|
|
699
|
+
if (!bundleRefunds[chainId] || !bundleRefunds[chainId][token]) {
|
|
683
700
|
return BigNumber.from(0);
|
|
684
701
|
}
|
|
685
|
-
const allRefunds = bundleRefunds[chainId][token
|
|
686
|
-
return allRefunds && allRefunds[relayer
|
|
702
|
+
const allRefunds = bundleRefunds[chainId][token];
|
|
703
|
+
return allRefunds && allRefunds[relayer] ? allRefunds[relayer] : BigNumber.from(0);
|
|
687
704
|
}
|
|
688
705
|
|
|
689
|
-
getTotalRefund(refunds: CombinedRefunds[], relayer:
|
|
706
|
+
getTotalRefund(refunds: CombinedRefunds[], relayer: string, chainId: number, refundToken: string): BigNumber {
|
|
690
707
|
return refunds.reduce((totalRefund, refunds) => {
|
|
691
708
|
return totalRefund.add(this.getRefundsFor(refunds, relayer, chainId, refundToken));
|
|
692
709
|
}, bnZero);
|
|
@@ -899,11 +916,7 @@ export class BundleDataClient {
|
|
|
899
916
|
"Not using correct bundle deposit hash key"
|
|
900
917
|
);
|
|
901
918
|
if (deposit.blockNumber >= originChainBlockRange[0]) {
|
|
902
|
-
if (
|
|
903
|
-
bundleDepositsV3?.[originChainId]?.[deposit.inputToken.toBytes32()]?.find((d) =>
|
|
904
|
-
duplicateEvent(deposit, d)
|
|
905
|
-
)
|
|
906
|
-
) {
|
|
919
|
+
if (bundleDepositsV3?.[originChainId]?.[deposit.inputToken]?.find((d) => duplicateEvent(deposit, d))) {
|
|
907
920
|
this.logger.debug({
|
|
908
921
|
at: "BundleDataClient#loadData",
|
|
909
922
|
message: "Duplicate deposit detected",
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
fixedPointAdjustment,
|
|
18
18
|
count2DDictionaryValues,
|
|
19
19
|
count3DDictionaryValues,
|
|
20
|
-
toAddressType,
|
|
21
20
|
} from "../../../utils";
|
|
22
21
|
import {
|
|
23
22
|
addLastRunningBalance,
|
|
@@ -66,10 +65,10 @@ export function getRefundsFromBundle(
|
|
|
66
65
|
Object.entries(depositsForChain).forEach(([l2TokenAddress, deposits]) => {
|
|
67
66
|
deposits.forEach((deposit) => {
|
|
68
67
|
if (combinedRefunds[originChainId][l2TokenAddress] === undefined) {
|
|
69
|
-
combinedRefunds[originChainId][l2TokenAddress] = { [deposit.depositor
|
|
68
|
+
combinedRefunds[originChainId][l2TokenAddress] = { [deposit.depositor]: deposit.inputAmount };
|
|
70
69
|
} else {
|
|
71
|
-
const existingRefundAmount = combinedRefunds[originChainId][l2TokenAddress][deposit.depositor
|
|
72
|
-
combinedRefunds[originChainId][l2TokenAddress][deposit.depositor
|
|
70
|
+
const existingRefundAmount = combinedRefunds[originChainId][l2TokenAddress][deposit.depositor];
|
|
71
|
+
combinedRefunds[originChainId][l2TokenAddress][deposit.depositor] = deposit.inputAmount.add(
|
|
73
72
|
existingRefundAmount ?? bnZero
|
|
74
73
|
);
|
|
75
74
|
}
|
|
@@ -154,23 +153,19 @@ export function _buildPoolRebalanceRoot(
|
|
|
154
153
|
// If the repayment token and repayment chain ID do not map to a PoolRebalanceRoute graph, then
|
|
155
154
|
// there are no relevant L1 running balances.
|
|
156
155
|
if (
|
|
157
|
-
!clients.hubPoolClient.l2TokenHasPoolRebalanceRoute(
|
|
158
|
-
toAddressType(l2TokenAddress, repaymentChainId),
|
|
159
|
-
repaymentChainId,
|
|
160
|
-
mainnetBundleEndBlock
|
|
161
|
-
)
|
|
156
|
+
!clients.hubPoolClient.l2TokenHasPoolRebalanceRoute(l2TokenAddress, repaymentChainId, mainnetBundleEndBlock)
|
|
162
157
|
) {
|
|
163
158
|
chainWithRefundsOnly.add(repaymentChainId);
|
|
164
159
|
return;
|
|
165
160
|
}
|
|
166
161
|
const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
|
|
167
|
-
|
|
162
|
+
l2TokenAddress,
|
|
168
163
|
repaymentChainId,
|
|
169
164
|
mainnetBundleEndBlock
|
|
170
165
|
);
|
|
171
166
|
|
|
172
|
-
updateRunningBalance(runningBalances, repaymentChainId, l1TokenCounterpart
|
|
173
|
-
updateRunningBalance(realizedLpFees, repaymentChainId, l1TokenCounterpart
|
|
167
|
+
updateRunningBalance(runningBalances, repaymentChainId, l1TokenCounterpart, totalRefundAmount);
|
|
168
|
+
updateRunningBalance(realizedLpFees, repaymentChainId, l1TokenCounterpart, totalRealizedLpFee);
|
|
174
169
|
}
|
|
175
170
|
);
|
|
176
171
|
});
|
|
@@ -187,17 +182,12 @@ export function _buildPoolRebalanceRoot(
|
|
|
187
182
|
Object.entries(depositsForChain).forEach(([outputToken, deposits]) => {
|
|
188
183
|
deposits.forEach((deposit) => {
|
|
189
184
|
const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
|
|
190
|
-
|
|
185
|
+
outputToken,
|
|
191
186
|
destinationChainId,
|
|
192
187
|
mainnetBundleEndBlock
|
|
193
188
|
);
|
|
194
189
|
const lpFee = deposit.lpFeePct.mul(deposit.inputAmount).div(fixedPointAdjustment);
|
|
195
|
-
updateRunningBalance(
|
|
196
|
-
runningBalances,
|
|
197
|
-
destinationChainId,
|
|
198
|
-
l1TokenCounterpart.toEvmAddress(),
|
|
199
|
-
deposit.inputAmount.sub(lpFee)
|
|
200
|
-
);
|
|
190
|
+
updateRunningBalance(runningBalances, destinationChainId, l1TokenCounterpart, deposit.inputAmount.sub(lpFee));
|
|
201
191
|
// Slow fill LP fees are accounted for when the slow fill executes and a V3FilledRelay is emitted. i.e. when
|
|
202
192
|
// the slow fill execution is included in bundleFillsV3.
|
|
203
193
|
});
|
|
@@ -216,17 +206,12 @@ export function _buildPoolRebalanceRoot(
|
|
|
216
206
|
Object.entries(slowFilledDepositsForChain).forEach(([outputToken, slowFilledDeposits]) => {
|
|
217
207
|
slowFilledDeposits.forEach((deposit) => {
|
|
218
208
|
const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
|
|
219
|
-
|
|
209
|
+
outputToken,
|
|
220
210
|
destinationChainId,
|
|
221
211
|
mainnetBundleEndBlock
|
|
222
212
|
);
|
|
223
213
|
const lpFee = deposit.lpFeePct.mul(deposit.inputAmount).div(fixedPointAdjustment);
|
|
224
|
-
updateRunningBalance(
|
|
225
|
-
runningBalances,
|
|
226
|
-
destinationChainId,
|
|
227
|
-
l1TokenCounterpart.toEvmAddress(),
|
|
228
|
-
lpFee.sub(deposit.inputAmount)
|
|
229
|
-
);
|
|
214
|
+
updateRunningBalance(runningBalances, destinationChainId, l1TokenCounterpart, lpFee.sub(deposit.inputAmount));
|
|
230
215
|
// Slow fills don't add to lpFees, only when the slow fill is executed and a V3FilledRelay is emitted, so
|
|
231
216
|
// we don't need to subtract it here. Moreover, the HubPoole expects bundleLpFees to be > 0.
|
|
232
217
|
});
|
|
@@ -286,11 +271,11 @@ export function _buildPoolRebalanceRoot(
|
|
|
286
271
|
return;
|
|
287
272
|
}
|
|
288
273
|
const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
|
|
289
|
-
|
|
274
|
+
inputToken,
|
|
290
275
|
originChainId,
|
|
291
276
|
mainnetBundleEndBlock
|
|
292
277
|
);
|
|
293
|
-
updateRunningBalance(runningBalances, originChainId, l1TokenCounterpart
|
|
278
|
+
updateRunningBalance(runningBalances, originChainId, l1TokenCounterpart, deposit.inputAmount);
|
|
294
279
|
});
|
|
295
280
|
});
|
|
296
281
|
});
|
|
@@ -2,7 +2,7 @@ import _ from "lodash";
|
|
|
2
2
|
import assert from "assert";
|
|
3
3
|
import { providers } from "ethers";
|
|
4
4
|
import { DepositWithBlock, Fill, FillWithBlock } from "../../../interfaces";
|
|
5
|
-
import { isSlowFill, isValidEvmAddress, isDefined, chainIsEvm
|
|
5
|
+
import { isSlowFill, isValidEvmAddress, isDefined, chainIsEvm } from "../../../utils";
|
|
6
6
|
import { HubPoolClient } from "../../HubPoolClient";
|
|
7
7
|
import { SVMProvider } from "../../../arch/svm";
|
|
8
8
|
|
|
@@ -25,7 +25,7 @@ export function getRefundInformationFromFill(
|
|
|
25
25
|
bundleEndBlockForMainnet: number
|
|
26
26
|
): {
|
|
27
27
|
chainToSendRefundTo: number;
|
|
28
|
-
repaymentToken:
|
|
28
|
+
repaymentToken: string;
|
|
29
29
|
} {
|
|
30
30
|
const chainToSendRefundTo = _getRepaymentChainId(relayData, hubPoolClient, bundleEndBlockForMainnet);
|
|
31
31
|
if (chainToSendRefundTo === relayData.originChainId) {
|
|
@@ -49,7 +49,6 @@ export function getRefundInformationFromFill(
|
|
|
49
49
|
chainToSendRefundTo,
|
|
50
50
|
bundleEndBlockForMainnet
|
|
51
51
|
);
|
|
52
|
-
|
|
53
52
|
return {
|
|
54
53
|
chainToSendRefundTo,
|
|
55
54
|
repaymentToken,
|
|
@@ -126,11 +125,7 @@ export async function verifyFillRepayment(
|
|
|
126
125
|
return undefined;
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
|
-
fill.relayer =
|
|
130
|
-
assert(
|
|
131
|
-
fill.relayer.isValidOn(fill.destinationChainId),
|
|
132
|
-
`Cannot re-assign fill to msg.sender: ${destinationRelayer}`
|
|
133
|
-
);
|
|
128
|
+
fill.relayer = destinationRelayer;
|
|
134
129
|
} else {
|
|
135
130
|
return undefined;
|
|
136
131
|
}
|
|
@@ -205,6 +200,5 @@ function _repaymentAddressNeedsToBeOverwritten(fill: Fill): boolean {
|
|
|
205
200
|
// - i.e. If chainIsSvm && !isValidSvmAddress(fill.relayer) then return false
|
|
206
201
|
// If chainIsEvm && !isValidEvmAddress(fill.relayer) then return false
|
|
207
202
|
// If chainIsEvm && isValidEvmAddress(fill.relayer) then return true
|
|
208
|
-
|
|
209
|
-
return !fill.relayer.isValidOn(fill.repaymentChainId);
|
|
203
|
+
return !isValidEvmAddress(fill.relayer);
|
|
210
204
|
}
|
|
@@ -21,12 +21,6 @@ export function buildPoolRebalanceLeafTree(poolRebalanceLeaves: PoolRebalanceLea
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const paramType = getParamType("MerkleLibTest", "verifyPoolRebalance", "rebalance");
|
|
24
|
-
const hashFn = (input: PoolRebalanceLeaf) =>
|
|
25
|
-
const ethersLeaf = {
|
|
26
|
-
...input,
|
|
27
|
-
l1Tokens: input.l1Tokens.map((l1Token) => l1Token.toEvmAddress()),
|
|
28
|
-
};
|
|
29
|
-
return utils.keccak256(utils.defaultAbiCoder.encode([paramType], [ethersLeaf]));
|
|
30
|
-
};
|
|
24
|
+
const hashFn = (input: PoolRebalanceLeaf) => utils.keccak256(utils.defaultAbiCoder.encode([paramType], [input]));
|
|
31
25
|
return new MerkleTree<PoolRebalanceLeaf>(poolRebalanceLeaves, hashFn);
|
|
32
26
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MerkleTree } from "@across-protocol/contracts/dist/utils/MerkleTree";
|
|
2
2
|
import { RunningBalances, PoolRebalanceLeaf, Clients, SpokePoolTargetBalance } from "../../../interfaces";
|
|
3
3
|
import { SpokePoolClient } from "../../SpokePoolClient";
|
|
4
|
-
import { BigNumber, bnZero, compareAddresses
|
|
4
|
+
import { BigNumber, bnZero, compareAddresses } from "../../../utils";
|
|
5
5
|
import { HubPoolClient } from "../../HubPoolClient";
|
|
6
6
|
import { V3DepositWithBlock } from "./shims";
|
|
7
7
|
import { AcrossConfigStoreClient } from "../../AcrossConfigStoreClient";
|
|
@@ -151,7 +151,7 @@ export function addLastRunningBalance(
|
|
|
151
151
|
const { runningBalance } = hubPoolClient.getRunningBalanceBeforeBlockForChain(
|
|
152
152
|
latestMainnetBlock,
|
|
153
153
|
Number(repaymentChainId),
|
|
154
|
-
|
|
154
|
+
l1TokenAddress
|
|
155
155
|
);
|
|
156
156
|
if (!runningBalance.eq(bnZero)) {
|
|
157
157
|
updateRunningBalance(runningBalances, Number(repaymentChainId), l1TokenAddress, runningBalance);
|
|
@@ -172,7 +172,7 @@ export function updateRunningBalanceForDeposit(
|
|
|
172
172
|
deposit.originChainId,
|
|
173
173
|
mainnetBundleEndBlock
|
|
174
174
|
);
|
|
175
|
-
updateRunningBalance(runningBalances, deposit.originChainId, l1TokenCounterpart
|
|
175
|
+
updateRunningBalance(runningBalances, deposit.originChainId, l1TokenCounterpart, updateAmount);
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
export function constructPoolRebalanceLeaves(
|
|
@@ -253,7 +253,7 @@ export function constructPoolRebalanceLeaves(
|
|
|
253
253
|
runningBalances: leafRunningBalances,
|
|
254
254
|
groupIndex: groupIndexForChainId++,
|
|
255
255
|
leafId: leaves.length,
|
|
256
|
-
l1Tokens: l1TokensToIncludeInThisLeaf
|
|
256
|
+
l1Tokens: l1TokensToIncludeInThisLeaf,
|
|
257
257
|
});
|
|
258
258
|
}
|
|
259
259
|
});
|