@pyron-finance/pyron-client 2.5.2 → 2.6.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/dist/bank-metadata-X4_5k9-u.d.cts +9488 -0
- package/dist/bank-metadata-X4_5k9-u.d.ts +9488 -0
- package/dist/common/index.cjs +1255 -68
- package/dist/common/index.d.cts +296 -2
- package/dist/common/index.d.ts +296 -2
- package/dist/common/index.js +1159 -2
- package/dist/index.cjs +27305 -25577
- package/dist/index.d.cts +3445 -2
- package/dist/index.d.ts +3445 -2
- package/dist/index.js +27137 -25337
- package/package.json +9 -7
- package/dist/chunk-DcLnE9XY.js +0 -37
- package/dist/common/index-B8FKDxAd.d.cts +0 -2
- package/dist/common/index-CyNmUxZS.d.ts +0 -2
- package/dist/common-DBVYOab7.cjs +0 -1954
- package/dist/common-IgVl6MYx.js +0 -1222
- package/dist/common-IgVl6MYx.js.map +0 -1
- package/dist/index-676IKB7k.d.ts +0 -12674
- package/dist/index-676IKB7k.d.ts.map +0 -1
- package/dist/index-B-Q6sJAm.d.cts +0 -2
- package/dist/index-B6N7zb5f.d.ts +0 -2
- package/dist/index-Mtc43T83.d.cts +0 -12675
- package/dist/index-Mtc43T83.d.cts.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/common/index.d.cts
CHANGED
|
@@ -1,2 +1,296 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Keypair, Transaction, VersionedTransaction, PublicKey, Connection, AccountInfo, AddressLookupTableAccount, TransactionMessage, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
+
import { j as Wallet, e as ExtendedTransactionProperties, S as SolanaTransaction, W as WrappedI80F48, A as Amount } from '../bank-metadata-X4_5k9-u.cjs';
|
|
3
|
+
export { a as BankExtendedMetadata, m as BankExtendedMetadataMap, X as BankExtendedMetadataOverride, h as BankMetadata, b as BankMetadataMap, l as BanksExtendedMetadataOverrideMap, E as ExtendedTransaction, f as ExtendedV0Transaction, I as InstructionsWrapper, D as MaxCapType, G as PriotitizationFeeLevels, P as Program, R as ProgramReadonly, z as TransactionArenaKeyMap, g as TransactionBroadcastType, y as TransactionConfigMap, d as TransactionOptions, C as TransactionPriorityType, F as TransactionSettings, x as TransactionType, U as WalletToken, V as bankExtendedMetadataOverrideSchema, Z as fetchBanksExtendedMetadata, H as getCalculatedPrioritizationFeeByPercentile, K as getMaxPrioritizationFeeByPercentile, N as getMeanPrioritizationFeeByPercentile, O as getMedianPrioritizationFeeByPercentile, J as getMinPrioritizationFeeByPercentile, Q as getRecentPrioritizationFeesByPercentile, Y as parseBanksMetadataOverride } from '../bank-metadata-X4_5k9-u.cjs';
|
|
4
|
+
import { Idl, Instruction, Address } from '@coral-xyz/anchor';
|
|
5
|
+
import BigNumber from 'bignumber.js';
|
|
6
|
+
import BN from 'bn.js';
|
|
7
|
+
import 'zod';
|
|
8
|
+
import '@solana/wallet-adapter-base';
|
|
9
|
+
import 'unstorage';
|
|
10
|
+
import 'zod/v4-mini';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* NodeWallet
|
|
14
|
+
*
|
|
15
|
+
* Anchor-compliant wallet implementation.
|
|
16
|
+
*/
|
|
17
|
+
declare class NodeWallet implements Wallet {
|
|
18
|
+
readonly payer: Keypair;
|
|
19
|
+
/**
|
|
20
|
+
* @param payer Keypair of the associated payer
|
|
21
|
+
*/
|
|
22
|
+
constructor(payer: Keypair);
|
|
23
|
+
signTransaction<T extends Transaction | VersionedTransaction>(tx: T): Promise<T>;
|
|
24
|
+
signAllTransactions<T extends Transaction | VersionedTransaction>(txs: T[]): Promise<T[]>;
|
|
25
|
+
get publicKey(): PublicKey;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare function floor(value: number, decimals: number): number;
|
|
29
|
+
declare function ceil(value: number, decimals: number): number;
|
|
30
|
+
declare function median(values: number[]): number;
|
|
31
|
+
|
|
32
|
+
declare function getValueInsensitive<T>(map: Record<string, T>, key: string): T;
|
|
33
|
+
/**
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
declare function sleep(ms: number): Promise<unknown>;
|
|
37
|
+
declare function chunks<T>(array: T[], size: number): T[][];
|
|
38
|
+
declare function setTimeoutPromise(duration: number, message: string): Promise<Error>;
|
|
39
|
+
declare function chunkedGetRawMultipleAccountInfos(connection: Connection, pks: string[], batchChunkSize?: number, maxAccountsChunkSize?: number): Promise<[number, Map<string, AccountInfo<Buffer>>]>;
|
|
40
|
+
declare function chunkedGetRawMultipleAccountInfoOrderedWithNulls(connection: Connection, pks: string[], batchChunkSize?: number, maxAccountsChunkSize?: number): Promise<Array<AccountInfo<Buffer> | null>>;
|
|
41
|
+
declare function chunkedGetRawMultipleAccountInfoOrdered(connection: Connection, pks: string[], batchChunkSize?: number, maxAccountsChunkSize?: number): Promise<Array<AccountInfo<Buffer>>>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Determines if a given transaction is a VersionedTransaction.
|
|
45
|
+
* This function checks for the presence of a 'message' property to identify
|
|
46
|
+
* if the transaction is of type VersionedTransaction.
|
|
47
|
+
*
|
|
48
|
+
* @param tx - The transaction object, which can be either a VersionedTransaction or a Transaction.
|
|
49
|
+
* @returns A boolean indicating whether the transaction is a VersionedTransaction.
|
|
50
|
+
*/
|
|
51
|
+
declare function isV0Tx(tx: Transaction | VersionedTransaction): tx is VersionedTransaction;
|
|
52
|
+
/**
|
|
53
|
+
* Calculates the size of a Solana transaction in bytes.
|
|
54
|
+
* This function considers the number of required signatures and other transaction components.
|
|
55
|
+
*
|
|
56
|
+
* @param tx - The transaction object, which can be either a VersionedTransaction or a Transaction.
|
|
57
|
+
* @returns The size of the transaction in bytes.
|
|
58
|
+
*/
|
|
59
|
+
declare function getTxSize(tx: VersionedTransaction | Transaction): number;
|
|
60
|
+
declare function getAccountKeys(tx: VersionedTransaction | Transaction, lookupTableAccounts: AddressLookupTableAccount[]): number;
|
|
61
|
+
/**
|
|
62
|
+
* Decodes a Solana transaction instruction using the provided Interface Definition Language (IDL).
|
|
63
|
+
* This function utilizes the BorshInstructionCoder to interpret the encoded instruction data.
|
|
64
|
+
*
|
|
65
|
+
* @param idl - The Interface Definition Language object that defines the structure of the instruction.
|
|
66
|
+
* @param encoded - The Buffer containing the encoded instruction data.
|
|
67
|
+
* @returns The decoded instruction object.
|
|
68
|
+
*/
|
|
69
|
+
declare function decodeInstruction(idl: Idl, encoded: Buffer): Instruction | null;
|
|
70
|
+
/**
|
|
71
|
+
* Decompiles a VersionedTransaction into a TransactionMessage.
|
|
72
|
+
*
|
|
73
|
+
* @param tx - The VersionedTransaction to be decompiled.
|
|
74
|
+
* @param lookupTableAccounts - An array of AddressLookupTableAccount used for decompiling the transaction message.
|
|
75
|
+
* @returns A TransactionMessage object representing the decompiled transaction.
|
|
76
|
+
*/
|
|
77
|
+
declare function decompileV0Transaction(tx: VersionedTransaction, lookupTableAccounts: AddressLookupTableAccount[]): TransactionMessage;
|
|
78
|
+
/**
|
|
79
|
+
* Options for updating a transaction.
|
|
80
|
+
* - `feePayer`: Optional public key of the fee payer. Defaults to the transaction's fee payer.
|
|
81
|
+
* - `blockhash`: Optional blockhash for the transaction. Defaults to the transaction's recent blockhash.
|
|
82
|
+
* - `addressLookupTables`: Optional array of address lookup table accounts for the transaction.
|
|
83
|
+
* - `additionalIxs`: Optional array of additional transaction instructions to include.
|
|
84
|
+
*/
|
|
85
|
+
type UpdateTxOptions = {
|
|
86
|
+
feePayer?: PublicKey;
|
|
87
|
+
blockhash?: string;
|
|
88
|
+
addressLookupTables?: AddressLookupTableAccount[];
|
|
89
|
+
additionalIxs?: TransactionInstruction[];
|
|
90
|
+
replaceOnly?: boolean;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Converts a legacy Solana transaction to a versioned transaction. *
|
|
94
|
+
* @param transaction - The legacy transaction to be converted.
|
|
95
|
+
* @param opts - Optional parameters for the conversion process.
|
|
96
|
+
* @returns A VersionedTransaction object representing the converted transaction.
|
|
97
|
+
* @throws Will throw an error if the fee payer or blockhash is not provided.
|
|
98
|
+
*/
|
|
99
|
+
declare function legacyTxToV0Tx(transaction: Transaction, opts?: UpdateTxOptions): VersionedTransaction;
|
|
100
|
+
/**
|
|
101
|
+
* Updates a VersionedTransaction with new options.
|
|
102
|
+
*
|
|
103
|
+
* This function allows you to modify a given VersionedTransaction by providing
|
|
104
|
+
* additional transaction instructions, address lookup tables, a new fee payer,
|
|
105
|
+
* and a new blockhash. It decompiles the existing transaction, applies the updates,
|
|
106
|
+
* and recompiles it into a new VersionedTransaction.
|
|
107
|
+
*
|
|
108
|
+
* @param transaction - The VersionedTransaction to be updated.
|
|
109
|
+
* @param opts - Optional parameters for updating the transaction.
|
|
110
|
+
* @returns A new VersionedTransaction object with the applied updates.
|
|
111
|
+
* @throws Will throw an error if the fee payer or blockhash is not provided.
|
|
112
|
+
*/
|
|
113
|
+
declare function updateV0Tx(transaction: VersionedTransaction, opts?: UpdateTxOptions): VersionedTransaction;
|
|
114
|
+
/**
|
|
115
|
+
* Checks if two transaction instructions are identical by comparing their data, program IDs, and account keys.
|
|
116
|
+
*
|
|
117
|
+
* @param ix1 - First transaction instruction to compare
|
|
118
|
+
* @param ix2 - Second transaction instruction to compare
|
|
119
|
+
* @returns True if instructions are identical, false otherwise
|
|
120
|
+
*/
|
|
121
|
+
declare function compareInstructions(ix1: TransactionInstruction, ix2: TransactionInstruction): boolean;
|
|
122
|
+
declare function replaceV0TxInstructions(additionalInstructions: TransactionInstruction[], instructions: TransactionInstruction[], replaceOnly?: boolean): TransactionInstruction[];
|
|
123
|
+
declare function replaceV0TxBlockhash(transaction: VersionedTransaction, blockhash: string): VersionedTransaction;
|
|
124
|
+
/**
|
|
125
|
+
* Enhances a given transaction with additional metadata.
|
|
126
|
+
*
|
|
127
|
+
* @param transaction - The transaction to be enhanced, can be either VersionedTransaction or Transaction.
|
|
128
|
+
* @param options - An object containing optional metadata:
|
|
129
|
+
* - signers: An array of Signer objects that are associated with the transaction.
|
|
130
|
+
* - addressLookupTables: An array of AddressLookupTableAccount objects for address resolution.
|
|
131
|
+
* - unitsConsumed: A number representing the compute units consumed by the transaction.
|
|
132
|
+
* - type: The type of the transaction, as defined by TransactionType.
|
|
133
|
+
* @returns A SolanaTransaction object that includes the original transaction and the additional metadata.
|
|
134
|
+
*/
|
|
135
|
+
declare function addTransactionMetadata<T extends Transaction | VersionedTransaction>(transaction: T, options: ExtendedTransactionProperties): T & ExtendedTransactionProperties;
|
|
136
|
+
/**
|
|
137
|
+
* Decodes a ComputeBudget program instruction into a readable format.
|
|
138
|
+
*
|
|
139
|
+
* @param instruction - The ComputeBudget program instruction to decode
|
|
140
|
+
* @returns An object containing the decoded instruction data with fields depending on the instruction type:
|
|
141
|
+
* - RequestUnits: { instructionType: string, units: number, additionalFee: number }
|
|
142
|
+
* - RequestHeapFrame: { instructionType: string, bytes: number }
|
|
143
|
+
* - SetComputeUnitLimit: { instructionType: string, units: number }
|
|
144
|
+
* - SetComputeUnitPrice: { instructionType: string, microLamports: string }
|
|
145
|
+
* - SetLoadedAccountsDataSizeLimit: { instructionType: string, accountDataSizeLimit: number }
|
|
146
|
+
* @throws Error if the instruction data is invalid or the instruction type is unknown
|
|
147
|
+
*/
|
|
148
|
+
declare function decodeComputeBudgetInstruction(instruction: TransactionInstruction): {
|
|
149
|
+
instructionType: "RequestUnits";
|
|
150
|
+
units: number;
|
|
151
|
+
additionalFee: number;
|
|
152
|
+
bytes?: undefined;
|
|
153
|
+
microLamports?: undefined;
|
|
154
|
+
accountDataSizeLimit?: undefined;
|
|
155
|
+
} | {
|
|
156
|
+
instructionType: "RequestHeapFrame";
|
|
157
|
+
bytes: number;
|
|
158
|
+
units?: undefined;
|
|
159
|
+
additionalFee?: undefined;
|
|
160
|
+
microLamports?: undefined;
|
|
161
|
+
accountDataSizeLimit?: undefined;
|
|
162
|
+
} | {
|
|
163
|
+
instructionType: "SetComputeUnitLimit";
|
|
164
|
+
units: number;
|
|
165
|
+
additionalFee?: undefined;
|
|
166
|
+
bytes?: undefined;
|
|
167
|
+
microLamports?: undefined;
|
|
168
|
+
accountDataSizeLimit?: undefined;
|
|
169
|
+
} | {
|
|
170
|
+
instructionType: "SetComputeUnitPrice";
|
|
171
|
+
microLamports: string;
|
|
172
|
+
units?: undefined;
|
|
173
|
+
additionalFee?: undefined;
|
|
174
|
+
bytes?: undefined;
|
|
175
|
+
accountDataSizeLimit?: undefined;
|
|
176
|
+
} | {
|
|
177
|
+
instructionType: "SetLoadedAccountsDataSizeLimit";
|
|
178
|
+
accountDataSizeLimit: number;
|
|
179
|
+
units?: undefined;
|
|
180
|
+
additionalFee?: undefined;
|
|
181
|
+
bytes?: undefined;
|
|
182
|
+
microLamports?: undefined;
|
|
183
|
+
};
|
|
184
|
+
declare function getComputeBudgetUnits(tx: SolanaTransaction): number | undefined;
|
|
185
|
+
/**
|
|
186
|
+
* Converts a priority fee from UI units (SOL) to micro-lamports per compute unit
|
|
187
|
+
* @param ui - Priority fee amount in SOL
|
|
188
|
+
* @param limitCU - Compute unit limit, defaults to 1.4M CU
|
|
189
|
+
* @returns Priority fee in micro-lamports per compute unit
|
|
190
|
+
*/
|
|
191
|
+
declare const uiToMicroLamports: (ui: number, limitCU?: number) => number;
|
|
192
|
+
/**
|
|
193
|
+
* Converts a priority fee from micro-lamports per compute unit to UI units (SOL)
|
|
194
|
+
* @param microLamports - Priority fee in micro-lamports per compute unit
|
|
195
|
+
* @param limitCU - Compute unit limit, defaults to 1.4M CU
|
|
196
|
+
* @returns Priority fee amount in SOL, truncated to 9 decimal places
|
|
197
|
+
*/
|
|
198
|
+
declare const microLamportsToUi: (microLamports: number, limitCU?: number) => number;
|
|
199
|
+
/**
|
|
200
|
+
* Splits your instructions into as many VersionedTransactions as needed
|
|
201
|
+
* so that none exceed MAX_TX_SIZE.
|
|
202
|
+
*/
|
|
203
|
+
declare function splitInstructionsToFitTransactions(mandatoryIxs: TransactionInstruction[], ixs: TransactionInstruction[], opts: {
|
|
204
|
+
blockhash: string;
|
|
205
|
+
payerKey: PublicKey;
|
|
206
|
+
luts: AddressLookupTableAccount[];
|
|
207
|
+
}): VersionedTransaction[];
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Formula source: http://www.linked8.com/blog/158-apy-to-apr-and-apr-to-apy-calculation-methodologies
|
|
211
|
+
*
|
|
212
|
+
* @param apy {Number} APY (i.e. 0.06 for 6%)
|
|
213
|
+
* @param compoundingFrequency {Number} Compounding frequency (times a year)
|
|
214
|
+
* @returns {Number} APR (i.e. 0.0582 for APY of 0.06)
|
|
215
|
+
*/
|
|
216
|
+
declare const apyToApr: (apy: number, compoundingFrequency?: number) => number;
|
|
217
|
+
/**
|
|
218
|
+
* Formula source: http://www.linked8.com/blog/158-apy-to-apr-and-apr-to-apy-calculation-methodologies
|
|
219
|
+
*
|
|
220
|
+
*
|
|
221
|
+
* @param apr {Number} APR (i.e. 0.0582 for 5.82%)
|
|
222
|
+
* @param compoundingFrequency {Number} Compounding frequency (times a year)
|
|
223
|
+
* @returns {Number} APY (i.e. 0.06 for APR of 0.0582)
|
|
224
|
+
*/
|
|
225
|
+
declare const aprToApy: (apr: number, compoundingFrequency?: number, apyCap?: number) => number;
|
|
226
|
+
declare function calculateInterestFromApy(principal: number, durationInYears: number, apy: number): number;
|
|
227
|
+
declare function calculateApyFromInterest(principal: number, durationInYears: number, interest: number): number;
|
|
228
|
+
|
|
229
|
+
declare function wrappedI80F48toBigNumber(wrapped: WrappedI80F48): BigNumber;
|
|
230
|
+
declare function bigNumberToWrappedI80F48(value: Amount): WrappedI80F48;
|
|
231
|
+
/**
|
|
232
|
+
* Converts a ui representation of a token amount into its native value as `BN`, given the specified mint decimal amount (default to 6 for USDC).
|
|
233
|
+
*/
|
|
234
|
+
declare function toNumber(amount: Amount): number;
|
|
235
|
+
/**
|
|
236
|
+
* Converts a ui representation of a token amount into its native value as `BN`, given the specified mint decimal amount (default to 6 for USDC).
|
|
237
|
+
*/
|
|
238
|
+
declare function toBigNumber(amount: Amount | BN): BigNumber;
|
|
239
|
+
/**
|
|
240
|
+
* Converts a UI representation of a token amount into its native value as `BN`, given the specified mint decimal amount (default to 6 for USDC).
|
|
241
|
+
*/
|
|
242
|
+
declare function uiToNative(amount: Amount, decimals: number): BN;
|
|
243
|
+
declare function uiToNativeBigNumber(amount: Amount, decimals: number): BigNumber;
|
|
244
|
+
/**
|
|
245
|
+
* Converts a native representation of a token amount into its UI value as `number`, given the specified mint decimal amount.
|
|
246
|
+
*/
|
|
247
|
+
declare function nativeToUi(amount: Amount | BN, decimals: number): number;
|
|
248
|
+
declare function shortenAddress(pubkey: Address, chars?: number): string;
|
|
249
|
+
/**
|
|
250
|
+
* Converts basis points (bps) to a decimal percentage value.
|
|
251
|
+
*/
|
|
252
|
+
declare function bpsToPercentile(bps: number): number;
|
|
253
|
+
/**
|
|
254
|
+
* Prepares transaction remaining accounts by processing bank-oracle groups:
|
|
255
|
+
* 1. Sorts groups in descending order by bank public key (pushes inactive accounts to end)
|
|
256
|
+
* 2. Flattens the structure into a single public key array
|
|
257
|
+
*
|
|
258
|
+
* Stable on most JS implementations (this shouldn't matter since we do not generally have duplicate
|
|
259
|
+
* banks), in place, and uses the raw 32-byte value to sort in byte-wise lexicographical order (like
|
|
260
|
+
* Rust's b.key.cmp(&a.key))
|
|
261
|
+
*
|
|
262
|
+
* @param banksAndOracles - Array where each element is a bank-oracle group: [bankPubkey,
|
|
263
|
+
* oracle1Pubkey, oracle2Pubkey?, ...] Note: SystemProgram keys (111..111)
|
|
264
|
+
* represent inactive accounts
|
|
265
|
+
* @returns Flattened array of public keys with inactive accounts at the end, ready for transaction
|
|
266
|
+
* composition
|
|
267
|
+
*/
|
|
268
|
+
declare const composeRemainingAccounts: (banksAndOracles: PublicKey[][]) => PublicKey[];
|
|
269
|
+
|
|
270
|
+
declare class CustomNumberFormat extends Intl.NumberFormat {
|
|
271
|
+
format(value: number | bigint): string;
|
|
272
|
+
}
|
|
273
|
+
declare const groupedNumberFormatter: CustomNumberFormat;
|
|
274
|
+
declare const numeralFormatter: (value: number) => string;
|
|
275
|
+
interface dynamicNumeralFormatterOptions {
|
|
276
|
+
minDisplay?: number;
|
|
277
|
+
tokenPrice?: number;
|
|
278
|
+
forceDecimals?: boolean;
|
|
279
|
+
maxDisplay?: number;
|
|
280
|
+
logging?: boolean;
|
|
281
|
+
ignoreMinDisplay?: boolean;
|
|
282
|
+
}
|
|
283
|
+
declare const dynamicNumeralFormatter: (value: number, options?: dynamicNumeralFormatterOptions) => string;
|
|
284
|
+
declare const groupedNumberFormatterDyn: Intl.NumberFormat;
|
|
285
|
+
declare const usdFormatter: Intl.NumberFormat;
|
|
286
|
+
declare const usdFormatterDyn: Intl.NumberFormat;
|
|
287
|
+
declare const percentFormatter: Intl.NumberFormat;
|
|
288
|
+
declare const percentFormatterDyn: Intl.NumberFormat;
|
|
289
|
+
declare const percentFormatterMod: (value: number, opts?: {
|
|
290
|
+
minFractionDigits: number;
|
|
291
|
+
maxFractionDigits: number;
|
|
292
|
+
}) => string;
|
|
293
|
+
declare const clampedNumeralFormatter: (value: number) => string;
|
|
294
|
+
declare const tokenPriceFormatter: (price: number, style?: "currency" | "decimal") => string | 0;
|
|
295
|
+
|
|
296
|
+
export { Amount, CustomNumberFormat, ExtendedTransactionProperties, NodeWallet, SolanaTransaction, Wallet, WrappedI80F48, addTransactionMetadata, aprToApy, apyToApr, bigNumberToWrappedI80F48, bpsToPercentile, calculateApyFromInterest, calculateInterestFromApy, ceil, chunkedGetRawMultipleAccountInfoOrdered, chunkedGetRawMultipleAccountInfoOrderedWithNulls, chunkedGetRawMultipleAccountInfos, chunks, clampedNumeralFormatter, compareInstructions, composeRemainingAccounts, decodeComputeBudgetInstruction, decodeInstruction, decompileV0Transaction, dynamicNumeralFormatter, floor, getAccountKeys, getComputeBudgetUnits, getTxSize, getValueInsensitive, groupedNumberFormatter, groupedNumberFormatterDyn, isV0Tx, legacyTxToV0Tx, median, microLamportsToUi, nativeToUi, numeralFormatter, percentFormatter, percentFormatterDyn, percentFormatterMod, replaceV0TxBlockhash, replaceV0TxInstructions, setTimeoutPromise, shortenAddress, sleep, splitInstructionsToFitTransactions, toBigNumber, toNumber, tokenPriceFormatter, uiToMicroLamports, uiToNative, uiToNativeBigNumber, updateV0Tx, usdFormatter, usdFormatterDyn, wrappedI80F48toBigNumber };
|
package/dist/common/index.d.ts
CHANGED
|
@@ -1,2 +1,296 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Keypair, Transaction, VersionedTransaction, PublicKey, Connection, AccountInfo, AddressLookupTableAccount, TransactionMessage, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
+
import { j as Wallet, e as ExtendedTransactionProperties, S as SolanaTransaction, W as WrappedI80F48, A as Amount } from '../bank-metadata-X4_5k9-u.js';
|
|
3
|
+
export { a as BankExtendedMetadata, m as BankExtendedMetadataMap, X as BankExtendedMetadataOverride, h as BankMetadata, b as BankMetadataMap, l as BanksExtendedMetadataOverrideMap, E as ExtendedTransaction, f as ExtendedV0Transaction, I as InstructionsWrapper, D as MaxCapType, G as PriotitizationFeeLevels, P as Program, R as ProgramReadonly, z as TransactionArenaKeyMap, g as TransactionBroadcastType, y as TransactionConfigMap, d as TransactionOptions, C as TransactionPriorityType, F as TransactionSettings, x as TransactionType, U as WalletToken, V as bankExtendedMetadataOverrideSchema, Z as fetchBanksExtendedMetadata, H as getCalculatedPrioritizationFeeByPercentile, K as getMaxPrioritizationFeeByPercentile, N as getMeanPrioritizationFeeByPercentile, O as getMedianPrioritizationFeeByPercentile, J as getMinPrioritizationFeeByPercentile, Q as getRecentPrioritizationFeesByPercentile, Y as parseBanksMetadataOverride } from '../bank-metadata-X4_5k9-u.js';
|
|
4
|
+
import { Idl, Instruction, Address } from '@coral-xyz/anchor';
|
|
5
|
+
import BigNumber from 'bignumber.js';
|
|
6
|
+
import BN from 'bn.js';
|
|
7
|
+
import 'zod';
|
|
8
|
+
import '@solana/wallet-adapter-base';
|
|
9
|
+
import 'unstorage';
|
|
10
|
+
import 'zod/v4-mini';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* NodeWallet
|
|
14
|
+
*
|
|
15
|
+
* Anchor-compliant wallet implementation.
|
|
16
|
+
*/
|
|
17
|
+
declare class NodeWallet implements Wallet {
|
|
18
|
+
readonly payer: Keypair;
|
|
19
|
+
/**
|
|
20
|
+
* @param payer Keypair of the associated payer
|
|
21
|
+
*/
|
|
22
|
+
constructor(payer: Keypair);
|
|
23
|
+
signTransaction<T extends Transaction | VersionedTransaction>(tx: T): Promise<T>;
|
|
24
|
+
signAllTransactions<T extends Transaction | VersionedTransaction>(txs: T[]): Promise<T[]>;
|
|
25
|
+
get publicKey(): PublicKey;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare function floor(value: number, decimals: number): number;
|
|
29
|
+
declare function ceil(value: number, decimals: number): number;
|
|
30
|
+
declare function median(values: number[]): number;
|
|
31
|
+
|
|
32
|
+
declare function getValueInsensitive<T>(map: Record<string, T>, key: string): T;
|
|
33
|
+
/**
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
declare function sleep(ms: number): Promise<unknown>;
|
|
37
|
+
declare function chunks<T>(array: T[], size: number): T[][];
|
|
38
|
+
declare function setTimeoutPromise(duration: number, message: string): Promise<Error>;
|
|
39
|
+
declare function chunkedGetRawMultipleAccountInfos(connection: Connection, pks: string[], batchChunkSize?: number, maxAccountsChunkSize?: number): Promise<[number, Map<string, AccountInfo<Buffer>>]>;
|
|
40
|
+
declare function chunkedGetRawMultipleAccountInfoOrderedWithNulls(connection: Connection, pks: string[], batchChunkSize?: number, maxAccountsChunkSize?: number): Promise<Array<AccountInfo<Buffer> | null>>;
|
|
41
|
+
declare function chunkedGetRawMultipleAccountInfoOrdered(connection: Connection, pks: string[], batchChunkSize?: number, maxAccountsChunkSize?: number): Promise<Array<AccountInfo<Buffer>>>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Determines if a given transaction is a VersionedTransaction.
|
|
45
|
+
* This function checks for the presence of a 'message' property to identify
|
|
46
|
+
* if the transaction is of type VersionedTransaction.
|
|
47
|
+
*
|
|
48
|
+
* @param tx - The transaction object, which can be either a VersionedTransaction or a Transaction.
|
|
49
|
+
* @returns A boolean indicating whether the transaction is a VersionedTransaction.
|
|
50
|
+
*/
|
|
51
|
+
declare function isV0Tx(tx: Transaction | VersionedTransaction): tx is VersionedTransaction;
|
|
52
|
+
/**
|
|
53
|
+
* Calculates the size of a Solana transaction in bytes.
|
|
54
|
+
* This function considers the number of required signatures and other transaction components.
|
|
55
|
+
*
|
|
56
|
+
* @param tx - The transaction object, which can be either a VersionedTransaction or a Transaction.
|
|
57
|
+
* @returns The size of the transaction in bytes.
|
|
58
|
+
*/
|
|
59
|
+
declare function getTxSize(tx: VersionedTransaction | Transaction): number;
|
|
60
|
+
declare function getAccountKeys(tx: VersionedTransaction | Transaction, lookupTableAccounts: AddressLookupTableAccount[]): number;
|
|
61
|
+
/**
|
|
62
|
+
* Decodes a Solana transaction instruction using the provided Interface Definition Language (IDL).
|
|
63
|
+
* This function utilizes the BorshInstructionCoder to interpret the encoded instruction data.
|
|
64
|
+
*
|
|
65
|
+
* @param idl - The Interface Definition Language object that defines the structure of the instruction.
|
|
66
|
+
* @param encoded - The Buffer containing the encoded instruction data.
|
|
67
|
+
* @returns The decoded instruction object.
|
|
68
|
+
*/
|
|
69
|
+
declare function decodeInstruction(idl: Idl, encoded: Buffer): Instruction | null;
|
|
70
|
+
/**
|
|
71
|
+
* Decompiles a VersionedTransaction into a TransactionMessage.
|
|
72
|
+
*
|
|
73
|
+
* @param tx - The VersionedTransaction to be decompiled.
|
|
74
|
+
* @param lookupTableAccounts - An array of AddressLookupTableAccount used for decompiling the transaction message.
|
|
75
|
+
* @returns A TransactionMessage object representing the decompiled transaction.
|
|
76
|
+
*/
|
|
77
|
+
declare function decompileV0Transaction(tx: VersionedTransaction, lookupTableAccounts: AddressLookupTableAccount[]): TransactionMessage;
|
|
78
|
+
/**
|
|
79
|
+
* Options for updating a transaction.
|
|
80
|
+
* - `feePayer`: Optional public key of the fee payer. Defaults to the transaction's fee payer.
|
|
81
|
+
* - `blockhash`: Optional blockhash for the transaction. Defaults to the transaction's recent blockhash.
|
|
82
|
+
* - `addressLookupTables`: Optional array of address lookup table accounts for the transaction.
|
|
83
|
+
* - `additionalIxs`: Optional array of additional transaction instructions to include.
|
|
84
|
+
*/
|
|
85
|
+
type UpdateTxOptions = {
|
|
86
|
+
feePayer?: PublicKey;
|
|
87
|
+
blockhash?: string;
|
|
88
|
+
addressLookupTables?: AddressLookupTableAccount[];
|
|
89
|
+
additionalIxs?: TransactionInstruction[];
|
|
90
|
+
replaceOnly?: boolean;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Converts a legacy Solana transaction to a versioned transaction. *
|
|
94
|
+
* @param transaction - The legacy transaction to be converted.
|
|
95
|
+
* @param opts - Optional parameters for the conversion process.
|
|
96
|
+
* @returns A VersionedTransaction object representing the converted transaction.
|
|
97
|
+
* @throws Will throw an error if the fee payer or blockhash is not provided.
|
|
98
|
+
*/
|
|
99
|
+
declare function legacyTxToV0Tx(transaction: Transaction, opts?: UpdateTxOptions): VersionedTransaction;
|
|
100
|
+
/**
|
|
101
|
+
* Updates a VersionedTransaction with new options.
|
|
102
|
+
*
|
|
103
|
+
* This function allows you to modify a given VersionedTransaction by providing
|
|
104
|
+
* additional transaction instructions, address lookup tables, a new fee payer,
|
|
105
|
+
* and a new blockhash. It decompiles the existing transaction, applies the updates,
|
|
106
|
+
* and recompiles it into a new VersionedTransaction.
|
|
107
|
+
*
|
|
108
|
+
* @param transaction - The VersionedTransaction to be updated.
|
|
109
|
+
* @param opts - Optional parameters for updating the transaction.
|
|
110
|
+
* @returns A new VersionedTransaction object with the applied updates.
|
|
111
|
+
* @throws Will throw an error if the fee payer or blockhash is not provided.
|
|
112
|
+
*/
|
|
113
|
+
declare function updateV0Tx(transaction: VersionedTransaction, opts?: UpdateTxOptions): VersionedTransaction;
|
|
114
|
+
/**
|
|
115
|
+
* Checks if two transaction instructions are identical by comparing their data, program IDs, and account keys.
|
|
116
|
+
*
|
|
117
|
+
* @param ix1 - First transaction instruction to compare
|
|
118
|
+
* @param ix2 - Second transaction instruction to compare
|
|
119
|
+
* @returns True if instructions are identical, false otherwise
|
|
120
|
+
*/
|
|
121
|
+
declare function compareInstructions(ix1: TransactionInstruction, ix2: TransactionInstruction): boolean;
|
|
122
|
+
declare function replaceV0TxInstructions(additionalInstructions: TransactionInstruction[], instructions: TransactionInstruction[], replaceOnly?: boolean): TransactionInstruction[];
|
|
123
|
+
declare function replaceV0TxBlockhash(transaction: VersionedTransaction, blockhash: string): VersionedTransaction;
|
|
124
|
+
/**
|
|
125
|
+
* Enhances a given transaction with additional metadata.
|
|
126
|
+
*
|
|
127
|
+
* @param transaction - The transaction to be enhanced, can be either VersionedTransaction or Transaction.
|
|
128
|
+
* @param options - An object containing optional metadata:
|
|
129
|
+
* - signers: An array of Signer objects that are associated with the transaction.
|
|
130
|
+
* - addressLookupTables: An array of AddressLookupTableAccount objects for address resolution.
|
|
131
|
+
* - unitsConsumed: A number representing the compute units consumed by the transaction.
|
|
132
|
+
* - type: The type of the transaction, as defined by TransactionType.
|
|
133
|
+
* @returns A SolanaTransaction object that includes the original transaction and the additional metadata.
|
|
134
|
+
*/
|
|
135
|
+
declare function addTransactionMetadata<T extends Transaction | VersionedTransaction>(transaction: T, options: ExtendedTransactionProperties): T & ExtendedTransactionProperties;
|
|
136
|
+
/**
|
|
137
|
+
* Decodes a ComputeBudget program instruction into a readable format.
|
|
138
|
+
*
|
|
139
|
+
* @param instruction - The ComputeBudget program instruction to decode
|
|
140
|
+
* @returns An object containing the decoded instruction data with fields depending on the instruction type:
|
|
141
|
+
* - RequestUnits: { instructionType: string, units: number, additionalFee: number }
|
|
142
|
+
* - RequestHeapFrame: { instructionType: string, bytes: number }
|
|
143
|
+
* - SetComputeUnitLimit: { instructionType: string, units: number }
|
|
144
|
+
* - SetComputeUnitPrice: { instructionType: string, microLamports: string }
|
|
145
|
+
* - SetLoadedAccountsDataSizeLimit: { instructionType: string, accountDataSizeLimit: number }
|
|
146
|
+
* @throws Error if the instruction data is invalid or the instruction type is unknown
|
|
147
|
+
*/
|
|
148
|
+
declare function decodeComputeBudgetInstruction(instruction: TransactionInstruction): {
|
|
149
|
+
instructionType: "RequestUnits";
|
|
150
|
+
units: number;
|
|
151
|
+
additionalFee: number;
|
|
152
|
+
bytes?: undefined;
|
|
153
|
+
microLamports?: undefined;
|
|
154
|
+
accountDataSizeLimit?: undefined;
|
|
155
|
+
} | {
|
|
156
|
+
instructionType: "RequestHeapFrame";
|
|
157
|
+
bytes: number;
|
|
158
|
+
units?: undefined;
|
|
159
|
+
additionalFee?: undefined;
|
|
160
|
+
microLamports?: undefined;
|
|
161
|
+
accountDataSizeLimit?: undefined;
|
|
162
|
+
} | {
|
|
163
|
+
instructionType: "SetComputeUnitLimit";
|
|
164
|
+
units: number;
|
|
165
|
+
additionalFee?: undefined;
|
|
166
|
+
bytes?: undefined;
|
|
167
|
+
microLamports?: undefined;
|
|
168
|
+
accountDataSizeLimit?: undefined;
|
|
169
|
+
} | {
|
|
170
|
+
instructionType: "SetComputeUnitPrice";
|
|
171
|
+
microLamports: string;
|
|
172
|
+
units?: undefined;
|
|
173
|
+
additionalFee?: undefined;
|
|
174
|
+
bytes?: undefined;
|
|
175
|
+
accountDataSizeLimit?: undefined;
|
|
176
|
+
} | {
|
|
177
|
+
instructionType: "SetLoadedAccountsDataSizeLimit";
|
|
178
|
+
accountDataSizeLimit: number;
|
|
179
|
+
units?: undefined;
|
|
180
|
+
additionalFee?: undefined;
|
|
181
|
+
bytes?: undefined;
|
|
182
|
+
microLamports?: undefined;
|
|
183
|
+
};
|
|
184
|
+
declare function getComputeBudgetUnits(tx: SolanaTransaction): number | undefined;
|
|
185
|
+
/**
|
|
186
|
+
* Converts a priority fee from UI units (SOL) to micro-lamports per compute unit
|
|
187
|
+
* @param ui - Priority fee amount in SOL
|
|
188
|
+
* @param limitCU - Compute unit limit, defaults to 1.4M CU
|
|
189
|
+
* @returns Priority fee in micro-lamports per compute unit
|
|
190
|
+
*/
|
|
191
|
+
declare const uiToMicroLamports: (ui: number, limitCU?: number) => number;
|
|
192
|
+
/**
|
|
193
|
+
* Converts a priority fee from micro-lamports per compute unit to UI units (SOL)
|
|
194
|
+
* @param microLamports - Priority fee in micro-lamports per compute unit
|
|
195
|
+
* @param limitCU - Compute unit limit, defaults to 1.4M CU
|
|
196
|
+
* @returns Priority fee amount in SOL, truncated to 9 decimal places
|
|
197
|
+
*/
|
|
198
|
+
declare const microLamportsToUi: (microLamports: number, limitCU?: number) => number;
|
|
199
|
+
/**
|
|
200
|
+
* Splits your instructions into as many VersionedTransactions as needed
|
|
201
|
+
* so that none exceed MAX_TX_SIZE.
|
|
202
|
+
*/
|
|
203
|
+
declare function splitInstructionsToFitTransactions(mandatoryIxs: TransactionInstruction[], ixs: TransactionInstruction[], opts: {
|
|
204
|
+
blockhash: string;
|
|
205
|
+
payerKey: PublicKey;
|
|
206
|
+
luts: AddressLookupTableAccount[];
|
|
207
|
+
}): VersionedTransaction[];
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Formula source: http://www.linked8.com/blog/158-apy-to-apr-and-apr-to-apy-calculation-methodologies
|
|
211
|
+
*
|
|
212
|
+
* @param apy {Number} APY (i.e. 0.06 for 6%)
|
|
213
|
+
* @param compoundingFrequency {Number} Compounding frequency (times a year)
|
|
214
|
+
* @returns {Number} APR (i.e. 0.0582 for APY of 0.06)
|
|
215
|
+
*/
|
|
216
|
+
declare const apyToApr: (apy: number, compoundingFrequency?: number) => number;
|
|
217
|
+
/**
|
|
218
|
+
* Formula source: http://www.linked8.com/blog/158-apy-to-apr-and-apr-to-apy-calculation-methodologies
|
|
219
|
+
*
|
|
220
|
+
*
|
|
221
|
+
* @param apr {Number} APR (i.e. 0.0582 for 5.82%)
|
|
222
|
+
* @param compoundingFrequency {Number} Compounding frequency (times a year)
|
|
223
|
+
* @returns {Number} APY (i.e. 0.06 for APR of 0.0582)
|
|
224
|
+
*/
|
|
225
|
+
declare const aprToApy: (apr: number, compoundingFrequency?: number, apyCap?: number) => number;
|
|
226
|
+
declare function calculateInterestFromApy(principal: number, durationInYears: number, apy: number): number;
|
|
227
|
+
declare function calculateApyFromInterest(principal: number, durationInYears: number, interest: number): number;
|
|
228
|
+
|
|
229
|
+
declare function wrappedI80F48toBigNumber(wrapped: WrappedI80F48): BigNumber;
|
|
230
|
+
declare function bigNumberToWrappedI80F48(value: Amount): WrappedI80F48;
|
|
231
|
+
/**
|
|
232
|
+
* Converts a ui representation of a token amount into its native value as `BN`, given the specified mint decimal amount (default to 6 for USDC).
|
|
233
|
+
*/
|
|
234
|
+
declare function toNumber(amount: Amount): number;
|
|
235
|
+
/**
|
|
236
|
+
* Converts a ui representation of a token amount into its native value as `BN`, given the specified mint decimal amount (default to 6 for USDC).
|
|
237
|
+
*/
|
|
238
|
+
declare function toBigNumber(amount: Amount | BN): BigNumber;
|
|
239
|
+
/**
|
|
240
|
+
* Converts a UI representation of a token amount into its native value as `BN`, given the specified mint decimal amount (default to 6 for USDC).
|
|
241
|
+
*/
|
|
242
|
+
declare function uiToNative(amount: Amount, decimals: number): BN;
|
|
243
|
+
declare function uiToNativeBigNumber(amount: Amount, decimals: number): BigNumber;
|
|
244
|
+
/**
|
|
245
|
+
* Converts a native representation of a token amount into its UI value as `number`, given the specified mint decimal amount.
|
|
246
|
+
*/
|
|
247
|
+
declare function nativeToUi(amount: Amount | BN, decimals: number): number;
|
|
248
|
+
declare function shortenAddress(pubkey: Address, chars?: number): string;
|
|
249
|
+
/**
|
|
250
|
+
* Converts basis points (bps) to a decimal percentage value.
|
|
251
|
+
*/
|
|
252
|
+
declare function bpsToPercentile(bps: number): number;
|
|
253
|
+
/**
|
|
254
|
+
* Prepares transaction remaining accounts by processing bank-oracle groups:
|
|
255
|
+
* 1. Sorts groups in descending order by bank public key (pushes inactive accounts to end)
|
|
256
|
+
* 2. Flattens the structure into a single public key array
|
|
257
|
+
*
|
|
258
|
+
* Stable on most JS implementations (this shouldn't matter since we do not generally have duplicate
|
|
259
|
+
* banks), in place, and uses the raw 32-byte value to sort in byte-wise lexicographical order (like
|
|
260
|
+
* Rust's b.key.cmp(&a.key))
|
|
261
|
+
*
|
|
262
|
+
* @param banksAndOracles - Array where each element is a bank-oracle group: [bankPubkey,
|
|
263
|
+
* oracle1Pubkey, oracle2Pubkey?, ...] Note: SystemProgram keys (111..111)
|
|
264
|
+
* represent inactive accounts
|
|
265
|
+
* @returns Flattened array of public keys with inactive accounts at the end, ready for transaction
|
|
266
|
+
* composition
|
|
267
|
+
*/
|
|
268
|
+
declare const composeRemainingAccounts: (banksAndOracles: PublicKey[][]) => PublicKey[];
|
|
269
|
+
|
|
270
|
+
declare class CustomNumberFormat extends Intl.NumberFormat {
|
|
271
|
+
format(value: number | bigint): string;
|
|
272
|
+
}
|
|
273
|
+
declare const groupedNumberFormatter: CustomNumberFormat;
|
|
274
|
+
declare const numeralFormatter: (value: number) => string;
|
|
275
|
+
interface dynamicNumeralFormatterOptions {
|
|
276
|
+
minDisplay?: number;
|
|
277
|
+
tokenPrice?: number;
|
|
278
|
+
forceDecimals?: boolean;
|
|
279
|
+
maxDisplay?: number;
|
|
280
|
+
logging?: boolean;
|
|
281
|
+
ignoreMinDisplay?: boolean;
|
|
282
|
+
}
|
|
283
|
+
declare const dynamicNumeralFormatter: (value: number, options?: dynamicNumeralFormatterOptions) => string;
|
|
284
|
+
declare const groupedNumberFormatterDyn: Intl.NumberFormat;
|
|
285
|
+
declare const usdFormatter: Intl.NumberFormat;
|
|
286
|
+
declare const usdFormatterDyn: Intl.NumberFormat;
|
|
287
|
+
declare const percentFormatter: Intl.NumberFormat;
|
|
288
|
+
declare const percentFormatterDyn: Intl.NumberFormat;
|
|
289
|
+
declare const percentFormatterMod: (value: number, opts?: {
|
|
290
|
+
minFractionDigits: number;
|
|
291
|
+
maxFractionDigits: number;
|
|
292
|
+
}) => string;
|
|
293
|
+
declare const clampedNumeralFormatter: (value: number) => string;
|
|
294
|
+
declare const tokenPriceFormatter: (price: number, style?: "currency" | "decimal") => string | 0;
|
|
295
|
+
|
|
296
|
+
export { Amount, CustomNumberFormat, ExtendedTransactionProperties, NodeWallet, SolanaTransaction, Wallet, WrappedI80F48, addTransactionMetadata, aprToApy, apyToApr, bigNumberToWrappedI80F48, bpsToPercentile, calculateApyFromInterest, calculateInterestFromApy, ceil, chunkedGetRawMultipleAccountInfoOrdered, chunkedGetRawMultipleAccountInfoOrderedWithNulls, chunkedGetRawMultipleAccountInfos, chunks, clampedNumeralFormatter, compareInstructions, composeRemainingAccounts, decodeComputeBudgetInstruction, decodeInstruction, decompileV0Transaction, dynamicNumeralFormatter, floor, getAccountKeys, getComputeBudgetUnits, getTxSize, getValueInsensitive, groupedNumberFormatter, groupedNumberFormatterDyn, isV0Tx, legacyTxToV0Tx, median, microLamportsToUi, nativeToUi, numeralFormatter, percentFormatter, percentFormatterDyn, percentFormatterMod, replaceV0TxBlockhash, replaceV0TxInstructions, setTimeoutPromise, shortenAddress, sleep, splitInstructionsToFitTransactions, toBigNumber, toNumber, tokenPriceFormatter, uiToMicroLamports, uiToNative, uiToNativeBigNumber, updateV0Tx, usdFormatter, usdFormatterDyn, wrappedI80F48toBigNumber };
|