@across-protocol/sdk 4.2.16 → 4.3.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.
- package/dist/cjs/arch/evm/SpokeUtils.d.ts +8 -3
- package/dist/cjs/arch/evm/SpokeUtils.js +26 -11
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.d.ts +8 -2
- package/dist/cjs/arch/svm/SpokeUtils.js +41 -50
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/eventsClient.js +4 -2
- 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 +16 -14
- 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 +4 -2
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +59 -59
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +16 -13
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +3 -2
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
- 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 +13 -8
- 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 +85 -58
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js +1 -3
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +66 -46
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/index.d.ts +1 -0
- package/dist/cjs/clients/SpokePoolClient/index.js +3 -1
- package/dist/cjs/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/cjs/clients/index.d.ts +1 -1
- package/dist/cjs/clients/index.js +2 -1
- package/dist/cjs/clients/index.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +15 -9
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +5 -3
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +40 -36
- 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 +6 -4
- 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 +19 -14
- package/dist/cjs/interfaces/SpokePool.d.ts +18 -19
- package/dist/cjs/interfaces/SpokePool.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +17 -9
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +24 -15
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +8 -5
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +13 -5
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +61 -58
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +15 -7
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +13 -13
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +12 -8
- package/dist/cjs/utils/AddressUtils.js +33 -36
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/DepositUtils.d.ts +2 -2
- package/dist/cjs/utils/DepositUtils.js +1 -1
- package/dist/cjs/utils/DepositUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.d.ts +1 -3
- package/dist/cjs/utils/SpokeUtils.js +3 -25
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.d.ts +4 -4
- package/dist/cjs/utils/TokenUtils.js +5 -3
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.d.ts +9 -4
- package/dist/esm/arch/evm/SpokeUtils.js +29 -14
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.d.ts +9 -3
- package/dist/esm/arch/svm/SpokeUtils.js +42 -55
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/eventsClient.js +5 -3
- 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 +17 -15
- 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 +4 -2
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +60 -60
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +18 -15
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +7 -7
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
- 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 +20 -10
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +22 -22
- package/dist/esm/clients/HubPoolClient.js +93 -66
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +3 -3
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js +2 -4
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +69 -48
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/index.d.ts +1 -0
- package/dist/esm/clients/SpokePoolClient/index.js +1 -0
- package/dist/esm/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/esm/clients/index.d.ts +1 -1
- package/dist/esm/clients/index.js +1 -1
- package/dist/esm/clients/index.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/esm/clients/mocks/MockHubPoolClient.js +16 -10
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +5 -3
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +42 -38
- 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 +7 -5
- 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 +19 -14
- package/dist/esm/interfaces/SpokePool.d.ts +18 -19
- package/dist/esm/interfaces/SpokePool.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +20 -12
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +28 -19
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js +9 -6
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +15 -7
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +67 -63
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +25 -8
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +12 -12
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +12 -8
- package/dist/esm/utils/AddressUtils.js +36 -38
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/DepositUtils.d.ts +2 -2
- package/dist/esm/utils/DepositUtils.js +2 -2
- package/dist/esm/utils/DepositUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +1 -8
- package/dist/esm/utils/SpokeUtils.js +3 -29
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.d.ts +6 -18
- package/dist/esm/utils/TokenUtils.js +6 -4
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/types/arch/evm/SpokeUtils.d.ts +9 -4
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts +9 -3
- 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 +4 -4
- 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 +2 -1
- 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 -22
- 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/SVMSpokePoolClient.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/index.d.ts +1 -0
- package/dist/types/clients/SpokePoolClient/index.d.ts.map +1 -1
- package/dist/types/clients/index.d.ts +1 -1
- package/dist/types/clients/index.d.ts.map +1 -1
- 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 +5 -3
- 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 +19 -14
- package/dist/types/interfaces/HubPool.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +18 -19
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +20 -12
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +15 -7
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +25 -8
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +12 -8
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/DepositUtils.d.ts +2 -2
- package/dist/types/utils/DepositUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts +1 -8
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts +6 -18
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/arch/evm/SpokeUtils.ts +72 -22
- package/src/arch/svm/SpokeUtils.ts +67 -53
- package/src/arch/svm/eventsClient.ts +40 -8
- package/src/arch/svm/utils.ts +6 -6
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -4
- package/src/clients/BundleDataClient/BundleDataClient.ts +56 -56
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +32 -15
- package/src/clients/BundleDataClient/utils/FillUtils.ts +12 -8
- package/src/clients/BundleDataClient/utils/MerkleTreeUtils.ts +7 -1
- package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +4 -4
- package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +22 -10
- package/src/clients/HubPoolClient.ts +125 -86
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +7 -2
- package/src/clients/SpokePoolClient/SVMSpokePoolClient.ts +1 -4
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +122 -37
- package/src/clients/SpokePoolClient/index.ts +1 -0
- package/src/clients/index.ts +1 -0
- package/src/clients/mocks/MockHubPoolClient.ts +24 -19
- package/src/clients/mocks/MockSpokePoolClient.ts +39 -27
- package/src/clients/mocks/MockSvmCpiEventsClient.ts +8 -5
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +12 -3
- package/src/interfaces/HubPool.ts +20 -14
- package/src/interfaces/SpokePool.ts +19 -19
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +39 -21
- package/src/relayFeeCalculator/chain-queries/factory.ts +8 -5
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +73 -58
- package/src/relayFeeCalculator/relayFeeCalculator.ts +23 -21
- package/src/utils/AddressUtils.ts +39 -51
- package/src/utils/DepositUtils.ts +4 -4
- package/src/utils/SpokeUtils.ts +8 -36
- package/src/utils/TokenUtils.ts +10 -8
|
@@ -24,13 +24,13 @@ import {
|
|
|
24
24
|
import assert from "assert";
|
|
25
25
|
import { arrayify, hexZeroPad, hexlify } from "ethers/lib/utils";
|
|
26
26
|
import { Logger } from "winston";
|
|
27
|
-
|
|
28
27
|
import { SYSTEM_PROGRAM_ADDRESS } from "@solana-program/system";
|
|
29
|
-
import {
|
|
28
|
+
import { DepositWithBlock, FillStatus, FillWithBlock, RelayData, RelayExecutionEventInfo } from "../../interfaces";
|
|
30
29
|
import {
|
|
31
30
|
BigNumber,
|
|
32
31
|
EvmAddress,
|
|
33
32
|
SvmAddress,
|
|
33
|
+
Address as SdkAddress,
|
|
34
34
|
chainIsSvm,
|
|
35
35
|
chunk,
|
|
36
36
|
isUnsafeDepositId,
|
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
toAddress,
|
|
47
47
|
unwrapEventData,
|
|
48
48
|
} from "./";
|
|
49
|
+
import { CHAIN_IDs } from "../../constants";
|
|
49
50
|
import { SVMEventNames, SVMProvider } from "./types";
|
|
50
51
|
|
|
51
52
|
/**
|
|
@@ -54,6 +55,12 @@ import { SVMEventNames, SVMProvider } from "./types";
|
|
|
54
55
|
*/
|
|
55
56
|
export const SLOT_DURATION_MS = 400;
|
|
56
57
|
|
|
58
|
+
type ProtoFill = Omit<RelayData, "recipient" | "outputToken"> & {
|
|
59
|
+
destinationChainId: number;
|
|
60
|
+
recipient: SvmAddress;
|
|
61
|
+
outputToken: SvmAddress;
|
|
62
|
+
};
|
|
63
|
+
|
|
57
64
|
/**
|
|
58
65
|
* Retrieves the chain time at a particular slot.
|
|
59
66
|
*/
|
|
@@ -145,13 +152,20 @@ export async function findDeposit(
|
|
|
145
152
|
return undefined;
|
|
146
153
|
}
|
|
147
154
|
|
|
155
|
+
const unwrappedDepositEvent = unwrapEventData(depositEvent.data) as Record<string, unknown>;
|
|
156
|
+
const destinationChainId = unwrappedDepositEvent.destinationChainId as number;
|
|
148
157
|
// Return the deposit event with block info
|
|
149
158
|
return {
|
|
150
159
|
txnRef: depositEvent.signature.toString(),
|
|
151
160
|
blockNumber: Number(depositEvent.slot),
|
|
152
161
|
txnIndex: 0,
|
|
153
162
|
logIndex: 0,
|
|
154
|
-
...
|
|
163
|
+
...unwrappedDepositEvent,
|
|
164
|
+
depositor: toAddressType(unwrappedDepositEvent.depositor as string, CHAIN_IDs.SOLANA),
|
|
165
|
+
recipient: toAddressType(unwrappedDepositEvent.recipient as string, destinationChainId),
|
|
166
|
+
inputToken: toAddressType(unwrappedDepositEvent.inputToken as string, CHAIN_IDs.SOLANA),
|
|
167
|
+
outputToken: toAddressType(unwrappedDepositEvent.outputToken as string, destinationChainId),
|
|
168
|
+
exclusiveRelayer: toAddressType(unwrappedDepositEvent.exclusiveRelayer as string, destinationChainId),
|
|
155
169
|
} as DepositWithBlock;
|
|
156
170
|
}
|
|
157
171
|
|
|
@@ -327,14 +341,34 @@ export async function findFillEvent(
|
|
|
327
341
|
|
|
328
342
|
if (fillEvents.length > 0) {
|
|
329
343
|
const rawFillEvent = fillEvents[0];
|
|
344
|
+
const eventData = unwrapEventData(rawFillEvent.data) as FillWithBlock & {
|
|
345
|
+
depositor: string;
|
|
346
|
+
recipient: string;
|
|
347
|
+
inputToken: string;
|
|
348
|
+
outputToken: string;
|
|
349
|
+
exclusiveRelayer: string;
|
|
350
|
+
relayer: string;
|
|
351
|
+
relayExecutionInfo: RelayExecutionEventInfo & { updatedRecipient: string };
|
|
352
|
+
};
|
|
353
|
+
const originChainId = eventData.originChainId;
|
|
330
354
|
const parsedFillEvent = {
|
|
355
|
+
...eventData,
|
|
331
356
|
transactionHash: rawFillEvent.signature,
|
|
332
357
|
blockNumber: Number(rawFillEvent.slot),
|
|
333
358
|
transactionIndex: 0,
|
|
334
359
|
logIndex: 0,
|
|
335
360
|
destinationChainId,
|
|
336
|
-
|
|
337
|
-
|
|
361
|
+
inputToken: toAddressType(eventData.inputToken, originChainId),
|
|
362
|
+
outputToken: toAddressType(eventData.outputToken, destinationChainId),
|
|
363
|
+
relayer: toAddressType(eventData.relayer, destinationChainId),
|
|
364
|
+
exclusiveRelayer: toAddressType(eventData.exclusiveRelayer, destinationChainId),
|
|
365
|
+
depositor: toAddressType(eventData.depositor, originChainId),
|
|
366
|
+
recipient: toAddressType(eventData.recipient, destinationChainId),
|
|
367
|
+
relayExecutionInfo: {
|
|
368
|
+
...eventData.relayExecutionInfo,
|
|
369
|
+
updatedRecipient: eventData.relayExecutionInfo.updatedRecipient,
|
|
370
|
+
},
|
|
371
|
+
} as FillWithBlock;
|
|
338
372
|
return parsedFillEvent;
|
|
339
373
|
}
|
|
340
374
|
|
|
@@ -343,18 +377,18 @@ export async function findFillEvent(
|
|
|
343
377
|
|
|
344
378
|
/**
|
|
345
379
|
* @param spokePool Address (program ID) of the SvmSpoke.
|
|
346
|
-
* @param
|
|
380
|
+
* @param relayData RelayData instance, supplemented with destinationChainId
|
|
347
381
|
* @param relayer Address of the relayer filling the deposit.
|
|
348
382
|
* @param repaymentChainId Optional repaymentChainId (defaults to destinationChainId).
|
|
349
383
|
* @returns An Ethers UnsignedTransaction instance.
|
|
350
384
|
*/
|
|
351
385
|
export async function fillRelayInstruction(
|
|
352
386
|
spokePool: SvmAddress,
|
|
353
|
-
|
|
387
|
+
relayData: ProtoFill,
|
|
354
388
|
signer: TransactionSigner<string>,
|
|
355
389
|
recipientTokenAccount: Address<string>,
|
|
356
390
|
repaymentAddress: EvmAddress | SvmAddress = SvmAddress.from(signer.address),
|
|
357
|
-
repaymentChainId =
|
|
391
|
+
repaymentChainId = relayData.destinationChainId
|
|
358
392
|
) {
|
|
359
393
|
const program = toAddress(spokePool);
|
|
360
394
|
|
|
@@ -363,25 +397,22 @@ export async function fillRelayInstruction(
|
|
|
363
397
|
`Invalid repayment address for chain ${repaymentChainId}: ${repaymentAddress.toNative()}.`
|
|
364
398
|
);
|
|
365
399
|
|
|
366
|
-
const _relayDataHash = getRelayDataHash(
|
|
400
|
+
const _relayDataHash = getRelayDataHash(relayData, relayData.destinationChainId);
|
|
367
401
|
const relayDataHash = new Uint8Array(Buffer.from(_relayDataHash.slice(2), "hex"));
|
|
368
402
|
|
|
369
403
|
const relayer = SvmAddress.from(signer.address);
|
|
370
|
-
const outputTokenAddress = toAddressType(deposit.outputToken, deposit.destinationChainId);
|
|
371
|
-
if (!(outputTokenAddress instanceof SvmAddress)) {
|
|
372
|
-
return undefined;
|
|
373
|
-
}
|
|
374
404
|
|
|
375
405
|
// Create ATA for the relayer and recipient token accounts
|
|
376
|
-
const relayerTokenAccount = await getAssociatedTokenAddress(relayer,
|
|
406
|
+
const relayerTokenAccount = await getAssociatedTokenAddress(relayer, relayData.outputToken);
|
|
377
407
|
|
|
378
408
|
const [statePda, fillStatusPda, eventAuthority] = await Promise.all([
|
|
379
409
|
getStatePda(program),
|
|
380
|
-
getFillStatusPda(program,
|
|
381
|
-
getEventAuthority(),
|
|
410
|
+
getFillStatusPda(program, relayData, relayData.destinationChainId),
|
|
411
|
+
getEventAuthority(program),
|
|
382
412
|
]);
|
|
413
|
+
|
|
383
414
|
const depositIdBuffer = new Uint8Array(32);
|
|
384
|
-
const shortenedBuffer = new Uint8Array(Buffer.from(
|
|
415
|
+
const shortenedBuffer = new Uint8Array(Buffer.from(relayData.depositId.toHexString().slice(2), "hex"));
|
|
385
416
|
depositIdBuffer.set(shortenedBuffer, 32 - shortenedBuffer.length);
|
|
386
417
|
|
|
387
418
|
const delegatePda = await getFillRelayDelegatePda(
|
|
@@ -391,26 +422,14 @@ export async function fillRelayInstruction(
|
|
|
391
422
|
program
|
|
392
423
|
);
|
|
393
424
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
const [recipient, exclusiveRelayer] = [deposit.recipient, deposit.exclusiveRelayer].map((addr) => {
|
|
404
|
-
const addressObj = toAddressType(addr, deposit.originChainId);
|
|
405
|
-
if (!(addressObj instanceof SvmAddress)) {
|
|
406
|
-
return undefined;
|
|
407
|
-
}
|
|
408
|
-
return toAddress(addressObj);
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
if (!recipient || !exclusiveRelayer) return undefined;
|
|
425
|
+
const [recipient, outputToken, exclusiveRelayer, depositor, inputToken] = [
|
|
426
|
+
relayData.recipient,
|
|
427
|
+
relayData.outputToken,
|
|
428
|
+
relayData.exclusiveRelayer,
|
|
429
|
+
relayData.depositor,
|
|
430
|
+
relayData.inputToken,
|
|
431
|
+
].map(toAddress);
|
|
412
432
|
|
|
413
|
-
const outputToken = toAddress(outputTokenAddress);
|
|
414
433
|
return SvmSpokeClient.getFillRelayInstruction({
|
|
415
434
|
signer,
|
|
416
435
|
state: statePda,
|
|
@@ -428,13 +447,13 @@ export async function fillRelayInstruction(
|
|
|
428
447
|
exclusiveRelayer,
|
|
429
448
|
inputToken,
|
|
430
449
|
outputToken,
|
|
431
|
-
inputAmount:
|
|
432
|
-
outputAmount:
|
|
433
|
-
originChainId: BigInt(
|
|
434
|
-
fillDeadline:
|
|
435
|
-
exclusivityDeadline:
|
|
450
|
+
inputAmount: relayData.inputAmount.toBigInt(),
|
|
451
|
+
outputAmount: relayData.outputAmount.toBigInt(),
|
|
452
|
+
originChainId: BigInt(relayData.originChainId),
|
|
453
|
+
fillDeadline: relayData.fillDeadline,
|
|
454
|
+
exclusivityDeadline: relayData.exclusivityDeadline,
|
|
436
455
|
depositId: depositIdBuffer,
|
|
437
|
-
message: new Uint8Array(Buffer.from(
|
|
456
|
+
message: new Uint8Array(Buffer.from(relayData.message.slice(2), "hex")),
|
|
438
457
|
}),
|
|
439
458
|
repaymentChainId: some(BigInt(repaymentChainId)),
|
|
440
459
|
repaymentAddress: toAddress(repaymentAddress),
|
|
@@ -616,19 +635,14 @@ export function getRelayDataHash(relayData: RelayData, destinationChainId: numbe
|
|
|
616
635
|
const uint32Encoder = getU32Encoder();
|
|
617
636
|
|
|
618
637
|
assert(relayData.message.startsWith("0x"), "Message must be a hex string");
|
|
619
|
-
const encodeAddress = (
|
|
620
|
-
const addrObj = toAddressType(addr, chainId);
|
|
621
|
-
// @dev even if `addrObj` is of type `Address` here, we still want to calculate the relayHash
|
|
622
|
-
// based on `base58` representation of the `Address`
|
|
623
|
-
return Uint8Array.from(addressEncoder.encode(addrObj.toBase58() as Address<string>));
|
|
624
|
-
};
|
|
638
|
+
const encodeAddress = (data: SdkAddress) => Uint8Array.from(addressEncoder.encode(toAddress(data)));
|
|
625
639
|
|
|
626
640
|
const contentToHash = Buffer.concat([
|
|
627
|
-
encodeAddress(relayData.depositor
|
|
628
|
-
encodeAddress(relayData.recipient
|
|
629
|
-
encodeAddress(relayData.exclusiveRelayer
|
|
630
|
-
encodeAddress(relayData.inputToken
|
|
631
|
-
encodeAddress(relayData.outputToken
|
|
641
|
+
encodeAddress(relayData.depositor),
|
|
642
|
+
encodeAddress(relayData.recipient),
|
|
643
|
+
encodeAddress(relayData.exclusiveRelayer),
|
|
644
|
+
encodeAddress(relayData.inputToken),
|
|
645
|
+
encodeAddress(relayData.outputToken),
|
|
632
646
|
Uint8Array.from(uint64Encoder.encode(BigInt(relayData.inputAmount.toString()))),
|
|
633
647
|
Uint8Array.from(uint64Encoder.encode(BigInt(relayData.outputAmount.toString()))),
|
|
634
648
|
Uint8Array.from(uint64Encoder.encode(BigInt(relayData.originChainId.toString()))),
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
GetTransactionApi,
|
|
11
11
|
Signature,
|
|
12
12
|
} from "@solana/kit";
|
|
13
|
-
import { bs58, chainIsSvm, getMessageHash } from "../../utils";
|
|
13
|
+
import { bs58, chainIsSvm, getMessageHash, toAddressType } from "../../utils";
|
|
14
14
|
import { EventName, EventWithData, SVMProvider } from "./types";
|
|
15
15
|
import { decodeEvent, isDevnet } from "./utils";
|
|
16
16
|
import { Deposit, DepositWithTime, Fill, FillWithTime } from "../../interfaces";
|
|
@@ -252,7 +252,6 @@ export class SvmCpiEventsClient {
|
|
|
252
252
|
|
|
253
253
|
// Filter for FundsDeposited events only
|
|
254
254
|
const depositEvents = events?.filter((event) => event?.name === "FundsDeposited");
|
|
255
|
-
|
|
256
255
|
if (!txDetails || !depositEvents?.length) {
|
|
257
256
|
return;
|
|
258
257
|
}
|
|
@@ -261,13 +260,29 @@ export class SvmCpiEventsClient {
|
|
|
261
260
|
const unwrappedEventArgs = unwrapEventData(event as Record<string, unknown>, ["depositId"]) as Record<
|
|
262
261
|
"data",
|
|
263
262
|
Deposit
|
|
264
|
-
|
|
265
|
-
|
|
263
|
+
> &
|
|
264
|
+
Record<
|
|
265
|
+
"data",
|
|
266
|
+
{
|
|
267
|
+
depositor: string;
|
|
268
|
+
recipient: string;
|
|
269
|
+
exclusiveRelayer: string;
|
|
270
|
+
inputToken: string;
|
|
271
|
+
outputToken: string;
|
|
272
|
+
}
|
|
273
|
+
>;
|
|
274
|
+
|
|
275
|
+
const { data } = unwrappedEventArgs;
|
|
266
276
|
return {
|
|
267
|
-
...
|
|
277
|
+
...data,
|
|
278
|
+
depositor: toAddressType(data.depositor, data.originChainId),
|
|
279
|
+
recipient: toAddressType(data.recipient, data.destinationChainId),
|
|
280
|
+
exclusiveRelayer: toAddressType(data.exclusiveRelayer, data.destinationChainId),
|
|
281
|
+
inputToken: toAddressType(data.inputToken, data.originChainId),
|
|
282
|
+
outputToken: toAddressType(data.outputToken, data.destinationChainId),
|
|
268
283
|
depositTimestamp: Number(txDetails.blockTime),
|
|
269
284
|
originChainId,
|
|
270
|
-
messageHash: getMessageHash(
|
|
285
|
+
messageHash: getMessageHash(data.message),
|
|
271
286
|
blockNumber: Number(txDetails.slot),
|
|
272
287
|
txnIndex: 0,
|
|
273
288
|
txnRef: txSignature,
|
|
@@ -309,9 +324,26 @@ export class SvmCpiEventsClient {
|
|
|
309
324
|
}
|
|
310
325
|
|
|
311
326
|
return fillEvents.map((event) => {
|
|
312
|
-
const unwrappedEventData = unwrapEventData(event as Record<string, unknown>) as Record<"data", Fill
|
|
327
|
+
const unwrappedEventData = unwrapEventData(event as Record<string, unknown>) as Record<"data", Fill> &
|
|
328
|
+
Record<
|
|
329
|
+
"data",
|
|
330
|
+
{
|
|
331
|
+
depositor: string;
|
|
332
|
+
recipient: string;
|
|
333
|
+
exclusiveRelayer: string;
|
|
334
|
+
inputToken: string;
|
|
335
|
+
outputToken: string;
|
|
336
|
+
}
|
|
337
|
+
>;
|
|
338
|
+
|
|
339
|
+
const { data } = unwrappedEventData;
|
|
313
340
|
return {
|
|
314
|
-
...
|
|
341
|
+
...data,
|
|
342
|
+
depositor: toAddressType(data.depositor, data.originChainId),
|
|
343
|
+
recipient: toAddressType(data.recipient, data.destinationChainId),
|
|
344
|
+
exclusiveRelayer: toAddressType(data.exclusiveRelayer, data.destinationChainId),
|
|
345
|
+
inputToken: toAddressType(data.inputToken, data.originChainId),
|
|
346
|
+
outputToken: toAddressType(data.outputToken, data.destinationChainId),
|
|
315
347
|
fillTimestamp: Number(txDetails.blockTime),
|
|
316
348
|
blockNumber: Number(txDetails.slot),
|
|
317
349
|
txnRef: txSignature,
|
package/src/arch/svm/utils.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "@solana/kit";
|
|
18
18
|
import { SvmSpokeClient } from "@across-protocol/contracts";
|
|
19
19
|
import { FillType, RelayData } from "../../interfaces";
|
|
20
|
-
import { BigNumber,
|
|
20
|
+
import { BigNumber, getRelayDataHash, isUint8Array, Address as SdkAddress } from "../../utils";
|
|
21
21
|
import { EventName, SVMEventNames, SVMProvider } from "./types";
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -45,7 +45,7 @@ export async function isDevnet(rpc: SVMProvider): Promise<boolean> {
|
|
|
45
45
|
/**
|
|
46
46
|
* Small utility to convert an Address to a Solana Kit branded type.
|
|
47
47
|
*/
|
|
48
|
-
export function toAddress(address:
|
|
48
|
+
export function toAddress(address: SdkAddress): Address<string> {
|
|
49
49
|
return address.toBase58() as Address<string>;
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -144,7 +144,7 @@ export function unwrapEventData(
|
|
|
144
144
|
}
|
|
145
145
|
// Handle strings (potential addresses)
|
|
146
146
|
if (typeof data === "string" && isAddress(data)) {
|
|
147
|
-
return
|
|
147
|
+
return ethers.utils.hexlify(bs58.decode(data));
|
|
148
148
|
}
|
|
149
149
|
// Handle objects
|
|
150
150
|
if (typeof data === "object") {
|
|
@@ -280,13 +280,13 @@ export async function getInstructionParamsPda(programId: Address, signer: Addres
|
|
|
280
280
|
* Returns the PDA for the Event Authority.
|
|
281
281
|
* @returns The PDA for the Event Authority.
|
|
282
282
|
*/
|
|
283
|
-
export
|
|
283
|
+
export async function getEventAuthority(programId: Address): Promise<Address> {
|
|
284
284
|
const [eventAuthority] = await getProgramDerivedAddress({
|
|
285
|
-
programAddress:
|
|
285
|
+
programAddress: programId,
|
|
286
286
|
seeds: ["__event_authority"],
|
|
287
287
|
});
|
|
288
288
|
return eventAuthority;
|
|
289
|
-
}
|
|
289
|
+
}
|
|
290
290
|
|
|
291
291
|
/**
|
|
292
292
|
* Returns a random SVM address.
|
|
@@ -5,6 +5,7 @@ import winston from "winston";
|
|
|
5
5
|
import { isError } from "../../typeguards";
|
|
6
6
|
import {
|
|
7
7
|
EventSearchConfig,
|
|
8
|
+
EvmAddress,
|
|
8
9
|
MakeOptional,
|
|
9
10
|
isArrayOf,
|
|
10
11
|
isDefined,
|
|
@@ -107,7 +108,7 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
107
108
|
}
|
|
108
109
|
|
|
109
110
|
getRateModelForBlockNumber(
|
|
110
|
-
l1Token:
|
|
111
|
+
l1Token: EvmAddress,
|
|
111
112
|
originChainId: number | string,
|
|
112
113
|
destinationChainId: number | string,
|
|
113
114
|
blockNumber: number | undefined = undefined
|
|
@@ -121,7 +122,9 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
121
122
|
|
|
122
123
|
const defaultRateModelUpdate = sortEventsDescending(this.cumulativeRateModelUpdates).find(
|
|
123
124
|
(config) =>
|
|
124
|
-
config.blockNumber <= (blockNumber ?? 0) &&
|
|
125
|
+
config.blockNumber <= (blockNumber ?? 0) &&
|
|
126
|
+
config.l1Token === l1Token.toEvmAddress() &&
|
|
127
|
+
config.rateModel !== undefined
|
|
125
128
|
);
|
|
126
129
|
if (!defaultRateModelUpdate) {
|
|
127
130
|
throw new Error(`Could not find TokenConfig update for ${l1Token} at block ${blockNumber}`);
|
|
@@ -130,12 +133,12 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
130
133
|
}
|
|
131
134
|
|
|
132
135
|
getRouteRateModelForBlockNumber(
|
|
133
|
-
l1Token:
|
|
136
|
+
l1Token: EvmAddress,
|
|
134
137
|
route: string,
|
|
135
138
|
blockNumber: number | undefined = undefined
|
|
136
139
|
): RateModel | undefined {
|
|
137
140
|
const config = (sortEventsDescending(this.cumulativeRouteRateModelUpdates) as RouteRateModelUpdate[]).find(
|
|
138
|
-
(config) => config.blockNumber <= (blockNumber ?? 0) && config.l1Token === l1Token
|
|
141
|
+
(config) => config.blockNumber <= (blockNumber ?? 0) && config.l1Token === l1Token.toEvmAddress()
|
|
139
142
|
);
|
|
140
143
|
if (config?.routeRateModel[route] === undefined) {
|
|
141
144
|
return undefined;
|
|
@@ -39,10 +39,9 @@ import {
|
|
|
39
39
|
bnUint32Max,
|
|
40
40
|
isZeroValueDeposit,
|
|
41
41
|
isZeroValueFillOrSlowFillRequest,
|
|
42
|
-
chainIsEvm,
|
|
43
|
-
isValidEvmAddress,
|
|
44
42
|
duplicateEvent,
|
|
45
43
|
invalidOutputToken,
|
|
44
|
+
Address,
|
|
46
45
|
getNetworkName,
|
|
47
46
|
} from "../../utils";
|
|
48
47
|
import winston from "winston";
|
|
@@ -69,22 +68,21 @@ type DataCache = Record<string, Promise<LoadDataReturnValue>>;
|
|
|
69
68
|
// V3 dictionary helper functions
|
|
70
69
|
function updateExpiredDepositsV3(dict: ExpiredDepositsToRefundV3, deposit: V3DepositWithBlock): void {
|
|
71
70
|
// A deposit refund for a deposit is invalid if the depositor has a bytes32 address input for an EVM chain. It is valid otherwise.
|
|
72
|
-
if (
|
|
71
|
+
if (!deposit.depositor.isValidOn(deposit.originChainId)) {
|
|
73
72
|
return;
|
|
74
73
|
}
|
|
74
|
+
|
|
75
75
|
const { originChainId, inputToken } = deposit;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
dict[originChainId][inputToken].push(deposit);
|
|
76
|
+
dict[originChainId] ??= {};
|
|
77
|
+
dict[originChainId][inputToken.toBytes32()] ??= [];
|
|
78
|
+
dict[originChainId][inputToken.toBytes32()].push(deposit);
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
function updateBundleDepositsV3(dict: BundleDepositsV3, deposit: V3DepositWithBlock): void {
|
|
83
82
|
const { originChainId, inputToken } = deposit;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
dict[originChainId][inputToken].push(deposit);
|
|
83
|
+
dict[originChainId] ??= {};
|
|
84
|
+
dict[originChainId][inputToken.toBytes32()] ??= [];
|
|
85
|
+
dict[originChainId][inputToken.toBytes32()].push(deposit);
|
|
88
86
|
}
|
|
89
87
|
|
|
90
88
|
function updateBundleFillsV3(
|
|
@@ -92,29 +90,29 @@ function updateBundleFillsV3(
|
|
|
92
90
|
fill: V3FillWithBlock,
|
|
93
91
|
lpFeePct: BigNumber,
|
|
94
92
|
repaymentChainId: number,
|
|
95
|
-
repaymentToken:
|
|
96
|
-
repaymentAddress:
|
|
93
|
+
repaymentToken: Address,
|
|
94
|
+
repaymentAddress: Address
|
|
97
95
|
): void {
|
|
98
96
|
// We shouldn't pass any unrepayable fills into this function, so we perform an extra safety check.
|
|
99
|
-
if (
|
|
97
|
+
if (!fill.relayer.isValidOn(repaymentChainId)) {
|
|
100
98
|
return;
|
|
101
99
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
}
|
|
100
|
+
|
|
101
|
+
dict[repaymentChainId] ??= {};
|
|
102
|
+
dict[repaymentChainId][repaymentToken.toBytes32()] ??= {
|
|
103
|
+
fills: [],
|
|
104
|
+
totalRefundAmount: bnZero,
|
|
105
|
+
realizedLpFees: bnZero,
|
|
106
|
+
refunds: {},
|
|
107
|
+
};
|
|
110
108
|
|
|
111
109
|
const bundleFill: BundleFillV3 = { ...fill, lpFeePct, relayer: repaymentAddress };
|
|
112
110
|
|
|
113
111
|
// Add all fills, slow and fast, to dictionary.
|
|
114
|
-
assign(dict, [repaymentChainId, repaymentToken, "fills"], [bundleFill]);
|
|
112
|
+
assign(dict, [repaymentChainId, repaymentToken.toBytes32(), "fills"], [bundleFill]);
|
|
115
113
|
|
|
116
114
|
// All fills update the bundle LP fees.
|
|
117
|
-
const refundObj = dict[repaymentChainId][repaymentToken];
|
|
115
|
+
const refundObj = dict[repaymentChainId][repaymentToken.toBytes32()];
|
|
118
116
|
const realizedLpFee = bundleFill.inputAmount.mul(bundleFill.lpFeePct).div(fixedPointAdjustment);
|
|
119
117
|
refundObj.realizedLpFees = refundObj.realizedLpFees ? refundObj.realizedLpFees.add(realizedLpFee) : realizedLpFee;
|
|
120
118
|
|
|
@@ -128,10 +126,11 @@ function updateBundleFillsV3(
|
|
|
128
126
|
// Instantiate dictionary if it doesn't exist.
|
|
129
127
|
refundObj.refunds ??= {};
|
|
130
128
|
|
|
131
|
-
if (refundObj.refunds[bundleFill.relayer]) {
|
|
132
|
-
refundObj.refunds[bundleFill.relayer] =
|
|
129
|
+
if (refundObj.refunds[bundleFill.relayer.toBytes32()]) {
|
|
130
|
+
refundObj.refunds[bundleFill.relayer.toBytes32()] =
|
|
131
|
+
refundObj.refunds[bundleFill.relayer.toBytes32()].add(refundAmount);
|
|
133
132
|
} else {
|
|
134
|
-
refundObj.refunds[bundleFill.relayer] = refundAmount;
|
|
133
|
+
refundObj.refunds[bundleFill.relayer.toBytes32()] = refundAmount;
|
|
135
134
|
}
|
|
136
135
|
}
|
|
137
136
|
}
|
|
@@ -141,21 +140,20 @@ function updateBundleExcessSlowFills(
|
|
|
141
140
|
deposit: V3DepositWithBlock & { lpFeePct: BigNumber }
|
|
142
141
|
): void {
|
|
143
142
|
const { destinationChainId, outputToken } = deposit;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
dict[destinationChainId][outputToken].push(deposit);
|
|
143
|
+
dict[destinationChainId] ??= {};
|
|
144
|
+
dict[destinationChainId][outputToken.toBytes32()] ??= [];
|
|
145
|
+
dict[destinationChainId][outputToken.toBytes32()].push(deposit);
|
|
148
146
|
}
|
|
149
147
|
|
|
150
148
|
function updateBundleSlowFills(dict: BundleSlowFills, deposit: V3DepositWithBlock & { lpFeePct: BigNumber }): void {
|
|
151
|
-
if (
|
|
149
|
+
if (!deposit.recipient.isValidOn(deposit.destinationChainId)) {
|
|
152
150
|
return;
|
|
153
151
|
}
|
|
152
|
+
|
|
154
153
|
const { destinationChainId, outputToken } = deposit;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
dict[destinationChainId][outputToken].push(deposit);
|
|
154
|
+
dict[destinationChainId] ??= {};
|
|
155
|
+
dict[destinationChainId][outputToken.toBytes32()] ??= [];
|
|
156
|
+
dict[destinationChainId][outputToken.toBytes32()].push(deposit);
|
|
159
157
|
}
|
|
160
158
|
|
|
161
159
|
// @notice Shared client for computing data needed to construct or validate a bundle.
|
|
@@ -507,22 +505,24 @@ export class BundleDataClient {
|
|
|
507
505
|
// worst from the relayer's perspective.
|
|
508
506
|
const { relayer, inputAmount: refundAmount } = fill;
|
|
509
507
|
refundsForChain[chainToSendRefundTo] ??= {};
|
|
510
|
-
refundsForChain[chainToSendRefundTo][repaymentToken] ??= {};
|
|
511
|
-
const existingRefundAmount =
|
|
512
|
-
|
|
508
|
+
refundsForChain[chainToSendRefundTo][repaymentToken.toBytes32()] ??= {};
|
|
509
|
+
const existingRefundAmount =
|
|
510
|
+
refundsForChain[chainToSendRefundTo][repaymentToken.toBytes32()][relayer.toBytes32()] ?? bnZero;
|
|
511
|
+
refundsForChain[chainToSendRefundTo][repaymentToken.toBytes32()][relayer.toBytes32()] =
|
|
512
|
+
existingRefundAmount.add(refundAmount);
|
|
513
513
|
});
|
|
514
514
|
}
|
|
515
515
|
return refundsForChain;
|
|
516
516
|
}
|
|
517
517
|
|
|
518
|
-
getUpcomingDepositAmount(chainId: number, l2Token:
|
|
518
|
+
getUpcomingDepositAmount(chainId: number, l2Token: Address, latestBlockToSearch: number): BigNumber {
|
|
519
519
|
const spokePoolClient = this.spokePoolClientManager.getClient(chainId);
|
|
520
520
|
if (!isDefined(spokePoolClient)) {
|
|
521
521
|
return toBN(0);
|
|
522
522
|
}
|
|
523
523
|
return spokePoolClient
|
|
524
524
|
.getDeposits()
|
|
525
|
-
.filter((deposit) => deposit.blockNumber > latestBlockToSearch && deposit.inputToken
|
|
525
|
+
.filter((deposit) => deposit.blockNumber > latestBlockToSearch && deposit.inputToken.eq(l2Token))
|
|
526
526
|
.reduce((acc, deposit) => {
|
|
527
527
|
return acc.add(deposit.inputAmount);
|
|
528
528
|
}, toBN(0));
|
|
@@ -644,18 +644,14 @@ export class BundleDataClient {
|
|
|
644
644
|
.filter((leaf) => leaf.rootBundleId === bundle.rootBundleId);
|
|
645
645
|
const executedRefunds: { [tokenAddress: string]: { [relayer: string]: BigNumber } } = {};
|
|
646
646
|
for (const refundLeaf of executedRefundLeaves) {
|
|
647
|
-
const tokenAddress = refundLeaf.l2TokenAddress;
|
|
648
|
-
|
|
649
|
-
executedRefunds[tokenAddress] = {};
|
|
650
|
-
}
|
|
651
|
-
const executedTokenRefunds = executedRefunds[tokenAddress];
|
|
647
|
+
const tokenAddress = refundLeaf.l2TokenAddress.toBytes32();
|
|
648
|
+
const executedTokenRefunds = (executedRefunds[tokenAddress] ??= {});
|
|
652
649
|
|
|
653
650
|
for (let i = 0; i < refundLeaf.refundAddresses.length; i++) {
|
|
654
|
-
const relayer = refundLeaf.refundAddresses[i];
|
|
651
|
+
const relayer = refundLeaf.refundAddresses[i].toBytes32();
|
|
655
652
|
const refundAmount = refundLeaf.refundAmounts[i];
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
}
|
|
653
|
+
|
|
654
|
+
executedTokenRefunds[relayer] ??= bnZero;
|
|
659
655
|
executedTokenRefunds[relayer] = executedTokenRefunds[relayer].add(refundAmount);
|
|
660
656
|
}
|
|
661
657
|
}
|
|
@@ -695,15 +691,15 @@ export class BundleDataClient {
|
|
|
695
691
|
return allRefunds;
|
|
696
692
|
}
|
|
697
693
|
|
|
698
|
-
getRefundsFor(bundleRefunds: CombinedRefunds, relayer:
|
|
699
|
-
if (!bundleRefunds[chainId] || !bundleRefunds[chainId][token]) {
|
|
694
|
+
getRefundsFor(bundleRefunds: CombinedRefunds, relayer: Address, chainId: number, token: Address): BigNumber {
|
|
695
|
+
if (!bundleRefunds[chainId] || !bundleRefunds[chainId][token.toBytes32()]) {
|
|
700
696
|
return BigNumber.from(0);
|
|
701
697
|
}
|
|
702
|
-
const allRefunds = bundleRefunds[chainId][token];
|
|
703
|
-
return allRefunds && allRefunds[relayer] ? allRefunds[relayer] : BigNumber.from(0);
|
|
698
|
+
const allRefunds = bundleRefunds[chainId][token.toBytes32()];
|
|
699
|
+
return allRefunds && allRefunds[relayer.toBytes32()] ? allRefunds[relayer.toBytes32()] : BigNumber.from(0);
|
|
704
700
|
}
|
|
705
701
|
|
|
706
|
-
getTotalRefund(refunds: CombinedRefunds[], relayer:
|
|
702
|
+
getTotalRefund(refunds: CombinedRefunds[], relayer: Address, chainId: number, refundToken: Address): BigNumber {
|
|
707
703
|
return refunds.reduce((totalRefund, refunds) => {
|
|
708
704
|
return totalRefund.add(this.getRefundsFor(refunds, relayer, chainId, refundToken));
|
|
709
705
|
}, bnZero);
|
|
@@ -916,7 +912,11 @@ export class BundleDataClient {
|
|
|
916
912
|
"Not using correct bundle deposit hash key"
|
|
917
913
|
);
|
|
918
914
|
if (deposit.blockNumber >= originChainBlockRange[0]) {
|
|
919
|
-
if (
|
|
915
|
+
if (
|
|
916
|
+
bundleDepositsV3?.[originChainId]?.[deposit.inputToken.toBytes32()]?.find((d) =>
|
|
917
|
+
duplicateEvent(deposit, d)
|
|
918
|
+
)
|
|
919
|
+
) {
|
|
920
920
|
this.logger.debug({
|
|
921
921
|
at: "BundleDataClient#loadData",
|
|
922
922
|
message: "Duplicate deposit detected",
|