@across-protocol/sdk 4.3.106-beta.0 → 4.3.106
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/svm/SpokeUtils.d.ts +1 -8
- package/dist/cjs/arch/svm/SpokeUtils.js +3 -26
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/encoders.d.ts +0 -1
- package/dist/cjs/arch/svm/encoders.js +0 -4
- package/dist/cjs/arch/svm/encoders.js.map +1 -1
- package/dist/cjs/arch/svm/eventsClient.js +1 -1
- package/dist/cjs/arch/svm/eventsClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +4 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/constants.js +0 -3
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/gasPriceOracle/oracle.js +0 -1
- package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
- package/dist/cjs/providers/solana/utils.d.ts +0 -13
- package/dist/cjs/providers/solana/utils.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +0 -6
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +27 -77
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/utils/Multicall.js +1 -2
- package/dist/cjs/utils/Multicall.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.d.ts +1 -27
- package/dist/esm/arch/svm/SpokeUtils.js +3 -44
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/encoders.d.ts +0 -1
- package/dist/esm/arch/svm/encoders.js +0 -3
- package/dist/esm/arch/svm/encoders.js.map +1 -1
- package/dist/esm/arch/svm/eventsClient.js +1 -1
- package/dist/esm/arch/svm/eventsClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +5 -2
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/constants.js +0 -3
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/gasPriceOracle/oracle.js +0 -1
- package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
- package/dist/esm/providers/solana/utils.d.ts +0 -13
- package/dist/esm/providers/solana/utils.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +0 -6
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +31 -82
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/utils/Multicall.js +1 -2
- package/dist/esm/utils/Multicall.js.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts +1 -27
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/encoders.d.ts +0 -1
- package/dist/types/arch/svm/encoders.d.ts.map +1 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
- package/dist/types/providers/solana/utils.d.ts +0 -13
- package/dist/types/providers/solana/utils.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +0 -6
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/dist/types/utils/Multicall.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/arch/svm/SpokeUtils.ts +1 -50
- package/src/arch/svm/encoders.ts +0 -4
- package/src/arch/svm/eventsClient.ts +1 -1
- package/src/clients/BundleDataClient/utils/FillUtils.ts +5 -2
- package/src/constants.ts +0 -3
- package/src/gasPriceOracle/oracle.ts +0 -1
- package/src/providers/solana/utils.ts +0 -14
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +5 -80
- package/src/utils/Multicall.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Multicall.d.ts","sourceRoot":"","sources":["../../../src/utils/Multicall.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AAI3E,OAAO,EAAE,UAAU,EAAuB,MAAM,iBAAiB,CAAC;AAElE,KAAK,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;AACnC,KAAK,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;AACnC,KAAK,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;AAEjC,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IAEf,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;CACd,CAAC;
|
|
1
|
+
{"version":3,"file":"Multicall.d.ts","sourceRoot":"","sources":["../../../src/utils/Multicall.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AAI3E,OAAO,EAAE,UAAU,EAAuB,MAAM,iBAAiB,CAAC;AAElE,KAAK,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;AACnC,KAAK,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;AACnC,KAAK,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;AAEjC,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IAEf,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;CACd,CAAC;AA+BF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKvE;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAO1G;AAED,wBAAsB,SAAS,CAAC,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAY5G;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,QAAQ,EACpB,KAAK,EAAE,KAAK,EAAE,EACd,QAAQ,CAAC,EAAE,QAAQ,GAClB,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAqBxD;AASD;;;;GAIG;AACH,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,oBAa1C"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@across-protocol/sdk",
|
|
3
3
|
"author": "UMA Team",
|
|
4
|
-
"version": "4.3.106
|
|
4
|
+
"version": "4.3.106",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"homepage": "https://docs.across.to/reference/sdk",
|
|
7
7
|
"repository": {
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"dependencies": {
|
|
112
112
|
"@across-protocol/across-token": "^1.0.0",
|
|
113
113
|
"@across-protocol/constants": "^3.1.94",
|
|
114
|
-
"@across-protocol/contracts": "
|
|
114
|
+
"@across-protocol/contracts": "4.1.16",
|
|
115
115
|
"@coral-xyz/anchor": "^0.30.1",
|
|
116
116
|
"@eth-optimism/sdk": "^3.3.1",
|
|
117
117
|
"@ethersproject/bignumber": "^5.7.0",
|
|
@@ -32,12 +32,10 @@ import {
|
|
|
32
32
|
pipe,
|
|
33
33
|
signTransactionMessageWithSigners,
|
|
34
34
|
some,
|
|
35
|
-
compileTransaction,
|
|
36
35
|
type TransactionSigner,
|
|
37
36
|
type WritableAccount,
|
|
38
37
|
type ReadonlyAccount,
|
|
39
38
|
type Commitment,
|
|
40
|
-
type CompilableTransactionMessage,
|
|
41
39
|
} from "@solana/kit";
|
|
42
40
|
import assert from "assert";
|
|
43
41
|
import winston from "winston";
|
|
@@ -102,8 +100,6 @@ import {
|
|
|
102
100
|
*/
|
|
103
101
|
export const SLOT_DURATION_MS = 400;
|
|
104
102
|
|
|
105
|
-
export const SOLANA_TX_SIZE_LIMIT = 1232;
|
|
106
|
-
|
|
107
103
|
type ProtoFill = Omit<RelayData, "recipient" | "outputToken"> & {
|
|
108
104
|
destinationChainId: number;
|
|
109
105
|
recipient: SvmAddress;
|
|
@@ -697,8 +693,6 @@ export async function getIPFillRelayTx(
|
|
|
697
693
|
getEventAuthority(program),
|
|
698
694
|
]);
|
|
699
695
|
|
|
700
|
-
const recipientAtaEncodedAccount = await fetchEncodedAccount(solanaClient, recipientAta);
|
|
701
|
-
|
|
702
696
|
// Add remaining accounts if the relayData has a non-empty message.
|
|
703
697
|
// @dev ! since in the context of creating a `fillRelayTx`, `relayData` must be defined.
|
|
704
698
|
const remainingAccounts: (WritableAccount | ReadonlyAccount)[] = [];
|
|
@@ -742,7 +736,7 @@ export async function getIPFillRelayTx(
|
|
|
742
736
|
fillInput,
|
|
743
737
|
{ outputAmount: relayData.outputAmount.toBigInt(), recipient: toAddress(relayData.recipient) },
|
|
744
738
|
mintInfo.data.decimals,
|
|
745
|
-
|
|
739
|
+
true,
|
|
746
740
|
remainingAccounts
|
|
747
741
|
);
|
|
748
742
|
}
|
|
@@ -1090,8 +1084,6 @@ async function fetchBatchFillStatusFromPdaAccounts(
|
|
|
1090
1084
|
* Returns a set of instructions to execute to fill a relay via instruction params.
|
|
1091
1085
|
* @param spokePool The program ID of the Solana spoke pool.
|
|
1092
1086
|
* @param relayData The relay data to write to the instruction params PDA.
|
|
1093
|
-
* @param repaymentChainId: The chain ID to take repayment.
|
|
1094
|
-
* @param repaymentAddress: The address to receive repayment on the specified repayment chain.
|
|
1095
1087
|
* @param signer The transaction signer and authority of the instruction params PDA.
|
|
1096
1088
|
* @param maxWriteSize The maximum fragment size to write to instruction params.
|
|
1097
1089
|
*/
|
|
@@ -1421,47 +1413,6 @@ export async function getCCTPDepositAccounts(
|
|
|
1421
1413
|
};
|
|
1422
1414
|
}
|
|
1423
1415
|
|
|
1424
|
-
/**
|
|
1425
|
-
* Returns true if the input deposit's corresponding relay data would result in a transaction size
|
|
1426
|
-
* that is larger than the Solana transaction size limit.
|
|
1427
|
-
* @param fillRelayTx The compilable fill relay transaction to check.
|
|
1428
|
-
* @returns Object containing a boolean if the input deposit requires a multipart fill, false otherwise and
|
|
1429
|
-
* the number of bytes in the serialized transaction.
|
|
1430
|
-
*/
|
|
1431
|
-
export function isSVMFillTooLarge(fillRelayTx: CompilableTransactionMessage): {
|
|
1432
|
-
tooLarge: boolean;
|
|
1433
|
-
sizeBytes: number;
|
|
1434
|
-
} {
|
|
1435
|
-
const sizeBytes = calculateFillSizeBytes(fillRelayTx);
|
|
1436
|
-
return {
|
|
1437
|
-
tooLarge: sizeBytes > SOLANA_TX_SIZE_LIMIT,
|
|
1438
|
-
sizeBytes,
|
|
1439
|
-
};
|
|
1440
|
-
}
|
|
1441
|
-
|
|
1442
|
-
/**
|
|
1443
|
-
* Returns the byte size of a base64 transaction.
|
|
1444
|
-
* @param base64TxString base64 serialized Solana transaction.
|
|
1445
|
-
* @returns The number of bytes in the transaction.
|
|
1446
|
-
*/
|
|
1447
|
-
export function base64StrToByteSize(base64TxString: string): number {
|
|
1448
|
-
// base64 string has 6 bits per character, so every 4 symbols represent 3 bytes
|
|
1449
|
-
// However, we also need to account for padding: https://en.wikipedia.org/wiki/Base64#Padding
|
|
1450
|
-
const paddingLen = base64TxString.endsWith("==") ? 2 : base64TxString.endsWith("=") ? 1 : 0;
|
|
1451
|
-
return (base64TxString.length * 3) / 4 - paddingLen;
|
|
1452
|
-
}
|
|
1453
|
-
|
|
1454
|
-
/**
|
|
1455
|
-
* Returns the size of the fill relay transaction using the input relayData.
|
|
1456
|
-
* @param fillTx The compilable fill relay transaction.
|
|
1457
|
-
* @returns The number of bytes in the serialized fillRelay transaction.
|
|
1458
|
-
*/
|
|
1459
|
-
export function calculateFillSizeBytes(fillTx: CompilableTransactionMessage): number {
|
|
1460
|
-
const signedTransaction = compileTransaction(fillTx);
|
|
1461
|
-
const serializedTx = getBase64EncodedWireTransaction(signedTransaction);
|
|
1462
|
-
return base64StrToByteSize(serializedTx);
|
|
1463
|
-
}
|
|
1464
|
-
|
|
1465
1416
|
/**
|
|
1466
1417
|
* Returns the account metas for a deposit message.
|
|
1467
1418
|
* @param message The CCTP message.
|
package/src/arch/svm/encoders.ts
CHANGED
|
@@ -62,10 +62,6 @@ export function getHandlerMessageEncoder(): Encoder<Array<CompiledIx>> {
|
|
|
62
62
|
return getArrayEncoder(getCompiledIxEncoder());
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export function getHandlerMessageDecoder(): Decoder<Array<CompiledIx>> {
|
|
66
|
-
return getArrayDecoder(getCompiledIxDecoder());
|
|
67
|
-
}
|
|
68
|
-
|
|
69
65
|
export function getCompiledIxEncoder(): Encoder<CompiledIx> {
|
|
70
66
|
return getStructEncoder([
|
|
71
67
|
["program_id_index", getU8Encoder()],
|
|
@@ -255,7 +255,7 @@ export class SvmCpiEventsClient {
|
|
|
255
255
|
return;
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
return
|
|
258
|
+
return depositEvents.map((event) => {
|
|
259
259
|
const unwrappedEventArgs = unwrapEventData(event as Record<string, unknown>, [
|
|
260
260
|
"depositId",
|
|
261
261
|
"outputAmount",
|
|
@@ -161,9 +161,12 @@ function _getRepaymentChainId(
|
|
|
161
161
|
return relayData.destinationChainId;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
// Repayment chain is valid if the input token and repayment chain are mapped to the same PoolRebalanceRoute.
|
|
164
|
+
// Repayment chain is valid if the input token and repayment chain are mapped to the same PoolRebalanceRoute and the repayment chain is not disabled in protocol.
|
|
165
165
|
const repaymentTokenIsValid = _repaymentChainTokenIsValid(relayData, hubPoolClient, bundleEndBlockForMainnet);
|
|
166
|
-
|
|
166
|
+
const repaymentChainIsValid = !hubPoolClient.configStoreClient
|
|
167
|
+
.getDisabledChainsForBlock(bundleEndBlockForMainnet)
|
|
168
|
+
.includes(relayData.repaymentChainId);
|
|
169
|
+
if (repaymentTokenIsValid && repaymentChainIsValid) {
|
|
167
170
|
return relayData.repaymentChainId;
|
|
168
171
|
}
|
|
169
172
|
|
package/src/constants.ts
CHANGED
|
@@ -80,9 +80,6 @@ export const STABLE_COIN_SYMBOLS = [
|
|
|
80
80
|
TOKEN_SYMBOLS_MAP["USDT-BNB"].symbol,
|
|
81
81
|
TOKEN_SYMBOLS_MAP["USDT-SPOT"].symbol,
|
|
82
82
|
TOKEN_SYMBOLS_MAP.DAI.symbol,
|
|
83
|
-
TOKEN_SYMBOLS_MAP["TATARA-USDC"].symbol,
|
|
84
|
-
TOKEN_SYMBOLS_MAP["TATARA-USDT"].symbol,
|
|
85
|
-
TOKEN_SYMBOLS_MAP["TATARA-USDS"].symbol,
|
|
86
83
|
TOKEN_SYMBOLS_MAP.GHO.symbol,
|
|
87
84
|
TOKEN_SYMBOLS_MAP.WGHO.symbol,
|
|
88
85
|
];
|
|
@@ -118,7 +118,6 @@ function _getEthersGasPriceEstimate(
|
|
|
118
118
|
[CHAIN_IDs.ARBITRUM_SEPOLIA]: arbitrum.eip1559,
|
|
119
119
|
[CHAIN_IDs.POLYGON_AMOY]: polygon.gasStation,
|
|
120
120
|
[CHAIN_IDs.SEPOLIA]: ethereum.eip1559,
|
|
121
|
-
[CHAIN_IDs.TATARA]: ethereum.eip1559,
|
|
122
121
|
} as const;
|
|
123
122
|
|
|
124
123
|
let gasPriceFeed = gasPriceFeeds[chainId];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { RpcTransport } from "@solana/rpc-spec";
|
|
2
|
-
import { CompilableTransactionMessage, SolanaRpcApi } from "@solana/kit";
|
|
3
2
|
import { isSolanaError, SVM_SLOT_SKIPPED, SVM_LONG_TERM_STORAGE_SLOT_SKIPPED } from "../../arch/svm";
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -15,19 +14,6 @@ export interface SolanaRateLimitTask {
|
|
|
15
14
|
reject: (err: unknown) => void;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
// `simulateBundle` minimal response struct.
|
|
19
|
-
export type SolanaBundleSimulation = {
|
|
20
|
-
result: {
|
|
21
|
-
unitsConsumed: number;
|
|
22
|
-
returnData: { programId: string; data: string };
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// Minimal extension of a Solana RPC Api which also supports some JITO RPC endpoints.
|
|
27
|
-
export interface JitoInterface extends SolanaRpcApi {
|
|
28
|
-
simulateBundle(transactions: CompilableTransactionMessage[]): SolanaBundleSimulation;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
17
|
/**
|
|
32
18
|
* Determine whether a Solana RPC error indicates an unrecoverable error that should not be retried.
|
|
33
19
|
* @param method RPC method name.
|
|
@@ -4,27 +4,13 @@ import {
|
|
|
4
4
|
TransactionSigner,
|
|
5
5
|
fetchEncodedAccount,
|
|
6
6
|
isSome,
|
|
7
|
-
Rpc,
|
|
8
|
-
pipe,
|
|
9
|
-
appendTransactionMessageInstruction,
|
|
10
7
|
} from "@solana/kit";
|
|
11
|
-
import {
|
|
12
|
-
SVMProvider,
|
|
13
|
-
SolanaVoidSigner,
|
|
14
|
-
getFillRelayTx,
|
|
15
|
-
getIPFillRelayTx,
|
|
16
|
-
getFillRelayViaInstructionParamsInstructions,
|
|
17
|
-
toAddress,
|
|
18
|
-
createDefaultTransaction,
|
|
19
|
-
getAssociatedTokenAddress,
|
|
20
|
-
isSVMFillTooLarge,
|
|
21
|
-
} from "../../arch/svm";
|
|
22
|
-
import { JitoInterface } from "../../providers/solana";
|
|
8
|
+
import { SVMProvider, SolanaVoidSigner, getFillRelayTx, toAddress, getAssociatedTokenAddress } from "../../arch/svm";
|
|
23
9
|
import { Coingecko } from "../../coingecko";
|
|
24
10
|
import { CHAIN_IDs } from "../../constants";
|
|
25
11
|
import { getGasPriceEstimate } from "../../gasPriceOracle";
|
|
26
12
|
import { RelayData } from "../../interfaces";
|
|
27
|
-
import { Address, BigNumber, BigNumberish, SvmAddress, TransactionCostEstimate, toBN
|
|
13
|
+
import { Address, BigNumber, BigNumberish, SvmAddress, TransactionCostEstimate, toBN } from "../../utils";
|
|
28
14
|
import { Logger, QueryInterface, getDefaultRelayer } from "../relayFeeCalculator";
|
|
29
15
|
import { SymbolMappingType } from "./";
|
|
30
16
|
import { TOKEN_PROGRAM_ADDRESS } from "@solana-program/token";
|
|
@@ -91,35 +77,15 @@ export class SvmQuery implements QueryInterface {
|
|
|
91
77
|
assert(relayer.isSVM());
|
|
92
78
|
|
|
93
79
|
const [repaymentChainId, repaymentAddress] = [destinationChainId, relayer]; // These are not important for gas cost simulation.
|
|
94
|
-
|
|
95
|
-
// For solana, we algorithmically estimate gas based on the size of the message.
|
|
96
|
-
const _fillRelayTx = await this.getFillRelayTx(
|
|
80
|
+
const fillRelayTx = await this.getFillRelayTx(
|
|
97
81
|
{ ...relayData, recipient, outputToken, exclusiveRelayer },
|
|
98
82
|
SolanaVoidSigner(relayer.toBase58()),
|
|
99
83
|
repaymentChainId,
|
|
100
84
|
repaymentAddress
|
|
101
85
|
);
|
|
102
86
|
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
// that the transaction won't be too large, we overwrite the message with empty bytes.
|
|
106
|
-
const fillRelayTx = fillTooLarge.tooLarge
|
|
107
|
-
? await this.getFillRelayTx(
|
|
108
|
-
{ ...relayData, recipient, outputToken, exclusiveRelayer, message: "0x" },
|
|
109
|
-
SolanaVoidSigner(relayer.toBase58()),
|
|
110
|
-
repaymentChainId,
|
|
111
|
-
repaymentAddress
|
|
112
|
-
)
|
|
113
|
-
: _fillRelayTx;
|
|
114
|
-
const [_computeUnitsConsumed, gasPriceEstimate, tokenAccountInfo] = await Promise.all([
|
|
115
|
-
fillTooLarge.tooLarge
|
|
116
|
-
? this.estimateComputeUnits(
|
|
117
|
-
{ ...relayData, recipient, outputToken, exclusiveRelayer },
|
|
118
|
-
relayer,
|
|
119
|
-
repaymentChainId,
|
|
120
|
-
repaymentAddress
|
|
121
|
-
)
|
|
122
|
-
: this.computeUnitEstimator(fillRelayTx),
|
|
87
|
+
const [computeUnitsConsumed, gasPriceEstimate, tokenAccountInfo] = await Promise.all([
|
|
88
|
+
toBN(await this.computeUnitEstimator(fillRelayTx)),
|
|
123
89
|
getGasPriceEstimate(this.provider, {
|
|
124
90
|
unsignedTx: fillRelayTx,
|
|
125
91
|
baseFeeMultiplier: options.baseFeeMultiplier,
|
|
@@ -127,7 +93,6 @@ export class SvmQuery implements QueryInterface {
|
|
|
127
93
|
}),
|
|
128
94
|
this.provider.getAccountInfo(toAddress(outputToken), { encoding: "base58" }).send(),
|
|
129
95
|
]);
|
|
130
|
-
const computeUnitsConsumed = toBN(_computeUnitsConsumed);
|
|
131
96
|
|
|
132
97
|
// If the owner of the token account is not the token program, then we can assume that it is the 2022 token program address, in which
|
|
133
98
|
// case we need to determine the extensions the token has to properly calculate rent exemption.
|
|
@@ -246,44 +211,4 @@ export class SvmQuery implements QueryInterface {
|
|
|
246
211
|
if (!this.symbolMapping[tokenSymbol]) throw new Error(`${tokenSymbol} does not exist in mapping`);
|
|
247
212
|
return this.symbolMapping[tokenSymbol].decimals;
|
|
248
213
|
}
|
|
249
|
-
|
|
250
|
-
// The fill is too large; we need to simulate the transaction in a bundle.
|
|
251
|
-
async estimateComputeUnits(
|
|
252
|
-
relayData: RelayData & {
|
|
253
|
-
destinationChainId: number;
|
|
254
|
-
recipient: SvmAddress;
|
|
255
|
-
outputToken: SvmAddress;
|
|
256
|
-
exclusiveRelayer: SvmAddress;
|
|
257
|
-
},
|
|
258
|
-
relayer: SvmAddress,
|
|
259
|
-
repaymentChainId: number,
|
|
260
|
-
repaymentAddress: SvmAddress
|
|
261
|
-
): Promise<number> {
|
|
262
|
-
// @dev There is no way to tell if the RPC supports the JITO interface without querying the rpc directly.
|
|
263
|
-
// Cast the rpc type to support JITO and attempt to call `simulateBundle`. Throw and error if it fails, since
|
|
264
|
-
// the transaction message cannot be simulated otherwise.
|
|
265
|
-
const provider = this.provider as Rpc<JitoInterface>;
|
|
266
|
-
|
|
267
|
-
const spokePoolAddr = toAddress(this.spokePool);
|
|
268
|
-
const voidSigner = SolanaVoidSigner(relayer.toBase58());
|
|
269
|
-
|
|
270
|
-
const [instructionParamsIxs, fillRelayTx] = await Promise.all([
|
|
271
|
-
getFillRelayViaInstructionParamsInstructions(
|
|
272
|
-
spokePoolAddr,
|
|
273
|
-
relayData,
|
|
274
|
-
repaymentChainId,
|
|
275
|
-
repaymentAddress,
|
|
276
|
-
voidSigner
|
|
277
|
-
),
|
|
278
|
-
getIPFillRelayTx(this.spokePool, provider, relayData, voidSigner, repaymentChainId, repaymentAddress),
|
|
279
|
-
]);
|
|
280
|
-
const instructionParamsTxs = await mapAsync(instructionParamsIxs, async (ix) => {
|
|
281
|
-
return pipe(await createDefaultTransaction(provider, voidSigner), (tx) =>
|
|
282
|
-
appendTransactionMessageInstruction(ix, tx)
|
|
283
|
-
);
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
const simulateBundleResponse = await provider.simulateBundle([...instructionParamsTxs, fillRelayTx]).send();
|
|
287
|
-
return simulateBundleResponse.result.unitsConsumed;
|
|
288
|
-
}
|
|
289
214
|
}
|
package/src/utils/Multicall.ts
CHANGED