@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
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { Fill, RelayData, SlowFillLeaf } from "../interfaces";
|
|
1
|
+
import { Deposit, Fill, RelayData, SlowFillLeaf } from "../interfaces";
|
|
2
2
|
import { BigNumber } from "./BigNumberUtils";
|
|
3
|
-
import { Address } from "./AddressUtils";
|
|
4
3
|
export declare function isSlowFill(fill: Fill): boolean;
|
|
5
4
|
export declare function getSlowFillLeafLpFeePct(leaf: SlowFillLeaf): BigNumber;
|
|
5
|
+
/**
|
|
6
|
+
* Produce the RelayData for a Deposit.
|
|
7
|
+
* @param deposit Deposit instance.
|
|
8
|
+
* @returns The corresponding RelayData object.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getDepositRelayData(deposit: Omit<Deposit, "messageHash">): RelayData;
|
|
6
11
|
/**
|
|
7
12
|
* Compute the RelayData hash for a fill. This can be used to determine the fill status.
|
|
8
13
|
* @param relayData RelayData information that is used to complete a fill.
|
|
@@ -14,6 +19,6 @@ export declare function getRelayHashFromEvent(e: RelayData & {
|
|
|
14
19
|
destinationChainId: number;
|
|
15
20
|
}): string;
|
|
16
21
|
export declare function isUnsafeDepositId(depositId: BigNumber): boolean;
|
|
17
|
-
export declare function isZeroAddress(address:
|
|
22
|
+
export declare function isZeroAddress(address: string): boolean;
|
|
18
23
|
export declare function getMessageHash(message: string): string;
|
|
19
24
|
//# sourceMappingURL=SpokeUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpokeUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/SpokeUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAY,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"SpokeUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/SpokeUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAY,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEjF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAK7C,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAE9C;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,YAAY,GAAG,SAAS,CAGrE;AACD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,GAAG,SAAS,CAepF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,GAAG,MAAM,CAkCzF;AAED,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,SAAS,GAAG;IAAE,kBAAkB,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAE3F;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAQ/D;AAGD,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BlockTag } from "@ethersproject/abstract-provider";
|
|
2
2
|
import { providers, Signer } from "ethers";
|
|
3
|
-
import {
|
|
3
|
+
import { L1Token } from "../interfaces";
|
|
4
4
|
import { BigNumber } from "./BigNumberUtils";
|
|
5
5
|
type SignerOrProvider = providers.Provider | Signer;
|
|
6
|
-
export declare function fetchTokenInfo(address: string, signerOrProvider: SignerOrProvider): Promise<
|
|
6
|
+
export declare function fetchTokenInfo(address: string, signerOrProvider: SignerOrProvider): Promise<L1Token>;
|
|
7
7
|
export declare const getL2TokenAddresses: (l1TokenAddress: string, l1ChainId?: number) => {
|
|
8
8
|
[chainId: number]: string;
|
|
9
9
|
} | undefined;
|
|
@@ -14,7 +14,7 @@ export declare const getL2TokenAddresses: (l1TokenAddress: string, l1ChainId?: n
|
|
|
14
14
|
* @param chainId Chain ID to query on.
|
|
15
15
|
* @returns Symbol, decimals and contract address on the requested chain.
|
|
16
16
|
*/
|
|
17
|
-
export declare function resolveSymbolOnChain(chainId: number, symbol: string):
|
|
17
|
+
export declare function resolveSymbolOnChain(chainId: number, symbol: string): L1Token;
|
|
18
18
|
/**
|
|
19
19
|
* Returns the contract address for a given token symbol and chainId.
|
|
20
20
|
* @param symbol A case-insensitive token symbol.
|
|
@@ -124,7 +124,13 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
|
|
|
124
124
|
};
|
|
125
125
|
GHO: {
|
|
126
126
|
name: string;
|
|
127
|
-
symbol: string;
|
|
127
|
+
symbol: string; /**
|
|
128
|
+
* Returns the contract address for a given token symbol and chainId.
|
|
129
|
+
* @param symbol A case-insensitive token symbol.
|
|
130
|
+
* @param chainId The chainId to resolve the contract address for.
|
|
131
|
+
* @param tokenMapping A parameter to determine where to source token information. Defaults to the constants variant.
|
|
132
|
+
* @returns The contract address for the given token symbol and chainId, or undefined if the token symbol is not supported.
|
|
133
|
+
*/
|
|
128
134
|
decimals: number;
|
|
129
135
|
addresses: {
|
|
130
136
|
[x: number]: string;
|
|
@@ -185,14 +191,6 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
|
|
|
185
191
|
};
|
|
186
192
|
coingeckoId: string;
|
|
187
193
|
};
|
|
188
|
-
/**
|
|
189
|
-
* Retrieves the ERC20 balance for a given address and token address.
|
|
190
|
-
* @param address The address to retrieve the balance for.
|
|
191
|
-
* @param tokenAddress The token address
|
|
192
|
-
* @param signerOrProvider A valid ethers.js Signer or Provider object.
|
|
193
|
-
* @param blockTag The block tag to retrieve the balance at.
|
|
194
|
-
* @returns The balance of the given address for the given token address.
|
|
195
|
-
*/
|
|
196
194
|
SOL: {
|
|
197
195
|
name: string;
|
|
198
196
|
symbol: string;
|
|
@@ -547,7 +545,13 @@ export declare function getTokenInfo(l2TokenAddress: string, chainId: number, to
|
|
|
547
545
|
};
|
|
548
546
|
GHO: {
|
|
549
547
|
name: string;
|
|
550
|
-
symbol: string;
|
|
548
|
+
symbol: string; /**
|
|
549
|
+
* Returns the contract address for a given token symbol and chainId.
|
|
550
|
+
* @param symbol A case-insensitive token symbol.
|
|
551
|
+
* @param chainId The chainId to resolve the contract address for.
|
|
552
|
+
* @param tokenMapping A parameter to determine where to source token information. Defaults to the constants variant.
|
|
553
|
+
* @returns The contract address for the given token symbol and chainId, or undefined if the token symbol is not supported.
|
|
554
|
+
*/
|
|
551
555
|
decimals: number;
|
|
552
556
|
addresses: {
|
|
553
557
|
[x: number]: string;
|
|
@@ -608,14 +612,6 @@ export declare function getTokenInfo(l2TokenAddress: string, chainId: number, to
|
|
|
608
612
|
};
|
|
609
613
|
coingeckoId: string;
|
|
610
614
|
};
|
|
611
|
-
/**
|
|
612
|
-
* Retrieves the ERC20 balance for a given address and token address.
|
|
613
|
-
* @param address The address to retrieve the balance for.
|
|
614
|
-
* @param tokenAddress The token address
|
|
615
|
-
* @param signerOrProvider A valid ethers.js Signer or Provider object.
|
|
616
|
-
* @param blockTag The block tag to retrieve the balance at.
|
|
617
|
-
* @returns The balance of the given address for the given token address.
|
|
618
|
-
*/
|
|
619
615
|
SOL: {
|
|
620
616
|
name: string;
|
|
621
617
|
symbol: string;
|
|
@@ -846,7 +842,7 @@ export declare function getTokenInfo(l2TokenAddress: string, chainId: number, to
|
|
|
846
842
|
};
|
|
847
843
|
coingeckoId: string;
|
|
848
844
|
};
|
|
849
|
-
}):
|
|
845
|
+
}): L1Token;
|
|
850
846
|
/**
|
|
851
847
|
* Get the USDC symbol for the given token address and chain ID.
|
|
852
848
|
* @param l2Token A Web3 token address (not case sensitive)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/TokenUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TokenUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/TokenUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAY,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAM7C,KAAK,gBAAgB,GAAG,SAAS,CAAC,QAAQ,GAAG,MAAM,CAAC;AAEpD,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAI1G;AAED,eAAO,MAAM,mBAAmB,mBACd,MAAM;;aAMvB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAY7E;AAED;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,WAC5B,MAAM,WACL,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBATjB;;;;;;WAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAKA,MAAM,GAAG,SAIX,CAAC;AAEF,wBAAgB,4BAA4B,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAM7F;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,GAAE,QAAmB,GAC5B,OAAO,CAAC,SAAS,CAAC,CAGpB;AAED,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAI1D;AAED,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAIzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAhElF;;;;;;WAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DmG,GAAG,OAAO,CAoB/G;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOlF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAUjF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@across-protocol/sdk",
|
|
3
3
|
"author": "UMA Team",
|
|
4
|
-
"version": "4.2.16
|
|
4
|
+
"version": "4.2.16",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"homepage": "https://docs.across.to/reference/sdk",
|
|
7
7
|
"files": [
|
|
@@ -111,6 +111,7 @@
|
|
|
111
111
|
"@ethersproject/bignumber": "^5.7.0",
|
|
112
112
|
"@pinata/sdk": "^2.1.0",
|
|
113
113
|
"@solana-program/system": "^0.7.0",
|
|
114
|
+
"@solana-program/token": "^0.5.1",
|
|
114
115
|
"@solana-program/token-2022": "^0.4.0",
|
|
115
116
|
"@solana/kit": "^2.1.0",
|
|
116
117
|
"@solana/web3.js": "^1.31.0",
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
2
|
import { BytesLike, Contract, PopulatedTransaction, providers } from "ethers";
|
|
3
3
|
import { CHAIN_IDs } from "../../constants";
|
|
4
|
-
import {
|
|
5
|
-
Deposit,
|
|
6
|
-
FillStatus,
|
|
7
|
-
FillWithBlock,
|
|
8
|
-
RelayData,
|
|
9
|
-
RelayExecutionEventInfo,
|
|
10
|
-
SpeedUpCommon,
|
|
11
|
-
} from "../../interfaces";
|
|
4
|
+
import { Deposit, FillStatus, FillWithBlock, RelayData } from "../../interfaces";
|
|
12
5
|
import {
|
|
13
6
|
bnUint32Max,
|
|
14
7
|
BigNumber,
|
|
15
|
-
EvmAddress,
|
|
16
8
|
toBN,
|
|
17
9
|
bnZero,
|
|
18
10
|
chunk,
|
|
@@ -20,70 +12,47 @@ import {
|
|
|
20
12
|
getRelayDataHash,
|
|
21
13
|
isDefined,
|
|
22
14
|
isUnsafeDepositId,
|
|
15
|
+
isZeroAddress,
|
|
16
|
+
getDepositRelayData,
|
|
23
17
|
getNetworkName,
|
|
24
18
|
paginatedEventQuery,
|
|
25
19
|
spreadEventWithBlockNumber,
|
|
26
|
-
|
|
27
|
-
toAddressType,
|
|
20
|
+
toBytes32,
|
|
28
21
|
} from "../../utils";
|
|
29
22
|
|
|
30
23
|
type BlockTag = providers.BlockTag;
|
|
31
24
|
|
|
32
|
-
type ProtoFill = Omit<RelayData, "recipient" | "outputToken"> &
|
|
33
|
-
Pick<Deposit, "speedUpSignature"> &
|
|
34
|
-
Partial<SpeedUpCommon> & {
|
|
35
|
-
destinationChainId: number;
|
|
36
|
-
recipient: EvmAddress;
|
|
37
|
-
outputToken: EvmAddress;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
25
|
/**
|
|
41
26
|
* @param spokePool SpokePool Contract instance.
|
|
42
|
-
* @param
|
|
27
|
+
* @param deposit V3Deopsit instance.
|
|
43
28
|
* @param repaymentChainId Optional repaymentChainId (defaults to destinationChainId).
|
|
44
29
|
* @returns An Ethers UnsignedTransaction instance.
|
|
45
30
|
*/
|
|
46
31
|
export function populateV3Relay(
|
|
47
32
|
spokePool: Contract,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
repaymentChainId =
|
|
33
|
+
deposit: Omit<Deposit, "messageHash">,
|
|
34
|
+
relayer: string,
|
|
35
|
+
repaymentChainId = deposit.destinationChainId
|
|
51
36
|
): Promise<PopulatedTransaction> {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
recipient: relayData.recipient.toBytes32(),
|
|
59
|
-
inputToken: relayData.inputToken.toBytes32(),
|
|
60
|
-
outputToken: relayData.outputToken.toBytes32(),
|
|
61
|
-
inputAmount: relayData.inputAmount,
|
|
62
|
-
outputAmount: relayData.outputAmount,
|
|
63
|
-
originChainId: relayData.originChainId,
|
|
64
|
-
depositId: relayData.depositId,
|
|
65
|
-
fillDeadline: relayData.fillDeadline,
|
|
66
|
-
exclusivityDeadline: relayData.exclusivityDeadline,
|
|
67
|
-
message: relayData.message,
|
|
68
|
-
exclusiveRelayer: relayData.exclusiveRelayer.toBytes32(),
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
if (isDefined(relayData.speedUpSignature)) {
|
|
72
|
-
assert(isDefined(relayData.updatedRecipient) && !relayData.updatedRecipient.isZeroAddress());
|
|
73
|
-
assert(isDefined(relayData.updatedOutputAmount));
|
|
74
|
-
assert(isDefined(relayData.updatedMessage));
|
|
37
|
+
const relayData = getDepositRelayData(deposit);
|
|
38
|
+
|
|
39
|
+
if (isDefined(deposit.speedUpSignature)) {
|
|
40
|
+
assert(isDefined(deposit.updatedRecipient) && !isZeroAddress(deposit.updatedRecipient));
|
|
41
|
+
assert(isDefined(deposit.updatedOutputAmount));
|
|
42
|
+
assert(isDefined(deposit.updatedMessage));
|
|
75
43
|
return spokePool.populateTransaction.fillRelayWithUpdatedDeposit(
|
|
76
44
|
relayData,
|
|
77
45
|
repaymentChainId,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
46
|
+
toBytes32(relayer),
|
|
47
|
+
deposit.updatedOutputAmount,
|
|
48
|
+
toBytes32(deposit.updatedRecipient),
|
|
49
|
+
deposit.updatedMessage,
|
|
50
|
+
deposit.speedUpSignature,
|
|
51
|
+
{ from: relayer }
|
|
83
52
|
);
|
|
84
53
|
}
|
|
85
54
|
|
|
86
|
-
return spokePool.populateTransaction.fillRelay(
|
|
55
|
+
return spokePool.populateTransaction.fillRelay(relayData, repaymentChainId, toBytes32(relayer), { from: relayer });
|
|
87
56
|
}
|
|
88
57
|
|
|
89
58
|
/**
|
|
@@ -346,27 +315,8 @@ export async function findFillEvent(
|
|
|
346
315
|
const destinationChainId = Object.values(CHAIN_IDs).includes(relayData.originChainId)
|
|
347
316
|
? (await spokePool.provider.getNetwork()).chainId
|
|
348
317
|
: Number(await spokePool.chainId());
|
|
349
|
-
const fillEvent = spreadEventWithBlockNumber(event) as FillWithBlock & {
|
|
350
|
-
depositor: string;
|
|
351
|
-
recipient: string;
|
|
352
|
-
inputToken: string;
|
|
353
|
-
outputToken: string;
|
|
354
|
-
exclusiveRelayer: string;
|
|
355
|
-
relayer: string;
|
|
356
|
-
relayExecutionInfo: RelayExecutionEventInfo & { updatedRecipient: string };
|
|
357
|
-
};
|
|
358
318
|
const fill = {
|
|
359
|
-
...
|
|
360
|
-
inputToken: toAddressType(fillEvent.inputToken, relayData.originChainId),
|
|
361
|
-
outputToken: toAddressType(fillEvent.outputToken, destinationChainId),
|
|
362
|
-
depositor: toAddressType(fillEvent.depositor, relayData.originChainId),
|
|
363
|
-
recipient: toAddressType(fillEvent.recipient, destinationChainId),
|
|
364
|
-
exclusiveRelayer: toAddressType(fillEvent.exclusiveRelayer, destinationChainId),
|
|
365
|
-
relayer: toAddressType(fillEvent.relayer, destinationChainId),
|
|
366
|
-
relayExecutionInfo: {
|
|
367
|
-
...fillEvent.relayExecutionInfo,
|
|
368
|
-
updatedRecipient: toAddressType(fillEvent.relayExecutionInfo.updatedRecipient, destinationChainId),
|
|
369
|
-
},
|
|
319
|
+
...spreadEventWithBlockNumber(event),
|
|
370
320
|
destinationChainId,
|
|
371
321
|
messageHash: getMessageHash(event.args.message),
|
|
372
322
|
} as FillWithBlock;
|
|
@@ -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
|
+
|
|
27
28
|
import { SYSTEM_PROGRAM_ADDRESS } from "@solana-program/system";
|
|
28
|
-
import { DepositWithBlock, FillStatus, FillWithBlock, RelayData
|
|
29
|
+
import { Deposit, DepositWithBlock, FillStatus, FillWithBlock, RelayData } from "../../interfaces";
|
|
29
30
|
import {
|
|
30
31
|
BigNumber,
|
|
31
32
|
EvmAddress,
|
|
32
33
|
SvmAddress,
|
|
33
|
-
Address as SdkAddress,
|
|
34
34
|
chainIsSvm,
|
|
35
35
|
chunk,
|
|
36
36
|
isUnsafeDepositId,
|
|
@@ -46,7 +46,6 @@ import {
|
|
|
46
46
|
toAddress,
|
|
47
47
|
unwrapEventData,
|
|
48
48
|
} from "./";
|
|
49
|
-
import { CHAIN_IDs } from "../../constants";
|
|
50
49
|
import { SVMEventNames, SVMProvider } from "./types";
|
|
51
50
|
|
|
52
51
|
/**
|
|
@@ -55,12 +54,6 @@ import { SVMEventNames, SVMProvider } from "./types";
|
|
|
55
54
|
*/
|
|
56
55
|
export const SLOT_DURATION_MS = 400;
|
|
57
56
|
|
|
58
|
-
type ProtoFill = Omit<RelayData, "recipient" | "outputToken"> & {
|
|
59
|
-
destinationChainId: number;
|
|
60
|
-
recipient: SvmAddress;
|
|
61
|
-
outputToken: SvmAddress;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
57
|
/**
|
|
65
58
|
* Retrieves the chain time at a particular slot.
|
|
66
59
|
*/
|
|
@@ -152,20 +145,13 @@ export async function findDeposit(
|
|
|
152
145
|
return undefined;
|
|
153
146
|
}
|
|
154
147
|
|
|
155
|
-
const unwrappedDepositEvent = unwrapEventData(depositEvent.data) as Record<string, unknown>;
|
|
156
|
-
const destinationChainId = unwrappedDepositEvent.destinationChainId as number;
|
|
157
148
|
// Return the deposit event with block info
|
|
158
149
|
return {
|
|
159
150
|
txnRef: depositEvent.signature.toString(),
|
|
160
151
|
blockNumber: Number(depositEvent.slot),
|
|
161
152
|
txnIndex: 0,
|
|
162
153
|
logIndex: 0,
|
|
163
|
-
...
|
|
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),
|
|
154
|
+
...(unwrapEventData(depositEvent.data) as Record<string, unknown>),
|
|
169
155
|
} as DepositWithBlock;
|
|
170
156
|
}
|
|
171
157
|
|
|
@@ -341,34 +327,14 @@ export async function findFillEvent(
|
|
|
341
327
|
|
|
342
328
|
if (fillEvents.length > 0) {
|
|
343
329
|
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;
|
|
354
330
|
const parsedFillEvent = {
|
|
355
|
-
...eventData,
|
|
356
331
|
transactionHash: rawFillEvent.signature,
|
|
357
332
|
blockNumber: Number(rawFillEvent.slot),
|
|
358
333
|
transactionIndex: 0,
|
|
359
334
|
logIndex: 0,
|
|
360
335
|
destinationChainId,
|
|
361
|
-
|
|
362
|
-
|
|
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;
|
|
336
|
+
...(unwrapEventData(rawFillEvent.data) as Record<string, unknown>),
|
|
337
|
+
} as unknown as FillWithBlock;
|
|
372
338
|
return parsedFillEvent;
|
|
373
339
|
}
|
|
374
340
|
|
|
@@ -377,18 +343,18 @@ export async function findFillEvent(
|
|
|
377
343
|
|
|
378
344
|
/**
|
|
379
345
|
* @param spokePool Address (program ID) of the SvmSpoke.
|
|
380
|
-
* @param
|
|
346
|
+
* @param deposit V3Deopsit instance.
|
|
381
347
|
* @param relayer Address of the relayer filling the deposit.
|
|
382
348
|
* @param repaymentChainId Optional repaymentChainId (defaults to destinationChainId).
|
|
383
349
|
* @returns An Ethers UnsignedTransaction instance.
|
|
384
350
|
*/
|
|
385
351
|
export async function fillRelayInstruction(
|
|
386
352
|
spokePool: SvmAddress,
|
|
387
|
-
|
|
353
|
+
deposit: Omit<Deposit, "messageHash" | "fromLiteChain" | "toLiteChain">,
|
|
388
354
|
signer: TransactionSigner<string>,
|
|
389
355
|
recipientTokenAccount: Address<string>,
|
|
390
356
|
repaymentAddress: EvmAddress | SvmAddress = SvmAddress.from(signer.address),
|
|
391
|
-
repaymentChainId =
|
|
357
|
+
repaymentChainId = deposit.destinationChainId
|
|
392
358
|
) {
|
|
393
359
|
const program = toAddress(spokePool);
|
|
394
360
|
|
|
@@ -397,22 +363,25 @@ export async function fillRelayInstruction(
|
|
|
397
363
|
`Invalid repayment address for chain ${repaymentChainId}: ${repaymentAddress.toNative()}.`
|
|
398
364
|
);
|
|
399
365
|
|
|
400
|
-
const _relayDataHash = getRelayDataHash(
|
|
366
|
+
const _relayDataHash = getRelayDataHash(deposit, deposit.destinationChainId);
|
|
401
367
|
const relayDataHash = new Uint8Array(Buffer.from(_relayDataHash.slice(2), "hex"));
|
|
402
368
|
|
|
403
369
|
const relayer = SvmAddress.from(signer.address);
|
|
370
|
+
const outputTokenAddress = toAddressType(deposit.outputToken, deposit.destinationChainId);
|
|
371
|
+
if (!(outputTokenAddress instanceof SvmAddress)) {
|
|
372
|
+
return undefined;
|
|
373
|
+
}
|
|
404
374
|
|
|
405
375
|
// Create ATA for the relayer and recipient token accounts
|
|
406
|
-
const relayerTokenAccount = await getAssociatedTokenAddress(relayer,
|
|
376
|
+
const relayerTokenAccount = await getAssociatedTokenAddress(relayer, outputTokenAddress);
|
|
407
377
|
|
|
408
378
|
const [statePda, fillStatusPda, eventAuthority] = await Promise.all([
|
|
409
379
|
getStatePda(program),
|
|
410
|
-
getFillStatusPda(program,
|
|
411
|
-
getEventAuthority(
|
|
380
|
+
getFillStatusPda(program, deposit, deposit.destinationChainId),
|
|
381
|
+
getEventAuthority(),
|
|
412
382
|
]);
|
|
413
|
-
|
|
414
383
|
const depositIdBuffer = new Uint8Array(32);
|
|
415
|
-
const shortenedBuffer = new Uint8Array(Buffer.from(
|
|
384
|
+
const shortenedBuffer = new Uint8Array(Buffer.from(deposit.depositId.toHexString().slice(2), "hex"));
|
|
416
385
|
depositIdBuffer.set(shortenedBuffer, 32 - shortenedBuffer.length);
|
|
417
386
|
|
|
418
387
|
const delegatePda = await getFillRelayDelegatePda(
|
|
@@ -422,14 +391,26 @@ export async function fillRelayInstruction(
|
|
|
422
391
|
program
|
|
423
392
|
);
|
|
424
393
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
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;
|
|
432
412
|
|
|
413
|
+
const outputToken = toAddress(outputTokenAddress);
|
|
433
414
|
return SvmSpokeClient.getFillRelayInstruction({
|
|
434
415
|
signer,
|
|
435
416
|
state: statePda,
|
|
@@ -447,13 +428,13 @@ export async function fillRelayInstruction(
|
|
|
447
428
|
exclusiveRelayer,
|
|
448
429
|
inputToken,
|
|
449
430
|
outputToken,
|
|
450
|
-
inputAmount:
|
|
451
|
-
outputAmount:
|
|
452
|
-
originChainId: BigInt(
|
|
453
|
-
fillDeadline:
|
|
454
|
-
exclusivityDeadline:
|
|
431
|
+
inputAmount: deposit.inputAmount.toBigInt(),
|
|
432
|
+
outputAmount: deposit.outputAmount.toBigInt(),
|
|
433
|
+
originChainId: BigInt(deposit.originChainId),
|
|
434
|
+
fillDeadline: deposit.fillDeadline,
|
|
435
|
+
exclusivityDeadline: deposit.exclusivityDeadline,
|
|
455
436
|
depositId: depositIdBuffer,
|
|
456
|
-
message: new Uint8Array(Buffer.from(
|
|
437
|
+
message: new Uint8Array(Buffer.from(deposit.message.slice(2), "hex")),
|
|
457
438
|
}),
|
|
458
439
|
repaymentChainId: some(BigInt(repaymentChainId)),
|
|
459
440
|
repaymentAddress: toAddress(repaymentAddress),
|
|
@@ -635,14 +616,19 @@ export function getRelayDataHash(relayData: RelayData, destinationChainId: numbe
|
|
|
635
616
|
const uint32Encoder = getU32Encoder();
|
|
636
617
|
|
|
637
618
|
assert(relayData.message.startsWith("0x"), "Message must be a hex string");
|
|
638
|
-
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
|
+
};
|
|
639
625
|
|
|
640
626
|
const contentToHash = Buffer.concat([
|
|
641
|
-
encodeAddress(relayData.depositor),
|
|
642
|
-
encodeAddress(relayData.recipient),
|
|
643
|
-
encodeAddress(relayData.exclusiveRelayer),
|
|
644
|
-
encodeAddress(relayData.inputToken),
|
|
645
|
-
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),
|
|
646
632
|
Uint8Array.from(uint64Encoder.encode(BigInt(relayData.inputAmount.toString()))),
|
|
647
633
|
Uint8Array.from(uint64Encoder.encode(BigInt(relayData.outputAmount.toString()))),
|
|
648
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.
|