@across-protocol/sdk 4.2.16-alpha.5 → 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 +2 -2
- package/dist/cjs/arch/evm/SpokeUtils.js +6 -21
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.d.ts +1 -5
- package/dist/cjs/arch/svm/SpokeUtils.js +39 -30
- 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 +63 -63
- 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 +13 -13
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -10
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +11 -20
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +3 -7
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +32 -34
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +7 -7
- 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 +2 -2
- package/dist/esm/arch/evm/SpokeUtils.js +7 -22
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.d.ts +1 -5
- package/dist/esm/arch/svm/SpokeUtils.js +44 -31
- 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 +63 -63
- 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 +13 -13
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -10
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +12 -21
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +3 -8
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +34 -38
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +8 -8
- 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 +2 -2
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts +1 -5
- 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 +63 -63
- 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 +13 -13
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -10
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +3 -8
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- 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 +12 -47
- package/src/arch/svm/SpokeUtils.ts +42 -64
- 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 +13 -13
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +11 -31
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +39 -43
- package/src/relayFeeCalculator/relayFeeCalculator.ts +12 -20
- 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
|
@@ -24,20 +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
|
+
|
|
27
28
|
import { SYSTEM_PROGRAM_ADDRESS } from "@solana-program/system";
|
|
28
|
-
import {
|
|
29
|
-
Deposit,
|
|
30
|
-
DepositWithBlock,
|
|
31
|
-
FillStatus,
|
|
32
|
-
FillWithBlock,
|
|
33
|
-
RelayData,
|
|
34
|
-
RelayExecutionEventInfo,
|
|
35
|
-
} from "../../interfaces";
|
|
29
|
+
import { Deposit, DepositWithBlock, FillStatus, FillWithBlock, RelayData } from "../../interfaces";
|
|
36
30
|
import {
|
|
37
31
|
BigNumber,
|
|
38
32
|
EvmAddress,
|
|
39
33
|
SvmAddress,
|
|
40
|
-
Address as SdkAddress,
|
|
41
34
|
chainIsSvm,
|
|
42
35
|
chunk,
|
|
43
36
|
isUnsafeDepositId,
|
|
@@ -53,7 +46,6 @@ import {
|
|
|
53
46
|
toAddress,
|
|
54
47
|
unwrapEventData,
|
|
55
48
|
} from "./";
|
|
56
|
-
import { CHAIN_IDs } from "../../constants";
|
|
57
49
|
import { SVMEventNames, SVMProvider } from "./types";
|
|
58
50
|
|
|
59
51
|
/**
|
|
@@ -153,20 +145,13 @@ export async function findDeposit(
|
|
|
153
145
|
return undefined;
|
|
154
146
|
}
|
|
155
147
|
|
|
156
|
-
const unwrappedDepositEvent = unwrapEventData(depositEvent.data) as Record<string, unknown>;
|
|
157
|
-
const destinationChainId = unwrappedDepositEvent.destinationChainId as number;
|
|
158
148
|
// Return the deposit event with block info
|
|
159
149
|
return {
|
|
160
150
|
txnRef: depositEvent.signature.toString(),
|
|
161
151
|
blockNumber: Number(depositEvent.slot),
|
|
162
152
|
txnIndex: 0,
|
|
163
153
|
logIndex: 0,
|
|
164
|
-
...
|
|
165
|
-
depositor: toAddressType(unwrappedDepositEvent.depositor as string, CHAIN_IDs.SOLANA),
|
|
166
|
-
recipient: toAddressType(unwrappedDepositEvent.recipient as string, destinationChainId),
|
|
167
|
-
inputToken: toAddressType(unwrappedDepositEvent.inputToken as string, CHAIN_IDs.SOLANA),
|
|
168
|
-
outputToken: toAddressType(unwrappedDepositEvent.outputToken as string, destinationChainId),
|
|
169
|
-
exclusiveRelayer: toAddressType(unwrappedDepositEvent.exclusiveRelayer as string, destinationChainId),
|
|
154
|
+
...(unwrapEventData(depositEvent.data) as Record<string, unknown>),
|
|
170
155
|
} as DepositWithBlock;
|
|
171
156
|
}
|
|
172
157
|
|
|
@@ -342,34 +327,14 @@ export async function findFillEvent(
|
|
|
342
327
|
|
|
343
328
|
if (fillEvents.length > 0) {
|
|
344
329
|
const rawFillEvent = fillEvents[0];
|
|
345
|
-
const eventData = unwrapEventData(rawFillEvent.data) as FillWithBlock & {
|
|
346
|
-
depositor: string;
|
|
347
|
-
recipient: string;
|
|
348
|
-
inputToken: string;
|
|
349
|
-
outputToken: string;
|
|
350
|
-
exclusiveRelayer: string;
|
|
351
|
-
relayer: string;
|
|
352
|
-
relayExecutionInfo: RelayExecutionEventInfo & { updatedRecipient: string };
|
|
353
|
-
};
|
|
354
|
-
const originChainId = eventData.originChainId;
|
|
355
330
|
const parsedFillEvent = {
|
|
356
|
-
...eventData,
|
|
357
331
|
transactionHash: rawFillEvent.signature,
|
|
358
332
|
blockNumber: Number(rawFillEvent.slot),
|
|
359
333
|
transactionIndex: 0,
|
|
360
334
|
logIndex: 0,
|
|
361
335
|
destinationChainId,
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
relayer: toAddressType(eventData.relayer, destinationChainId),
|
|
365
|
-
exclusiveRelayer: toAddressType(eventData.exclusiveRelayer, destinationChainId),
|
|
366
|
-
depositor: toAddressType(eventData.depositor, originChainId),
|
|
367
|
-
recipient: toAddressType(eventData.recipient, destinationChainId),
|
|
368
|
-
relayExecutionInfo: {
|
|
369
|
-
...eventData.relayExecutionInfo,
|
|
370
|
-
updatedRecipient: eventData.relayExecutionInfo.updatedRecipient,
|
|
371
|
-
},
|
|
372
|
-
} as FillWithBlock;
|
|
336
|
+
...(unwrapEventData(rawFillEvent.data) as Record<string, unknown>),
|
|
337
|
+
} as unknown as FillWithBlock;
|
|
373
338
|
return parsedFillEvent;
|
|
374
339
|
}
|
|
375
340
|
|
|
@@ -385,14 +350,7 @@ export async function findFillEvent(
|
|
|
385
350
|
*/
|
|
386
351
|
export async function fillRelayInstruction(
|
|
387
352
|
spokePool: SvmAddress,
|
|
388
|
-
deposit: Omit<
|
|
389
|
-
Deposit,
|
|
390
|
-
"recipient" | "outputToken" | "exclusiveRelayer" | "messageHash" | "fromLiteChain" | "toLiteChain"
|
|
391
|
-
> & {
|
|
392
|
-
recipient: SvmAddress;
|
|
393
|
-
outputToken: SvmAddress;
|
|
394
|
-
exclusiveRelayer: SvmAddress;
|
|
395
|
-
},
|
|
353
|
+
deposit: Omit<Deposit, "messageHash" | "fromLiteChain" | "toLiteChain">,
|
|
396
354
|
signer: TransactionSigner<string>,
|
|
397
355
|
recipientTokenAccount: Address<string>,
|
|
398
356
|
repaymentAddress: EvmAddress | SvmAddress = SvmAddress.from(signer.address),
|
|
@@ -409,16 +367,19 @@ export async function fillRelayInstruction(
|
|
|
409
367
|
const relayDataHash = new Uint8Array(Buffer.from(_relayDataHash.slice(2), "hex"));
|
|
410
368
|
|
|
411
369
|
const relayer = SvmAddress.from(signer.address);
|
|
370
|
+
const outputTokenAddress = toAddressType(deposit.outputToken, deposit.destinationChainId);
|
|
371
|
+
if (!(outputTokenAddress instanceof SvmAddress)) {
|
|
372
|
+
return undefined;
|
|
373
|
+
}
|
|
412
374
|
|
|
413
375
|
// Create ATA for the relayer and recipient token accounts
|
|
414
|
-
const relayerTokenAccount = await getAssociatedTokenAddress(relayer,
|
|
376
|
+
const relayerTokenAccount = await getAssociatedTokenAddress(relayer, outputTokenAddress);
|
|
415
377
|
|
|
416
378
|
const [statePda, fillStatusPda, eventAuthority] = await Promise.all([
|
|
417
379
|
getStatePda(program),
|
|
418
380
|
getFillStatusPda(program, deposit, deposit.destinationChainId),
|
|
419
|
-
getEventAuthority(
|
|
381
|
+
getEventAuthority(),
|
|
420
382
|
]);
|
|
421
|
-
|
|
422
383
|
const depositIdBuffer = new Uint8Array(32);
|
|
423
384
|
const shortenedBuffer = new Uint8Array(Buffer.from(deposit.depositId.toHexString().slice(2), "hex"));
|
|
424
385
|
depositIdBuffer.set(shortenedBuffer, 32 - shortenedBuffer.length);
|
|
@@ -430,14 +391,26 @@ export async function fillRelayInstruction(
|
|
|
430
391
|
program
|
|
431
392
|
);
|
|
432
393
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
deposit.
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
394
|
+
// @todo we need to convert the deposit's relayData to svm-like since the interface assumes the data originates
|
|
395
|
+
// from an EVM Spoke pool. Once we migrate to `Address` types, this can be modified/removed.
|
|
396
|
+
const [depositor, inputToken] = [deposit.depositor, deposit.inputToken].map((addr: string) => {
|
|
397
|
+
const addressObj = toAddressType(addr, deposit.originChainId);
|
|
398
|
+
// @dev we don't really care for correctness of format of depositor / inputToken, so we're fine converting to Solana
|
|
399
|
+
// SDK `Address<string>` type even if our `toAddressType` function returned a raw address.
|
|
400
|
+
return addressObj.toBase58() as Address<string>;
|
|
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;
|
|
440
412
|
|
|
413
|
+
const outputToken = toAddress(outputTokenAddress);
|
|
441
414
|
return SvmSpokeClient.getFillRelayInstruction({
|
|
442
415
|
signer,
|
|
443
416
|
state: statePda,
|
|
@@ -643,14 +616,19 @@ export function getRelayDataHash(relayData: RelayData, destinationChainId: numbe
|
|
|
643
616
|
const uint32Encoder = getU32Encoder();
|
|
644
617
|
|
|
645
618
|
assert(relayData.message.startsWith("0x"), "Message must be a hex string");
|
|
646
|
-
const encodeAddress = (
|
|
619
|
+
const encodeAddress = (addr: string, chainId: number) => {
|
|
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
|
+
};
|
|
647
625
|
|
|
648
626
|
const contentToHash = Buffer.concat([
|
|
649
|
-
encodeAddress(relayData.depositor),
|
|
650
|
-
encodeAddress(relayData.recipient),
|
|
651
|
-
encodeAddress(relayData.exclusiveRelayer),
|
|
652
|
-
encodeAddress(relayData.inputToken),
|
|
653
|
-
encodeAddress(relayData.outputToken),
|
|
627
|
+
encodeAddress(relayData.depositor, relayData.originChainId),
|
|
628
|
+
encodeAddress(relayData.recipient, destinationChainId),
|
|
629
|
+
encodeAddress(relayData.exclusiveRelayer, destinationChainId),
|
|
630
|
+
encodeAddress(relayData.inputToken, relayData.originChainId),
|
|
631
|
+
encodeAddress(relayData.outputToken, destinationChainId),
|
|
654
632
|
Uint8Array.from(uint64Encoder.encode(BigInt(relayData.inputAmount.toString()))),
|
|
655
633
|
Uint8Array.from(uint64Encoder.encode(BigInt(relayData.outputAmount.toString()))),
|
|
656
634
|
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
|
|
13
|
+
import { bs58, chainIsSvm, getMessageHash } 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,6 +252,7 @@ export class SvmCpiEventsClient {
|
|
|
252
252
|
|
|
253
253
|
// Filter for FundsDeposited events only
|
|
254
254
|
const depositEvents = events?.filter((event) => event?.name === "FundsDeposited");
|
|
255
|
+
|
|
255
256
|
if (!txDetails || !depositEvents?.length) {
|
|
256
257
|
return;
|
|
257
258
|
}
|
|
@@ -260,29 +261,13 @@ export class SvmCpiEventsClient {
|
|
|
260
261
|
const unwrappedEventArgs = unwrapEventData(event as Record<string, unknown>, ["depositId"]) as Record<
|
|
261
262
|
"data",
|
|
262
263
|
Deposit
|
|
263
|
-
|
|
264
|
-
|
|
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;
|
|
264
|
+
>;
|
|
265
|
+
|
|
276
266
|
return {
|
|
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),
|
|
267
|
+
...unwrappedEventArgs.data,
|
|
283
268
|
depositTimestamp: Number(txDetails.blockTime),
|
|
284
269
|
originChainId,
|
|
285
|
-
messageHash: getMessageHash(data.message),
|
|
270
|
+
messageHash: getMessageHash(unwrappedEventArgs.data.message),
|
|
286
271
|
blockNumber: Number(txDetails.slot),
|
|
287
272
|
txnIndex: 0,
|
|
288
273
|
txnRef: txSignature,
|
|
@@ -324,26 +309,9 @@ export class SvmCpiEventsClient {
|
|
|
324
309
|
}
|
|
325
310
|
|
|
326
311
|
return fillEvents.map((event) => {
|
|
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;
|
|
312
|
+
const unwrappedEventData = unwrapEventData(event as Record<string, unknown>) as Record<"data", Fill>;
|
|
340
313
|
return {
|
|
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),
|
|
314
|
+
...unwrappedEventData.data,
|
|
347
315
|
fillTimestamp: Number(txDetails.blockTime),
|
|
348
316
|
blockNumber: Number(txDetails.slot),
|
|
349
317
|
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, EvmAddress, SvmAddress, getRelayDataHash, isUint8Array } 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: EvmAddress | SvmAddress): 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 SvmAddress.from(data).toBytes32();
|
|
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 async
|
|
283
|
+
export const getEventAuthority = async () => {
|
|
284
284
|
const [eventAuthority] = await getProgramDerivedAddress({
|
|
285
|
-
programAddress:
|
|
285
|
+
programAddress: address(SvmSpokeClient.SVM_SPOKE_PROGRAM_ADDRESS),
|
|
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,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;
|