@atomiqlabs/chain-solana 13.5.13 → 13.5.14
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/LICENSE +201 -201
- package/README.md +73 -73
- package/dist/index.d.ts +81 -81
- package/dist/index.js +102 -102
- package/dist/node/index.d.ts +9 -9
- package/dist/node/index.js +13 -13
- package/dist/solana/SolanaChainType.d.ts +15 -15
- package/dist/solana/SolanaChainType.js +2 -2
- package/dist/solana/SolanaChains.d.ts +12 -12
- package/dist/solana/SolanaChains.js +45 -45
- package/dist/solana/SolanaInitializer.d.ts +94 -94
- package/dist/solana/SolanaInitializer.js +174 -174
- package/dist/solana/btcrelay/SolanaBtcRelay.d.ts +222 -222
- package/dist/solana/btcrelay/SolanaBtcRelay.js +455 -455
- package/dist/solana/btcrelay/headers/SolanaBtcHeader.d.ts +84 -84
- package/dist/solana/btcrelay/headers/SolanaBtcHeader.js +70 -70
- package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.d.ts +92 -92
- package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.js +109 -109
- package/dist/solana/btcrelay/program/programIdl.json +671 -671
- package/dist/solana/chain/SolanaAction.d.ts +26 -26
- package/dist/solana/chain/SolanaAction.js +87 -87
- package/dist/solana/chain/SolanaChainInterface.d.ts +224 -224
- package/dist/solana/chain/SolanaChainInterface.js +275 -275
- package/dist/solana/chain/SolanaModule.d.ts +14 -14
- package/dist/solana/chain/SolanaModule.js +13 -13
- package/dist/solana/chain/modules/SolanaAddresses.d.ts +8 -8
- package/dist/solana/chain/modules/SolanaAddresses.js +22 -22
- package/dist/solana/chain/modules/SolanaBlocks.d.ts +32 -32
- package/dist/solana/chain/modules/SolanaBlocks.js +78 -78
- package/dist/solana/chain/modules/SolanaEvents.d.ts +68 -68
- package/dist/solana/chain/modules/SolanaEvents.js +238 -238
- package/dist/solana/chain/modules/SolanaFees.d.ts +189 -189
- package/dist/solana/chain/modules/SolanaFees.js +434 -434
- package/dist/solana/chain/modules/SolanaSignatures.d.ts +24 -24
- package/dist/solana/chain/modules/SolanaSignatures.js +39 -39
- package/dist/solana/chain/modules/SolanaSlots.d.ts +33 -33
- package/dist/solana/chain/modules/SolanaSlots.js +72 -72
- package/dist/solana/chain/modules/SolanaTokens.d.ts +123 -123
- package/dist/solana/chain/modules/SolanaTokens.js +242 -242
- package/dist/solana/chain/modules/SolanaTransactions.d.ts +149 -149
- package/dist/solana/chain/modules/SolanaTransactions.js +445 -445
- package/dist/solana/connection/ConnectionWithRetries.d.ts +35 -35
- package/dist/solana/connection/ConnectionWithRetries.js +86 -71
- package/dist/solana/events/SolanaChainEvents.d.ts +45 -45
- package/dist/solana/events/SolanaChainEvents.js +108 -108
- package/dist/solana/events/SolanaChainEventsBrowser.d.ts +205 -205
- package/dist/solana/events/SolanaChainEventsBrowser.js +404 -404
- package/dist/solana/program/SolanaProgramBase.d.ts +73 -73
- package/dist/solana/program/SolanaProgramBase.js +54 -54
- package/dist/solana/program/SolanaProgramModule.d.ts +8 -8
- package/dist/solana/program/SolanaProgramModule.js +11 -11
- package/dist/solana/program/modules/SolanaProgramEvents.d.ts +53 -53
- package/dist/solana/program/modules/SolanaProgramEvents.js +117 -117
- package/dist/solana/swaps/SolanaSwapData.d.ts +333 -333
- package/dist/solana/swaps/SolanaSwapData.js +535 -535
- package/dist/solana/swaps/SolanaSwapModule.d.ts +11 -11
- package/dist/solana/swaps/SolanaSwapModule.js +12 -12
- package/dist/solana/swaps/SolanaSwapProgram.d.ts +376 -376
- package/dist/solana/swaps/SolanaSwapProgram.js +769 -769
- package/dist/solana/swaps/SwapTypeEnum.d.ts +11 -11
- package/dist/solana/swaps/SwapTypeEnum.js +43 -43
- package/dist/solana/swaps/modules/SolanaDataAccount.d.ts +95 -95
- package/dist/solana/swaps/modules/SolanaDataAccount.js +232 -232
- package/dist/solana/swaps/modules/SolanaLpVault.d.ts +69 -69
- package/dist/solana/swaps/modules/SolanaLpVault.js +171 -171
- package/dist/solana/swaps/modules/SwapClaim.d.ts +126 -126
- package/dist/solana/swaps/modules/SwapClaim.js +294 -294
- package/dist/solana/swaps/modules/SwapInit.d.ts +213 -213
- package/dist/solana/swaps/modules/SwapInit.js +658 -658
- package/dist/solana/swaps/modules/SwapRefund.d.ts +87 -87
- package/dist/solana/swaps/modules/SwapRefund.js +293 -293
- package/dist/solana/swaps/programIdl.json +945 -945
- package/dist/solana/swaps/programTypes.d.ts +943 -943
- package/dist/solana/swaps/programTypes.js +945 -945
- package/dist/solana/swaps/v1/programIdl.json +945 -945
- package/dist/solana/swaps/v1/programTypes.d.ts +943 -943
- package/dist/solana/swaps/v1/programTypes.js +945 -945
- package/dist/solana/swaps/v2/programIdl.json +952 -952
- package/dist/solana/swaps/v2/programTypes.d.ts +950 -950
- package/dist/solana/swaps/v2/programTypes.js +952 -952
- package/dist/solana/wallet/SolanaKeypairWallet.d.ts +29 -29
- package/dist/solana/wallet/SolanaKeypairWallet.js +50 -50
- package/dist/solana/wallet/SolanaSigner.d.ts +30 -30
- package/dist/solana/wallet/SolanaSigner.js +30 -30
- package/dist/utils/Utils.d.ts +58 -58
- package/dist/utils/Utils.js +170 -170
- package/node/index.d.ts +1 -1
- package/node/index.js +3 -3
- package/package.json +46 -46
- package/src/index.ts +87 -87
- package/src/node/index.ts +9 -9
- package/src/solana/SolanaChainType.ts +32 -32
- package/src/solana/SolanaChains.ts +46 -46
- package/src/solana/SolanaInitializer.ts +278 -278
- package/src/solana/btcrelay/SolanaBtcRelay.ts +615 -615
- package/src/solana/btcrelay/headers/SolanaBtcHeader.ts +116 -116
- package/src/solana/btcrelay/headers/SolanaBtcStoredHeader.ts +148 -148
- package/src/solana/btcrelay/program/programIdl.json +670 -670
- package/src/solana/chain/SolanaAction.ts +109 -109
- package/src/solana/chain/SolanaChainInterface.ts +404 -404
- package/src/solana/chain/SolanaModule.ts +20 -20
- package/src/solana/chain/modules/SolanaAddresses.ts +20 -20
- package/src/solana/chain/modules/SolanaBlocks.ts +89 -89
- package/src/solana/chain/modules/SolanaEvents.ts +271 -271
- package/src/solana/chain/modules/SolanaFees.ts +522 -522
- package/src/solana/chain/modules/SolanaSignatures.ts +39 -39
- package/src/solana/chain/modules/SolanaSlots.ts +85 -85
- package/src/solana/chain/modules/SolanaTokens.ts +300 -300
- package/src/solana/chain/modules/SolanaTransactions.ts +503 -503
- package/src/solana/connection/ConnectionWithRetries.ts +113 -96
- package/src/solana/events/SolanaChainEvents.ts +127 -127
- package/src/solana/events/SolanaChainEventsBrowser.ts +495 -495
- package/src/solana/program/SolanaProgramBase.ts +119 -119
- package/src/solana/program/SolanaProgramModule.ts +15 -15
- package/src/solana/program/modules/SolanaProgramEvents.ts +157 -157
- package/src/solana/swaps/SolanaSwapData.ts +735 -735
- package/src/solana/swaps/SolanaSwapModule.ts +19 -19
- package/src/solana/swaps/SolanaSwapProgram.ts +1074 -1074
- package/src/solana/swaps/SwapTypeEnum.ts +30 -30
- package/src/solana/swaps/modules/SolanaDataAccount.ts +302 -302
- package/src/solana/swaps/modules/SolanaLpVault.ts +208 -208
- package/src/solana/swaps/modules/SwapClaim.ts +387 -387
- package/src/solana/swaps/modules/SwapInit.ts +785 -785
- package/src/solana/swaps/modules/SwapRefund.ts +353 -353
- package/src/solana/swaps/v1/programIdl.json +944 -944
- package/src/solana/swaps/v1/programTypes.ts +1885 -1885
- package/src/solana/swaps/v2/programIdl.json +951 -951
- package/src/solana/swaps/v2/programTypes.ts +1899 -1899
- package/src/solana/wallet/SolanaKeypairWallet.ts +56 -56
- package/src/solana/wallet/SolanaSigner.ts +43 -43
- package/src/utils/Utils.ts +194 -194
|
@@ -1,189 +1,189 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { Connection, PublicKey, SendOptions, Transaction } from "@solana/web3.js";
|
|
4
|
-
/**
|
|
5
|
-
* Bribe configuration used for Jito-like tips that handled outside of native Solana network fees
|
|
6
|
-
*
|
|
7
|
-
* @category Chain Interface
|
|
8
|
-
*/
|
|
9
|
-
export type FeeBribeData = {
|
|
10
|
-
/**
|
|
11
|
-
* Address to send the bribe to (e.g. Jito tip)
|
|
12
|
-
*/
|
|
13
|
-
address: string;
|
|
14
|
-
/**
|
|
15
|
-
* HTTP endpoint to send the transaction to instead of the RPC, e.g. a Jito endpoint
|
|
16
|
-
*/
|
|
17
|
-
endpoint: string;
|
|
18
|
-
/**
|
|
19
|
-
* An optional function for overriding the bribe to be sent to the specified address for the tx
|
|
20
|
-
*/
|
|
21
|
-
getBribeFee?: (original: bigint) => bigint;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Fee estimation service for the Solana network. Uses client-side fee estimation algorithm by default, which
|
|
25
|
-
* fetches a bunch (default 8) random blocks in the past period (default 150) and computes the average fee. It
|
|
26
|
-
* automatically detects whether the underlying RPC endpoint is a Helius one which features the `getPriorityFeeEstimate`
|
|
27
|
-
* endpoint, and if available uses that one.
|
|
28
|
-
*
|
|
29
|
-
* @category Chain Interface
|
|
30
|
-
*/
|
|
31
|
-
export declare class SolanaFees {
|
|
32
|
-
private readonly connection;
|
|
33
|
-
private readonly maxFeeMicroLamports;
|
|
34
|
-
private readonly numSamples;
|
|
35
|
-
private readonly period;
|
|
36
|
-
private useHeliusApi;
|
|
37
|
-
private heliusApiSupported;
|
|
38
|
-
private readonly heliusFeeLevel;
|
|
39
|
-
private readonly bribeData?;
|
|
40
|
-
private readonly getStaticFee?;
|
|
41
|
-
private readonly logger;
|
|
42
|
-
private blockFeeCache?;
|
|
43
|
-
/**
|
|
44
|
-
* @param connection Underlying Solana network connection to use for read access to Solana
|
|
45
|
-
* @param maxFeeMicroLamports Maximum allowed fee in microLamports/CU (1/1,000,000 of a lamport per compute unit)
|
|
46
|
-
* @param numSamples Number of samples to use when estimating the global fee on the client-side, this many blocks are
|
|
47
|
-
* sampled from the last `period` blocks to estimate an average fee rate
|
|
48
|
-
* @param period Period of past blocks to sample random blocks from when estimating the global fee on the client-side
|
|
49
|
-
* @param useHeliusApi Whether to use the helius API or not, default to `"auto"`, which automatically detects if the
|
|
50
|
-
* underlying RPC supports Helius's `getPriorityFeeEstimate` RPC call
|
|
51
|
-
* @param heliusFeeLevel Fee level to use when fetching the fee rate from Helius's `getPriorityFeeEstimate` RPC endpoint,
|
|
52
|
-
* for the meaning of the different levels refer to https://www.helius.dev/docs/priority-fee-api#priority-levels-explained
|
|
53
|
-
* @param getStaticFee Optional function for adding a base fee to transactions (this function returns the base fee
|
|
54
|
-
* in lamports to be added to the transaction) - this fee doesn't scale with CUs of the transaction and is instead
|
|
55
|
-
* applied as-is
|
|
56
|
-
* @param bribeData Bribe fee configuration (used for e.g. Jito tips)
|
|
57
|
-
*/
|
|
58
|
-
constructor(connection: Connection, maxFeeMicroLamports?: number, numSamples?: number, period?: number, useHeliusApi?: "yes" | "no" | "auto", heliusFeeLevel?: "min" | "low" | "medium" | "high" | "veryHigh" | "unsafeMax", getStaticFee?: (feeRate: bigint) => bigint, bribeData?: FeeBribeData);
|
|
59
|
-
/**
|
|
60
|
-
* Returns solana block with transactionDetails="signatures"
|
|
61
|
-
*
|
|
62
|
-
* @param slot
|
|
63
|
-
* @private
|
|
64
|
-
*/
|
|
65
|
-
private getBlockWithSignature;
|
|
66
|
-
/**
|
|
67
|
-
* Returns fee estimate from Helius API - only works with Helius RPC, return null for all other RPC providers
|
|
68
|
-
*
|
|
69
|
-
* @param mutableAccounts
|
|
70
|
-
* @private
|
|
71
|
-
*/
|
|
72
|
-
private getPriorityFeeEstimate;
|
|
73
|
-
/**
|
|
74
|
-
* Sends the transaction over Jito
|
|
75
|
-
*
|
|
76
|
-
* @param tx
|
|
77
|
-
* @param options
|
|
78
|
-
* @private
|
|
79
|
-
* @returns {Promise<string>} transaction signature
|
|
80
|
-
*/
|
|
81
|
-
private sendJitoTx;
|
|
82
|
-
/**
|
|
83
|
-
* Checks whether the transaction should be sent over Jito, returns the fee paid to Jito in case the transaction
|
|
84
|
-
* should be sent over Jito, returns null if the transaction shouldn't be sent over Jito
|
|
85
|
-
*
|
|
86
|
-
* @param parsedTx
|
|
87
|
-
* @private
|
|
88
|
-
*/
|
|
89
|
-
private getJitoTxFee;
|
|
90
|
-
/**
|
|
91
|
-
* Gets the mean microLamports/CU fee rate for the block at a specific slot
|
|
92
|
-
*
|
|
93
|
-
* @param slot
|
|
94
|
-
* @private
|
|
95
|
-
*/
|
|
96
|
-
private getBlockMeanFeeRate;
|
|
97
|
-
/**
|
|
98
|
-
* Manually gets global fee rate by sampling random blocks over the last period
|
|
99
|
-
*
|
|
100
|
-
* @private
|
|
101
|
-
* @returns {Promise<BN>} sampled mean microLamports/CU fee over the last period
|
|
102
|
-
*/
|
|
103
|
-
private _getGlobalFeeRate;
|
|
104
|
-
/**
|
|
105
|
-
* Gets the combined microLamports/CU fee rate (from localized & global fee market)
|
|
106
|
-
*
|
|
107
|
-
* @param mutableAccounts
|
|
108
|
-
* @private
|
|
109
|
-
*/
|
|
110
|
-
private _getFeeRate;
|
|
111
|
-
/**
|
|
112
|
-
* Gets global fee rate, with caching
|
|
113
|
-
*
|
|
114
|
-
* @returns {Promise<BN>} global fee rate microLamports/CU
|
|
115
|
-
*/
|
|
116
|
-
getGlobalFeeRate(): Promise<bigint>;
|
|
117
|
-
/**
|
|
118
|
-
* Gets the combined microLamports/CU fee rate (from localized & global fee market), cached & adjusted as for
|
|
119
|
-
* when bribe and/or static fee should be included, format: <uLamports/CU>;<static fee lamport>[;<bribe address>]
|
|
120
|
-
*
|
|
121
|
-
* @param mutableAccounts
|
|
122
|
-
* @private
|
|
123
|
-
*/
|
|
124
|
-
getFeeRate(mutableAccounts: PublicKey[]): Promise<string>;
|
|
125
|
-
/**
|
|
126
|
-
* Calculates the total priority fee paid for a given compute budget at a given fee rate
|
|
127
|
-
*
|
|
128
|
-
* @param computeUnits
|
|
129
|
-
* @param feeRate
|
|
130
|
-
* @param includeStaticFee whether the include the static/base part of the fee rate
|
|
131
|
-
*/
|
|
132
|
-
getPriorityFee(computeUnits: number, feeRate: string, includeStaticFee?: boolean): bigint;
|
|
133
|
-
/**
|
|
134
|
-
* Applies fee rate to a transaction, should be called before adding instructions to the transaction, specifically
|
|
135
|
-
* it adds the setComputeUnitLimit & setComputeUnitPrice instruction.
|
|
136
|
-
*
|
|
137
|
-
* @example
|
|
138
|
-
* ```typescript
|
|
139
|
-
* const feeRate = solanaFees.getFeeRate([...writeableAccounts]);
|
|
140
|
-
* const tx = new Transaction();
|
|
141
|
-
* //Apply the fee rate part at the beginning of the transaction (specifically setComputeUnitLimit & setComputeUnitPrice)
|
|
142
|
-
* SolanaFees.applyFeeRateBegin(tx, feeRate);
|
|
143
|
-
* //Add instructions here
|
|
144
|
-
* tx.add(instruction1);
|
|
145
|
-
* tx.add(instruction2);
|
|
146
|
-
* //Set the fee payer
|
|
147
|
-
* tx.feePayer = feePayerPublicKey;
|
|
148
|
-
* //Apply the fee rate part at the end of the transaction (specifically the transfer to the bribe account, e.g. Jito tip)
|
|
149
|
-
* SolanaFees.applyFeeRateEnd(tx, feeRate);
|
|
150
|
-
* ```
|
|
151
|
-
*
|
|
152
|
-
* @param tx
|
|
153
|
-
* @param computeBudget
|
|
154
|
-
* @param feeRate
|
|
155
|
-
*/
|
|
156
|
-
static applyFeeRateBegin(tx: Transaction, computeBudget: number | null, feeRate: string): void;
|
|
157
|
-
/**
|
|
158
|
-
* Applies fee rate to a transaction, should be called after adding instructions to the transaction, specifically
|
|
159
|
-
* it adds the adds the bribe SystemProgram.transfer instruction.
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* ```typescript
|
|
163
|
-
* const feeRate = solanaFees.getFeeRate([...writeableAccounts]);
|
|
164
|
-
* const tx = new Transaction();
|
|
165
|
-
* //Apply the fee rate part at the beginning of the transaction (specifically setComputeUnitLimit & setComputeUnitPrice)
|
|
166
|
-
* SolanaFees.applyFeeRateBegin(tx, feeRate);
|
|
167
|
-
* //Add instructions here
|
|
168
|
-
* tx.add(instruction1);
|
|
169
|
-
* tx.add(instruction2);
|
|
170
|
-
* //Set the fee payer
|
|
171
|
-
* tx.feePayer = feePayerPublicKey;
|
|
172
|
-
* //Apply the fee rate part at the end of the transaction (specifically the transfer to the bribe account, e.g. Jito tip)
|
|
173
|
-
* SolanaFees.applyFeeRateEnd(tx, feeRate);
|
|
174
|
-
* ```
|
|
175
|
-
*
|
|
176
|
-
* @param tx
|
|
177
|
-
* @param computeBudget
|
|
178
|
-
* @param feeRate
|
|
179
|
-
*/
|
|
180
|
-
static applyFeeRateEnd(tx: Transaction, computeBudget: number | null, feeRate: string): void;
|
|
181
|
-
/**
|
|
182
|
-
* Checks if the transaction should be submitted over Jito and if yes submits it
|
|
183
|
-
*
|
|
184
|
-
* @param tx Raw signed transaction to be attempted to be sent over Jito
|
|
185
|
-
* @param options Send options for the sendTransaction RPC call
|
|
186
|
-
* @returns {Promise<string | null>} null if the transaction was not sent over Jito, tx signature when tx was sent over Jito
|
|
187
|
-
*/
|
|
188
|
-
submitTx(tx: Buffer, options?: SendOptions): Promise<string | null>;
|
|
189
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Connection, PublicKey, SendOptions, Transaction } from "@solana/web3.js";
|
|
4
|
+
/**
|
|
5
|
+
* Bribe configuration used for Jito-like tips that handled outside of native Solana network fees
|
|
6
|
+
*
|
|
7
|
+
* @category Chain Interface
|
|
8
|
+
*/
|
|
9
|
+
export type FeeBribeData = {
|
|
10
|
+
/**
|
|
11
|
+
* Address to send the bribe to (e.g. Jito tip)
|
|
12
|
+
*/
|
|
13
|
+
address: string;
|
|
14
|
+
/**
|
|
15
|
+
* HTTP endpoint to send the transaction to instead of the RPC, e.g. a Jito endpoint
|
|
16
|
+
*/
|
|
17
|
+
endpoint: string;
|
|
18
|
+
/**
|
|
19
|
+
* An optional function for overriding the bribe to be sent to the specified address for the tx
|
|
20
|
+
*/
|
|
21
|
+
getBribeFee?: (original: bigint) => bigint;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Fee estimation service for the Solana network. Uses client-side fee estimation algorithm by default, which
|
|
25
|
+
* fetches a bunch (default 8) random blocks in the past period (default 150) and computes the average fee. It
|
|
26
|
+
* automatically detects whether the underlying RPC endpoint is a Helius one which features the `getPriorityFeeEstimate`
|
|
27
|
+
* endpoint, and if available uses that one.
|
|
28
|
+
*
|
|
29
|
+
* @category Chain Interface
|
|
30
|
+
*/
|
|
31
|
+
export declare class SolanaFees {
|
|
32
|
+
private readonly connection;
|
|
33
|
+
private readonly maxFeeMicroLamports;
|
|
34
|
+
private readonly numSamples;
|
|
35
|
+
private readonly period;
|
|
36
|
+
private useHeliusApi;
|
|
37
|
+
private heliusApiSupported;
|
|
38
|
+
private readonly heliusFeeLevel;
|
|
39
|
+
private readonly bribeData?;
|
|
40
|
+
private readonly getStaticFee?;
|
|
41
|
+
private readonly logger;
|
|
42
|
+
private blockFeeCache?;
|
|
43
|
+
/**
|
|
44
|
+
* @param connection Underlying Solana network connection to use for read access to Solana
|
|
45
|
+
* @param maxFeeMicroLamports Maximum allowed fee in microLamports/CU (1/1,000,000 of a lamport per compute unit)
|
|
46
|
+
* @param numSamples Number of samples to use when estimating the global fee on the client-side, this many blocks are
|
|
47
|
+
* sampled from the last `period` blocks to estimate an average fee rate
|
|
48
|
+
* @param period Period of past blocks to sample random blocks from when estimating the global fee on the client-side
|
|
49
|
+
* @param useHeliusApi Whether to use the helius API or not, default to `"auto"`, which automatically detects if the
|
|
50
|
+
* underlying RPC supports Helius's `getPriorityFeeEstimate` RPC call
|
|
51
|
+
* @param heliusFeeLevel Fee level to use when fetching the fee rate from Helius's `getPriorityFeeEstimate` RPC endpoint,
|
|
52
|
+
* for the meaning of the different levels refer to https://www.helius.dev/docs/priority-fee-api#priority-levels-explained
|
|
53
|
+
* @param getStaticFee Optional function for adding a base fee to transactions (this function returns the base fee
|
|
54
|
+
* in lamports to be added to the transaction) - this fee doesn't scale with CUs of the transaction and is instead
|
|
55
|
+
* applied as-is
|
|
56
|
+
* @param bribeData Bribe fee configuration (used for e.g. Jito tips)
|
|
57
|
+
*/
|
|
58
|
+
constructor(connection: Connection, maxFeeMicroLamports?: number, numSamples?: number, period?: number, useHeliusApi?: "yes" | "no" | "auto", heliusFeeLevel?: "min" | "low" | "medium" | "high" | "veryHigh" | "unsafeMax", getStaticFee?: (feeRate: bigint) => bigint, bribeData?: FeeBribeData);
|
|
59
|
+
/**
|
|
60
|
+
* Returns solana block with transactionDetails="signatures"
|
|
61
|
+
*
|
|
62
|
+
* @param slot
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
private getBlockWithSignature;
|
|
66
|
+
/**
|
|
67
|
+
* Returns fee estimate from Helius API - only works with Helius RPC, return null for all other RPC providers
|
|
68
|
+
*
|
|
69
|
+
* @param mutableAccounts
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
private getPriorityFeeEstimate;
|
|
73
|
+
/**
|
|
74
|
+
* Sends the transaction over Jito
|
|
75
|
+
*
|
|
76
|
+
* @param tx
|
|
77
|
+
* @param options
|
|
78
|
+
* @private
|
|
79
|
+
* @returns {Promise<string>} transaction signature
|
|
80
|
+
*/
|
|
81
|
+
private sendJitoTx;
|
|
82
|
+
/**
|
|
83
|
+
* Checks whether the transaction should be sent over Jito, returns the fee paid to Jito in case the transaction
|
|
84
|
+
* should be sent over Jito, returns null if the transaction shouldn't be sent over Jito
|
|
85
|
+
*
|
|
86
|
+
* @param parsedTx
|
|
87
|
+
* @private
|
|
88
|
+
*/
|
|
89
|
+
private getJitoTxFee;
|
|
90
|
+
/**
|
|
91
|
+
* Gets the mean microLamports/CU fee rate for the block at a specific slot
|
|
92
|
+
*
|
|
93
|
+
* @param slot
|
|
94
|
+
* @private
|
|
95
|
+
*/
|
|
96
|
+
private getBlockMeanFeeRate;
|
|
97
|
+
/**
|
|
98
|
+
* Manually gets global fee rate by sampling random blocks over the last period
|
|
99
|
+
*
|
|
100
|
+
* @private
|
|
101
|
+
* @returns {Promise<BN>} sampled mean microLamports/CU fee over the last period
|
|
102
|
+
*/
|
|
103
|
+
private _getGlobalFeeRate;
|
|
104
|
+
/**
|
|
105
|
+
* Gets the combined microLamports/CU fee rate (from localized & global fee market)
|
|
106
|
+
*
|
|
107
|
+
* @param mutableAccounts
|
|
108
|
+
* @private
|
|
109
|
+
*/
|
|
110
|
+
private _getFeeRate;
|
|
111
|
+
/**
|
|
112
|
+
* Gets global fee rate, with caching
|
|
113
|
+
*
|
|
114
|
+
* @returns {Promise<BN>} global fee rate microLamports/CU
|
|
115
|
+
*/
|
|
116
|
+
getGlobalFeeRate(): Promise<bigint>;
|
|
117
|
+
/**
|
|
118
|
+
* Gets the combined microLamports/CU fee rate (from localized & global fee market), cached & adjusted as for
|
|
119
|
+
* when bribe and/or static fee should be included, format: <uLamports/CU>;<static fee lamport>[;<bribe address>]
|
|
120
|
+
*
|
|
121
|
+
* @param mutableAccounts
|
|
122
|
+
* @private
|
|
123
|
+
*/
|
|
124
|
+
getFeeRate(mutableAccounts: PublicKey[]): Promise<string>;
|
|
125
|
+
/**
|
|
126
|
+
* Calculates the total priority fee paid for a given compute budget at a given fee rate
|
|
127
|
+
*
|
|
128
|
+
* @param computeUnits
|
|
129
|
+
* @param feeRate
|
|
130
|
+
* @param includeStaticFee whether the include the static/base part of the fee rate
|
|
131
|
+
*/
|
|
132
|
+
getPriorityFee(computeUnits: number, feeRate: string, includeStaticFee?: boolean): bigint;
|
|
133
|
+
/**
|
|
134
|
+
* Applies fee rate to a transaction, should be called before adding instructions to the transaction, specifically
|
|
135
|
+
* it adds the setComputeUnitLimit & setComputeUnitPrice instruction.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const feeRate = solanaFees.getFeeRate([...writeableAccounts]);
|
|
140
|
+
* const tx = new Transaction();
|
|
141
|
+
* //Apply the fee rate part at the beginning of the transaction (specifically setComputeUnitLimit & setComputeUnitPrice)
|
|
142
|
+
* SolanaFees.applyFeeRateBegin(tx, feeRate);
|
|
143
|
+
* //Add instructions here
|
|
144
|
+
* tx.add(instruction1);
|
|
145
|
+
* tx.add(instruction2);
|
|
146
|
+
* //Set the fee payer
|
|
147
|
+
* tx.feePayer = feePayerPublicKey;
|
|
148
|
+
* //Apply the fee rate part at the end of the transaction (specifically the transfer to the bribe account, e.g. Jito tip)
|
|
149
|
+
* SolanaFees.applyFeeRateEnd(tx, feeRate);
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
* @param tx
|
|
153
|
+
* @param computeBudget
|
|
154
|
+
* @param feeRate
|
|
155
|
+
*/
|
|
156
|
+
static applyFeeRateBegin(tx: Transaction, computeBudget: number | null, feeRate: string): void;
|
|
157
|
+
/**
|
|
158
|
+
* Applies fee rate to a transaction, should be called after adding instructions to the transaction, specifically
|
|
159
|
+
* it adds the adds the bribe SystemProgram.transfer instruction.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* const feeRate = solanaFees.getFeeRate([...writeableAccounts]);
|
|
164
|
+
* const tx = new Transaction();
|
|
165
|
+
* //Apply the fee rate part at the beginning of the transaction (specifically setComputeUnitLimit & setComputeUnitPrice)
|
|
166
|
+
* SolanaFees.applyFeeRateBegin(tx, feeRate);
|
|
167
|
+
* //Add instructions here
|
|
168
|
+
* tx.add(instruction1);
|
|
169
|
+
* tx.add(instruction2);
|
|
170
|
+
* //Set the fee payer
|
|
171
|
+
* tx.feePayer = feePayerPublicKey;
|
|
172
|
+
* //Apply the fee rate part at the end of the transaction (specifically the transfer to the bribe account, e.g. Jito tip)
|
|
173
|
+
* SolanaFees.applyFeeRateEnd(tx, feeRate);
|
|
174
|
+
* ```
|
|
175
|
+
*
|
|
176
|
+
* @param tx
|
|
177
|
+
* @param computeBudget
|
|
178
|
+
* @param feeRate
|
|
179
|
+
*/
|
|
180
|
+
static applyFeeRateEnd(tx: Transaction, computeBudget: number | null, feeRate: string): void;
|
|
181
|
+
/**
|
|
182
|
+
* Checks if the transaction should be submitted over Jito and if yes submits it
|
|
183
|
+
*
|
|
184
|
+
* @param tx Raw signed transaction to be attempted to be sent over Jito
|
|
185
|
+
* @param options Send options for the sendTransaction RPC call
|
|
186
|
+
* @returns {Promise<string | null>} null if the transaction was not sent over Jito, tx signature when tx was sent over Jito
|
|
187
|
+
*/
|
|
188
|
+
submitTx(tx: Buffer, options?: SendOptions): Promise<string | null>;
|
|
189
|
+
}
|