@pyron-finance/pyron-client 1.0.3 → 1.0.5
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/common/index.d.mts +1 -1
- package/dist/common/index.d.ts +1 -1
- package/dist/common/index.js +67 -67
- package/dist/common/index.mjs +1 -1
- package/dist/common-BDe3qLlR.js +1891 -0
- package/dist/common-BtUtEjzZ.mjs +1192 -0
- package/dist/common-BtUtEjzZ.mjs.map +1 -0
- package/dist/{index-C75esL_v.d.ts → index-BAC0ffmc.d.mts} +3183 -3146
- package/dist/index-BAC0ffmc.d.mts.map +1 -0
- package/dist/{index-Y9VW4ezm.d.mts → index-Bx-zRXFQ.d.ts} +3185 -3144
- package/dist/index-Bx-zRXFQ.d.ts.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +21696 -219
- package/dist/index.mjs +21481 -2
- package/dist/index.mjs.map +1 -0
- package/package.json +5 -14
- package/dist/index-C75esL_v.d.ts.map +0 -1
- package/dist/index-Y9VW4ezm.d.mts.map +0 -1
- package/dist/src-DITEj1yC.mjs +0 -22634
- package/dist/src-DITEj1yC.mjs.map +0 -1
- package/dist/src-WLna_-6m.js +0 -24357
|
@@ -0,0 +1,1891 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
16
|
+
key = keys[i];
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
+
get: ((k) => from[k]).bind(null, key),
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
25
|
+
value: mod,
|
|
26
|
+
enumerable: true
|
|
27
|
+
}) : target, mod));
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
const __coral_xyz_anchor = __toESM(require("@coral-xyz/anchor"));
|
|
31
|
+
const __solana_web3_js = __toESM(require("@solana/web3.js"));
|
|
32
|
+
const bignumber_js = __toESM(require("bignumber.js"));
|
|
33
|
+
const zod = __toESM(require("zod"));
|
|
34
|
+
const decimal_js = __toESM(require("decimal.js"));
|
|
35
|
+
const numeral = __toESM(require("numeral"));
|
|
36
|
+
|
|
37
|
+
//#region src/common/bank-metadata.ts
|
|
38
|
+
const bankExtendedMetadataOverrideSchema = zod.z.object({
|
|
39
|
+
name: zod.z.string().optional(),
|
|
40
|
+
symbol: zod.z.string().optional(),
|
|
41
|
+
logoURI: zod.z.string().url().optional(),
|
|
42
|
+
address: zod.z.string().optional(),
|
|
43
|
+
mint: zod.z.string().optional(),
|
|
44
|
+
validatorVoteAccount: zod.z.string().optional()
|
|
45
|
+
});
|
|
46
|
+
const parseBanksMetadataOverride = (data) => {
|
|
47
|
+
return zod.z.record(zod.z.string(), bankExtendedMetadataOverrideSchema).parse(data);
|
|
48
|
+
};
|
|
49
|
+
const fetchBanksExtendedMetadata = async ({ mintsWithOwner, metadataService, logger, overrideBanksMetadata }) => {
|
|
50
|
+
const metas = await metadataService.forMints(mintsWithOwner.map(({ mint }) => mint));
|
|
51
|
+
const results = await Promise.all(mintsWithOwner.map(async ({ mint }) => {
|
|
52
|
+
const mintAddress = mint.toBase58();
|
|
53
|
+
const tokenMeta = metas[mintAddress];
|
|
54
|
+
if (!tokenMeta) {
|
|
55
|
+
logger.warn({ mintStr: mintAddress }, "fetched metadata was null");
|
|
56
|
+
if (!overrideBanksMetadata) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const overrideMetadata$1 = Object.values(overrideBanksMetadata).find((m) => m?.mint === mintAddress);
|
|
60
|
+
if (!overrideMetadata$1) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const { name: name$1, symbol: symbol$1, logoURI } = overrideMetadata$1;
|
|
64
|
+
if (name$1 && symbol$1) {
|
|
65
|
+
return {
|
|
66
|
+
mint: mintAddress,
|
|
67
|
+
name: name$1,
|
|
68
|
+
symbol: symbol$1,
|
|
69
|
+
logoURI,
|
|
70
|
+
uri: "",
|
|
71
|
+
additionalMetadata: []
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
logger.warn({
|
|
75
|
+
overrideMetadata: overrideMetadata$1,
|
|
76
|
+
mint: mintAddress
|
|
77
|
+
}, "override metadata exists but is missing required fields: name, symbol, mint");
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const { name, symbol, image } = tokenMeta;
|
|
81
|
+
const overrideMetadata = overrideBanksMetadata?.[symbol];
|
|
82
|
+
return {
|
|
83
|
+
mint: mintAddress,
|
|
84
|
+
name: overrideMetadata?.name ?? name,
|
|
85
|
+
symbol: overrideMetadata?.symbol ?? symbol,
|
|
86
|
+
logoURI: overrideMetadata?.logoURI ?? image,
|
|
87
|
+
uri: `https://www.fogo.io/tokens/${symbol.toLowerCase()}`,
|
|
88
|
+
additionalMetadata: []
|
|
89
|
+
};
|
|
90
|
+
}));
|
|
91
|
+
const metadataMap = new Map();
|
|
92
|
+
for (const result of results) {
|
|
93
|
+
if (!result) continue;
|
|
94
|
+
metadataMap.set(result.mint, result);
|
|
95
|
+
}
|
|
96
|
+
return metadataMap;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/common/nodeWallet.ts
|
|
101
|
+
/**
|
|
102
|
+
* NodeWallet
|
|
103
|
+
*
|
|
104
|
+
* Anchor-compliant wallet implementation.
|
|
105
|
+
*/
|
|
106
|
+
var NodeWallet = class {
|
|
107
|
+
/**
|
|
108
|
+
* @param payer Keypair of the associated payer
|
|
109
|
+
*/
|
|
110
|
+
constructor(payer) {
|
|
111
|
+
this.payer = payer;
|
|
112
|
+
}
|
|
113
|
+
async signTransaction(tx) {
|
|
114
|
+
if ("version" in tx) {
|
|
115
|
+
tx.sign([this.payer]);
|
|
116
|
+
} else {
|
|
117
|
+
tx.partialSign(this.payer);
|
|
118
|
+
}
|
|
119
|
+
return tx;
|
|
120
|
+
}
|
|
121
|
+
async signAllTransactions(txs) {
|
|
122
|
+
return txs.map((tx) => {
|
|
123
|
+
if ("version" in tx) {
|
|
124
|
+
tx.sign([this.payer]);
|
|
125
|
+
return tx;
|
|
126
|
+
} else {
|
|
127
|
+
tx.partialSign(this.payer);
|
|
128
|
+
return tx;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
get publicKey() {
|
|
133
|
+
return this.payer.publicKey;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/common/math.ts
|
|
139
|
+
function floor(value, decimals) {
|
|
140
|
+
return Math.floor(value * 10 ** decimals) / 10 ** decimals;
|
|
141
|
+
}
|
|
142
|
+
function ceil(value, decimals) {
|
|
143
|
+
return Math.ceil(value * 10 ** decimals) / 10 ** decimals;
|
|
144
|
+
}
|
|
145
|
+
function median(values) {
|
|
146
|
+
if (values.length === 0) {
|
|
147
|
+
throw new Error("Input array is empty");
|
|
148
|
+
}
|
|
149
|
+
values = [...values].sort((a, b) => a - b);
|
|
150
|
+
const half = Math.floor(values.length / 2);
|
|
151
|
+
return values.length % 2 ? values[half] : (values[half - 1] + values[half]) / 2;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/common/misc.ts
|
|
156
|
+
function getValueInsensitive(map, key) {
|
|
157
|
+
const lowerCaseLabel = key.toLowerCase();
|
|
158
|
+
for (const key$1 in map) {
|
|
159
|
+
if (key$1.toLowerCase() === lowerCaseLabel) {
|
|
160
|
+
return map[key$1];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
throw new Error(`Token metadata not found for ${key}`);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
function sleep(ms) {
|
|
169
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
170
|
+
}
|
|
171
|
+
function chunks(array, size) {
|
|
172
|
+
return Array.apply(0, new Array(Math.ceil(array.length / size))).map((_, index) => array.slice(index * size, (index + 1) * size));
|
|
173
|
+
}
|
|
174
|
+
function setTimeoutPromise(duration, message) {
|
|
175
|
+
return new Promise((_, reject) => setTimeout(() => reject(new Error(message)), duration));
|
|
176
|
+
}
|
|
177
|
+
async function chunkedGetRawMultipleAccountInfos(connection, pks, batchChunkSize = 1e3, maxAccountsChunkSize = 100) {
|
|
178
|
+
const accountInfoMap = new Map();
|
|
179
|
+
let contextSlot = 0;
|
|
180
|
+
const batches = chunkArray(pks, batchChunkSize);
|
|
181
|
+
for (let i = 0; i < batches.length; i++) {
|
|
182
|
+
const batch = batches[i];
|
|
183
|
+
const batchRequest = chunkArray(batch, maxAccountsChunkSize).map((pubkeys) => ({
|
|
184
|
+
methodName: "getMultipleAccounts",
|
|
185
|
+
args: connection._buildArgs([pubkeys], "confirmed", "base64")
|
|
186
|
+
}));
|
|
187
|
+
let accountInfos = [];
|
|
188
|
+
let retries = 0;
|
|
189
|
+
const maxRetries = 3;
|
|
190
|
+
while (retries < maxRetries && accountInfos.length === 0) {
|
|
191
|
+
try {
|
|
192
|
+
accountInfos = await connection._rpcBatchRequest(batchRequest).then((batchResults) => {
|
|
193
|
+
contextSlot = Math.max(...batchResults.map((res) => res.result.context.slot));
|
|
194
|
+
const accounts = batchResults.reduce((acc, res) => {
|
|
195
|
+
acc.push(...res.result.value);
|
|
196
|
+
return acc;
|
|
197
|
+
}, []);
|
|
198
|
+
return accounts;
|
|
199
|
+
});
|
|
200
|
+
} catch (error) {
|
|
201
|
+
retries++;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (accountInfos.length === 0) {
|
|
205
|
+
throw new Error(`Failed to fetch account infos after ${maxRetries} retries`);
|
|
206
|
+
}
|
|
207
|
+
accountInfos.forEach((item, index) => {
|
|
208
|
+
const publicKey = batch[index];
|
|
209
|
+
if (item) {
|
|
210
|
+
accountInfoMap.set(publicKey, {
|
|
211
|
+
...item,
|
|
212
|
+
owner: new __solana_web3_js.PublicKey(item.owner),
|
|
213
|
+
data: Buffer.from(item.data[0], "base64")
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return [contextSlot, accountInfoMap];
|
|
219
|
+
}
|
|
220
|
+
async function chunkedGetRawMultipleAccountInfoOrderedWithNulls(connection, pks, batchChunkSize = 1e3, maxAccountsChunkSize = 100) {
|
|
221
|
+
const allAccountInfos = [];
|
|
222
|
+
const batches = chunkArray(pks, batchChunkSize);
|
|
223
|
+
for (let i = 0; i < batches.length; i++) {
|
|
224
|
+
const batch = batches[i];
|
|
225
|
+
const batchRequest = chunkArray(batch, maxAccountsChunkSize).map((pubkeys) => ({
|
|
226
|
+
methodName: "getMultipleAccounts",
|
|
227
|
+
args: connection._buildArgs([pubkeys], "confirmed", "base64")
|
|
228
|
+
}));
|
|
229
|
+
let accountInfos = [];
|
|
230
|
+
let retries = 0;
|
|
231
|
+
const maxRetries = 3;
|
|
232
|
+
while (retries < maxRetries && accountInfos.length === 0) {
|
|
233
|
+
try {
|
|
234
|
+
accountInfos = await connection._rpcBatchRequest(batchRequest).then((batchResults) => {
|
|
235
|
+
const accounts = batchResults.reduce((acc, res) => {
|
|
236
|
+
acc.push(...res.result.value);
|
|
237
|
+
return acc;
|
|
238
|
+
}, []);
|
|
239
|
+
return accounts;
|
|
240
|
+
});
|
|
241
|
+
} catch (error) {
|
|
242
|
+
retries++;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (accountInfos.length === 0) {
|
|
246
|
+
throw new Error(`Failed to fetch account infos after ${maxRetries} retries`);
|
|
247
|
+
}
|
|
248
|
+
accountInfos.forEach((item) => {
|
|
249
|
+
if (item) {
|
|
250
|
+
allAccountInfos.push({
|
|
251
|
+
...item,
|
|
252
|
+
owner: new __solana_web3_js.PublicKey(item.owner),
|
|
253
|
+
data: Buffer.from(item.data[0], "base64")
|
|
254
|
+
});
|
|
255
|
+
} else {
|
|
256
|
+
allAccountInfos.push(null);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
return allAccountInfos;
|
|
261
|
+
}
|
|
262
|
+
async function chunkedGetRawMultipleAccountInfoOrdered(connection, pks, batchChunkSize = 1e3, maxAccountsChunkSize = 100) {
|
|
263
|
+
const allAccountInfos = [];
|
|
264
|
+
const batches = chunkArray(pks, batchChunkSize);
|
|
265
|
+
for (let i = 0; i < batches.length; i++) {
|
|
266
|
+
const batch = batches[i];
|
|
267
|
+
const batchRequest = chunkArray(batch, maxAccountsChunkSize).map((pubkeys) => ({
|
|
268
|
+
methodName: "getMultipleAccounts",
|
|
269
|
+
args: connection._buildArgs([pubkeys], "confirmed", "base64")
|
|
270
|
+
}));
|
|
271
|
+
let accountInfos = [];
|
|
272
|
+
let retries = 0;
|
|
273
|
+
const maxRetries = 3;
|
|
274
|
+
while (retries < maxRetries && accountInfos.length === 0) {
|
|
275
|
+
try {
|
|
276
|
+
accountInfos = await connection._rpcBatchRequest(batchRequest).then((batchResults) => {
|
|
277
|
+
const accounts = batchResults.reduce((acc, res) => {
|
|
278
|
+
acc.push(...res.result.value);
|
|
279
|
+
return acc;
|
|
280
|
+
}, []);
|
|
281
|
+
return accounts;
|
|
282
|
+
});
|
|
283
|
+
} catch (error) {
|
|
284
|
+
retries++;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (accountInfos.length === 0) {
|
|
288
|
+
throw new Error(`Failed to fetch account infos after ${maxRetries} retries`);
|
|
289
|
+
}
|
|
290
|
+
accountInfos.forEach((item) => {
|
|
291
|
+
if (item) {
|
|
292
|
+
allAccountInfos.push({
|
|
293
|
+
...item,
|
|
294
|
+
owner: new __solana_web3_js.PublicKey(item.owner),
|
|
295
|
+
data: Buffer.from(item.data[0], "base64")
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
return allAccountInfos;
|
|
301
|
+
}
|
|
302
|
+
function chunkArray(array, chunkSize) {
|
|
303
|
+
const chunks$1 = [];
|
|
304
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
|
305
|
+
chunks$1.push(array.slice(i, i + chunkSize));
|
|
306
|
+
}
|
|
307
|
+
return chunks$1;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region src/common/modules/transactions/transaction.types.ts
|
|
312
|
+
let TransactionType = /* @__PURE__ */ function(TransactionType$1) {
|
|
313
|
+
TransactionType$1["DEPOSIT"] = "DEPOSIT";
|
|
314
|
+
TransactionType$1["WITHDRAW"] = "WITHDRAW";
|
|
315
|
+
TransactionType$1["REPAY"] = "REPAY";
|
|
316
|
+
TransactionType$1["BORROW"] = "BORROW";
|
|
317
|
+
TransactionType$1["FLASHLOAN"] = "FLASHLOAN";
|
|
318
|
+
TransactionType$1["LOOP"] = "LOOP";
|
|
319
|
+
TransactionType$1["REPAY_COLLAT"] = "REPAY_COLLAT";
|
|
320
|
+
TransactionType$1["LONG"] = "LONG";
|
|
321
|
+
TransactionType$1["SHORT"] = "SHORT";
|
|
322
|
+
TransactionType$1["CREATE_ACCOUNT"] = "CREATE_ACCOUNT";
|
|
323
|
+
TransactionType$1["CREATE_ATA"] = "CREATE_ATA";
|
|
324
|
+
TransactionType$1["CLOSE_ACCOUNT"] = "CLOSE_ACCOUNT";
|
|
325
|
+
TransactionType$1["CLOSE_POSITION"] = "CLOSE_POSITION";
|
|
326
|
+
TransactionType$1["MOVE_POSITION_WITHDRAW"] = "MOVE_POSITION_WITHDRAW";
|
|
327
|
+
TransactionType$1["MOVE_POSITION_DEPOSIT"] = "MOVE_POSITION_DEPOSIT";
|
|
328
|
+
TransactionType$1["WITHDRAW_ALL"] = "WITHDRAW_ALL";
|
|
329
|
+
TransactionType$1["TRANSFER_AUTH"] = "TRANSFER_AUTH";
|
|
330
|
+
TransactionType$1["CRANK"] = "CRANK";
|
|
331
|
+
TransactionType$1["DEPOSIT_STAKE"] = "DEPOSIT_STAKE";
|
|
332
|
+
TransactionType$1["WITHDRAW_STAKE"] = "WITHDRAW_STAKE";
|
|
333
|
+
TransactionType$1["INITIALIZE_STAKED_POOL"] = "INITIALIZE_STAKED_POOL";
|
|
334
|
+
TransactionType$1["ADD_STAKED_BANK"] = "ADD_STAKED_BANK";
|
|
335
|
+
TransactionType$1["MERGE_STAKE_ACCOUNTS"] = "MERGE_STAKE_ACCOUNTS";
|
|
336
|
+
TransactionType$1["STAKE_TO_STAKE"] = "STAKE_TO_STAKE";
|
|
337
|
+
TransactionType$1["MINT_LST_NATIVE"] = "MINT_LST_NATIVE";
|
|
338
|
+
TransactionType$1["SWAP_TO_SOL"] = "SWAP_TO_SOL";
|
|
339
|
+
TransactionType$1["SOL_TO_LST"] = "SOL_TO_LST";
|
|
340
|
+
TransactionType$1["UNSTAKE_LST"] = "UNSTAKE_LST";
|
|
341
|
+
TransactionType$1["WITHDRAW_EMISSIONS"] = "WITHDRAW_EMISSIONS";
|
|
342
|
+
TransactionType$1["LIQUIDATE_ACCOUNT"] = "LIQUIDATE_ACCOUNT";
|
|
343
|
+
TransactionType$1["CREATE_PERM_BANK"] = "CREATE_PERM_BANK";
|
|
344
|
+
TransactionType$1["CREATE_GROUP"] = "CREATE_GROUP";
|
|
345
|
+
TransactionType$1["JUPITER_SWAP"] = "JUPITER_SWAP";
|
|
346
|
+
return TransactionType$1;
|
|
347
|
+
}({});
|
|
348
|
+
const TransactionConfigMap = {
|
|
349
|
+
[TransactionType.DEPOSIT]: { label: ({ amount, token } = {}) => amount && token ? `Deposit ${amount} ${token}` : "Deposit" },
|
|
350
|
+
[TransactionType.WITHDRAW]: { label: ({ amount, token } = {}) => amount && token ? `Withdraw ${amount} ${token}` : "Withdraw" },
|
|
351
|
+
[TransactionType.REPAY]: { label: ({ amount, token } = {}) => amount && token ? `Repay ${amount} ${token}` : "Repay" },
|
|
352
|
+
[TransactionType.BORROW]: { label: ({ amount, token } = {}) => amount && token ? `Borrow ${amount} ${token}` : "Borrow" },
|
|
353
|
+
[TransactionType.FLASHLOAN]: { label: () => "Executing Flashloan" },
|
|
354
|
+
[TransactionType.LOOP]: { label: ({ depositAmount, depositToken, borrowAmount, borrowToken } = {}) => depositAmount && depositToken && borrowAmount && borrowToken ? `Loop ${depositAmount} ${depositToken} with ${borrowAmount} ${borrowToken}` : "Loop" },
|
|
355
|
+
[TransactionType.REPAY_COLLAT]: { label: ({ repayAmount, repayToken, amount, token } = {}) => repayAmount && repayToken && amount && token ? `Repay ${repayAmount} ${token} with ${amount} ${repayToken}` : "Repay with collateral" },
|
|
356
|
+
[TransactionType.LONG]: { label: ({ depositToken, depositAmount, borrowToken } = {}) => depositToken && depositAmount && borrowToken ? `Long ${depositToken} with ${depositAmount} ${borrowToken}` : "Open long position" },
|
|
357
|
+
[TransactionType.SHORT]: { label: ({ borrowToken, depositAmount, depositToken } = {}) => borrowToken && depositAmount && depositToken ? `Short ${borrowToken} with ${depositAmount} ${depositToken}` : "Open short position" },
|
|
358
|
+
[TransactionType.CRANK]: { label: () => "Updating latest prices" },
|
|
359
|
+
[TransactionType.JUPITER_SWAP]: { label: ({ originAmount, originToken, destinationAmount, destinationToken } = {}) => originAmount && originToken && destinationAmount && destinationToken ? `Swap ${originAmount} ${originToken} for ${destinationAmount} ${destinationToken}` : "Swap tokens" },
|
|
360
|
+
[TransactionType.CREATE_ACCOUNT]: { label: () => "Create lendr account" },
|
|
361
|
+
[TransactionType.CREATE_ATA]: { label: () => "Configure token account" },
|
|
362
|
+
[TransactionType.CLOSE_ACCOUNT]: { label: () => "Close lendr account" },
|
|
363
|
+
[TransactionType.CLOSE_POSITION]: { label: () => "Close position" },
|
|
364
|
+
[TransactionType.MOVE_POSITION_WITHDRAW]: { label: ({ originAccountAddress } = {}) => `Move position from ${originAccountAddress}` },
|
|
365
|
+
[TransactionType.MOVE_POSITION_DEPOSIT]: { label: ({ destinationAccountAddress } = {}) => `Move position to ${destinationAccountAddress}` },
|
|
366
|
+
[TransactionType.TRANSFER_AUTH]: { label: () => "Authorize account transfer" },
|
|
367
|
+
[TransactionType.DEPOSIT_STAKE]: { label: ({ amount, token } = {}) => amount && token ? `Authorize stake account and deposit ${amount} ${token}` : "Authorize stake and deposit" },
|
|
368
|
+
[TransactionType.WITHDRAW_STAKE]: { label: ({ amount, token } = {}) => "Authorize stake account" },
|
|
369
|
+
[TransactionType.INITIALIZE_STAKED_POOL]: { label: () => "Initialize stake pool" },
|
|
370
|
+
[TransactionType.ADD_STAKED_BANK]: { label: () => "Create staked asset bank" },
|
|
371
|
+
[TransactionType.MERGE_STAKE_ACCOUNTS]: { label: () => "Merge stake accounts" },
|
|
372
|
+
[TransactionType.STAKE_TO_STAKE]: { label: () => "Convert stake" },
|
|
373
|
+
[TransactionType.MINT_LST_NATIVE]: { label: () => "Mint LST" },
|
|
374
|
+
[TransactionType.SWAP_TO_SOL]: { label: ({ swapAmount, token } = {}) => swapAmount && token ? `Swap ${swapAmount} ${token} to SOL` : "Swap to SOL" },
|
|
375
|
+
[TransactionType.SOL_TO_LST]: { label: ({ amount } = {}) => amount ? `Mint LST with ${amount} SOL` : "Mint LST with SOL" },
|
|
376
|
+
[TransactionType.UNSTAKE_LST]: { label: ({ amount } = {}) => amount ? `Unstake ${amount} LST` : "Unstake LST" },
|
|
377
|
+
[TransactionType.WITHDRAW_EMISSIONS]: { label: () => "Withdraw emissions" },
|
|
378
|
+
[TransactionType.LIQUIDATE_ACCOUNT]: { label: () => "Liquidate account" },
|
|
379
|
+
[TransactionType.CREATE_PERM_BANK]: { label: () => "Create permissionless bank" },
|
|
380
|
+
[TransactionType.CREATE_GROUP]: { label: () => "Create lendr group" },
|
|
381
|
+
[TransactionType.WITHDRAW_ALL]: { label: ({ amount, token } = {}) => amount && token ? `Withdraw ${amount} ${token}` : "Withdraw all" }
|
|
382
|
+
};
|
|
383
|
+
const TransactionArenaKeyMap = {
|
|
384
|
+
[TransactionType.DEPOSIT]: new __solana_web3_js.PublicKey("ArenaDeposit1111111111111111111111111111111"),
|
|
385
|
+
[TransactionType.WITHDRAW]: new __solana_web3_js.PublicKey("ArenaWithdraw111111111111111111111111111111"),
|
|
386
|
+
[TransactionType.BORROW]: new __solana_web3_js.PublicKey("ArenaBorrow11111111111111111111111111111111"),
|
|
387
|
+
[TransactionType.REPAY]: new __solana_web3_js.PublicKey("ArenaRepay111111111111111111111111111111111"),
|
|
388
|
+
[TransactionType.REPAY_COLLAT]: new __solana_web3_js.PublicKey("ArenaRepayCo11at111111111111111111111111111"),
|
|
389
|
+
[TransactionType.LONG]: new __solana_web3_js.PublicKey("ArenaLong1111111111111111111111111111111111"),
|
|
390
|
+
[TransactionType.SHORT]: new __solana_web3_js.PublicKey("ArenaShort111111111111111111111111111111111"),
|
|
391
|
+
[TransactionType.CLOSE_POSITION]: new __solana_web3_js.PublicKey("ArenaC1ose111111111111111111111111111111111")
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region src/constants/bank.ts
|
|
396
|
+
const PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED = Buffer.from("liquidity_vault_auth");
|
|
397
|
+
const PDA_BANK_INSURANCE_VAULT_AUTH_SEED = Buffer.from("insurance_vault_auth");
|
|
398
|
+
const PDA_BANK_FEE_VAULT_AUTH_SEED = Buffer.from("fee_vault_auth");
|
|
399
|
+
const PDA_BANK_LIQUIDITY_VAULT_SEED = Buffer.from("liquidity_vault");
|
|
400
|
+
const PDA_BANK_INSURANCE_VAULT_SEED = Buffer.from("insurance_vault");
|
|
401
|
+
const PDA_BANK_FEE_VAULT_SEED = Buffer.from("fee_vault");
|
|
402
|
+
|
|
403
|
+
//#endregion
|
|
404
|
+
//#region src/constants/misc.ts
|
|
405
|
+
const HOURS_PER_YEAR = 365.25 * 24;
|
|
406
|
+
const MAX_U64 = BigInt("18446744073709551615").toString();
|
|
407
|
+
const PYTH_PRICE_CONF_INTERVALS = new bignumber_js.default(2.12);
|
|
408
|
+
const SWB_PRICE_CONF_INTERVALS = new bignumber_js.default(1.96);
|
|
409
|
+
const MAX_CONFIDENCE_INTERVAL_RATIO = new bignumber_js.default(.05);
|
|
410
|
+
const PYTH_PUSH_ORACLE_ID = new __solana_web3_js.PublicKey("pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT");
|
|
411
|
+
const GROUP_PK = new __solana_web3_js.PublicKey(process.env.LENDR_GROUP_PK ?? "4vDRNkXaeAcwJULZCQFFdNBM295sD8hSKQt3RaMwsRFc");
|
|
412
|
+
const PROGRAM_ID = new __solana_web3_js.PublicKey(process.env.LENDR_PROGRAM_ID ?? "89ZQeCPwkzSPJyTpktCKWNY6hBWMKuYt47R85Jo36yyh");
|
|
413
|
+
const DEFAULT_CLUSTER = process.env.LENDR_CLUSTER_OVERRIDE ?? "mainnet";
|
|
414
|
+
|
|
415
|
+
//#endregion
|
|
416
|
+
//#region src/constants/flags.ts
|
|
417
|
+
const DISABLED_FLAG = 1 << 0;
|
|
418
|
+
const FLASHLOAN_ENABLED_FLAG = 1 << 2;
|
|
419
|
+
const TRANSFER_ACCOUNT_AUTHORITY_FLAG = 1 << 3;
|
|
420
|
+
|
|
421
|
+
//#endregion
|
|
422
|
+
//#region src/constants/tokens.ts
|
|
423
|
+
const WSOL_MINT = new __solana_web3_js.PublicKey("So11111111111111111111111111111111111111112");
|
|
424
|
+
const WSOL_EXTENDED_METADATA = {
|
|
425
|
+
symbol: "wSOL",
|
|
426
|
+
name: "Wrapped SOL",
|
|
427
|
+
address: "D7zkaUgFUDkhQHExySRxokL3Fa1GFnnuiVDTs9yMrFHY",
|
|
428
|
+
logoURI: "https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/So11111111111111111111111111111111111111112/logo.png",
|
|
429
|
+
additionalMetadata: [],
|
|
430
|
+
uri: "",
|
|
431
|
+
mint: WSOL_MINT.toBase58()
|
|
432
|
+
};
|
|
433
|
+
const LST_MINT = new __solana_web3_js.PublicKey("LSTxxxnJzKDFSLr4dUkPcmCf5VyryEqzPLz5j4bpxFp");
|
|
434
|
+
const USDC_MINT = new __solana_web3_js.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
435
|
+
const DUMMY_USDC_MINT = new __solana_web3_js.PublicKey("JAiSLhTCvAhGM4SojCYGoTPuqjw7KaCsopvRuNryzbML");
|
|
436
|
+
const USDC_DECIMALS = 6;
|
|
437
|
+
|
|
438
|
+
//#endregion
|
|
439
|
+
//#region src/constants/defaults.ts
|
|
440
|
+
const DEFAULT_COMMITMENT = "processed";
|
|
441
|
+
const DEFAULT_SEND_OPTS = {
|
|
442
|
+
skipPreflight: false,
|
|
443
|
+
preflightCommitment: DEFAULT_COMMITMENT
|
|
444
|
+
};
|
|
445
|
+
const DEFAULT_CONFIRM_OPTS = {
|
|
446
|
+
commitment: DEFAULT_COMMITMENT,
|
|
447
|
+
...DEFAULT_SEND_OPTS
|
|
448
|
+
};
|
|
449
|
+
const MAX_TX_SIZE = 1232;
|
|
450
|
+
const MAX_ACCOUNT_KEYS = 64;
|
|
451
|
+
const BUNDLE_TX_SIZE = 81;
|
|
452
|
+
const PRIORITY_TX_SIZE = 44;
|
|
453
|
+
const SKIP_SIMULATION = false;
|
|
454
|
+
const DEFAULT_ORACLE_MAX_AGE = 60;
|
|
455
|
+
|
|
456
|
+
//#endregion
|
|
457
|
+
//#region src/constants/programs.ts
|
|
458
|
+
const LUT_PROGRAM_AUTHORITY_INDEX = 5;
|
|
459
|
+
const JUPITER_V6_PROGRAM = new __solana_web3_js.PublicKey("JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4");
|
|
460
|
+
const LENDR_PROGRAM = new __solana_web3_js.PublicKey("89ZQeCPwkzSPJyTpktCKWNY6hBWMKuYt47R85Jo36yyh");
|
|
461
|
+
const SINGLE_POOL_PROGRAM_ID = new __solana_web3_js.PublicKey("SVSPxpvHdN29nkVg9rPapPNDddN5DipNLRUFhyjFThE");
|
|
462
|
+
const STAKE_PROGRAM_ID = new __solana_web3_js.PublicKey("Stake11111111111111111111111111111111111111");
|
|
463
|
+
const MPL_METADATA_PROGRAM_ID = new __solana_web3_js.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
|
|
464
|
+
const SYSTEM_PROGRAM_ID = new __solana_web3_js.PublicKey("11111111111111111111111111111111");
|
|
465
|
+
const SYSVAR_RENT_ID = new __solana_web3_js.PublicKey("SysvarRent111111111111111111111111111111111");
|
|
466
|
+
const SYSVAR_CLOCK_ID = new __solana_web3_js.PublicKey("SysvarC1ock11111111111111111111111111111111");
|
|
467
|
+
const SYSVAR_STAKE_HISTORY_ID = new __solana_web3_js.PublicKey("SysvarStakeHistory1111111111111111111111111");
|
|
468
|
+
const STAKE_CONFIG_ID = new __solana_web3_js.PublicKey("StakeConfig11111111111111111111111111111111");
|
|
469
|
+
|
|
470
|
+
//#endregion
|
|
471
|
+
//#region src/common/modules/transactions/transaction.utils.ts
|
|
472
|
+
/**
|
|
473
|
+
* Determines if a given transaction is a VersionedTransaction.
|
|
474
|
+
* This function checks for the presence of a 'message' property to identify
|
|
475
|
+
* if the transaction is of type VersionedTransaction.
|
|
476
|
+
*
|
|
477
|
+
* @param tx - The transaction object, which can be either a VersionedTransaction or a Transaction.
|
|
478
|
+
* @returns A boolean indicating whether the transaction is a VersionedTransaction.
|
|
479
|
+
*/
|
|
480
|
+
function isV0Tx(tx) {
|
|
481
|
+
return "message" in tx;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Calculates the size of a Solana transaction in bytes.
|
|
485
|
+
* This function considers the number of required signatures and other transaction components.
|
|
486
|
+
*
|
|
487
|
+
* @param tx - The transaction object, which can be either a VersionedTransaction or a Transaction.
|
|
488
|
+
* @returns The size of the transaction in bytes.
|
|
489
|
+
*/
|
|
490
|
+
function getTxSize(tx) {
|
|
491
|
+
const isVersioned = isV0Tx(tx);
|
|
492
|
+
const numSigners = tx.signatures.length;
|
|
493
|
+
const numRequiredSignatures = isVersioned ? tx.message.header.numRequiredSignatures : 0;
|
|
494
|
+
const feePayerSize = isVersioned || tx.feePayer ? 0 : 32;
|
|
495
|
+
const signaturesSize = (numRequiredSignatures - numSigners) * 64 + 1;
|
|
496
|
+
try {
|
|
497
|
+
const baseTxSize = isVersioned ? tx.serialize().length : tx.serialize({
|
|
498
|
+
requireAllSignatures: false,
|
|
499
|
+
verifySignatures: false
|
|
500
|
+
}).length;
|
|
501
|
+
return baseTxSize + feePayerSize + signaturesSize;
|
|
502
|
+
} catch (error) {
|
|
503
|
+
return 9999;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
function getAccountKeys(tx, lookupTableAccounts) {
|
|
507
|
+
const isVersioned = isV0Tx(tx);
|
|
508
|
+
try {
|
|
509
|
+
if (isVersioned) {
|
|
510
|
+
const message = __solana_web3_js.TransactionMessage.decompile(tx.message, { addressLookupTableAccounts: lookupTableAccounts });
|
|
511
|
+
return message.compileToLegacyMessage().getAccountKeys().length;
|
|
512
|
+
} else {
|
|
513
|
+
return tx.compileMessage().getAccountKeys().length;
|
|
514
|
+
}
|
|
515
|
+
} catch (error) {
|
|
516
|
+
return 9999;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Decodes a Solana transaction instruction using the provided Interface Definition Language (IDL).
|
|
521
|
+
* This function utilizes the BorshInstructionCoder to interpret the encoded instruction data.
|
|
522
|
+
*
|
|
523
|
+
* @param idl - The Interface Definition Language object that defines the structure of the instruction.
|
|
524
|
+
* @param encoded - The Buffer containing the encoded instruction data.
|
|
525
|
+
* @returns The decoded instruction object.
|
|
526
|
+
*/
|
|
527
|
+
function decodeInstruction(idl, encoded) {
|
|
528
|
+
const coder = new __coral_xyz_anchor.BorshInstructionCoder(idl);
|
|
529
|
+
return coder.decode(encoded, "base58");
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Decompiles a VersionedTransaction into a TransactionMessage.
|
|
533
|
+
*
|
|
534
|
+
* @param tx - The VersionedTransaction to be decompiled.
|
|
535
|
+
* @param lookupTableAccounts - An array of AddressLookupTableAccount used for decompiling the transaction message.
|
|
536
|
+
* @returns A TransactionMessage object representing the decompiled transaction.
|
|
537
|
+
*/
|
|
538
|
+
function decompileV0Transaction(tx, lookupTableAccounts) {
|
|
539
|
+
return __solana_web3_js.TransactionMessage.decompile(tx.message, { addressLookupTableAccounts: lookupTableAccounts });
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Converts a legacy Solana transaction to a versioned transaction. *
|
|
543
|
+
* @param transaction - The legacy transaction to be converted.
|
|
544
|
+
* @param opts - Optional parameters for the conversion process.
|
|
545
|
+
* @returns A VersionedTransaction object representing the converted transaction.
|
|
546
|
+
* @throws Will throw an error if the fee payer or blockhash is not provided.
|
|
547
|
+
*/
|
|
548
|
+
function legacyTxToV0Tx(transaction, opts) {
|
|
549
|
+
const feePayer = opts?.feePayer ?? transaction.feePayer;
|
|
550
|
+
const blockhash = opts?.blockhash ?? transaction.recentBlockhash;
|
|
551
|
+
const additionalIxs = opts?.additionalIxs ?? [];
|
|
552
|
+
const addressLookupTables = opts?.addressLookupTables ?? [];
|
|
553
|
+
if (!feePayer || !blockhash) {
|
|
554
|
+
throw new Error("Fee payer and blockhash are required");
|
|
555
|
+
}
|
|
556
|
+
const ixs = transaction.instructions;
|
|
557
|
+
const versionedMessage = new __solana_web3_js.TransactionMessage({
|
|
558
|
+
instructions: [...additionalIxs, ...ixs],
|
|
559
|
+
payerKey: feePayer,
|
|
560
|
+
recentBlockhash: blockhash
|
|
561
|
+
});
|
|
562
|
+
return new __solana_web3_js.VersionedTransaction(versionedMessage.compileToV0Message(addressLookupTables));
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Updates a VersionedTransaction with new options.
|
|
566
|
+
*
|
|
567
|
+
* This function allows you to modify a given VersionedTransaction by providing
|
|
568
|
+
* additional transaction instructions, address lookup tables, a new fee payer,
|
|
569
|
+
* and a new blockhash. It decompiles the existing transaction, applies the updates,
|
|
570
|
+
* and recompiles it into a new VersionedTransaction.
|
|
571
|
+
*
|
|
572
|
+
* @param transaction - The VersionedTransaction to be updated.
|
|
573
|
+
* @param opts - Optional parameters for updating the transaction.
|
|
574
|
+
* @returns A new VersionedTransaction object with the applied updates.
|
|
575
|
+
* @throws Will throw an error if the fee payer or blockhash is not provided.
|
|
576
|
+
*/
|
|
577
|
+
function updateV0Tx(transaction, opts) {
|
|
578
|
+
const additionalIxs = opts?.additionalIxs ?? [];
|
|
579
|
+
const addressLookupTables = opts?.addressLookupTables ?? [];
|
|
580
|
+
let instructions = [];
|
|
581
|
+
const message = decompileV0Transaction(transaction, addressLookupTables);
|
|
582
|
+
const feePayer = opts?.feePayer ?? message.payerKey;
|
|
583
|
+
const blockhash = opts?.blockhash ?? message.recentBlockhash;
|
|
584
|
+
if (additionalIxs.length > 0) {
|
|
585
|
+
instructions = replaceV0TxInstructions(additionalIxs, message.instructions, opts?.replaceOnly);
|
|
586
|
+
} else {
|
|
587
|
+
instructions = message.instructions;
|
|
588
|
+
}
|
|
589
|
+
const versionedMessage = new __solana_web3_js.TransactionMessage({
|
|
590
|
+
instructions,
|
|
591
|
+
payerKey: feePayer,
|
|
592
|
+
recentBlockhash: blockhash
|
|
593
|
+
});
|
|
594
|
+
return new __solana_web3_js.VersionedTransaction(versionedMessage.compileToV0Message(addressLookupTables));
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Checks if two transaction instructions are identical by comparing their data, program IDs, and account keys.
|
|
598
|
+
*
|
|
599
|
+
* @param ix1 - First transaction instruction to compare
|
|
600
|
+
* @param ix2 - Second transaction instruction to compare
|
|
601
|
+
* @returns True if instructions are identical, false otherwise
|
|
602
|
+
*/
|
|
603
|
+
function compareInstructions(ix1, ix2) {
|
|
604
|
+
const dataCompare = ix1.data.equals(ix2.data);
|
|
605
|
+
const programIdCompare = ix1.programId.equals(ix2.programId);
|
|
606
|
+
const keysCompare = ix1.keys.length === ix2.keys.length && ix1.keys.every((key, index) => {
|
|
607
|
+
const key2 = ix2.keys[index];
|
|
608
|
+
return key.pubkey.equals(key2.pubkey) && key.isSigner === key2.isSigner && key.isWritable === key2.isWritable;
|
|
609
|
+
});
|
|
610
|
+
return dataCompare && programIdCompare && keysCompare;
|
|
611
|
+
}
|
|
612
|
+
function replaceV0TxInstructions(additionalInstructions, instructions, replaceOnly) {
|
|
613
|
+
let updatedAdditionalIxs = additionalInstructions;
|
|
614
|
+
const updatedInstructions = instructions.map((ix) => {
|
|
615
|
+
const programId = ix.programId;
|
|
616
|
+
const additionalIxs = additionalInstructions.filter((a) => a.programId.equals(programId));
|
|
617
|
+
if (additionalIxs.length > 0) {
|
|
618
|
+
if (ix.programId.equals(__solana_web3_js.ComputeBudgetProgram.programId)) {
|
|
619
|
+
const decoded = decodeComputeBudgetInstruction(ix);
|
|
620
|
+
const updatedCuPriceIx = additionalIxs.find((a) => decodeComputeBudgetInstruction(a).instructionType === "SetComputeUnitPrice");
|
|
621
|
+
const updatedCuLimitIx = additionalIxs.find((a) => decodeComputeBudgetInstruction(a).instructionType === "SetComputeUnitLimit");
|
|
622
|
+
if (decoded.instructionType === "SetComputeUnitPrice" && updatedCuPriceIx) {
|
|
623
|
+
updatedAdditionalIxs = updatedAdditionalIxs.filter((a) => !compareInstructions(a, updatedCuPriceIx));
|
|
624
|
+
return updatedCuPriceIx;
|
|
625
|
+
}
|
|
626
|
+
if (decoded.instructionType === "SetComputeUnitLimit" && updatedCuLimitIx) {
|
|
627
|
+
updatedAdditionalIxs = updatedAdditionalIxs.filter((a) => !compareInstructions(a, updatedCuLimitIx));
|
|
628
|
+
return updatedCuLimitIx;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
return ix;
|
|
633
|
+
});
|
|
634
|
+
return [...replaceOnly ? [] : updatedAdditionalIxs, ...updatedInstructions];
|
|
635
|
+
}
|
|
636
|
+
function replaceV0TxBlockhash(transaction, blockhash) {
|
|
637
|
+
const message = transaction.message;
|
|
638
|
+
message.recentBlockhash = blockhash;
|
|
639
|
+
return new __solana_web3_js.VersionedTransaction(message);
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Enhances a given transaction with additional metadata.
|
|
643
|
+
*
|
|
644
|
+
* @param transaction - The transaction to be enhanced, can be either VersionedTransaction or Transaction.
|
|
645
|
+
* @param options - An object containing optional metadata:
|
|
646
|
+
* - signers: An array of Signer objects that are associated with the transaction.
|
|
647
|
+
* - addressLookupTables: An array of AddressLookupTableAccount objects for address resolution.
|
|
648
|
+
* - unitsConsumed: A number representing the compute units consumed by the transaction.
|
|
649
|
+
* - type: The type of the transaction, as defined by TransactionType.
|
|
650
|
+
* @returns A SolanaTransaction object that includes the original transaction and the additional metadata.
|
|
651
|
+
*/
|
|
652
|
+
function addTransactionMetadata(transaction, options) {
|
|
653
|
+
return Object.assign(transaction, options);
|
|
654
|
+
}
|
|
655
|
+
function identifyComputeBudgetInstruction(data) {
|
|
656
|
+
const discriminator = data.readUInt8(0);
|
|
657
|
+
switch (discriminator) {
|
|
658
|
+
case 0: return "RequestUnits";
|
|
659
|
+
case 1: return "RequestHeapFrame";
|
|
660
|
+
case 2: return "SetComputeUnitLimit";
|
|
661
|
+
case 3: return "SetComputeUnitPrice";
|
|
662
|
+
case 4: return "SetLoadedAccountsDataSizeLimit";
|
|
663
|
+
default: throw new Error("Unknown ComputeBudget instruction discriminator.");
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Decodes a ComputeBudget program instruction into a readable format.
|
|
668
|
+
*
|
|
669
|
+
* @param instruction - The ComputeBudget program instruction to decode
|
|
670
|
+
* @returns An object containing the decoded instruction data with fields depending on the instruction type:
|
|
671
|
+
* - RequestUnits: { instructionType: string, units: number, additionalFee: number }
|
|
672
|
+
* - RequestHeapFrame: { instructionType: string, bytes: number }
|
|
673
|
+
* - SetComputeUnitLimit: { instructionType: string, units: number }
|
|
674
|
+
* - SetComputeUnitPrice: { instructionType: string, microLamports: string }
|
|
675
|
+
* - SetLoadedAccountsDataSizeLimit: { instructionType: string, accountDataSizeLimit: number }
|
|
676
|
+
* @throws Error if the instruction data is invalid or the instruction type is unknown
|
|
677
|
+
*/
|
|
678
|
+
function decodeComputeBudgetInstruction(instruction) {
|
|
679
|
+
const data = Buffer.from(instruction.data || instruction);
|
|
680
|
+
const instructionType = identifyComputeBudgetInstruction(data);
|
|
681
|
+
switch (instructionType) {
|
|
682
|
+
case "RequestUnits": {
|
|
683
|
+
if (data.length !== 9) {
|
|
684
|
+
throw new Error("Invalid data length for RequestUnits");
|
|
685
|
+
}
|
|
686
|
+
const units = data.readUInt32LE(1);
|
|
687
|
+
const additionalFee = data.readUInt32LE(5);
|
|
688
|
+
return {
|
|
689
|
+
instructionType,
|
|
690
|
+
units,
|
|
691
|
+
additionalFee
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
case "RequestHeapFrame": {
|
|
695
|
+
if (data.length !== 5) {
|
|
696
|
+
throw new Error("Invalid data length for RequestHeapFrame");
|
|
697
|
+
}
|
|
698
|
+
const bytes = data.readUInt32LE(1);
|
|
699
|
+
return {
|
|
700
|
+
instructionType,
|
|
701
|
+
bytes
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
case "SetComputeUnitLimit": {
|
|
705
|
+
if (data.length !== 5) {
|
|
706
|
+
throw new Error("Invalid data length for SetComputeUnitLimit");
|
|
707
|
+
}
|
|
708
|
+
const units = data.readUInt32LE(1);
|
|
709
|
+
return {
|
|
710
|
+
instructionType,
|
|
711
|
+
units
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
case "SetComputeUnitPrice": {
|
|
715
|
+
if (data.length !== 9) {
|
|
716
|
+
throw new Error("Invalid data length for SetComputeUnitPrice");
|
|
717
|
+
}
|
|
718
|
+
const microLamports = data.readBigUInt64LE(1);
|
|
719
|
+
return {
|
|
720
|
+
instructionType,
|
|
721
|
+
microLamports: microLamports.toString()
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
case "SetLoadedAccountsDataSizeLimit": {
|
|
725
|
+
if (data.length !== 5) {
|
|
726
|
+
throw new Error("Invalid data length for SetLoadedAccountsDataSizeLimit");
|
|
727
|
+
}
|
|
728
|
+
const accountDataSizeLimit = data.readUInt32LE(1);
|
|
729
|
+
return {
|
|
730
|
+
instructionType,
|
|
731
|
+
accountDataSizeLimit
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
default: throw new Error("Unknown ComputeBudget instruction type.");
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
const DEFAULT_COMPUTE_BUDGET_IX = 2e5;
|
|
738
|
+
function getComputeBudgetUnits(tx) {
|
|
739
|
+
let instructions = [];
|
|
740
|
+
if (isV0Tx(tx)) {
|
|
741
|
+
const addressLookupTableAccounts = tx.addressLookupTables ?? [];
|
|
742
|
+
const message = decompileV0Transaction(tx, addressLookupTableAccounts);
|
|
743
|
+
instructions = message.instructions;
|
|
744
|
+
} else {
|
|
745
|
+
instructions = tx.instructions;
|
|
746
|
+
}
|
|
747
|
+
const computeBudgetIxs = instructions.filter((ix) => ix.programId.equals(__solana_web3_js.ComputeBudgetProgram.programId));
|
|
748
|
+
if (computeBudgetIxs.length === 0) {
|
|
749
|
+
return Math.min(instructions.length * DEFAULT_COMPUTE_BUDGET_IX, 14e5);
|
|
750
|
+
}
|
|
751
|
+
const decoded = computeBudgetIxs.map((ix) => decodeComputeBudgetInstruction(ix));
|
|
752
|
+
const limit = decoded.find((ix) => ix.instructionType === "SetComputeUnitLimit");
|
|
753
|
+
return limit?.units ?? instructions.length * DEFAULT_COMPUTE_BUDGET_IX;
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Converts a priority fee from UI units (SOL) to micro-lamports per compute unit
|
|
757
|
+
* @param ui - Priority fee amount in SOL
|
|
758
|
+
* @param limitCU - Compute unit limit, defaults to 1.4M CU
|
|
759
|
+
* @returns Priority fee in micro-lamports per compute unit
|
|
760
|
+
*/
|
|
761
|
+
const uiToMicroLamports = (ui, limitCU = 14e5) => {
|
|
762
|
+
const priorityFeeMicroLamports = ui * __solana_web3_js.LAMPORTS_PER_SOL * 1e6;
|
|
763
|
+
return priorityFeeMicroLamports / limitCU;
|
|
764
|
+
};
|
|
765
|
+
/**
|
|
766
|
+
* Converts a priority fee from micro-lamports per compute unit to UI units (SOL)
|
|
767
|
+
* @param microLamports - Priority fee in micro-lamports per compute unit
|
|
768
|
+
* @param limitCU - Compute unit limit, defaults to 1.4M CU
|
|
769
|
+
* @returns Priority fee amount in SOL, truncated to 9 decimal places
|
|
770
|
+
*/
|
|
771
|
+
const microLamportsToUi = (microLamports, limitCU = 14e5) => {
|
|
772
|
+
const priorityFeeMicroLamports = microLamports * limitCU;
|
|
773
|
+
const priorityFeeUi = priorityFeeMicroLamports / (__solana_web3_js.LAMPORTS_PER_SOL * 1e6);
|
|
774
|
+
return Math.trunc(priorityFeeUi * __solana_web3_js.LAMPORTS_PER_SOL) / __solana_web3_js.LAMPORTS_PER_SOL;
|
|
775
|
+
};
|
|
776
|
+
/**
|
|
777
|
+
* Splits your instructions into as many VersionedTransactions as needed
|
|
778
|
+
* so that none exceed MAX_TX_SIZE.
|
|
779
|
+
*/
|
|
780
|
+
function splitInstructionsToFitTransactions(mandatoryIxs, ixs, opts) {
|
|
781
|
+
const result = [];
|
|
782
|
+
let buffer = [];
|
|
783
|
+
function buildTx(mandatoryIxs$1, extraIxs, opts$1) {
|
|
784
|
+
const messageV0 = new __solana_web3_js.TransactionMessage({
|
|
785
|
+
payerKey: opts$1.payerKey,
|
|
786
|
+
recentBlockhash: opts$1.blockhash,
|
|
787
|
+
instructions: [...mandatoryIxs$1, ...extraIxs]
|
|
788
|
+
}).compileToV0Message(opts$1.luts);
|
|
789
|
+
return new __solana_web3_js.VersionedTransaction(messageV0);
|
|
790
|
+
}
|
|
791
|
+
for (const ix of ixs) {
|
|
792
|
+
const trial = buildTx(mandatoryIxs, [...buffer, ix], opts);
|
|
793
|
+
if (getTxSize(trial) <= MAX_TX_SIZE) {
|
|
794
|
+
buffer.push(ix);
|
|
795
|
+
} else {
|
|
796
|
+
if (buffer.length === 0) {
|
|
797
|
+
throw new Error("Single instruction too large to fit in a transaction");
|
|
798
|
+
}
|
|
799
|
+
const tx = buildTx(mandatoryIxs, buffer, opts);
|
|
800
|
+
result.push(tx);
|
|
801
|
+
buffer = [ix];
|
|
802
|
+
const solo = buildTx(mandatoryIxs, buffer, opts);
|
|
803
|
+
if (getTxSize(solo) > MAX_TX_SIZE) {
|
|
804
|
+
throw new Error("Single instruction too large to fit in a transaction");
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
if (buffer.length > 0) {
|
|
809
|
+
const tx = buildTx(mandatoryIxs, buffer, opts);
|
|
810
|
+
result.push(tx);
|
|
811
|
+
}
|
|
812
|
+
return result;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
//#endregion
|
|
816
|
+
//#region src/common/priority.ts
|
|
817
|
+
let PriotitizationFeeLevels = /* @__PURE__ */ function(PriotitizationFeeLevels$1) {
|
|
818
|
+
PriotitizationFeeLevels$1[PriotitizationFeeLevels$1["LOW"] = 2500] = "LOW";
|
|
819
|
+
PriotitizationFeeLevels$1[PriotitizationFeeLevels$1["MEDIAN"] = 5e3] = "MEDIAN";
|
|
820
|
+
PriotitizationFeeLevels$1[PriotitizationFeeLevels$1["HIGH"] = 7500] = "HIGH";
|
|
821
|
+
PriotitizationFeeLevels$1[PriotitizationFeeLevels$1["MAX"] = 1e4] = "MAX";
|
|
822
|
+
return PriotitizationFeeLevels$1;
|
|
823
|
+
}({});
|
|
824
|
+
const getCalculatedPrioritizationFeeByPercentile = async (connection, config, slotsToReturn) => {
|
|
825
|
+
const fees = await getRecentPrioritizationFeesByPercentile(connection, config, slotsToReturn);
|
|
826
|
+
const { min, max, sum } = fees.reduce((acc, fee) => ({
|
|
827
|
+
min: fee.prioritizationFee < acc.min.prioritizationFee ? fee : acc.min,
|
|
828
|
+
max: fee.prioritizationFee > acc.max.prioritizationFee ? fee : acc.max,
|
|
829
|
+
sum: acc.sum + fee.prioritizationFee
|
|
830
|
+
}), {
|
|
831
|
+
min: fees[0],
|
|
832
|
+
max: fees[0],
|
|
833
|
+
sum: 0
|
|
834
|
+
});
|
|
835
|
+
const mean = Math.ceil(sum / fees.length);
|
|
836
|
+
const sortedFees = [...fees].sort((a, b) => a.prioritizationFee - b.prioritizationFee);
|
|
837
|
+
const midIndex = Math.floor(fees.length / 2);
|
|
838
|
+
const median$1 = fees.length % 2 === 0 ? Math.ceil((sortedFees[midIndex - 1].prioritizationFee + sortedFees[midIndex].prioritizationFee) / 2) : sortedFees[midIndex].prioritizationFee;
|
|
839
|
+
return {
|
|
840
|
+
min,
|
|
841
|
+
max,
|
|
842
|
+
mean,
|
|
843
|
+
median: median$1
|
|
844
|
+
};
|
|
845
|
+
};
|
|
846
|
+
const getMinPrioritizationFeeByPercentile = async (connection, config, slotsToReturn) => {
|
|
847
|
+
const recentPrioritizationFees = await getRecentPrioritizationFeesByPercentile(connection, config, slotsToReturn);
|
|
848
|
+
const minPriorityFee = recentPrioritizationFees.reduce((min, current) => {
|
|
849
|
+
return current.prioritizationFee < min.prioritizationFee ? current : min;
|
|
850
|
+
});
|
|
851
|
+
return minPriorityFee.prioritizationFee;
|
|
852
|
+
};
|
|
853
|
+
const getMaxPrioritizationFeeByPercentile = async (connection, config, slotsToReturn) => {
|
|
854
|
+
const recentPrioritizationFees = await getRecentPrioritizationFeesByPercentile(connection, config, slotsToReturn);
|
|
855
|
+
const maxPriorityFee = recentPrioritizationFees.reduce((max, current) => {
|
|
856
|
+
return current.prioritizationFee > max.prioritizationFee ? current : max;
|
|
857
|
+
});
|
|
858
|
+
return maxPriorityFee.prioritizationFee;
|
|
859
|
+
};
|
|
860
|
+
const getMeanPrioritizationFeeByPercentile = async (connection, config, slotsToReturn) => {
|
|
861
|
+
const recentPrioritizationFees = await getRecentPrioritizationFeesByPercentile(connection, config, slotsToReturn);
|
|
862
|
+
const mean = Math.ceil(recentPrioritizationFees.reduce((acc, fee) => acc + fee.prioritizationFee, 0) / recentPrioritizationFees.length);
|
|
863
|
+
return mean;
|
|
864
|
+
};
|
|
865
|
+
const getMedianPrioritizationFeeByPercentile = async (connection, config, slotsToReturn) => {
|
|
866
|
+
const recentPrioritizationFees = await getRecentPrioritizationFeesByPercentile(connection, config, slotsToReturn);
|
|
867
|
+
recentPrioritizationFees.sort((a, b) => a.prioritizationFee - b.prioritizationFee);
|
|
868
|
+
const half = Math.floor(recentPrioritizationFees.length / 2);
|
|
869
|
+
if (recentPrioritizationFees.length % 2) {
|
|
870
|
+
return recentPrioritizationFees[half].prioritizationFee;
|
|
871
|
+
}
|
|
872
|
+
return Math.ceil((recentPrioritizationFees[half - 1].prioritizationFee + recentPrioritizationFees[half].prioritizationFee) / 2);
|
|
873
|
+
};
|
|
874
|
+
const getRecentPrioritizationFeesFromRpc = async (config, rpcRequest) => {
|
|
875
|
+
const accounts = config?.lockedWritableAccounts?.map((key) => key.toBase58());
|
|
876
|
+
const args = accounts?.length ? [accounts] : [[]];
|
|
877
|
+
config.percentile && args.push({ percentile: config.percentile });
|
|
878
|
+
const response = await rpcRequest("getRecentPrioritizationFees", args);
|
|
879
|
+
return response;
|
|
880
|
+
};
|
|
881
|
+
const getRecentPrioritizationFeesByPercentile = async (connection, config, slotsToReturn) => {
|
|
882
|
+
const { fallback = true, lockedWritableAccounts = [] } = config || {};
|
|
883
|
+
slotsToReturn = slotsToReturn && Number.isInteger(slotsToReturn) ? slotsToReturn : -1;
|
|
884
|
+
const promises = [];
|
|
885
|
+
let tritonRpcResponse;
|
|
886
|
+
let fallbackRpcResponse;
|
|
887
|
+
const rpcRequest = connection._rpcRequest;
|
|
888
|
+
promises.push(getRecentPrioritizationFeesFromRpc(config, rpcRequest).then((result) => {
|
|
889
|
+
tritonRpcResponse = result;
|
|
890
|
+
}));
|
|
891
|
+
if (fallback) {
|
|
892
|
+
promises.push(getRecentPrioritizationFeesFromRpc({ lockedWritableAccounts }, rpcRequest).then((result) => {
|
|
893
|
+
fallbackRpcResponse = result;
|
|
894
|
+
}));
|
|
895
|
+
}
|
|
896
|
+
await Promise.all(promises);
|
|
897
|
+
const tritonGRPFResponse = tritonRpcResponse;
|
|
898
|
+
const fallbackGRPFResponse = fallbackRpcResponse;
|
|
899
|
+
let recentPrioritizationFees = [];
|
|
900
|
+
if (tritonGRPFResponse?.result) {
|
|
901
|
+
recentPrioritizationFees = tritonGRPFResponse.result;
|
|
902
|
+
}
|
|
903
|
+
if (fallbackGRPFResponse?.result && !tritonGRPFResponse?.result) {
|
|
904
|
+
recentPrioritizationFees = fallbackGRPFResponse.result;
|
|
905
|
+
}
|
|
906
|
+
if (fallback && fallbackGRPFResponse.error) {
|
|
907
|
+
return fallbackGRPFResponse.error;
|
|
908
|
+
}
|
|
909
|
+
if (tritonGRPFResponse?.error) {
|
|
910
|
+
return tritonGRPFResponse.error;
|
|
911
|
+
}
|
|
912
|
+
recentPrioritizationFees.sort((a, b) => a.slot - b.slot);
|
|
913
|
+
if (slotsToReturn > 0) return recentPrioritizationFees.slice(0, slotsToReturn);
|
|
914
|
+
return recentPrioritizationFees;
|
|
915
|
+
};
|
|
916
|
+
|
|
917
|
+
//#endregion
|
|
918
|
+
//#region src/common/utils/accounting.utils.ts
|
|
919
|
+
/**
|
|
920
|
+
* Formula source: http://www.linked8.com/blog/158-apy-to-apr-and-apr-to-apy-calculation-methodologies
|
|
921
|
+
*
|
|
922
|
+
* @param apy {Number} APY (i.e. 0.06 for 6%)
|
|
923
|
+
* @param compoundingFrequency {Number} Compounding frequency (times a year)
|
|
924
|
+
* @returns {Number} APR (i.e. 0.0582 for APY of 0.06)
|
|
925
|
+
*/
|
|
926
|
+
const apyToApr = (apy, compoundingFrequency = HOURS_PER_YEAR) => ((1 + apy) ** (1 / compoundingFrequency) - 1) * compoundingFrequency;
|
|
927
|
+
/**
|
|
928
|
+
* Formula source: http://www.linked8.com/blog/158-apy-to-apr-and-apr-to-apy-calculation-methodologies
|
|
929
|
+
*
|
|
930
|
+
*
|
|
931
|
+
* @param apr {Number} APR (i.e. 0.0582 for 5.82%)
|
|
932
|
+
* @param compoundingFrequency {Number} Compounding frequency (times a year)
|
|
933
|
+
* @returns {Number} APY (i.e. 0.06 for APR of 0.0582)
|
|
934
|
+
*/
|
|
935
|
+
const aprToApy = (apr, compoundingFrequency = HOURS_PER_YEAR, apyCap = 3) => Math.min((1 + apr / compoundingFrequency) ** compoundingFrequency - 1, apyCap);
|
|
936
|
+
function calculateInterestFromApy(principal, durationInYears, apy) {
|
|
937
|
+
return principal * apy * durationInYears;
|
|
938
|
+
}
|
|
939
|
+
function calculateApyFromInterest(principal, durationInYears, interest) {
|
|
940
|
+
return interest / (principal * durationInYears);
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
//#endregion
|
|
944
|
+
//#region src/common/utils/conversion.utils.ts
|
|
945
|
+
const I80F48_FRACTIONAL_BYTES = 6;
|
|
946
|
+
const I80F48_TOTAL_BYTES = 16;
|
|
947
|
+
const I80F48_DIVISOR = new decimal_js.Decimal(2).pow(8 * I80F48_FRACTIONAL_BYTES);
|
|
948
|
+
function wrappedI80F48toBigNumber(wrapped) {
|
|
949
|
+
const bytesLE = wrapped.value;
|
|
950
|
+
if (bytesLE.length !== I80F48_TOTAL_BYTES) {
|
|
951
|
+
throw new Error(`Expected a ${I80F48_TOTAL_BYTES}-byte buffer`);
|
|
952
|
+
}
|
|
953
|
+
let bytesBE = bytesLE.slice();
|
|
954
|
+
bytesBE.reverse();
|
|
955
|
+
let signChar = "";
|
|
956
|
+
const msb = bytesBE[0];
|
|
957
|
+
if (msb & 128) {
|
|
958
|
+
signChar = "-";
|
|
959
|
+
bytesBE = bytesBE.map((v) => ~v & 255);
|
|
960
|
+
}
|
|
961
|
+
const hex = signChar + "0x" + bytesBE.map((v) => v.toString(16).padStart(2, "0")).join("");
|
|
962
|
+
const decoded = new decimal_js.Decimal(hex).dividedBy(I80F48_DIVISOR);
|
|
963
|
+
return new bignumber_js.default(decoded.toString());
|
|
964
|
+
}
|
|
965
|
+
function bigNumberToWrappedI80F48(value) {
|
|
966
|
+
let decimalValue = new decimal_js.Decimal(value.toString());
|
|
967
|
+
const isNegative = decimalValue.isNegative();
|
|
968
|
+
decimalValue = decimalValue.times(I80F48_DIVISOR);
|
|
969
|
+
let wrappedValue = new __coral_xyz_anchor.BN(decimalValue.round().toFixed()).toArray();
|
|
970
|
+
if (wrappedValue.length < I80F48_TOTAL_BYTES) {
|
|
971
|
+
const padding = Array(I80F48_TOTAL_BYTES - wrappedValue.length).fill(0);
|
|
972
|
+
wrappedValue.unshift(...padding);
|
|
973
|
+
}
|
|
974
|
+
if (isNegative) {
|
|
975
|
+
wrappedValue[wrappedValue.length - 1] |= 128;
|
|
976
|
+
wrappedValue = wrappedValue.map((v) => ~v & 255);
|
|
977
|
+
}
|
|
978
|
+
wrappedValue.reverse();
|
|
979
|
+
return { value: wrappedValue };
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* 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).
|
|
983
|
+
*/
|
|
984
|
+
function toNumber(amount) {
|
|
985
|
+
let amt;
|
|
986
|
+
if (typeof amount === "number") {
|
|
987
|
+
amt = amount;
|
|
988
|
+
} else if (typeof amount === "string") {
|
|
989
|
+
amt = Number(amount);
|
|
990
|
+
} else {
|
|
991
|
+
amt = amount.toNumber();
|
|
992
|
+
}
|
|
993
|
+
return amt;
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* 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).
|
|
997
|
+
*/
|
|
998
|
+
function toBigNumber(amount) {
|
|
999
|
+
let amt;
|
|
1000
|
+
if (amount instanceof bignumber_js.default) {
|
|
1001
|
+
amt = amount;
|
|
1002
|
+
} else {
|
|
1003
|
+
amt = new bignumber_js.default(amount.toString());
|
|
1004
|
+
}
|
|
1005
|
+
return amt;
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* 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).
|
|
1009
|
+
*/
|
|
1010
|
+
function uiToNative(amount, decimals) {
|
|
1011
|
+
const amt = toBigNumber(amount);
|
|
1012
|
+
return new __coral_xyz_anchor.BN(amt.times(10 ** decimals).toFixed(0, bignumber_js.default.ROUND_FLOOR));
|
|
1013
|
+
}
|
|
1014
|
+
function uiToNativeBigNumber(amount, decimals) {
|
|
1015
|
+
const amt = toBigNumber(amount);
|
|
1016
|
+
return amt.times(10 ** decimals);
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Converts a native representation of a token amount into its UI value as `number`, given the specified mint decimal amount.
|
|
1020
|
+
*/
|
|
1021
|
+
function nativeToUi(amount, decimals) {
|
|
1022
|
+
const amt = toBigNumber(amount);
|
|
1023
|
+
return amt.div(10 ** decimals).toNumber();
|
|
1024
|
+
}
|
|
1025
|
+
function shortenAddress(pubkey, chars = 4) {
|
|
1026
|
+
const pubkeyStr = pubkey.toString();
|
|
1027
|
+
return `${pubkeyStr.slice(0, chars)}...${pubkeyStr.slice(-chars)}`;
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Converts basis points (bps) to a decimal percentage value.
|
|
1031
|
+
*/
|
|
1032
|
+
function bpsToPercentile(bps) {
|
|
1033
|
+
return bps / 1e4;
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Prepares transaction remaining accounts by processing bank-oracle groups:
|
|
1037
|
+
* 1. Sorts groups in descending order by bank public key (pushes inactive accounts to end)
|
|
1038
|
+
* 2. Flattens the structure into a single public key array
|
|
1039
|
+
*
|
|
1040
|
+
* Stable on most JS implementations (this shouldn't matter since we do not generally have duplicate
|
|
1041
|
+
* banks), in place, and uses the raw 32-byte value to sort in byte-wise lexicographical order (like
|
|
1042
|
+
* Rust's b.key.cmp(&a.key))
|
|
1043
|
+
*
|
|
1044
|
+
* @param banksAndOracles - Array where each element is a bank-oracle group: [bankPubkey,
|
|
1045
|
+
* oracle1Pubkey, oracle2Pubkey?, ...] Note: SystemProgram keys (111..111)
|
|
1046
|
+
* represent inactive accounts
|
|
1047
|
+
* @returns Flattened array of public keys with inactive accounts at the end, ready for transaction
|
|
1048
|
+
* composition
|
|
1049
|
+
*/
|
|
1050
|
+
const composeRemainingAccounts = (banksAndOracles) => {
|
|
1051
|
+
banksAndOracles.sort((a, b) => {
|
|
1052
|
+
const A = a[0].toBytes();
|
|
1053
|
+
const B = b[0].toBytes();
|
|
1054
|
+
for (let i = 0; i < 32; i++) {
|
|
1055
|
+
if (A[i] !== B[i]) {
|
|
1056
|
+
return B[i] - A[i];
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
return 0;
|
|
1060
|
+
});
|
|
1061
|
+
return banksAndOracles.flat();
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
//#endregion
|
|
1065
|
+
//#region src/common/utils/formatters.utils.ts
|
|
1066
|
+
var CustomNumberFormat = class extends Intl.NumberFormat {
|
|
1067
|
+
constructor(locale, options) {
|
|
1068
|
+
super(locale, options);
|
|
1069
|
+
}
|
|
1070
|
+
format(value) {
|
|
1071
|
+
if (value === 0) {
|
|
1072
|
+
return "-";
|
|
1073
|
+
} else {
|
|
1074
|
+
return super.format(value);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
1078
|
+
const groupedNumberFormatter = new CustomNumberFormat("en-US", {
|
|
1079
|
+
useGrouping: true,
|
|
1080
|
+
minimumFractionDigits: 0,
|
|
1081
|
+
maximumFractionDigits: 2
|
|
1082
|
+
});
|
|
1083
|
+
const numeralFormatter = (value) => {
|
|
1084
|
+
if (value < .01) {
|
|
1085
|
+
return "0";
|
|
1086
|
+
} else {
|
|
1087
|
+
return (0, numeral.default)(value).format("0.00a");
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
const dynamicNumeralFormatter = (value, options = {}) => {
|
|
1091
|
+
const { minDisplay = 1e-5, maxDisplay = 1e4, tokenPrice, logging = false, ignoreMinDisplay = false, forceDecimals } = options;
|
|
1092
|
+
if (value === 0 || isNaN(value)) return "0";
|
|
1093
|
+
const absValue = Math.abs(value);
|
|
1094
|
+
if (logging) {
|
|
1095
|
+
console.log({
|
|
1096
|
+
value,
|
|
1097
|
+
minDisplay,
|
|
1098
|
+
maxDisplay,
|
|
1099
|
+
tokenPrice,
|
|
1100
|
+
ignoreMinDisplay,
|
|
1101
|
+
absValue
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
if (!ignoreMinDisplay && absValue < minDisplay) {
|
|
1105
|
+
return `<${minDisplay}`;
|
|
1106
|
+
}
|
|
1107
|
+
if (absValue > maxDisplay) {
|
|
1108
|
+
return (0, numeral.default)(value).format(forceDecimals ? "0,0.00a" : "0,0.[00]a");
|
|
1109
|
+
}
|
|
1110
|
+
if (!ignoreMinDisplay && Math.abs(value) >= .01) {
|
|
1111
|
+
return (0, numeral.default)(value).format(forceDecimals && Math.abs(value) > .99 ? "0,0.00a" : "0,0.[0000]a");
|
|
1112
|
+
}
|
|
1113
|
+
if (ignoreMinDisplay) {
|
|
1114
|
+
const decimalPart = absValue - Math.floor(absValue);
|
|
1115
|
+
const decimalPlaces = decimalPart > 0 ? 3 : 0;
|
|
1116
|
+
if (absValue >= 1) {
|
|
1117
|
+
return value.toFixed(decimalPlaces).replace(/\.?0+$/, "");
|
|
1118
|
+
} else {
|
|
1119
|
+
const exponent = Math.floor(Math.log10(absValue));
|
|
1120
|
+
const significantDecimals = Math.max(3, 2 - exponent);
|
|
1121
|
+
return value.toFixed(significantDecimals).replace(/\.?0+$/, "");
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
if (Math.abs(value) >= minDisplay) {
|
|
1125
|
+
const decimalPlaces = Math.max(0, Math.ceil(-Math.log10(minDisplay)));
|
|
1126
|
+
return (0, numeral.default)(value).format(`0,0.[${"0".repeat(decimalPlaces)}]`);
|
|
1127
|
+
}
|
|
1128
|
+
if (tokenPrice) {
|
|
1129
|
+
const smallestUnit = minDisplay / tokenPrice;
|
|
1130
|
+
const significantDecimals = Math.max(3, Math.ceil(-Math.log10(smallestUnit)));
|
|
1131
|
+
return value.toFixed(significantDecimals).replace(/\.?0+$/, "");
|
|
1132
|
+
}
|
|
1133
|
+
return "0";
|
|
1134
|
+
};
|
|
1135
|
+
const groupedNumberFormatterDyn = new Intl.NumberFormat("en-US", {
|
|
1136
|
+
useGrouping: true,
|
|
1137
|
+
minimumFractionDigits: 0,
|
|
1138
|
+
maximumFractionDigits: 2
|
|
1139
|
+
});
|
|
1140
|
+
const usdFormatter = new Intl.NumberFormat("en-US", {
|
|
1141
|
+
style: "currency",
|
|
1142
|
+
currency: "USD",
|
|
1143
|
+
minimumFractionDigits: 2,
|
|
1144
|
+
maximumFractionDigits: 2,
|
|
1145
|
+
signDisplay: "auto"
|
|
1146
|
+
});
|
|
1147
|
+
const usdFormatterDyn = new Intl.NumberFormat("en-US", {
|
|
1148
|
+
style: "currency",
|
|
1149
|
+
currency: "USD",
|
|
1150
|
+
minimumFractionDigits: 0,
|
|
1151
|
+
maximumFractionDigits: 2,
|
|
1152
|
+
signDisplay: "auto"
|
|
1153
|
+
});
|
|
1154
|
+
const percentFormatter = new Intl.NumberFormat("en-US", {
|
|
1155
|
+
style: "percent",
|
|
1156
|
+
minimumFractionDigits: 2,
|
|
1157
|
+
maximumFractionDigits: 2
|
|
1158
|
+
});
|
|
1159
|
+
const percentFormatterDyn = new Intl.NumberFormat("en-US", {
|
|
1160
|
+
style: "percent",
|
|
1161
|
+
minimumFractionDigits: 0,
|
|
1162
|
+
maximumFractionDigits: 2
|
|
1163
|
+
});
|
|
1164
|
+
const percentFormatterMod = (value, opts = {
|
|
1165
|
+
minFractionDigits: 2,
|
|
1166
|
+
maxFractionDigits: 2
|
|
1167
|
+
}) => {
|
|
1168
|
+
const percentFormatter$1 = new Intl.NumberFormat("en-US", {
|
|
1169
|
+
style: "percent",
|
|
1170
|
+
minimumFractionDigits: opts.minFractionDigits,
|
|
1171
|
+
maximumFractionDigits: opts.maxFractionDigits
|
|
1172
|
+
});
|
|
1173
|
+
if (value === 0) {
|
|
1174
|
+
return "0%";
|
|
1175
|
+
} else {
|
|
1176
|
+
return percentFormatter$1.format(value);
|
|
1177
|
+
}
|
|
1178
|
+
};
|
|
1179
|
+
const clampedNumeralFormatter = (value) => {
|
|
1180
|
+
if (value === 0) {
|
|
1181
|
+
return "0";
|
|
1182
|
+
} else if (value < .01) {
|
|
1183
|
+
return "< 0.01";
|
|
1184
|
+
} else {
|
|
1185
|
+
return (0, numeral.default)(value).format("0.00a");
|
|
1186
|
+
}
|
|
1187
|
+
};
|
|
1188
|
+
const tokenPriceFormatter = (price, style = "currency") => {
|
|
1189
|
+
if (price === 0) {
|
|
1190
|
+
return 0;
|
|
1191
|
+
}
|
|
1192
|
+
const reformatNum = Number(price.toFixed(20));
|
|
1193
|
+
if (price === 0) {
|
|
1194
|
+
return 0;
|
|
1195
|
+
}
|
|
1196
|
+
if (reformatNum < 1e-8) {
|
|
1197
|
+
return price.toExponential(2);
|
|
1198
|
+
}
|
|
1199
|
+
const { minFractionDigits, maxFractionDigits } = reformatNum > 1 ? {
|
|
1200
|
+
minFractionDigits: 2,
|
|
1201
|
+
maxFractionDigits: 2
|
|
1202
|
+
} : reformatNum > 1e-6 ? {
|
|
1203
|
+
minFractionDigits: 2,
|
|
1204
|
+
maxFractionDigits: 7
|
|
1205
|
+
} : {
|
|
1206
|
+
minFractionDigits: 7,
|
|
1207
|
+
maxFractionDigits: 10
|
|
1208
|
+
};
|
|
1209
|
+
const formatter = new Intl.NumberFormat("en-US", {
|
|
1210
|
+
style,
|
|
1211
|
+
currency: "USD",
|
|
1212
|
+
minimumFractionDigits: minFractionDigits,
|
|
1213
|
+
maximumFractionDigits: maxFractionDigits,
|
|
1214
|
+
signDisplay: "auto"
|
|
1215
|
+
});
|
|
1216
|
+
return formatter.format(price);
|
|
1217
|
+
};
|
|
1218
|
+
|
|
1219
|
+
//#endregion
|
|
1220
|
+
Object.defineProperty(exports, 'BUNDLE_TX_SIZE', {
|
|
1221
|
+
enumerable: true,
|
|
1222
|
+
get: function () {
|
|
1223
|
+
return BUNDLE_TX_SIZE;
|
|
1224
|
+
}
|
|
1225
|
+
});
|
|
1226
|
+
Object.defineProperty(exports, 'CustomNumberFormat', {
|
|
1227
|
+
enumerable: true,
|
|
1228
|
+
get: function () {
|
|
1229
|
+
return CustomNumberFormat;
|
|
1230
|
+
}
|
|
1231
|
+
});
|
|
1232
|
+
Object.defineProperty(exports, 'DEFAULT_CLUSTER', {
|
|
1233
|
+
enumerable: true,
|
|
1234
|
+
get: function () {
|
|
1235
|
+
return DEFAULT_CLUSTER;
|
|
1236
|
+
}
|
|
1237
|
+
});
|
|
1238
|
+
Object.defineProperty(exports, 'DEFAULT_COMMITMENT', {
|
|
1239
|
+
enumerable: true,
|
|
1240
|
+
get: function () {
|
|
1241
|
+
return DEFAULT_COMMITMENT;
|
|
1242
|
+
}
|
|
1243
|
+
});
|
|
1244
|
+
Object.defineProperty(exports, 'DEFAULT_CONFIRM_OPTS', {
|
|
1245
|
+
enumerable: true,
|
|
1246
|
+
get: function () {
|
|
1247
|
+
return DEFAULT_CONFIRM_OPTS;
|
|
1248
|
+
}
|
|
1249
|
+
});
|
|
1250
|
+
Object.defineProperty(exports, 'DEFAULT_ORACLE_MAX_AGE', {
|
|
1251
|
+
enumerable: true,
|
|
1252
|
+
get: function () {
|
|
1253
|
+
return DEFAULT_ORACLE_MAX_AGE;
|
|
1254
|
+
}
|
|
1255
|
+
});
|
|
1256
|
+
Object.defineProperty(exports, 'DEFAULT_SEND_OPTS', {
|
|
1257
|
+
enumerable: true,
|
|
1258
|
+
get: function () {
|
|
1259
|
+
return DEFAULT_SEND_OPTS;
|
|
1260
|
+
}
|
|
1261
|
+
});
|
|
1262
|
+
Object.defineProperty(exports, 'DISABLED_FLAG', {
|
|
1263
|
+
enumerable: true,
|
|
1264
|
+
get: function () {
|
|
1265
|
+
return DISABLED_FLAG;
|
|
1266
|
+
}
|
|
1267
|
+
});
|
|
1268
|
+
Object.defineProperty(exports, 'DUMMY_USDC_MINT', {
|
|
1269
|
+
enumerable: true,
|
|
1270
|
+
get: function () {
|
|
1271
|
+
return DUMMY_USDC_MINT;
|
|
1272
|
+
}
|
|
1273
|
+
});
|
|
1274
|
+
Object.defineProperty(exports, 'FLASHLOAN_ENABLED_FLAG', {
|
|
1275
|
+
enumerable: true,
|
|
1276
|
+
get: function () {
|
|
1277
|
+
return FLASHLOAN_ENABLED_FLAG;
|
|
1278
|
+
}
|
|
1279
|
+
});
|
|
1280
|
+
Object.defineProperty(exports, 'GROUP_PK', {
|
|
1281
|
+
enumerable: true,
|
|
1282
|
+
get: function () {
|
|
1283
|
+
return GROUP_PK;
|
|
1284
|
+
}
|
|
1285
|
+
});
|
|
1286
|
+
Object.defineProperty(exports, 'HOURS_PER_YEAR', {
|
|
1287
|
+
enumerable: true,
|
|
1288
|
+
get: function () {
|
|
1289
|
+
return HOURS_PER_YEAR;
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
Object.defineProperty(exports, 'JUPITER_V6_PROGRAM', {
|
|
1293
|
+
enumerable: true,
|
|
1294
|
+
get: function () {
|
|
1295
|
+
return JUPITER_V6_PROGRAM;
|
|
1296
|
+
}
|
|
1297
|
+
});
|
|
1298
|
+
Object.defineProperty(exports, 'LENDR_PROGRAM', {
|
|
1299
|
+
enumerable: true,
|
|
1300
|
+
get: function () {
|
|
1301
|
+
return LENDR_PROGRAM;
|
|
1302
|
+
}
|
|
1303
|
+
});
|
|
1304
|
+
Object.defineProperty(exports, 'LST_MINT', {
|
|
1305
|
+
enumerable: true,
|
|
1306
|
+
get: function () {
|
|
1307
|
+
return LST_MINT;
|
|
1308
|
+
}
|
|
1309
|
+
});
|
|
1310
|
+
Object.defineProperty(exports, 'LUT_PROGRAM_AUTHORITY_INDEX', {
|
|
1311
|
+
enumerable: true,
|
|
1312
|
+
get: function () {
|
|
1313
|
+
return LUT_PROGRAM_AUTHORITY_INDEX;
|
|
1314
|
+
}
|
|
1315
|
+
});
|
|
1316
|
+
Object.defineProperty(exports, 'MAX_ACCOUNT_KEYS', {
|
|
1317
|
+
enumerable: true,
|
|
1318
|
+
get: function () {
|
|
1319
|
+
return MAX_ACCOUNT_KEYS;
|
|
1320
|
+
}
|
|
1321
|
+
});
|
|
1322
|
+
Object.defineProperty(exports, 'MAX_CONFIDENCE_INTERVAL_RATIO', {
|
|
1323
|
+
enumerable: true,
|
|
1324
|
+
get: function () {
|
|
1325
|
+
return MAX_CONFIDENCE_INTERVAL_RATIO;
|
|
1326
|
+
}
|
|
1327
|
+
});
|
|
1328
|
+
Object.defineProperty(exports, 'MAX_TX_SIZE', {
|
|
1329
|
+
enumerable: true,
|
|
1330
|
+
get: function () {
|
|
1331
|
+
return MAX_TX_SIZE;
|
|
1332
|
+
}
|
|
1333
|
+
});
|
|
1334
|
+
Object.defineProperty(exports, 'MAX_U64', {
|
|
1335
|
+
enumerable: true,
|
|
1336
|
+
get: function () {
|
|
1337
|
+
return MAX_U64;
|
|
1338
|
+
}
|
|
1339
|
+
});
|
|
1340
|
+
Object.defineProperty(exports, 'MPL_METADATA_PROGRAM_ID', {
|
|
1341
|
+
enumerable: true,
|
|
1342
|
+
get: function () {
|
|
1343
|
+
return MPL_METADATA_PROGRAM_ID;
|
|
1344
|
+
}
|
|
1345
|
+
});
|
|
1346
|
+
Object.defineProperty(exports, 'NodeWallet', {
|
|
1347
|
+
enumerable: true,
|
|
1348
|
+
get: function () {
|
|
1349
|
+
return NodeWallet;
|
|
1350
|
+
}
|
|
1351
|
+
});
|
|
1352
|
+
Object.defineProperty(exports, 'PDA_BANK_FEE_VAULT_AUTH_SEED', {
|
|
1353
|
+
enumerable: true,
|
|
1354
|
+
get: function () {
|
|
1355
|
+
return PDA_BANK_FEE_VAULT_AUTH_SEED;
|
|
1356
|
+
}
|
|
1357
|
+
});
|
|
1358
|
+
Object.defineProperty(exports, 'PDA_BANK_FEE_VAULT_SEED', {
|
|
1359
|
+
enumerable: true,
|
|
1360
|
+
get: function () {
|
|
1361
|
+
return PDA_BANK_FEE_VAULT_SEED;
|
|
1362
|
+
}
|
|
1363
|
+
});
|
|
1364
|
+
Object.defineProperty(exports, 'PDA_BANK_INSURANCE_VAULT_AUTH_SEED', {
|
|
1365
|
+
enumerable: true,
|
|
1366
|
+
get: function () {
|
|
1367
|
+
return PDA_BANK_INSURANCE_VAULT_AUTH_SEED;
|
|
1368
|
+
}
|
|
1369
|
+
});
|
|
1370
|
+
Object.defineProperty(exports, 'PDA_BANK_INSURANCE_VAULT_SEED', {
|
|
1371
|
+
enumerable: true,
|
|
1372
|
+
get: function () {
|
|
1373
|
+
return PDA_BANK_INSURANCE_VAULT_SEED;
|
|
1374
|
+
}
|
|
1375
|
+
});
|
|
1376
|
+
Object.defineProperty(exports, 'PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED', {
|
|
1377
|
+
enumerable: true,
|
|
1378
|
+
get: function () {
|
|
1379
|
+
return PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED;
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
1382
|
+
Object.defineProperty(exports, 'PDA_BANK_LIQUIDITY_VAULT_SEED', {
|
|
1383
|
+
enumerable: true,
|
|
1384
|
+
get: function () {
|
|
1385
|
+
return PDA_BANK_LIQUIDITY_VAULT_SEED;
|
|
1386
|
+
}
|
|
1387
|
+
});
|
|
1388
|
+
Object.defineProperty(exports, 'PRIORITY_TX_SIZE', {
|
|
1389
|
+
enumerable: true,
|
|
1390
|
+
get: function () {
|
|
1391
|
+
return PRIORITY_TX_SIZE;
|
|
1392
|
+
}
|
|
1393
|
+
});
|
|
1394
|
+
Object.defineProperty(exports, 'PROGRAM_ID', {
|
|
1395
|
+
enumerable: true,
|
|
1396
|
+
get: function () {
|
|
1397
|
+
return PROGRAM_ID;
|
|
1398
|
+
}
|
|
1399
|
+
});
|
|
1400
|
+
Object.defineProperty(exports, 'PYTH_PRICE_CONF_INTERVALS', {
|
|
1401
|
+
enumerable: true,
|
|
1402
|
+
get: function () {
|
|
1403
|
+
return PYTH_PRICE_CONF_INTERVALS;
|
|
1404
|
+
}
|
|
1405
|
+
});
|
|
1406
|
+
Object.defineProperty(exports, 'PYTH_PUSH_ORACLE_ID', {
|
|
1407
|
+
enumerable: true,
|
|
1408
|
+
get: function () {
|
|
1409
|
+
return PYTH_PUSH_ORACLE_ID;
|
|
1410
|
+
}
|
|
1411
|
+
});
|
|
1412
|
+
Object.defineProperty(exports, 'PriotitizationFeeLevels', {
|
|
1413
|
+
enumerable: true,
|
|
1414
|
+
get: function () {
|
|
1415
|
+
return PriotitizationFeeLevels;
|
|
1416
|
+
}
|
|
1417
|
+
});
|
|
1418
|
+
Object.defineProperty(exports, 'SINGLE_POOL_PROGRAM_ID', {
|
|
1419
|
+
enumerable: true,
|
|
1420
|
+
get: function () {
|
|
1421
|
+
return SINGLE_POOL_PROGRAM_ID;
|
|
1422
|
+
}
|
|
1423
|
+
});
|
|
1424
|
+
Object.defineProperty(exports, 'SKIP_SIMULATION', {
|
|
1425
|
+
enumerable: true,
|
|
1426
|
+
get: function () {
|
|
1427
|
+
return SKIP_SIMULATION;
|
|
1428
|
+
}
|
|
1429
|
+
});
|
|
1430
|
+
Object.defineProperty(exports, 'STAKE_CONFIG_ID', {
|
|
1431
|
+
enumerable: true,
|
|
1432
|
+
get: function () {
|
|
1433
|
+
return STAKE_CONFIG_ID;
|
|
1434
|
+
}
|
|
1435
|
+
});
|
|
1436
|
+
Object.defineProperty(exports, 'STAKE_PROGRAM_ID', {
|
|
1437
|
+
enumerable: true,
|
|
1438
|
+
get: function () {
|
|
1439
|
+
return STAKE_PROGRAM_ID;
|
|
1440
|
+
}
|
|
1441
|
+
});
|
|
1442
|
+
Object.defineProperty(exports, 'SWB_PRICE_CONF_INTERVALS', {
|
|
1443
|
+
enumerable: true,
|
|
1444
|
+
get: function () {
|
|
1445
|
+
return SWB_PRICE_CONF_INTERVALS;
|
|
1446
|
+
}
|
|
1447
|
+
});
|
|
1448
|
+
Object.defineProperty(exports, 'SYSTEM_PROGRAM_ID', {
|
|
1449
|
+
enumerable: true,
|
|
1450
|
+
get: function () {
|
|
1451
|
+
return SYSTEM_PROGRAM_ID;
|
|
1452
|
+
}
|
|
1453
|
+
});
|
|
1454
|
+
Object.defineProperty(exports, 'SYSVAR_CLOCK_ID', {
|
|
1455
|
+
enumerable: true,
|
|
1456
|
+
get: function () {
|
|
1457
|
+
return SYSVAR_CLOCK_ID;
|
|
1458
|
+
}
|
|
1459
|
+
});
|
|
1460
|
+
Object.defineProperty(exports, 'SYSVAR_RENT_ID', {
|
|
1461
|
+
enumerable: true,
|
|
1462
|
+
get: function () {
|
|
1463
|
+
return SYSVAR_RENT_ID;
|
|
1464
|
+
}
|
|
1465
|
+
});
|
|
1466
|
+
Object.defineProperty(exports, 'SYSVAR_STAKE_HISTORY_ID', {
|
|
1467
|
+
enumerable: true,
|
|
1468
|
+
get: function () {
|
|
1469
|
+
return SYSVAR_STAKE_HISTORY_ID;
|
|
1470
|
+
}
|
|
1471
|
+
});
|
|
1472
|
+
Object.defineProperty(exports, 'TRANSFER_ACCOUNT_AUTHORITY_FLAG', {
|
|
1473
|
+
enumerable: true,
|
|
1474
|
+
get: function () {
|
|
1475
|
+
return TRANSFER_ACCOUNT_AUTHORITY_FLAG;
|
|
1476
|
+
}
|
|
1477
|
+
});
|
|
1478
|
+
Object.defineProperty(exports, 'TransactionArenaKeyMap', {
|
|
1479
|
+
enumerable: true,
|
|
1480
|
+
get: function () {
|
|
1481
|
+
return TransactionArenaKeyMap;
|
|
1482
|
+
}
|
|
1483
|
+
});
|
|
1484
|
+
Object.defineProperty(exports, 'TransactionConfigMap', {
|
|
1485
|
+
enumerable: true,
|
|
1486
|
+
get: function () {
|
|
1487
|
+
return TransactionConfigMap;
|
|
1488
|
+
}
|
|
1489
|
+
});
|
|
1490
|
+
Object.defineProperty(exports, 'TransactionType', {
|
|
1491
|
+
enumerable: true,
|
|
1492
|
+
get: function () {
|
|
1493
|
+
return TransactionType;
|
|
1494
|
+
}
|
|
1495
|
+
});
|
|
1496
|
+
Object.defineProperty(exports, 'USDC_DECIMALS', {
|
|
1497
|
+
enumerable: true,
|
|
1498
|
+
get: function () {
|
|
1499
|
+
return USDC_DECIMALS;
|
|
1500
|
+
}
|
|
1501
|
+
});
|
|
1502
|
+
Object.defineProperty(exports, 'USDC_MINT', {
|
|
1503
|
+
enumerable: true,
|
|
1504
|
+
get: function () {
|
|
1505
|
+
return USDC_MINT;
|
|
1506
|
+
}
|
|
1507
|
+
});
|
|
1508
|
+
Object.defineProperty(exports, 'WSOL_EXTENDED_METADATA', {
|
|
1509
|
+
enumerable: true,
|
|
1510
|
+
get: function () {
|
|
1511
|
+
return WSOL_EXTENDED_METADATA;
|
|
1512
|
+
}
|
|
1513
|
+
});
|
|
1514
|
+
Object.defineProperty(exports, 'WSOL_MINT', {
|
|
1515
|
+
enumerable: true,
|
|
1516
|
+
get: function () {
|
|
1517
|
+
return WSOL_MINT;
|
|
1518
|
+
}
|
|
1519
|
+
});
|
|
1520
|
+
Object.defineProperty(exports, '__export', {
|
|
1521
|
+
enumerable: true,
|
|
1522
|
+
get: function () {
|
|
1523
|
+
return __export;
|
|
1524
|
+
}
|
|
1525
|
+
});
|
|
1526
|
+
Object.defineProperty(exports, '__toESM', {
|
|
1527
|
+
enumerable: true,
|
|
1528
|
+
get: function () {
|
|
1529
|
+
return __toESM;
|
|
1530
|
+
}
|
|
1531
|
+
});
|
|
1532
|
+
Object.defineProperty(exports, 'addTransactionMetadata', {
|
|
1533
|
+
enumerable: true,
|
|
1534
|
+
get: function () {
|
|
1535
|
+
return addTransactionMetadata;
|
|
1536
|
+
}
|
|
1537
|
+
});
|
|
1538
|
+
Object.defineProperty(exports, 'aprToApy', {
|
|
1539
|
+
enumerable: true,
|
|
1540
|
+
get: function () {
|
|
1541
|
+
return aprToApy;
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
Object.defineProperty(exports, 'apyToApr', {
|
|
1545
|
+
enumerable: true,
|
|
1546
|
+
get: function () {
|
|
1547
|
+
return apyToApr;
|
|
1548
|
+
}
|
|
1549
|
+
});
|
|
1550
|
+
Object.defineProperty(exports, 'bankExtendedMetadataOverrideSchema', {
|
|
1551
|
+
enumerable: true,
|
|
1552
|
+
get: function () {
|
|
1553
|
+
return bankExtendedMetadataOverrideSchema;
|
|
1554
|
+
}
|
|
1555
|
+
});
|
|
1556
|
+
Object.defineProperty(exports, 'bigNumberToWrappedI80F48', {
|
|
1557
|
+
enumerable: true,
|
|
1558
|
+
get: function () {
|
|
1559
|
+
return bigNumberToWrappedI80F48;
|
|
1560
|
+
}
|
|
1561
|
+
});
|
|
1562
|
+
Object.defineProperty(exports, 'bpsToPercentile', {
|
|
1563
|
+
enumerable: true,
|
|
1564
|
+
get: function () {
|
|
1565
|
+
return bpsToPercentile;
|
|
1566
|
+
}
|
|
1567
|
+
});
|
|
1568
|
+
Object.defineProperty(exports, 'calculateApyFromInterest', {
|
|
1569
|
+
enumerable: true,
|
|
1570
|
+
get: function () {
|
|
1571
|
+
return calculateApyFromInterest;
|
|
1572
|
+
}
|
|
1573
|
+
});
|
|
1574
|
+
Object.defineProperty(exports, 'calculateInterestFromApy', {
|
|
1575
|
+
enumerable: true,
|
|
1576
|
+
get: function () {
|
|
1577
|
+
return calculateInterestFromApy;
|
|
1578
|
+
}
|
|
1579
|
+
});
|
|
1580
|
+
Object.defineProperty(exports, 'ceil', {
|
|
1581
|
+
enumerable: true,
|
|
1582
|
+
get: function () {
|
|
1583
|
+
return ceil;
|
|
1584
|
+
}
|
|
1585
|
+
});
|
|
1586
|
+
Object.defineProperty(exports, 'chunkedGetRawMultipleAccountInfoOrdered', {
|
|
1587
|
+
enumerable: true,
|
|
1588
|
+
get: function () {
|
|
1589
|
+
return chunkedGetRawMultipleAccountInfoOrdered;
|
|
1590
|
+
}
|
|
1591
|
+
});
|
|
1592
|
+
Object.defineProperty(exports, 'chunkedGetRawMultipleAccountInfoOrderedWithNulls', {
|
|
1593
|
+
enumerable: true,
|
|
1594
|
+
get: function () {
|
|
1595
|
+
return chunkedGetRawMultipleAccountInfoOrderedWithNulls;
|
|
1596
|
+
}
|
|
1597
|
+
});
|
|
1598
|
+
Object.defineProperty(exports, 'chunkedGetRawMultipleAccountInfos', {
|
|
1599
|
+
enumerable: true,
|
|
1600
|
+
get: function () {
|
|
1601
|
+
return chunkedGetRawMultipleAccountInfos;
|
|
1602
|
+
}
|
|
1603
|
+
});
|
|
1604
|
+
Object.defineProperty(exports, 'chunks', {
|
|
1605
|
+
enumerable: true,
|
|
1606
|
+
get: function () {
|
|
1607
|
+
return chunks;
|
|
1608
|
+
}
|
|
1609
|
+
});
|
|
1610
|
+
Object.defineProperty(exports, 'clampedNumeralFormatter', {
|
|
1611
|
+
enumerable: true,
|
|
1612
|
+
get: function () {
|
|
1613
|
+
return clampedNumeralFormatter;
|
|
1614
|
+
}
|
|
1615
|
+
});
|
|
1616
|
+
Object.defineProperty(exports, 'compareInstructions', {
|
|
1617
|
+
enumerable: true,
|
|
1618
|
+
get: function () {
|
|
1619
|
+
return compareInstructions;
|
|
1620
|
+
}
|
|
1621
|
+
});
|
|
1622
|
+
Object.defineProperty(exports, 'composeRemainingAccounts', {
|
|
1623
|
+
enumerable: true,
|
|
1624
|
+
get: function () {
|
|
1625
|
+
return composeRemainingAccounts;
|
|
1626
|
+
}
|
|
1627
|
+
});
|
|
1628
|
+
Object.defineProperty(exports, 'decodeComputeBudgetInstruction', {
|
|
1629
|
+
enumerable: true,
|
|
1630
|
+
get: function () {
|
|
1631
|
+
return decodeComputeBudgetInstruction;
|
|
1632
|
+
}
|
|
1633
|
+
});
|
|
1634
|
+
Object.defineProperty(exports, 'decodeInstruction', {
|
|
1635
|
+
enumerable: true,
|
|
1636
|
+
get: function () {
|
|
1637
|
+
return decodeInstruction;
|
|
1638
|
+
}
|
|
1639
|
+
});
|
|
1640
|
+
Object.defineProperty(exports, 'decompileV0Transaction', {
|
|
1641
|
+
enumerable: true,
|
|
1642
|
+
get: function () {
|
|
1643
|
+
return decompileV0Transaction;
|
|
1644
|
+
}
|
|
1645
|
+
});
|
|
1646
|
+
Object.defineProperty(exports, 'dynamicNumeralFormatter', {
|
|
1647
|
+
enumerable: true,
|
|
1648
|
+
get: function () {
|
|
1649
|
+
return dynamicNumeralFormatter;
|
|
1650
|
+
}
|
|
1651
|
+
});
|
|
1652
|
+
Object.defineProperty(exports, 'fetchBanksExtendedMetadata', {
|
|
1653
|
+
enumerable: true,
|
|
1654
|
+
get: function () {
|
|
1655
|
+
return fetchBanksExtendedMetadata;
|
|
1656
|
+
}
|
|
1657
|
+
});
|
|
1658
|
+
Object.defineProperty(exports, 'floor', {
|
|
1659
|
+
enumerable: true,
|
|
1660
|
+
get: function () {
|
|
1661
|
+
return floor;
|
|
1662
|
+
}
|
|
1663
|
+
});
|
|
1664
|
+
Object.defineProperty(exports, 'getAccountKeys', {
|
|
1665
|
+
enumerable: true,
|
|
1666
|
+
get: function () {
|
|
1667
|
+
return getAccountKeys;
|
|
1668
|
+
}
|
|
1669
|
+
});
|
|
1670
|
+
Object.defineProperty(exports, 'getCalculatedPrioritizationFeeByPercentile', {
|
|
1671
|
+
enumerable: true,
|
|
1672
|
+
get: function () {
|
|
1673
|
+
return getCalculatedPrioritizationFeeByPercentile;
|
|
1674
|
+
}
|
|
1675
|
+
});
|
|
1676
|
+
Object.defineProperty(exports, 'getComputeBudgetUnits', {
|
|
1677
|
+
enumerable: true,
|
|
1678
|
+
get: function () {
|
|
1679
|
+
return getComputeBudgetUnits;
|
|
1680
|
+
}
|
|
1681
|
+
});
|
|
1682
|
+
Object.defineProperty(exports, 'getMaxPrioritizationFeeByPercentile', {
|
|
1683
|
+
enumerable: true,
|
|
1684
|
+
get: function () {
|
|
1685
|
+
return getMaxPrioritizationFeeByPercentile;
|
|
1686
|
+
}
|
|
1687
|
+
});
|
|
1688
|
+
Object.defineProperty(exports, 'getMeanPrioritizationFeeByPercentile', {
|
|
1689
|
+
enumerable: true,
|
|
1690
|
+
get: function () {
|
|
1691
|
+
return getMeanPrioritizationFeeByPercentile;
|
|
1692
|
+
}
|
|
1693
|
+
});
|
|
1694
|
+
Object.defineProperty(exports, 'getMedianPrioritizationFeeByPercentile', {
|
|
1695
|
+
enumerable: true,
|
|
1696
|
+
get: function () {
|
|
1697
|
+
return getMedianPrioritizationFeeByPercentile;
|
|
1698
|
+
}
|
|
1699
|
+
});
|
|
1700
|
+
Object.defineProperty(exports, 'getMinPrioritizationFeeByPercentile', {
|
|
1701
|
+
enumerable: true,
|
|
1702
|
+
get: function () {
|
|
1703
|
+
return getMinPrioritizationFeeByPercentile;
|
|
1704
|
+
}
|
|
1705
|
+
});
|
|
1706
|
+
Object.defineProperty(exports, 'getRecentPrioritizationFeesByPercentile', {
|
|
1707
|
+
enumerable: true,
|
|
1708
|
+
get: function () {
|
|
1709
|
+
return getRecentPrioritizationFeesByPercentile;
|
|
1710
|
+
}
|
|
1711
|
+
});
|
|
1712
|
+
Object.defineProperty(exports, 'getTxSize', {
|
|
1713
|
+
enumerable: true,
|
|
1714
|
+
get: function () {
|
|
1715
|
+
return getTxSize;
|
|
1716
|
+
}
|
|
1717
|
+
});
|
|
1718
|
+
Object.defineProperty(exports, 'getValueInsensitive', {
|
|
1719
|
+
enumerable: true,
|
|
1720
|
+
get: function () {
|
|
1721
|
+
return getValueInsensitive;
|
|
1722
|
+
}
|
|
1723
|
+
});
|
|
1724
|
+
Object.defineProperty(exports, 'groupedNumberFormatter', {
|
|
1725
|
+
enumerable: true,
|
|
1726
|
+
get: function () {
|
|
1727
|
+
return groupedNumberFormatter;
|
|
1728
|
+
}
|
|
1729
|
+
});
|
|
1730
|
+
Object.defineProperty(exports, 'groupedNumberFormatterDyn', {
|
|
1731
|
+
enumerable: true,
|
|
1732
|
+
get: function () {
|
|
1733
|
+
return groupedNumberFormatterDyn;
|
|
1734
|
+
}
|
|
1735
|
+
});
|
|
1736
|
+
Object.defineProperty(exports, 'isV0Tx', {
|
|
1737
|
+
enumerable: true,
|
|
1738
|
+
get: function () {
|
|
1739
|
+
return isV0Tx;
|
|
1740
|
+
}
|
|
1741
|
+
});
|
|
1742
|
+
Object.defineProperty(exports, 'legacyTxToV0Tx', {
|
|
1743
|
+
enumerable: true,
|
|
1744
|
+
get: function () {
|
|
1745
|
+
return legacyTxToV0Tx;
|
|
1746
|
+
}
|
|
1747
|
+
});
|
|
1748
|
+
Object.defineProperty(exports, 'median', {
|
|
1749
|
+
enumerable: true,
|
|
1750
|
+
get: function () {
|
|
1751
|
+
return median;
|
|
1752
|
+
}
|
|
1753
|
+
});
|
|
1754
|
+
Object.defineProperty(exports, 'microLamportsToUi', {
|
|
1755
|
+
enumerable: true,
|
|
1756
|
+
get: function () {
|
|
1757
|
+
return microLamportsToUi;
|
|
1758
|
+
}
|
|
1759
|
+
});
|
|
1760
|
+
Object.defineProperty(exports, 'nativeToUi', {
|
|
1761
|
+
enumerable: true,
|
|
1762
|
+
get: function () {
|
|
1763
|
+
return nativeToUi;
|
|
1764
|
+
}
|
|
1765
|
+
});
|
|
1766
|
+
Object.defineProperty(exports, 'numeralFormatter', {
|
|
1767
|
+
enumerable: true,
|
|
1768
|
+
get: function () {
|
|
1769
|
+
return numeralFormatter;
|
|
1770
|
+
}
|
|
1771
|
+
});
|
|
1772
|
+
Object.defineProperty(exports, 'parseBanksMetadataOverride', {
|
|
1773
|
+
enumerable: true,
|
|
1774
|
+
get: function () {
|
|
1775
|
+
return parseBanksMetadataOverride;
|
|
1776
|
+
}
|
|
1777
|
+
});
|
|
1778
|
+
Object.defineProperty(exports, 'percentFormatter', {
|
|
1779
|
+
enumerable: true,
|
|
1780
|
+
get: function () {
|
|
1781
|
+
return percentFormatter;
|
|
1782
|
+
}
|
|
1783
|
+
});
|
|
1784
|
+
Object.defineProperty(exports, 'percentFormatterDyn', {
|
|
1785
|
+
enumerable: true,
|
|
1786
|
+
get: function () {
|
|
1787
|
+
return percentFormatterDyn;
|
|
1788
|
+
}
|
|
1789
|
+
});
|
|
1790
|
+
Object.defineProperty(exports, 'percentFormatterMod', {
|
|
1791
|
+
enumerable: true,
|
|
1792
|
+
get: function () {
|
|
1793
|
+
return percentFormatterMod;
|
|
1794
|
+
}
|
|
1795
|
+
});
|
|
1796
|
+
Object.defineProperty(exports, 'replaceV0TxBlockhash', {
|
|
1797
|
+
enumerable: true,
|
|
1798
|
+
get: function () {
|
|
1799
|
+
return replaceV0TxBlockhash;
|
|
1800
|
+
}
|
|
1801
|
+
});
|
|
1802
|
+
Object.defineProperty(exports, 'replaceV0TxInstructions', {
|
|
1803
|
+
enumerable: true,
|
|
1804
|
+
get: function () {
|
|
1805
|
+
return replaceV0TxInstructions;
|
|
1806
|
+
}
|
|
1807
|
+
});
|
|
1808
|
+
Object.defineProperty(exports, 'setTimeoutPromise', {
|
|
1809
|
+
enumerable: true,
|
|
1810
|
+
get: function () {
|
|
1811
|
+
return setTimeoutPromise;
|
|
1812
|
+
}
|
|
1813
|
+
});
|
|
1814
|
+
Object.defineProperty(exports, 'shortenAddress', {
|
|
1815
|
+
enumerable: true,
|
|
1816
|
+
get: function () {
|
|
1817
|
+
return shortenAddress;
|
|
1818
|
+
}
|
|
1819
|
+
});
|
|
1820
|
+
Object.defineProperty(exports, 'sleep', {
|
|
1821
|
+
enumerable: true,
|
|
1822
|
+
get: function () {
|
|
1823
|
+
return sleep;
|
|
1824
|
+
}
|
|
1825
|
+
});
|
|
1826
|
+
Object.defineProperty(exports, 'splitInstructionsToFitTransactions', {
|
|
1827
|
+
enumerable: true,
|
|
1828
|
+
get: function () {
|
|
1829
|
+
return splitInstructionsToFitTransactions;
|
|
1830
|
+
}
|
|
1831
|
+
});
|
|
1832
|
+
Object.defineProperty(exports, 'toBigNumber', {
|
|
1833
|
+
enumerable: true,
|
|
1834
|
+
get: function () {
|
|
1835
|
+
return toBigNumber;
|
|
1836
|
+
}
|
|
1837
|
+
});
|
|
1838
|
+
Object.defineProperty(exports, 'toNumber', {
|
|
1839
|
+
enumerable: true,
|
|
1840
|
+
get: function () {
|
|
1841
|
+
return toNumber;
|
|
1842
|
+
}
|
|
1843
|
+
});
|
|
1844
|
+
Object.defineProperty(exports, 'tokenPriceFormatter', {
|
|
1845
|
+
enumerable: true,
|
|
1846
|
+
get: function () {
|
|
1847
|
+
return tokenPriceFormatter;
|
|
1848
|
+
}
|
|
1849
|
+
});
|
|
1850
|
+
Object.defineProperty(exports, 'uiToMicroLamports', {
|
|
1851
|
+
enumerable: true,
|
|
1852
|
+
get: function () {
|
|
1853
|
+
return uiToMicroLamports;
|
|
1854
|
+
}
|
|
1855
|
+
});
|
|
1856
|
+
Object.defineProperty(exports, 'uiToNative', {
|
|
1857
|
+
enumerable: true,
|
|
1858
|
+
get: function () {
|
|
1859
|
+
return uiToNative;
|
|
1860
|
+
}
|
|
1861
|
+
});
|
|
1862
|
+
Object.defineProperty(exports, 'uiToNativeBigNumber', {
|
|
1863
|
+
enumerable: true,
|
|
1864
|
+
get: function () {
|
|
1865
|
+
return uiToNativeBigNumber;
|
|
1866
|
+
}
|
|
1867
|
+
});
|
|
1868
|
+
Object.defineProperty(exports, 'updateV0Tx', {
|
|
1869
|
+
enumerable: true,
|
|
1870
|
+
get: function () {
|
|
1871
|
+
return updateV0Tx;
|
|
1872
|
+
}
|
|
1873
|
+
});
|
|
1874
|
+
Object.defineProperty(exports, 'usdFormatter', {
|
|
1875
|
+
enumerable: true,
|
|
1876
|
+
get: function () {
|
|
1877
|
+
return usdFormatter;
|
|
1878
|
+
}
|
|
1879
|
+
});
|
|
1880
|
+
Object.defineProperty(exports, 'usdFormatterDyn', {
|
|
1881
|
+
enumerable: true,
|
|
1882
|
+
get: function () {
|
|
1883
|
+
return usdFormatterDyn;
|
|
1884
|
+
}
|
|
1885
|
+
});
|
|
1886
|
+
Object.defineProperty(exports, 'wrappedI80F48toBigNumber', {
|
|
1887
|
+
enumerable: true,
|
|
1888
|
+
get: function () {
|
|
1889
|
+
return wrappedI80F48toBigNumber;
|
|
1890
|
+
}
|
|
1891
|
+
});
|