@lifi/sdk 3.13.5 → 3.14.0-alpha.0
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/package.json +1 -1
- package/src/_cjs/core/Solana/SolanaStepExecutor.js +57 -12
- package/src/_cjs/core/Solana/SolanaStepExecutor.js.map +1 -1
- package/src/_cjs/core/Solana/connection.js +21 -2
- package/src/_cjs/core/Solana/connection.js.map +1 -1
- package/src/_cjs/core/Solana/jito/JitoConnection.js +67 -0
- package/src/_cjs/core/Solana/jito/JitoConnection.js.map +1 -0
- package/src/_cjs/core/Solana/jito/constants.js +27 -0
- package/src/_cjs/core/Solana/jito/constants.js.map +1 -0
- package/src/_cjs/core/Solana/jito/isJitoRpc.js +23 -0
- package/src/_cjs/core/Solana/jito/isJitoRpc.js.map +1 -0
- package/src/_cjs/core/Solana/jito/sendAndConfirmBundle.js +118 -0
- package/src/_cjs/core/Solana/jito/sendAndConfirmBundle.js.map +1 -0
- package/src/_cjs/index.js.map +1 -1
- package/src/_cjs/services/api.js +9 -1
- package/src/_cjs/services/api.js.map +1 -1
- package/src/_cjs/utils/uint8ArrayToBase64.js +11 -0
- package/src/_cjs/utils/uint8ArrayToBase64.js.map +1 -0
- package/src/_cjs/version.js +1 -1
- package/src/_cjs/version.js.map +1 -1
- package/src/_esm/core/Solana/SolanaStepExecutor.js +83 -12
- package/src/_esm/core/Solana/SolanaStepExecutor.js.map +1 -1
- package/src/_esm/core/Solana/connection.js +26 -1
- package/src/_esm/core/Solana/connection.js.map +1 -1
- package/src/_esm/core/Solana/jito/JitoConnection.js +90 -0
- package/src/_esm/core/Solana/jito/JitoConnection.js.map +1 -0
- package/src/_esm/core/Solana/jito/constants.js +25 -0
- package/src/_esm/core/Solana/jito/constants.js.map +1 -0
- package/src/_esm/core/Solana/jito/isJitoRpc.js +21 -0
- package/src/_esm/core/Solana/jito/isJitoRpc.js.map +1 -0
- package/src/_esm/core/Solana/jito/sendAndConfirmBundle.js +140 -0
- package/src/_esm/core/Solana/jito/sendAndConfirmBundle.js.map +1 -0
- package/src/_esm/index.js.map +1 -1
- package/src/_esm/services/api.js +11 -2
- package/src/_esm/services/api.js.map +1 -1
- package/src/_esm/utils/uint8ArrayToBase64.js +10 -0
- package/src/_esm/utils/uint8ArrayToBase64.js.map +1 -0
- package/src/_esm/version.js +1 -1
- package/src/_esm/version.js.map +1 -1
- package/src/_types/core/Solana/SolanaStepExecutor.d.ts +18 -0
- package/src/_types/core/Solana/SolanaStepExecutor.d.ts.map +1 -1
- package/src/_types/core/Solana/connection.d.ts +7 -1
- package/src/_types/core/Solana/connection.d.ts.map +1 -1
- package/src/_types/core/Solana/jito/JitoConnection.d.ts +55 -0
- package/src/_types/core/Solana/jito/JitoConnection.d.ts.map +1 -0
- package/src/_types/core/Solana/jito/constants.d.ts +3 -0
- package/src/_types/core/Solana/jito/constants.d.ts.map +1 -0
- package/src/_types/core/Solana/jito/isJitoRpc.d.ts +2 -0
- package/src/_types/core/Solana/jito/isJitoRpc.d.ts.map +1 -0
- package/src/_types/core/Solana/jito/sendAndConfirmBundle.d.ts +15 -0
- package/src/_types/core/Solana/jito/sendAndConfirmBundle.d.ts.map +1 -0
- package/src/_types/index.d.ts +1 -1
- package/src/_types/index.d.ts.map +1 -1
- package/src/_types/services/api.d.ts.map +1 -1
- package/src/_types/services/types.d.ts +3 -0
- package/src/_types/services/types.d.ts.map +1 -1
- package/src/_types/utils/uint8ArrayToBase64.d.ts +2 -0
- package/src/_types/utils/uint8ArrayToBase64.d.ts.map +1 -0
- package/src/_types/version.d.ts +1 -1
- package/src/_types/version.d.ts.map +1 -1
- package/src/core/Solana/SolanaStepExecutor.ts +122 -22
- package/src/core/Solana/connection.ts +35 -4
- package/src/core/Solana/jito/JitoConnection.ts +122 -0
- package/src/core/Solana/jito/constants.ts +26 -0
- package/src/core/Solana/jito/isJitoRpc.ts +21 -0
- package/src/core/Solana/jito/sendAndConfirmBundle.ts +195 -0
- package/src/index.ts +1 -0
- package/src/services/api.ts +20 -11
- package/src/services/types.ts +4 -0
- package/src/utils/uint8ArrayToBase64.ts +12 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function uint8ArrayToBase64(bytes) {
|
|
2
|
+
// Node.js environment
|
|
3
|
+
if (typeof Buffer !== 'undefined') {
|
|
4
|
+
return Buffer.from(bytes).toString('base64');
|
|
5
|
+
}
|
|
6
|
+
// Browser environment
|
|
7
|
+
const binaryString = Array.from(bytes, (byte) => String.fromCharCode(byte)).join('');
|
|
8
|
+
return btoa(binaryString);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=uint8ArrayToBase64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uint8ArrayToBase64.js","sourceRoot":"","sources":["../../utils/uint8ArrayToBase64.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB,CAAC,KAAiB;IAClD,sBAAsB;IACtB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAC9C,CAAC;IAED,sBAAsB;IACtB,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAC9C,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAC1B,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACV,OAAO,IAAI,CAAC,YAAY,CAAC,CAAA;AAC3B,CAAC"}
|
package/src/_esm/version.js
CHANGED
package/src/_esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG,WAAW,CAAA;AAC/B,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG,WAAW,CAAA;AAC/B,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAA"}
|
|
@@ -5,6 +5,24 @@ export declare class SolanaStepExecutor extends BaseStepExecutor {
|
|
|
5
5
|
private walletAdapter;
|
|
6
6
|
constructor(options: SolanaStepExecutorOptions);
|
|
7
7
|
checkWalletAdapter: (step: LiFiStepExtended) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Deserializes base64-encoded transaction data into VersionedTransaction objects.
|
|
10
|
+
* Handles both single transactions and arrays of transactions.
|
|
11
|
+
*
|
|
12
|
+
* @param transactionRequest - Transaction parameters containing base64-encoded transaction data
|
|
13
|
+
* @returns {VersionedTransaction[]} Array of deserialized VersionedTransaction objects
|
|
14
|
+
* @throws {TransactionError} If transaction data is missing or empty
|
|
15
|
+
*/
|
|
16
|
+
private deserializeTransactions;
|
|
17
|
+
/**
|
|
18
|
+
* Determines whether to use Jito bundle submission for the given transactions.
|
|
19
|
+
* Multiple transactions require Jito bundle support to be enabled in config.
|
|
20
|
+
*
|
|
21
|
+
* @param transactions - Array of transactions to evaluate
|
|
22
|
+
* @returns {Boolean} True if Jito bundle should be used (multiple transactions + Jito enabled), false otherwise
|
|
23
|
+
* @throws {TransactionError} If multiple transactions are provided but Jito bundle is not enabled
|
|
24
|
+
*/
|
|
25
|
+
private shouldUseJitoBundle;
|
|
8
26
|
executeStep: (step: LiFiStepExtended) => Promise<LiFiStepExtended>;
|
|
9
27
|
}
|
|
10
28
|
//# sourceMappingURL=SolanaStepExecutor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolanaStepExecutor.d.ts","sourceRoot":"","sources":["../../../core/Solana/SolanaStepExecutor.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAGzD,OAAO,KAAK,EAAE,gBAAgB,EAAyB,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"SolanaStepExecutor.d.ts","sourceRoot":"","sources":["../../../core/Solana/SolanaStepExecutor.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAGzD,OAAO,KAAK,EAAE,gBAAgB,EAAyB,MAAM,aAAa,CAAA;AAM1E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAE3D,qBAAa,kBAAmB,SAAQ,gBAAgB;IACtD,OAAO,CAAC,aAAa,CAAqB;gBAE9B,OAAO,EAAE,yBAAyB;IAK9C,kBAAkB,GAAI,MAAM,gBAAgB,UAQ3C;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,uBAAuB;IAqB/B;;;;;;;OAOG;IACH,OAAO,CAAC,mBAAmB;IAc3B,WAAW,GAAU,MAAM,gBAAgB,KAAG,OAAO,CAAC,gBAAgB,CAAC,CA2OtE;CACF"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { Connection } from '@solana/web3.js';
|
|
2
|
+
import { JitoConnection } from './jito/JitoConnection.js';
|
|
2
3
|
/**
|
|
3
4
|
* Wrapper around getting the connection (RPC provider) for Solana
|
|
4
5
|
* @returns - Solana RPC connections
|
|
5
6
|
*/
|
|
6
|
-
export declare const getSolanaConnections: () => Promise<Connection[]>;
|
|
7
|
+
export declare const getSolanaConnections: () => Promise<(Connection | JitoConnection)[]>;
|
|
8
|
+
/**
|
|
9
|
+
* Get Jito-enabled connections only
|
|
10
|
+
* @returns - Array of JitoConnection instances
|
|
11
|
+
*/
|
|
12
|
+
export declare const getJitoConnections: () => Promise<JitoConnection[]>;
|
|
7
13
|
/**
|
|
8
14
|
* Calls a function on the Connection instances with retry logic.
|
|
9
15
|
* @param fn - The function to call, which receives a Connection instance.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../core/Solana/connection.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../core/Solana/connection.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG1D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAkCzD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAAa,OAAO,CACnD,CAAC,UAAU,GAAG,cAAc,CAAC,EAAE,CAIhC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAa,OAAO,CAAC,cAAc,EAAE,CAKnE,CAAA;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,EAAE,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC,GACzC,OAAO,CAAC,CAAC,CAAC,CAcZ"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type Cluster, Connection, type VersionedTransaction } from '@solana/web3.js';
|
|
2
|
+
export type SimulateBundleResult = {
|
|
3
|
+
value: {
|
|
4
|
+
summary: 'succeeded' | {
|
|
5
|
+
failed: {
|
|
6
|
+
error: any;
|
|
7
|
+
tx_signature: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
transactionResults: Array<{
|
|
11
|
+
err: any;
|
|
12
|
+
logs: string[] | null;
|
|
13
|
+
unitsConsumed?: number;
|
|
14
|
+
}>;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Extended Connection class with Jito bundle support
|
|
19
|
+
* Adds simulateBundle, sendBundle, and getTipAccounts methods
|
|
20
|
+
*/
|
|
21
|
+
export declare class JitoConnection extends Connection {
|
|
22
|
+
private tipAccountsCache;
|
|
23
|
+
private cluster;
|
|
24
|
+
constructor(endpoint: string, cluster?: Cluster);
|
|
25
|
+
/**
|
|
26
|
+
* Makes a direct RPC request to the Jito-enabled endpoint
|
|
27
|
+
*/
|
|
28
|
+
private rpcRequest;
|
|
29
|
+
/**
|
|
30
|
+
* Serialize a transaction to base64 for RPC submission
|
|
31
|
+
*/
|
|
32
|
+
private serializeTransaction;
|
|
33
|
+
/**
|
|
34
|
+
* Get the tip accounts from the Jito endpoint
|
|
35
|
+
* Results are cached to avoid repeated RPC calls
|
|
36
|
+
*/
|
|
37
|
+
getTipAccounts(): Promise<string[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Get a random Jito tip account to reduce contention
|
|
40
|
+
*/
|
|
41
|
+
getRandomTipAccount(): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Simulate a bundle before sending it
|
|
44
|
+
* @param bundle - Array of signed transactions
|
|
45
|
+
* @returns Simulation result
|
|
46
|
+
*/
|
|
47
|
+
simulateBundle(bundle: VersionedTransaction[]): Promise<SimulateBundleResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Send a bundle to the Jito block engine
|
|
50
|
+
* @param bundle - Array of signed transactions
|
|
51
|
+
* @returns Bundle UUID
|
|
52
|
+
*/
|
|
53
|
+
sendBundle(bundle: VersionedTransaction[]): Promise<string>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=JitoConnection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JitoConnection.d.ts","sourceRoot":"","sources":["../../../../core/Solana/jito/JitoConnection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,UAAU,EACV,KAAK,oBAAoB,EAC1B,MAAM,iBAAiB,CAAA;AAIxB,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE;QACL,OAAO,EAAE,WAAW,GAAG;YAAE,MAAM,EAAE;gBAAE,KAAK,EAAE,GAAG,CAAC;gBAAC,YAAY,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,CAAA;QACvE,kBAAkB,EAAE,KAAK,CAAC;YACxB,GAAG,EAAE,GAAG,CAAA;YACR,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;YACrB,aAAa,CAAC,EAAE,MAAM,CAAA;SACvB,CAAC,CAAA;KACH,CAAA;CACF,CAAA;AAED;;;GAGG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC5C,OAAO,CAAC,gBAAgB,CAAwB;IAChD,OAAO,CAAC,OAAO,CAAS;gBAEZ,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,OAAwB;IAK/D;;OAEG;YACW,UAAU;IAqBxB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAI5B;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAmBzC;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;IAK5C;;;;OAIG;IACG,cAAc,CAClB,MAAM,EAAE,oBAAoB,EAAE,GAC7B,OAAO,CAAC,oBAAoB,CAAC;IAShC;;;;OAIG;IACG,UAAU,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAMlE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../core/Solana/jito/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAG9C,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,CAsBvD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isJitoRpc.d.ts","sourceRoot":"","sources":["../../../../core/Solana/jito/isJitoRpc.ts"],"names":[],"mappings":"AAAA,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAoBhE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SignatureResult, VersionedTransaction } from '@solana/web3.js';
|
|
2
|
+
export type BundleResult = {
|
|
3
|
+
bundleId: string;
|
|
4
|
+
txSignatures: string[];
|
|
5
|
+
signatureResults: (SignatureResult | null)[];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Send and confirm a bundle of transactions using Jito
|
|
9
|
+
* Automatically selects a Jito-enabled RPC connection and polls for confirmation
|
|
10
|
+
* across multiple Jito RPCs in parallel
|
|
11
|
+
* @param signedTransactions - Array of signed transactions
|
|
12
|
+
* @returns Bundle ID, transaction signatures, and confirmation results
|
|
13
|
+
*/
|
|
14
|
+
export declare function sendAndConfirmBundle(signedTransactions: VersionedTransaction[]): Promise<BundleResult>;
|
|
15
|
+
//# sourceMappingURL=sendAndConfirmBundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendAndConfirmBundle.d.ts","sourceRoot":"","sources":["../../../../core/Solana/jito/sendAndConfirmBundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAK5E,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,gBAAgB,EAAE,CAAC,eAAe,GAAG,IAAI,CAAC,EAAE,CAAA;CAC7C,CAAA;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,kBAAkB,EAAE,oBAAoB,EAAE,GACzC,OAAO,CAAC,YAAY,CAAC,CA8KvB"}
|
package/src/_types/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export { SDKError } from './errors/SDKError.js';
|
|
|
35
35
|
export { getChains, getConnections, getContractCallsQuote, getGasRecommendation, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getToken, getTokens, getTools, getTransactionHistory, relayTransaction, } from './services/api.js';
|
|
36
36
|
export { getTokenBalance, getTokenBalances, getTokenBalancesByChain, getWalletBalances, } from './services/balance.js';
|
|
37
37
|
export { getNameServiceAddress } from './services/getNameServiceAddress.js';
|
|
38
|
-
export type { GetStatusRequestExtended, QuoteRequest, QuoteRequestFromAmount, QuoteRequestToAmount, } from './services/types.js';
|
|
38
|
+
export type { GetStatusRequestExtended, GetStepTransactionRequest, QuoteRequest, QuoteRequestFromAmount, QuoteRequestToAmount, } from './services/types.js';
|
|
39
39
|
export type { RPCUrls, SDKBaseConfig, SDKConfig } from './types/internal.js';
|
|
40
40
|
export { checkPackageUpdates } from './utils/checkPackageUpdates.js';
|
|
41
41
|
export { convertQuoteToRoute } from './utils/convertQuoteToRoute.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AACrE,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AACvC,OAAO,EACL,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAA;AACvE,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,iBAAiB,GAClB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACL,aAAa,EACb,aAAa,GACd,MAAM,0BAA0B,CAAA;AACjC,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,YAAY,EACZ,cAAc,EACd,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,q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,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,YAAY,EACV,wBAAwB,EACxB,yBAAyB,EACzB,YAAY,EACZ,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../services/api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../services/api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,aAAa,EAGlB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAG9B,KAAK,QAAQ,EAEb,KAAK,YAAY,EAEjB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EAEvB,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,2BA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,CAqCjC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GACpB,SAAS,aAAa,EACtB,UAAU,cAAc,KACvB,OAAO,CAAC,aAAa,EAAE,CAsBzB,CAAA;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAC7B,MAAM,CAAC,EAAE,aAAa,GAAG;IAAE,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,CAAA;CAAE,EACzD,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,cAAc,CAAC,CAAA;AAC1B,wBAAsB,SAAS,CAC7B,MAAM,EAAE,aAAa,GAAG;IAAE,QAAQ,EAAE,IAAI,CAAA;CAAE,EAC1C,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,sBAAsB,CAAC,CAAA;AA4BlC;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,GACnB,OAAO,QAAQ,GAAG,OAAO,EACzB,OAAO,MAAM,EACb,UAAU,cAAc,KACvB,OAAO,CAAC,aAAa,CAoBvB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GACnB,SAAS,YAAY,EACrB,UAAU,cAAc,KACvB,OAAO,CAAC,aAAa,CAgBvB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,wBAAwB,EAChC,UAAU,cAAc,KACvB,OAAO,CAAC,yBAAyB,CAkBnC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GACzB,mBAAmB,kBAAkB,EACrC,UAAU,cAAc,KACvB,OAAO,CAAC,mBAAmB,CAmC7B,CAAA;AAED,eAAO,MAAM,qBAAqB,GAChC,gDAAgD,2BAA2B,EAC3E,UAAU,cAAc,KACvB,OAAO,CAAC,4BAA4B,CA2BtC,CAAA"}
|
|
@@ -2,6 +2,9 @@ import type { GetStatusRequest, QuoteRequest as QuoteRequestBase } from '@lifi/t
|
|
|
2
2
|
export type GetStatusRequestExtended = GetStatusRequest & {
|
|
3
3
|
fromAddress?: string;
|
|
4
4
|
};
|
|
5
|
+
export type GetStepTransactionRequest = {
|
|
6
|
+
jitoBundle?: boolean;
|
|
7
|
+
};
|
|
5
8
|
export type QuoteRequestFromAmount = QuoteRequestBase;
|
|
6
9
|
export type QuoteRequestToAmount = Omit<QuoteRequestBase, 'fromAmount'> & {
|
|
7
10
|
toAmount: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../services/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,IAAI,gBAAgB,EACjC,MAAM,aAAa,CAAA;AAEpB,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,GAAG;IACxD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CAAA;AAErD,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,GAAG;IACxE,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,sBAAsB,GAAG,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../services/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,IAAI,gBAAgB,EACjC,MAAM,aAAa,CAAA;AAEpB,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,GAAG;IACxD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CAAA;AAErD,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,GAAG;IACxE,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,sBAAsB,GAAG,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uint8ArrayToBase64.d.ts","sourceRoot":"","sources":["../../utils/uint8ArrayToBase64.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAW5D"}
|
package/src/_types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,cAAc,CAAA;AAC/B,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,cAAc,CAAA;AAC/B,eAAO,MAAM,OAAO,mBAAmB,CAAA"}
|
|
@@ -12,6 +12,7 @@ import { stepComparison } from '../stepComparison.js'
|
|
|
12
12
|
import type { LiFiStepExtended, TransactionParameters } from '../types.js'
|
|
13
13
|
import { waitForDestinationChainTransaction } from '../waitForDestinationChainTransaction.js'
|
|
14
14
|
import { callSolanaWithRetry } from './connection.js'
|
|
15
|
+
import { sendAndConfirmBundle } from './jito/sendAndConfirmBundle.js'
|
|
15
16
|
import { parseSolanaErrors } from './parseSolanaErrors.js'
|
|
16
17
|
import { sendAndConfirmTransaction } from './sendAndConfirmTransaction.js'
|
|
17
18
|
import type { SolanaStepExecutorOptions } from './types.js'
|
|
@@ -34,6 +35,57 @@ export class SolanaStepExecutor extends BaseStepExecutor {
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Deserializes base64-encoded transaction data into VersionedTransaction objects.
|
|
40
|
+
* Handles both single transactions and arrays of transactions.
|
|
41
|
+
*
|
|
42
|
+
* @param transactionRequest - Transaction parameters containing base64-encoded transaction data
|
|
43
|
+
* @returns {VersionedTransaction[]} Array of deserialized VersionedTransaction objects
|
|
44
|
+
* @throws {TransactionError} If transaction data is missing or empty
|
|
45
|
+
*/
|
|
46
|
+
private deserializeTransactions(transactionRequest: TransactionParameters) {
|
|
47
|
+
if (!transactionRequest.data?.length) {
|
|
48
|
+
throw new TransactionError(
|
|
49
|
+
LiFiErrorCode.TransactionUnprepared,
|
|
50
|
+
'Unable to prepare transaction.'
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (Array.isArray(transactionRequest.data)) {
|
|
55
|
+
return transactionRequest.data.map((tx) =>
|
|
56
|
+
VersionedTransaction.deserialize(base64ToUint8Array(tx))
|
|
57
|
+
)
|
|
58
|
+
} else {
|
|
59
|
+
return [
|
|
60
|
+
VersionedTransaction.deserialize(
|
|
61
|
+
base64ToUint8Array(transactionRequest.data)
|
|
62
|
+
),
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Determines whether to use Jito bundle submission for the given transactions.
|
|
69
|
+
* Multiple transactions require Jito bundle support to be enabled in config.
|
|
70
|
+
*
|
|
71
|
+
* @param transactions - Array of transactions to evaluate
|
|
72
|
+
* @returns {Boolean} True if Jito bundle should be used (multiple transactions + Jito enabled), false otherwise
|
|
73
|
+
* @throws {TransactionError} If multiple transactions are provided but Jito bundle is not enabled
|
|
74
|
+
*/
|
|
75
|
+
private shouldUseJitoBundle(transactions: VersionedTransaction[]): boolean {
|
|
76
|
+
const isJitoBundleEnabled = Boolean(config.get().routeOptions?.jitoBundle)
|
|
77
|
+
// If we received multiple transactions but Jito is not enabled,
|
|
78
|
+
// this indicates an unexpected state (possibly an API error or misconfiguration)
|
|
79
|
+
if (transactions.length > 1 && !isJitoBundleEnabled) {
|
|
80
|
+
throw new TransactionError(
|
|
81
|
+
LiFiErrorCode.TransactionUnprepared,
|
|
82
|
+
`Received ${transactions.length} transactions but Jito bundle is not enabled. Multiple transactions require Jito bundle support. Please enable jitoBundle in routeOptions.`
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return transactions.length > 1 && isJitoBundleEnabled
|
|
87
|
+
}
|
|
88
|
+
|
|
37
89
|
executeStep = async (step: LiFiStepExtended): Promise<LiFiStepExtended> => {
|
|
38
90
|
step.execution = this.statusManager.initExecutionObject(step)
|
|
39
91
|
|
|
@@ -112,22 +164,15 @@ export class SolanaStepExecutor extends BaseStepExecutor {
|
|
|
112
164
|
}
|
|
113
165
|
}
|
|
114
166
|
|
|
115
|
-
|
|
116
|
-
throw new TransactionError(
|
|
117
|
-
LiFiErrorCode.TransactionUnprepared,
|
|
118
|
-
'Unable to prepare transaction.'
|
|
119
|
-
)
|
|
120
|
-
}
|
|
167
|
+
const transactions = this.deserializeTransactions(transactionRequest)
|
|
121
168
|
|
|
122
|
-
const
|
|
123
|
-
base64ToUint8Array(transactionRequest.data)
|
|
124
|
-
)
|
|
169
|
+
const shouldUseJitoBundle = this.shouldUseJitoBundle(transactions)
|
|
125
170
|
|
|
126
171
|
this.checkWalletAdapter(step)
|
|
127
172
|
|
|
128
173
|
// We give users 2 minutes to sign the transaction or it should be considered expired
|
|
129
|
-
const
|
|
130
|
-
() => this.walletAdapter.
|
|
174
|
+
const signedTransactions = await withTimeout<VersionedTransaction[]>(
|
|
175
|
+
() => this.walletAdapter.signAllTransactions(transactions),
|
|
131
176
|
{
|
|
132
177
|
// https://solana.com/docs/advanced/confirmation#transaction-expiration
|
|
133
178
|
// Use 2 minutes to account for fluctuations
|
|
@@ -145,21 +190,76 @@ export class SolanaStepExecutor extends BaseStepExecutor {
|
|
|
145
190
|
'PENDING'
|
|
146
191
|
)
|
|
147
192
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
commitment: 'confirmed',
|
|
151
|
-
replaceRecentBlockhash: true,
|
|
152
|
-
})
|
|
153
|
-
)
|
|
154
|
-
|
|
155
|
-
if (simulationResult.value.err) {
|
|
193
|
+
// Verify wallet adapter returned signed transactions
|
|
194
|
+
if (!signedTransactions.length) {
|
|
156
195
|
throw new TransactionError(
|
|
157
|
-
LiFiErrorCode.
|
|
158
|
-
'
|
|
196
|
+
LiFiErrorCode.TransactionUnprepared,
|
|
197
|
+
'There was a problem signing the transactions. Wallet adapter did not return any signed transactions.'
|
|
159
198
|
)
|
|
160
199
|
}
|
|
161
200
|
|
|
162
|
-
|
|
201
|
+
let confirmedTx: any
|
|
202
|
+
|
|
203
|
+
if (shouldUseJitoBundle) {
|
|
204
|
+
// Use Jito bundle for multiple transactions
|
|
205
|
+
const bundleResult = await sendAndConfirmBundle(signedTransactions)
|
|
206
|
+
|
|
207
|
+
// Check if all transactions in the bundle were confirmed
|
|
208
|
+
// All transactions must succeed for the bundle to be considered successful
|
|
209
|
+
const allConfirmed = bundleResult.signatureResults.every(
|
|
210
|
+
(result) => result !== null
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
if (!allConfirmed) {
|
|
214
|
+
throw new TransactionError(
|
|
215
|
+
LiFiErrorCode.TransactionExpired,
|
|
216
|
+
'One or more bundle transactions were not confirmed within the expected time frame.'
|
|
217
|
+
)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Check if any transaction in the bundle has an error
|
|
221
|
+
const failedResult = bundleResult.signatureResults.find(
|
|
222
|
+
(result) => result?.err !== null
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
if (failedResult) {
|
|
226
|
+
const reason =
|
|
227
|
+
typeof failedResult.err === 'object'
|
|
228
|
+
? JSON.stringify(failedResult.err)
|
|
229
|
+
: failedResult.err
|
|
230
|
+
throw new TransactionError(
|
|
231
|
+
LiFiErrorCode.TransactionFailed,
|
|
232
|
+
`Bundle transaction failed: ${reason}`
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Use the first transaction's signature result for reporting
|
|
237
|
+
// (all transactions succeeded if we reach here)
|
|
238
|
+
confirmedTx = {
|
|
239
|
+
signatureResult: bundleResult.signatureResults[0],
|
|
240
|
+
txSignature: bundleResult.txSignatures[0],
|
|
241
|
+
bundleId: bundleResult.bundleId,
|
|
242
|
+
}
|
|
243
|
+
} else {
|
|
244
|
+
// Use regular transaction for single transaction
|
|
245
|
+
const signedTx = signedTransactions[0]
|
|
246
|
+
|
|
247
|
+
const simulationResult = await callSolanaWithRetry((connection) =>
|
|
248
|
+
connection.simulateTransaction(signedTx, {
|
|
249
|
+
commitment: 'confirmed',
|
|
250
|
+
replaceRecentBlockhash: true,
|
|
251
|
+
})
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
if (simulationResult.value.err) {
|
|
255
|
+
throw new TransactionError(
|
|
256
|
+
LiFiErrorCode.TransactionSimulationFailed,
|
|
257
|
+
'Transaction simulation failed'
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
confirmedTx = await sendAndConfirmTransaction(signedTx)
|
|
262
|
+
}
|
|
163
263
|
|
|
164
264
|
if (!confirmedTx.signatureResult) {
|
|
165
265
|
throw new TransactionError(
|
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
import { ChainId } from '@lifi/types'
|
|
2
|
-
import { Connection } from '@solana/web3.js'
|
|
2
|
+
import { type Cluster, Connection } from '@solana/web3.js'
|
|
3
3
|
import { getRpcUrls } from '../rpc.js'
|
|
4
|
+
import { isJitoRpc } from './jito/isJitoRpc.js'
|
|
5
|
+
import { JitoConnection } from './jito/JitoConnection.js'
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Detect the cluster (network) from an RPC URL
|
|
9
|
+
*/
|
|
10
|
+
const detectCluster = (rpcUrl: string): Cluster => {
|
|
11
|
+
const url = rpcUrl.toLowerCase()
|
|
12
|
+
if (url.includes('devnet')) {
|
|
13
|
+
return 'devnet'
|
|
14
|
+
}
|
|
15
|
+
if (url.includes('testnet')) {
|
|
16
|
+
return 'testnet'
|
|
17
|
+
}
|
|
18
|
+
return 'mainnet-beta'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const connections = new Map<string, Connection | JitoConnection>()
|
|
6
22
|
|
|
7
23
|
/**
|
|
8
24
|
* Initializes the Solana connections if they haven't been initialized yet.
|
|
@@ -12,7 +28,9 @@ const ensureConnections = async (): Promise<void> => {
|
|
|
12
28
|
const rpcUrls = await getRpcUrls(ChainId.SOL)
|
|
13
29
|
for (const rpcUrl of rpcUrls) {
|
|
14
30
|
if (!connections.get(rpcUrl)) {
|
|
15
|
-
const connection =
|
|
31
|
+
const connection = (await isJitoRpc(rpcUrl))
|
|
32
|
+
? new JitoConnection(rpcUrl, detectCluster(rpcUrl))
|
|
33
|
+
: new Connection(rpcUrl)
|
|
16
34
|
connections.set(rpcUrl, connection)
|
|
17
35
|
}
|
|
18
36
|
}
|
|
@@ -22,11 +40,24 @@ const ensureConnections = async (): Promise<void> => {
|
|
|
22
40
|
* Wrapper around getting the connection (RPC provider) for Solana
|
|
23
41
|
* @returns - Solana RPC connections
|
|
24
42
|
*/
|
|
25
|
-
export const getSolanaConnections = async (): Promise<
|
|
43
|
+
export const getSolanaConnections = async (): Promise<
|
|
44
|
+
(Connection | JitoConnection)[]
|
|
45
|
+
> => {
|
|
26
46
|
await ensureConnections()
|
|
27
47
|
return Array.from(connections.values())
|
|
28
48
|
}
|
|
29
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Get Jito-enabled connections only
|
|
52
|
+
* @returns - Array of JitoConnection instances
|
|
53
|
+
*/
|
|
54
|
+
export const getJitoConnections = async (): Promise<JitoConnection[]> => {
|
|
55
|
+
await ensureConnections()
|
|
56
|
+
return Array.from(connections.values()).filter(
|
|
57
|
+
(conn): conn is JitoConnection => conn instanceof JitoConnection
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
30
61
|
/**
|
|
31
62
|
* Calls a function on the Connection instances with retry logic.
|
|
32
63
|
* @param fn - The function to call, which receives a Connection instance.
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Cluster,
|
|
3
|
+
Connection,
|
|
4
|
+
type VersionedTransaction,
|
|
5
|
+
} from '@solana/web3.js'
|
|
6
|
+
import { uint8ArrayToBase64 } from '../../../utils/uint8ArrayToBase64.js'
|
|
7
|
+
import { JITO_TIP_ACCOUNTS } from './constants.js'
|
|
8
|
+
|
|
9
|
+
export type SimulateBundleResult = {
|
|
10
|
+
value: {
|
|
11
|
+
summary: 'succeeded' | { failed: { error: any; tx_signature: string } }
|
|
12
|
+
transactionResults: Array<{
|
|
13
|
+
err: any
|
|
14
|
+
logs: string[] | null
|
|
15
|
+
unitsConsumed?: number
|
|
16
|
+
}>
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Extended Connection class with Jito bundle support
|
|
22
|
+
* Adds simulateBundle, sendBundle, and getTipAccounts methods
|
|
23
|
+
*/
|
|
24
|
+
export class JitoConnection extends Connection {
|
|
25
|
+
private tipAccountsCache: string[] | null = null
|
|
26
|
+
private cluster: Cluster
|
|
27
|
+
|
|
28
|
+
constructor(endpoint: string, cluster: Cluster = 'mainnet-beta') {
|
|
29
|
+
super(endpoint)
|
|
30
|
+
this.cluster = cluster
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Makes a direct RPC request to the Jito-enabled endpoint
|
|
35
|
+
*/
|
|
36
|
+
private async rpcRequest<T>(method: string, params: any[]): Promise<T> {
|
|
37
|
+
const response = await fetch(this.rpcEndpoint, {
|
|
38
|
+
method: 'POST',
|
|
39
|
+
headers: {
|
|
40
|
+
'Content-Type': 'application/json',
|
|
41
|
+
},
|
|
42
|
+
body: JSON.stringify({
|
|
43
|
+
jsonrpc: '2.0',
|
|
44
|
+
id: 1,
|
|
45
|
+
method,
|
|
46
|
+
params,
|
|
47
|
+
}),
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
const data = await response.json()
|
|
51
|
+
if (data.error) {
|
|
52
|
+
throw new Error(`Jito RPC Error: ${data.error.message}`)
|
|
53
|
+
}
|
|
54
|
+
return data.result
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Serialize a transaction to base64 for RPC submission
|
|
59
|
+
*/
|
|
60
|
+
private serializeTransaction(transaction: VersionedTransaction): string {
|
|
61
|
+
return uint8ArrayToBase64(transaction.serialize())
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get the tip accounts from the Jito endpoint
|
|
66
|
+
* Results are cached to avoid repeated RPC calls
|
|
67
|
+
*/
|
|
68
|
+
async getTipAccounts(): Promise<string[]> {
|
|
69
|
+
if (this.tipAccountsCache) {
|
|
70
|
+
return this.tipAccountsCache
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
const accounts = await this.rpcRequest<string[]>('getTipAccounts', [])
|
|
75
|
+
this.tipAccountsCache = accounts
|
|
76
|
+
return accounts
|
|
77
|
+
} catch (error) {
|
|
78
|
+
const fallbackAccounts = JITO_TIP_ACCOUNTS[this.cluster]
|
|
79
|
+
console.warn(
|
|
80
|
+
`Failed to fetch tip accounts from RPC, using ${this.cluster} fallback:`,
|
|
81
|
+
error
|
|
82
|
+
)
|
|
83
|
+
return fallbackAccounts
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get a random Jito tip account to reduce contention
|
|
89
|
+
*/
|
|
90
|
+
async getRandomTipAccount(): Promise<string> {
|
|
91
|
+
const accounts = await this.getTipAccounts()
|
|
92
|
+
return accounts[Math.floor(Math.random() * accounts.length)]
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Simulate a bundle before sending it
|
|
97
|
+
* @param bundle - Array of signed transactions
|
|
98
|
+
* @returns Simulation result
|
|
99
|
+
*/
|
|
100
|
+
async simulateBundle(
|
|
101
|
+
bundle: VersionedTransaction[]
|
|
102
|
+
): Promise<SimulateBundleResult> {
|
|
103
|
+
const encodedTransactions = bundle.map((tx) =>
|
|
104
|
+
this.serializeTransaction(tx)
|
|
105
|
+
)
|
|
106
|
+
return this.rpcRequest<SimulateBundleResult>('simulateBundle', [
|
|
107
|
+
{ encodedTransactions },
|
|
108
|
+
])
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Send a bundle to the Jito block engine
|
|
113
|
+
* @param bundle - Array of signed transactions
|
|
114
|
+
* @returns Bundle UUID
|
|
115
|
+
*/
|
|
116
|
+
async sendBundle(bundle: VersionedTransaction[]): Promise<string> {
|
|
117
|
+
const encodedTransactions = bundle.map((tx) =>
|
|
118
|
+
this.serializeTransaction(tx)
|
|
119
|
+
)
|
|
120
|
+
return this.rpcRequest<string>('sendBundle', [encodedTransactions])
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Cluster } from '@solana/web3.js'
|
|
2
|
+
|
|
3
|
+
// Jito Tip accounts gotten from https://jito-foundation.gitbook.io/mev/mev-payment-and-distribution/on-chain-addresses
|
|
4
|
+
export const JITO_TIP_ACCOUNTS: Record<Cluster, string[]> = {
|
|
5
|
+
'mainnet-beta': [
|
|
6
|
+
'Cw8CFyM9FkoMi7K7Crf6HNQqf4uEMzpKw6QNghXLvLkY',
|
|
7
|
+
'DttWaMuVvTiduZRnguLF7jNxTgiMBZ1hyAumKUiL2KRL',
|
|
8
|
+
'96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5',
|
|
9
|
+
'3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT',
|
|
10
|
+
'HFqU5x63VTqvQss8hp11i4wVV8bD44PvwucfZ2bU7gRe',
|
|
11
|
+
'ADaUMid9yfUytqMBgopwjb2DTLSokTSzL1zt6iGPaS49',
|
|
12
|
+
'ADuUkR4vqLUMWXxW9gh6D6L8pMSawimctcNZ5pGwDcEt',
|
|
13
|
+
'DfXygSm4jCyNCybVYYK6DwvWqjKee8pbDmJGcLWNDXjh',
|
|
14
|
+
],
|
|
15
|
+
devnet: [],
|
|
16
|
+
testnet: [
|
|
17
|
+
'BkMx5bRzQeP6tUZgzEs3xeDWJfQiLYvNDqSgmGZKYJDq',
|
|
18
|
+
'CwWZzvRgmxj9WLLhdoWUVrHZ1J8db3w2iptKuAitHqoC',
|
|
19
|
+
'4uRnem4BfVpZBv7kShVxUYtcipscgZMSHi3B9CSL6gAA',
|
|
20
|
+
'AzfhMPcx3qjbvCK3UUy868qmc5L451W341cpFqdL3EBe',
|
|
21
|
+
'84DrGKhycCUGfLzw8hXsUYX9SnWdh2wW3ozsTPrC5xyg',
|
|
22
|
+
'7aewvu8fMf1DK4fKoMXKfs3h3wpAQ7r7D8T1C71LmMF',
|
|
23
|
+
'G2d63CEgKBdgtpYT2BuheYQ9HFuFCenuHLNyKVpqAuSD',
|
|
24
|
+
'F7ThiQUBYiEcyaxpmMuUeACdoiSLKg4SZZ8JSfpFNwAf',
|
|
25
|
+
],
|
|
26
|
+
}
|