@pyron-finance/pyron-client 2.1.0 → 2.2.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/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { __export } from "./chunk-Cl8Af3a2.js";
2
- import { BUNDLE_TX_SIZE, DEFAULT_CLUSTER, DEFAULT_COMMITMENT, DEFAULT_CONFIRM_OPTS, DEFAULT_ORACLE_MAX_AGE, DEFAULT_SEND_OPTS, DISABLED_FLAG, DUMMY_USDC_MINT, FLASHLOAN_ENABLED_FLAG, GROUP_PK, HOURS_PER_YEAR, JUPITER_V6_PROGRAM, LENDR_PROGRAM, LST_MINT, LUT_PROGRAM_AUTHORITY_INDEX, MAX_ACCOUNT_KEYS, MAX_CONFIDENCE_INTERVAL_RATIO, MAX_TX_SIZE, MAX_U64, MPL_METADATA_PROGRAM_ID, PDA_BANK_FEE_VAULT_AUTH_SEED, PDA_BANK_FEE_VAULT_SEED, PDA_BANK_INSURANCE_VAULT_AUTH_SEED, PDA_BANK_INSURANCE_VAULT_SEED, PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED, PDA_BANK_LIQUIDITY_VAULT_SEED, PRIORITY_TX_SIZE, PROGRAM_ID, PYTH_PRICE_CONF_INTERVALS, PYTH_PUSH_ORACLE_ID, SINGLE_POOL_PROGRAM_ID, SKIP_SIMULATION, STAKE_CONFIG_ID, STAKE_PROGRAM_ID, SWB_PRICE_CONF_INTERVALS, SYSTEM_PROGRAM_ID, SYSVAR_CLOCK_ID, SYSVAR_RENT_ID, SYSVAR_STAKE_HISTORY_ID, TRANSFER_ACCOUNT_AUTHORITY_FLAG, TransactionArenaKeyMap, TransactionType, USDC_DECIMALS, USDC_MINT, WSOL_EXTENDED_METADATA, WSOL_MINT, addTransactionMetadata, aprToApy, bigNumberToWrappedI80F48, chunkedGetRawMultipleAccountInfoOrdered, chunkedGetRawMultipleAccountInfoOrderedWithNulls, composeRemainingAccounts, decodeInstruction, decompileV0Transaction, fetchBanksExtendedMetadata, getAccountKeys, getComputeBudgetUnits, getTxSize, isV0Tx, legacyTxToV0Tx, microLamportsToUi, nativeToUi, setTimeoutPromise, shortenAddress, sleep, splitInstructionsToFitTransactions, toBigNumber, uiToMicroLamports, uiToNative, updateV0Tx, wrappedI80F48toBigNumber } from "./common-ivGgLPrv.js";
1
+ import { __esm, __export, __toCommonJS } from "./chunk-BaU5PcSi.js";
2
+ import { BUNDLE_TX_SIZE, DEFAULT_CLUSTER, DEFAULT_COMMITMENT, DEFAULT_CONFIRM_OPTS, DEFAULT_ORACLE_MAX_AGE, DEFAULT_SEND_OPTS, DISABLED_FLAG, DUMMY_USDC_MINT, FLASHLOAN_ENABLED_FLAG, GROUP_PK, HOURS_PER_YEAR, JUPITER_V6_PROGRAM, LENDR_PROGRAM, LST_MINT, LUT_PROGRAM_AUTHORITY_INDEX, MAX_ACCOUNT_KEYS, MAX_CONFIDENCE_INTERVAL_RATIO, MAX_TX_SIZE, MAX_U64, MPL_METADATA_PROGRAM_ID, PDA_BANK_FEE_VAULT_AUTH_SEED, PDA_BANK_FEE_VAULT_SEED, PDA_BANK_INSURANCE_VAULT_AUTH_SEED, PDA_BANK_INSURANCE_VAULT_SEED, PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED, PDA_BANK_LIQUIDITY_VAULT_SEED, PRIORITY_TX_SIZE, PROGRAM_ID, PYTH_PRICE_CONF_INTERVALS, PYTH_PUSH_ORACLE_ID, SINGLE_POOL_PROGRAM_ID, SKIP_SIMULATION, STAKE_CONFIG_ID, STAKE_PROGRAM_ID, SWB_PRICE_CONF_INTERVALS, SYSTEM_PROGRAM_ID, SYSVAR_CLOCK_ID, SYSVAR_RENT_ID, SYSVAR_STAKE_HISTORY_ID, TRANSFER_ACCOUNT_AUTHORITY_FLAG, TransactionArenaKeyMap, TransactionType, USDC_DECIMALS, USDC_MINT, WSOL_EXTENDED_METADATA, WSOL_MINT, addTransactionMetadata, aprToApy, bigNumberToWrappedI80F48, chunkedGetRawMultipleAccountInfoOrdered, chunkedGetRawMultipleAccountInfoOrderedWithNulls, composeRemainingAccounts, decodeInstruction, decompileV0Transaction, fetchBanksExtendedMetadata, getAccountKeys, getComputeBudgetUnits, getTxSize, init_constants, isV0Tx, legacyTxToV0Tx, microLamportsToUi, nativeToUi, setTimeoutPromise, shortenAddress, sleep, splitInstructionsToFitTransactions, toBigNumber, uiToMicroLamports, uiToNative, updateV0Tx, wrappedI80F48toBigNumber } from "./common-BDgJX75H.js";
3
3
  import * as anchor from "@coral-xyz/anchor";
4
4
  import { AnchorProvider, BorshAccountsCoder, BorshCoder, BorshInstructionCoder, LangErrorMessage, Program, translateAddress } from "@coral-xyz/anchor";
5
5
  import { MintLayout, NATIVE_MINT, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, createApproveInstruction, createAssociatedTokenAccountIdempotentInstruction, createAssociatedTokenAccountInstruction, createCloseAccountInstruction, createSyncNativeInstruction, getAssociatedTokenAddressSync } from "@solana/spl-token";
@@ -232,6 +232,7 @@ var FogoMetadataFetcher = class {
232
232
 
233
233
  //#endregion
234
234
  //#region src/config.ts
235
+ init_constants();
235
236
  function getConfig({ environment = "production", overrides } = {}) {
236
237
  return {
237
238
  environment,
@@ -9883,6 +9884,7 @@ const LENDR_IDL = lendr_0_1_6_default;
9883
9884
 
9884
9885
  //#endregion
9885
9886
  //#region src/errors.ts
9887
+ init_constants();
9886
9888
  let ProcessTransactionErrorType = /* @__PURE__ */ function(ProcessTransactionErrorType$1) {
9887
9889
  ProcessTransactionErrorType$1[ProcessTransactionErrorType$1["TransactionBuildingError"] = 0] = "TransactionBuildingError";
9888
9890
  ProcessTransactionErrorType$1[ProcessTransactionErrorType$1["TransactionSendingError"] = 1] = "TransactionSendingError";
@@ -10488,6 +10490,7 @@ let AccountType = /* @__PURE__ */ function(AccountType$2) {
10488
10490
 
10489
10491
  //#endregion
10490
10492
  //#region src/services/bank/utils/deserialize.utils.ts
10493
+ init_constants();
10491
10494
  function decodeBankRaw(encoded, idl) {
10492
10495
  const coder = new BorshCoder(idl);
10493
10496
  return coder.accounts.decode(AccountType.Bank, encoded);
@@ -11153,554 +11156,576 @@ const getStakeAccount = (data) => {
11153
11156
 
11154
11157
  //#endregion
11155
11158
  //#region src/vendor/single-spl-pool/index.ts
11156
- var SinglePoolInstructionType = /* @__PURE__ */ function(SinglePoolInstructionType$1) {
11157
- SinglePoolInstructionType$1[SinglePoolInstructionType$1["InitializePool"] = 0] = "InitializePool";
11158
- SinglePoolInstructionType$1[SinglePoolInstructionType$1["ReplenishPool"] = 1] = "ReplenishPool";
11159
- SinglePoolInstructionType$1[SinglePoolInstructionType$1["DepositStake"] = 2] = "DepositStake";
11160
- SinglePoolInstructionType$1[SinglePoolInstructionType$1["WithdrawStake"] = 3] = "WithdrawStake";
11161
- SinglePoolInstructionType$1[SinglePoolInstructionType$1["CreateTokenMetadata"] = 4] = "CreateTokenMetadata";
11162
- SinglePoolInstructionType$1[SinglePoolInstructionType$1["UpdateTokenMetadata"] = 5] = "UpdateTokenMetadata";
11163
- SinglePoolInstructionType$1[SinglePoolInstructionType$1["InitializeOnRamp"] = 6] = "InitializeOnRamp";
11164
- return SinglePoolInstructionType$1;
11165
- }(SinglePoolInstructionType || {});
11166
- const SinglePoolInstruction = {
11167
- initializePool: (voteAccount) => {
11168
- const pool = findPoolAddress(voteAccount);
11169
- const stake = findPoolStakeAddress(pool);
11170
- const mint = findPoolMintAddress(pool);
11171
- const stakeAuthority = findPoolStakeAuthorityAddress(pool);
11172
- const mintAuthority = findPoolMintAuthorityAddress(pool);
11173
- return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
11174
- {
11175
- pubkey: voteAccount,
11176
- isSigner: false,
11177
- isWritable: false
11178
- },
11179
- {
11180
- pubkey: pool,
11181
- isSigner: false,
11182
- isWritable: true
11183
- },
11184
- {
11185
- pubkey: stake,
11186
- isSigner: false,
11187
- isWritable: true
11188
- },
11189
- {
11190
- pubkey: mint,
11191
- isSigner: false,
11192
- isWritable: true
11193
- },
11194
- {
11195
- pubkey: stakeAuthority,
11196
- isSigner: false,
11197
- isWritable: false
11198
- },
11199
- {
11200
- pubkey: mintAuthority,
11201
- isSigner: false,
11202
- isWritable: false
11203
- },
11204
- {
11205
- pubkey: SYSVAR_RENT_ID,
11206
- isSigner: false,
11207
- isWritable: false
11208
- },
11209
- {
11210
- pubkey: SYSVAR_CLOCK_ID,
11211
- isSigner: false,
11212
- isWritable: false
11213
- },
11214
- {
11215
- pubkey: SYSVAR_STAKE_HISTORY_ID,
11216
- isSigner: false,
11217
- isWritable: false
11218
- },
11219
- {
11220
- pubkey: STAKE_CONFIG_ID$1,
11221
- isSigner: false,
11222
- isWritable: false
11223
- },
11224
- {
11225
- pubkey: SYSTEM_PROGRAM_ID,
11226
- isSigner: false,
11227
- isWritable: false
11228
- },
11229
- {
11230
- pubkey: TOKEN_PROGRAM_ID,
11231
- isSigner: false,
11232
- isWritable: false
11233
- },
11234
- {
11235
- pubkey: STAKE_PROGRAM_ID,
11236
- isSigner: false,
11237
- isWritable: false
11238
- }
11239
- ], Buffer.from([SinglePoolInstructionType.InitializePool]));
11240
- },
11241
- initializeOnRamp: (pool) => {
11242
- const onRamp = findPoolOnRampAddress(pool);
11243
- const stakeAuthority = findPoolStakeAuthorityAddress(pool);
11244
- return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
11245
- {
11246
- pubkey: pool,
11247
- isSigner: false,
11248
- isWritable: false
11249
- },
11250
- {
11251
- pubkey: onRamp,
11252
- isSigner: false,
11253
- isWritable: true
11254
- },
11255
- {
11256
- pubkey: stakeAuthority,
11257
- isSigner: false,
11258
- isWritable: false
11259
- },
11260
- {
11261
- pubkey: SYSVAR_RENT_ID,
11262
- isSigner: false,
11263
- isWritable: false
11264
- },
11265
- {
11266
- pubkey: SYSTEM_PROGRAM_ID,
11267
- isSigner: false,
11268
- isWritable: false
11269
- },
11270
- {
11271
- pubkey: STAKE_PROGRAM_ID,
11272
- isSigner: false,
11273
- isWritable: false
11274
- }
11275
- ], Buffer.from([SinglePoolInstructionType.InitializeOnRamp]));
11276
- },
11277
- depositStake: async (pool, userStakeAccount, userTokenAccount, userLamportAccount) => {
11278
- const stake = findPoolStakeAddress(pool);
11279
- const mint = findPoolMintAddress(pool);
11280
- const stakeAuthority = findPoolStakeAuthorityAddress(pool);
11281
- const mintAuthority = findPoolMintAuthorityAddress(pool);
11282
- return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
11283
- {
11284
- pubkey: pool,
11285
- isSigner: false,
11286
- isWritable: false
11287
- },
11288
- {
11289
- pubkey: stake,
11290
- isSigner: false,
11291
- isWritable: true
11292
- },
11293
- {
11294
- pubkey: mint,
11295
- isSigner: false,
11296
- isWritable: true
11297
- },
11298
- {
11299
- pubkey: stakeAuthority,
11300
- isSigner: false,
11301
- isWritable: false
11302
- },
11303
- {
11304
- pubkey: mintAuthority,
11305
- isSigner: false,
11306
- isWritable: false
11307
- },
11308
- {
11309
- pubkey: userStakeAccount,
11310
- isSigner: false,
11311
- isWritable: true
11312
- },
11313
- {
11314
- pubkey: userTokenAccount,
11315
- isSigner: false,
11316
- isWritable: true
11317
- },
11318
- {
11319
- pubkey: userLamportAccount,
11320
- isSigner: false,
11321
- isWritable: true
11322
- },
11323
- {
11324
- pubkey: SYSVAR_CLOCK_ID,
11325
- isSigner: false,
11326
- isWritable: false
11327
- },
11328
- {
11329
- pubkey: SYSVAR_STAKE_HISTORY_ID,
11330
- isSigner: false,
11331
- isWritable: false
11332
- },
11333
- {
11334
- pubkey: TOKEN_PROGRAM_ID,
11335
- isSigner: false,
11336
- isWritable: false
11337
- },
11338
- {
11339
- pubkey: STAKE_PROGRAM_ID,
11340
- isSigner: false,
11341
- isWritable: false
11159
+ var single_spl_pool_exports = {};
11160
+ __export(single_spl_pool_exports, {
11161
+ SinglePoolInstruction: () => SinglePoolInstruction,
11162
+ createAccountIx: () => createAccountIx,
11163
+ createPoolOnrampIx: () => createPoolOnrampIx,
11164
+ findMplMetadataAddress: () => findMplMetadataAddress,
11165
+ findPoolAddress: () => findPoolAddress,
11166
+ findPoolMintAddress: () => findPoolMintAddress,
11167
+ findPoolMintAddressByVoteAccount: () => findPoolMintAddressByVoteAccount,
11168
+ findPoolMintAuthorityAddress: () => findPoolMintAuthorityAddress,
11169
+ findPoolMplAuthorityAddress: () => findPoolMplAuthorityAddress,
11170
+ findPoolOnRampAddress: () => findPoolOnRampAddress,
11171
+ findPoolStakeAddress: () => findPoolStakeAddress,
11172
+ findPoolStakeAuthorityAddress: () => findPoolStakeAuthorityAddress,
11173
+ initializeStakedPoolIxs: () => initializeStakedPoolIxs,
11174
+ initializeStakedPoolTx: () => initializeStakedPoolTx,
11175
+ replenishPoolIx: () => replenishPoolIx
11176
+ });
11177
+ async function initializeStakedPoolTx(connection, payer, voteAccountAddress) {
11178
+ const instructions$3 = await initializeStakedPoolIxs(connection, payer, voteAccountAddress);
11179
+ const tx = new Transaction().add(...instructions$3);
11180
+ return tx;
11181
+ }
11182
+ async function initializeStakedPoolIxs(connection, payer, voteAccountAddress) {
11183
+ const poolAddress = findPoolAddress(voteAccountAddress);
11184
+ const stakeAddress = findPoolStakeAddress(poolAddress);
11185
+ const mintAddress = findPoolMintAddress(poolAddress);
11186
+ const onRampAddress = findPoolOnRampAddress(poolAddress);
11187
+ const [poolRent, stakeRent, mintRent, minimumDelegationObj] = await Promise.all([
11188
+ connection.getMinimumBalanceForRentExemption(Number(SINGLE_POOL_ACCOUNT_SIZE), "confirmed"),
11189
+ connection.getMinimumBalanceForRentExemption(Number(STAKE_ACCOUNT_SIZE), "confirmed"),
11190
+ connection.getMinimumBalanceForRentExemption(Number(MINT_SIZE), "confirmed"),
11191
+ connection.getStakeMinimumDelegation()
11192
+ ]);
11193
+ const minimumDelegation = minimumDelegationObj.value;
11194
+ const instructions$3 = [];
11195
+ instructions$3.push(SystemProgram.transfer({
11196
+ fromPubkey: payer,
11197
+ toPubkey: poolAddress,
11198
+ lamports: poolRent
11199
+ }));
11200
+ instructions$3.push(SystemProgram.transfer({
11201
+ fromPubkey: payer,
11202
+ toPubkey: stakeAddress,
11203
+ lamports: stakeRent + minimumDelegation + LAMPORTS_PER_SOL * 1
11204
+ }));
11205
+ instructions$3.push(SystemProgram.transfer({
11206
+ fromPubkey: payer,
11207
+ toPubkey: onRampAddress,
11208
+ lamports: stakeRent
11209
+ }));
11210
+ instructions$3.push(SystemProgram.transfer({
11211
+ fromPubkey: payer,
11212
+ toPubkey: mintAddress,
11213
+ lamports: mintRent
11214
+ }));
11215
+ instructions$3.push(SinglePoolInstruction.initializePool(voteAccountAddress));
11216
+ instructions$3.push(SinglePoolInstruction.initializeOnRamp(poolAddress));
11217
+ instructions$3.push(await SinglePoolInstruction.createTokenMetadata(poolAddress, payer));
11218
+ return instructions$3;
11219
+ }
11220
+ var SinglePoolInstructionType, SinglePoolInstruction, createTransactionInstruction, findPda, findPoolMintAddressByVoteAccount, findPoolAddress, findPoolMintAddress, findPoolStakeAddress, findPoolStakeAuthorityAddress, findPoolMintAuthorityAddress, findPoolMplAuthorityAddress, findPoolOnRampAddress, findMplMetadataAddress, SINGLE_POOL_ACCOUNT_SIZE, STAKE_ACCOUNT_SIZE, MINT_SIZE, createAccountIx, createPoolOnrampIx, replenishPoolIx;
11221
+ var init_single_spl_pool = __esm({ "src/vendor/single-spl-pool/index.ts"() {
11222
+ init_constants();
11223
+ SinglePoolInstructionType = /* @__PURE__ */ function(SinglePoolInstructionType$1) {
11224
+ SinglePoolInstructionType$1[SinglePoolInstructionType$1["InitializePool"] = 0] = "InitializePool";
11225
+ SinglePoolInstructionType$1[SinglePoolInstructionType$1["ReplenishPool"] = 1] = "ReplenishPool";
11226
+ SinglePoolInstructionType$1[SinglePoolInstructionType$1["DepositStake"] = 2] = "DepositStake";
11227
+ SinglePoolInstructionType$1[SinglePoolInstructionType$1["WithdrawStake"] = 3] = "WithdrawStake";
11228
+ SinglePoolInstructionType$1[SinglePoolInstructionType$1["CreateTokenMetadata"] = 4] = "CreateTokenMetadata";
11229
+ SinglePoolInstructionType$1[SinglePoolInstructionType$1["UpdateTokenMetadata"] = 5] = "UpdateTokenMetadata";
11230
+ SinglePoolInstructionType$1[SinglePoolInstructionType$1["InitializeOnRamp"] = 6] = "InitializeOnRamp";
11231
+ return SinglePoolInstructionType$1;
11232
+ }(SinglePoolInstructionType || {});
11233
+ SinglePoolInstruction = {
11234
+ initializePool: (voteAccount) => {
11235
+ const pool = findPoolAddress(voteAccount);
11236
+ const stake = findPoolStakeAddress(pool);
11237
+ const mint = findPoolMintAddress(pool);
11238
+ const stakeAuthority = findPoolStakeAuthorityAddress(pool);
11239
+ const mintAuthority = findPoolMintAuthorityAddress(pool);
11240
+ return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
11241
+ {
11242
+ pubkey: voteAccount,
11243
+ isSigner: false,
11244
+ isWritable: false
11245
+ },
11246
+ {
11247
+ pubkey: pool,
11248
+ isSigner: false,
11249
+ isWritable: true
11250
+ },
11251
+ {
11252
+ pubkey: stake,
11253
+ isSigner: false,
11254
+ isWritable: true
11255
+ },
11256
+ {
11257
+ pubkey: mint,
11258
+ isSigner: false,
11259
+ isWritable: true
11260
+ },
11261
+ {
11262
+ pubkey: stakeAuthority,
11263
+ isSigner: false,
11264
+ isWritable: false
11265
+ },
11266
+ {
11267
+ pubkey: mintAuthority,
11268
+ isSigner: false,
11269
+ isWritable: false
11270
+ },
11271
+ {
11272
+ pubkey: SYSVAR_RENT_ID,
11273
+ isSigner: false,
11274
+ isWritable: false
11275
+ },
11276
+ {
11277
+ pubkey: SYSVAR_CLOCK_ID,
11278
+ isSigner: false,
11279
+ isWritable: false
11280
+ },
11281
+ {
11282
+ pubkey: SYSVAR_STAKE_HISTORY_ID,
11283
+ isSigner: false,
11284
+ isWritable: false
11285
+ },
11286
+ {
11287
+ pubkey: STAKE_CONFIG_ID$1,
11288
+ isSigner: false,
11289
+ isWritable: false
11290
+ },
11291
+ {
11292
+ pubkey: SYSTEM_PROGRAM_ID,
11293
+ isSigner: false,
11294
+ isWritable: false
11295
+ },
11296
+ {
11297
+ pubkey: TOKEN_PROGRAM_ID,
11298
+ isSigner: false,
11299
+ isWritable: false
11300
+ },
11301
+ {
11302
+ pubkey: STAKE_PROGRAM_ID,
11303
+ isSigner: false,
11304
+ isWritable: false
11305
+ }
11306
+ ], Buffer.from([SinglePoolInstructionType.InitializePool]));
11307
+ },
11308
+ initializeOnRamp: (pool) => {
11309
+ const onRamp = findPoolOnRampAddress(pool);
11310
+ const stakeAuthority = findPoolStakeAuthorityAddress(pool);
11311
+ return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
11312
+ {
11313
+ pubkey: pool,
11314
+ isSigner: false,
11315
+ isWritable: false
11316
+ },
11317
+ {
11318
+ pubkey: onRamp,
11319
+ isSigner: false,
11320
+ isWritable: true
11321
+ },
11322
+ {
11323
+ pubkey: stakeAuthority,
11324
+ isSigner: false,
11325
+ isWritable: false
11326
+ },
11327
+ {
11328
+ pubkey: SYSVAR_RENT_ID,
11329
+ isSigner: false,
11330
+ isWritable: false
11331
+ },
11332
+ {
11333
+ pubkey: SYSTEM_PROGRAM_ID,
11334
+ isSigner: false,
11335
+ isWritable: false
11336
+ },
11337
+ {
11338
+ pubkey: STAKE_PROGRAM_ID,
11339
+ isSigner: false,
11340
+ isWritable: false
11341
+ }
11342
+ ], Buffer.from([SinglePoolInstructionType.InitializeOnRamp]));
11343
+ },
11344
+ depositStake: async (pool, userStakeAccount, userTokenAccount, userLamportAccount) => {
11345
+ const stake = findPoolStakeAddress(pool);
11346
+ const mint = findPoolMintAddress(pool);
11347
+ const stakeAuthority = findPoolStakeAuthorityAddress(pool);
11348
+ const mintAuthority = findPoolMintAuthorityAddress(pool);
11349
+ return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
11350
+ {
11351
+ pubkey: pool,
11352
+ isSigner: false,
11353
+ isWritable: false
11354
+ },
11355
+ {
11356
+ pubkey: stake,
11357
+ isSigner: false,
11358
+ isWritable: true
11359
+ },
11360
+ {
11361
+ pubkey: mint,
11362
+ isSigner: false,
11363
+ isWritable: true
11364
+ },
11365
+ {
11366
+ pubkey: stakeAuthority,
11367
+ isSigner: false,
11368
+ isWritable: false
11369
+ },
11370
+ {
11371
+ pubkey: mintAuthority,
11372
+ isSigner: false,
11373
+ isWritable: false
11374
+ },
11375
+ {
11376
+ pubkey: userStakeAccount,
11377
+ isSigner: false,
11378
+ isWritable: true
11379
+ },
11380
+ {
11381
+ pubkey: userTokenAccount,
11382
+ isSigner: false,
11383
+ isWritable: true
11384
+ },
11385
+ {
11386
+ pubkey: userLamportAccount,
11387
+ isSigner: false,
11388
+ isWritable: true
11389
+ },
11390
+ {
11391
+ pubkey: SYSVAR_CLOCK_ID,
11392
+ isSigner: false,
11393
+ isWritable: false
11394
+ },
11395
+ {
11396
+ pubkey: SYSVAR_STAKE_HISTORY_ID,
11397
+ isSigner: false,
11398
+ isWritable: false
11399
+ },
11400
+ {
11401
+ pubkey: TOKEN_PROGRAM_ID,
11402
+ isSigner: false,
11403
+ isWritable: false
11404
+ },
11405
+ {
11406
+ pubkey: STAKE_PROGRAM_ID,
11407
+ isSigner: false,
11408
+ isWritable: false
11409
+ }
11410
+ ], Buffer.from([SinglePoolInstructionType.DepositStake]));
11411
+ },
11412
+ withdrawStake: async (pool, userStakeAccount, userStakeAuthority, userTokenAccount, tokenAmount) => {
11413
+ const stake = findPoolStakeAddress(pool);
11414
+ const mint = findPoolMintAddress(pool);
11415
+ const stakeAuthority = findPoolStakeAuthorityAddress(pool);
11416
+ const mintAuthority = findPoolMintAuthorityAddress(pool);
11417
+ const rawAmount = BigInt(tokenAmount.multipliedBy(1e9).toString());
11418
+ const data = Buffer.concat([
11419
+ Buffer.from([SinglePoolInstructionType.WithdrawStake]),
11420
+ userStakeAuthority.toBuffer(),
11421
+ Buffer.from(new BN(rawAmount.toString()).toArray("le", 8))
11422
+ ]);
11423
+ return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
11424
+ {
11425
+ pubkey: pool,
11426
+ isSigner: false,
11427
+ isWritable: false
11428
+ },
11429
+ {
11430
+ pubkey: stake,
11431
+ isSigner: false,
11432
+ isWritable: true
11433
+ },
11434
+ {
11435
+ pubkey: mint,
11436
+ isSigner: false,
11437
+ isWritable: true
11438
+ },
11439
+ {
11440
+ pubkey: stakeAuthority,
11441
+ isSigner: false,
11442
+ isWritable: false
11443
+ },
11444
+ {
11445
+ pubkey: mintAuthority,
11446
+ isSigner: false,
11447
+ isWritable: false
11448
+ },
11449
+ {
11450
+ pubkey: userStakeAccount,
11451
+ isSigner: false,
11452
+ isWritable: true
11453
+ },
11454
+ {
11455
+ pubkey: userTokenAccount,
11456
+ isSigner: false,
11457
+ isWritable: true
11458
+ },
11459
+ {
11460
+ pubkey: SYSVAR_CLOCK_ID,
11461
+ isSigner: false,
11462
+ isWritable: false
11463
+ },
11464
+ {
11465
+ pubkey: TOKEN_PROGRAM_ID,
11466
+ isSigner: false,
11467
+ isWritable: false
11468
+ },
11469
+ {
11470
+ pubkey: STAKE_PROGRAM_ID,
11471
+ isSigner: false,
11472
+ isWritable: false
11473
+ }
11474
+ ], data);
11475
+ },
11476
+ createTokenMetadata: async (pool, payer) => {
11477
+ const mint = findPoolMintAddress(pool);
11478
+ const [mintAuthority, mplAuthority, mplMetadata] = await Promise.all([
11479
+ findPoolMintAuthorityAddress(pool),
11480
+ findPoolMplAuthorityAddress(pool),
11481
+ findMplMetadataAddress(mint)
11482
+ ]);
11483
+ return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
11484
+ {
11485
+ pubkey: pool,
11486
+ isSigner: false,
11487
+ isWritable: false
11488
+ },
11489
+ {
11490
+ pubkey: mint,
11491
+ isSigner: false,
11492
+ isWritable: false
11493
+ },
11494
+ {
11495
+ pubkey: mintAuthority,
11496
+ isSigner: false,
11497
+ isWritable: false
11498
+ },
11499
+ {
11500
+ pubkey: mplAuthority,
11501
+ isSigner: false,
11502
+ isWritable: false
11503
+ },
11504
+ {
11505
+ pubkey: payer,
11506
+ isSigner: true,
11507
+ isWritable: true
11508
+ },
11509
+ {
11510
+ pubkey: mplMetadata,
11511
+ isSigner: false,
11512
+ isWritable: true
11513
+ },
11514
+ {
11515
+ pubkey: MPL_METADATA_PROGRAM_ID,
11516
+ isSigner: false,
11517
+ isWritable: false
11518
+ },
11519
+ {
11520
+ pubkey: SYSTEM_PROGRAM_ID,
11521
+ isSigner: false,
11522
+ isWritable: false
11523
+ }
11524
+ ], Buffer.from([SinglePoolInstructionType.CreateTokenMetadata]));
11525
+ },
11526
+ updateTokenMetadata: async (voteAccount, authorizedWithdrawer, tokenName, tokenSymbol, tokenUri = "") => {
11527
+ if (tokenName.length > 32) {
11528
+ throw new Error("maximum token name length is 32 characters");
11342
11529
  }
11343
- ], Buffer.from([SinglePoolInstructionType.DepositStake]));
11344
- },
11345
- withdrawStake: async (pool, userStakeAccount, userStakeAuthority, userTokenAccount, tokenAmount) => {
11346
- const stake = findPoolStakeAddress(pool);
11347
- const mint = findPoolMintAddress(pool);
11348
- const stakeAuthority = findPoolStakeAuthorityAddress(pool);
11349
- const mintAuthority = findPoolMintAuthorityAddress(pool);
11350
- const rawAmount = BigInt(tokenAmount.multipliedBy(1e9).toString());
11530
+ if (tokenSymbol.length > 10) {
11531
+ throw new Error("maximum token symbol length is 10 characters");
11532
+ }
11533
+ if (tokenUri.length > 200) {
11534
+ throw new Error("maximum token uri length is 200 characters");
11535
+ }
11536
+ const pool = findPoolAddress(voteAccount);
11537
+ const [mint, mplAuthority] = await Promise.all([findPoolMintAddress(pool), findPoolMplAuthorityAddress(pool)]);
11538
+ const mplMetadata = await findMplMetadataAddress(mint);
11539
+ const data = Buffer.concat([
11540
+ Buffer.from([SinglePoolInstructionType.UpdateTokenMetadata]),
11541
+ Buffer.from(new Uint32Array([tokenName.length]).buffer),
11542
+ Buffer.from(tokenName),
11543
+ Buffer.from(new Uint32Array([tokenSymbol.length]).buffer),
11544
+ Buffer.from(tokenSymbol),
11545
+ Buffer.from(new Uint32Array([tokenUri.length]).buffer),
11546
+ Buffer.from(tokenUri)
11547
+ ]);
11548
+ return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
11549
+ {
11550
+ pubkey: voteAccount,
11551
+ isSigner: false,
11552
+ isWritable: false
11553
+ },
11554
+ {
11555
+ pubkey: pool,
11556
+ isSigner: false,
11557
+ isWritable: false
11558
+ },
11559
+ {
11560
+ pubkey: mplAuthority,
11561
+ isSigner: false,
11562
+ isWritable: false
11563
+ },
11564
+ {
11565
+ pubkey: authorizedWithdrawer,
11566
+ isSigner: true,
11567
+ isWritable: false
11568
+ },
11569
+ {
11570
+ pubkey: mplMetadata,
11571
+ isSigner: false,
11572
+ isWritable: true
11573
+ },
11574
+ {
11575
+ pubkey: MPL_METADATA_PROGRAM_ID,
11576
+ isSigner: false,
11577
+ isWritable: false
11578
+ }
11579
+ ], data);
11580
+ }
11581
+ };
11582
+ createTransactionInstruction = (programId, keys, data) => {
11583
+ return {
11584
+ programId,
11585
+ keys,
11586
+ data
11587
+ };
11588
+ };
11589
+ findPda = (baseAddress, prefix, programId = SINGLE_POOL_PROGRAM_ID) => {
11590
+ const [pda] = PublicKey.findProgramAddressSync([Buffer.from(prefix), baseAddress.toBuffer()], programId);
11591
+ return pda;
11592
+ };
11593
+ findPoolMintAddressByVoteAccount = (voteAccountAddress) => findPda(findPoolAddress(voteAccountAddress), "mint");
11594
+ findPoolAddress = (voteAccountAddress) => findPda(voteAccountAddress, "pool");
11595
+ findPoolMintAddress = (poolAddress) => findPda(poolAddress, "mint");
11596
+ findPoolStakeAddress = (poolAddress) => findPda(poolAddress, "stake");
11597
+ findPoolStakeAuthorityAddress = (poolAddress) => findPda(poolAddress, "stake_authority");
11598
+ findPoolMintAuthorityAddress = (poolAddress) => findPda(poolAddress, "mint_authority");
11599
+ findPoolMplAuthorityAddress = (poolAddress) => findPda(poolAddress, "mpl_authority");
11600
+ findPoolOnRampAddress = (poolAddress) => findPda(poolAddress, "onramp");
11601
+ findMplMetadataAddress = async (poolMintAddress) => {
11602
+ const [pda] = PublicKey.findProgramAddressSync([
11603
+ Buffer.from("metadata"),
11604
+ MPL_METADATA_PROGRAM_ID.toBuffer(),
11605
+ poolMintAddress.toBuffer()
11606
+ ], MPL_METADATA_PROGRAM_ID);
11607
+ return pda;
11608
+ };
11609
+ SINGLE_POOL_ACCOUNT_SIZE = BigInt(33);
11610
+ STAKE_ACCOUNT_SIZE = BigInt(200);
11611
+ MINT_SIZE = BigInt(82);
11612
+ createAccountIx = (from, newAccount, lamports, space, programAddress) => {
11351
11613
  const data = Buffer.concat([
11352
- Buffer.from([SinglePoolInstructionType.WithdrawStake]),
11353
- userStakeAuthority.toBuffer(),
11354
- Buffer.from(new BN(rawAmount.toString()).toArray("le", 8))
11614
+ Buffer.from([0]),
11615
+ Buffer.from(new BN(lamports).toArray("le", 8)),
11616
+ Buffer.from(new BN(space).toArray("le", 8)),
11617
+ programAddress.toBuffer()
11355
11618
  ]);
11356
- return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
11619
+ const accounts$2 = [{
11620
+ pubkey: from,
11621
+ isSigner: true,
11622
+ isWritable: true
11623
+ }, {
11624
+ pubkey: newAccount,
11625
+ isSigner: true,
11626
+ isWritable: true
11627
+ }];
11628
+ return createTransactionInstruction(SYSTEM_PROGRAM_ID, accounts$2, data);
11629
+ };
11630
+ createPoolOnrampIx = (voteAccount) => {
11631
+ const poolAccount = findPoolAddress(voteAccount);
11632
+ const onRampAccount = findPoolOnRampAddress(poolAccount);
11633
+ const poolStakeAuthority = findPoolStakeAuthorityAddress(poolAccount);
11634
+ const keys = [
11357
11635
  {
11358
- pubkey: pool,
11636
+ pubkey: poolAccount,
11359
11637
  isSigner: false,
11360
11638
  isWritable: false
11361
11639
  },
11362
11640
  {
11363
- pubkey: stake,
11364
- isSigner: false,
11365
- isWritable: true
11366
- },
11367
- {
11368
- pubkey: mint,
11641
+ pubkey: onRampAccount,
11369
11642
  isSigner: false,
11370
11643
  isWritable: true
11371
11644
  },
11372
11645
  {
11373
- pubkey: stakeAuthority,
11646
+ pubkey: poolStakeAuthority,
11374
11647
  isSigner: false,
11375
11648
  isWritable: false
11376
11649
  },
11377
11650
  {
11378
- pubkey: mintAuthority,
11379
- isSigner: false,
11380
- isWritable: false
11381
- },
11382
- {
11383
- pubkey: userStakeAccount,
11384
- isSigner: false,
11385
- isWritable: true
11386
- },
11387
- {
11388
- pubkey: userTokenAccount,
11389
- isSigner: false,
11390
- isWritable: true
11391
- },
11392
- {
11393
- pubkey: SYSVAR_CLOCK_ID,
11651
+ pubkey: SYSVAR_RENT_PUBKEY,
11394
11652
  isSigner: false,
11395
11653
  isWritable: false
11396
11654
  },
11397
11655
  {
11398
- pubkey: TOKEN_PROGRAM_ID,
11656
+ pubkey: SystemProgram.programId,
11399
11657
  isSigner: false,
11400
11658
  isWritable: false
11401
11659
  },
11402
11660
  {
11403
- pubkey: STAKE_PROGRAM_ID,
11661
+ pubkey: StakeProgram.programId,
11404
11662
  isSigner: false,
11405
11663
  isWritable: false
11406
11664
  }
11407
- ], data);
11408
- },
11409
- createTokenMetadata: async (pool, payer) => {
11410
- const mint = findPoolMintAddress(pool);
11411
- const [mintAuthority, mplAuthority, mplMetadata] = await Promise.all([
11412
- findPoolMintAuthorityAddress(pool),
11413
- findPoolMplAuthorityAddress(pool),
11414
- findMplMetadataAddress(mint)
11415
- ]);
11416
- return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
11417
- {
11418
- pubkey: pool,
11419
- isSigner: false,
11420
- isWritable: false
11421
- },
11665
+ ];
11666
+ const data = Buffer.from(Uint8Array.of(6));
11667
+ return new TransactionInstruction({
11668
+ keys,
11669
+ programId: SINGLE_POOL_PROGRAM_ID,
11670
+ data
11671
+ });
11672
+ };
11673
+ replenishPoolIx = (voteAccount) => {
11674
+ const poolAccount = findPoolAddress(voteAccount);
11675
+ const stakePool = findPoolStakeAddress(poolAccount);
11676
+ const onRampPool = findPoolOnRampAddress(poolAccount);
11677
+ const authority = findPoolStakeAuthorityAddress(poolAccount);
11678
+ const keys = [
11422
11679
  {
11423
- pubkey: mint,
11680
+ pubkey: voteAccount,
11424
11681
  isSigner: false,
11425
11682
  isWritable: false
11426
11683
  },
11427
11684
  {
11428
- pubkey: mintAuthority,
11685
+ pubkey: poolAccount,
11429
11686
  isSigner: false,
11430
11687
  isWritable: false
11431
11688
  },
11432
11689
  {
11433
- pubkey: mplAuthority,
11690
+ pubkey: stakePool,
11434
11691
  isSigner: false,
11435
- isWritable: false
11436
- },
11437
- {
11438
- pubkey: payer,
11439
- isSigner: true,
11440
11692
  isWritable: true
11441
11693
  },
11442
11694
  {
11443
- pubkey: mplMetadata,
11695
+ pubkey: onRampPool,
11444
11696
  isSigner: false,
11445
11697
  isWritable: true
11446
11698
  },
11447
11699
  {
11448
- pubkey: MPL_METADATA_PROGRAM_ID,
11700
+ pubkey: authority,
11449
11701
  isSigner: false,
11450
11702
  isWritable: false
11451
11703
  },
11452
11704
  {
11453
- pubkey: SYSTEM_PROGRAM_ID,
11454
- isSigner: false,
11455
- isWritable: false
11456
- }
11457
- ], Buffer.from([SinglePoolInstructionType.CreateTokenMetadata]));
11458
- },
11459
- updateTokenMetadata: async (voteAccount, authorizedWithdrawer, tokenName, tokenSymbol, tokenUri = "") => {
11460
- if (tokenName.length > 32) {
11461
- throw new Error("maximum token name length is 32 characters");
11462
- }
11463
- if (tokenSymbol.length > 10) {
11464
- throw new Error("maximum token symbol length is 10 characters");
11465
- }
11466
- if (tokenUri.length > 200) {
11467
- throw new Error("maximum token uri length is 200 characters");
11468
- }
11469
- const pool = findPoolAddress(voteAccount);
11470
- const [mint, mplAuthority] = await Promise.all([findPoolMintAddress(pool), findPoolMplAuthorityAddress(pool)]);
11471
- const mplMetadata = await findMplMetadataAddress(mint);
11472
- const data = Buffer.concat([
11473
- Buffer.from([SinglePoolInstructionType.UpdateTokenMetadata]),
11474
- Buffer.from(new Uint32Array([tokenName.length]).buffer),
11475
- Buffer.from(tokenName),
11476
- Buffer.from(new Uint32Array([tokenSymbol.length]).buffer),
11477
- Buffer.from(tokenSymbol),
11478
- Buffer.from(new Uint32Array([tokenUri.length]).buffer),
11479
- Buffer.from(tokenUri)
11480
- ]);
11481
- return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
11482
- {
11483
- pubkey: voteAccount,
11705
+ pubkey: SYSVAR_CLOCK_PUBKEY,
11484
11706
  isSigner: false,
11485
11707
  isWritable: false
11486
11708
  },
11487
11709
  {
11488
- pubkey: pool,
11710
+ pubkey: SYSVAR_STAKE_HISTORY_ID,
11489
11711
  isSigner: false,
11490
11712
  isWritable: false
11491
11713
  },
11492
11714
  {
11493
- pubkey: mplAuthority,
11715
+ pubkey: STAKE_CONFIG_ID$1,
11494
11716
  isSigner: false,
11495
11717
  isWritable: false
11496
11718
  },
11497
11719
  {
11498
- pubkey: authorizedWithdrawer,
11499
- isSigner: true,
11500
- isWritable: false
11501
- },
11502
- {
11503
- pubkey: mplMetadata,
11504
- isSigner: false,
11505
- isWritable: true
11506
- },
11507
- {
11508
- pubkey: MPL_METADATA_PROGRAM_ID,
11720
+ pubkey: StakeProgram.programId,
11509
11721
  isSigner: false,
11510
11722
  isWritable: false
11511
11723
  }
11512
- ], data);
11513
- }
11514
- };
11515
- const createTransactionInstruction = (programId, keys, data) => {
11516
- return {
11517
- programId,
11518
- keys,
11519
- data
11724
+ ];
11725
+ const data = Buffer.from(Uint8Array.of(1));
11726
+ return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, keys, data);
11520
11727
  };
11521
- };
11522
- const findPda = (baseAddress, prefix, programId = SINGLE_POOL_PROGRAM_ID) => {
11523
- const [pda] = PublicKey.findProgramAddressSync([Buffer.from(prefix), baseAddress.toBuffer()], programId);
11524
- return pda;
11525
- };
11526
- const findPoolMintAddressByVoteAccount = (voteAccountAddress) => findPda(findPoolAddress(voteAccountAddress), "mint");
11527
- const findPoolAddress = (voteAccountAddress) => findPda(voteAccountAddress, "pool");
11528
- const findPoolMintAddress = (poolAddress) => findPda(poolAddress, "mint");
11529
- const findPoolStakeAddress = (poolAddress) => findPda(poolAddress, "stake");
11530
- const findPoolStakeAuthorityAddress = (poolAddress) => findPda(poolAddress, "stake_authority");
11531
- const findPoolMintAuthorityAddress = (poolAddress) => findPda(poolAddress, "mint_authority");
11532
- const findPoolMplAuthorityAddress = (poolAddress) => findPda(poolAddress, "mpl_authority");
11533
- const findPoolOnRampAddress = (poolAddress) => findPda(poolAddress, "onramp");
11534
- const findMplMetadataAddress = async (poolMintAddress) => {
11535
- const [pda] = PublicKey.findProgramAddressSync([
11536
- Buffer.from("metadata"),
11537
- MPL_METADATA_PROGRAM_ID.toBuffer(),
11538
- poolMintAddress.toBuffer()
11539
- ], MPL_METADATA_PROGRAM_ID);
11540
- return pda;
11541
- };
11542
- const SINGLE_POOL_ACCOUNT_SIZE = BigInt(33);
11543
- const STAKE_ACCOUNT_SIZE = BigInt(200);
11544
- const MINT_SIZE = BigInt(82);
11545
- async function initializeStakedPoolTx(connection, payer, voteAccountAddress) {
11546
- const instructions$3 = await initializeStakedPoolIxs(connection, payer, voteAccountAddress);
11547
- const tx = new Transaction().add(...instructions$3);
11548
- return tx;
11549
- }
11550
- async function initializeStakedPoolIxs(connection, payer, voteAccountAddress) {
11551
- const poolAddress = findPoolAddress(voteAccountAddress);
11552
- const stakeAddress = findPoolStakeAddress(poolAddress);
11553
- const mintAddress = findPoolMintAddress(poolAddress);
11554
- const onRampAddress = findPoolOnRampAddress(poolAddress);
11555
- const [poolRent, stakeRent, mintRent, minimumDelegationObj] = await Promise.all([
11556
- connection.getMinimumBalanceForRentExemption(Number(SINGLE_POOL_ACCOUNT_SIZE), "confirmed"),
11557
- connection.getMinimumBalanceForRentExemption(Number(STAKE_ACCOUNT_SIZE), "confirmed"),
11558
- connection.getMinimumBalanceForRentExemption(Number(MINT_SIZE), "confirmed"),
11559
- connection.getStakeMinimumDelegation()
11560
- ]);
11561
- const minimumDelegation = minimumDelegationObj.value;
11562
- const instructions$3 = [];
11563
- instructions$3.push(SystemProgram.transfer({
11564
- fromPubkey: payer,
11565
- toPubkey: poolAddress,
11566
- lamports: poolRent
11567
- }));
11568
- instructions$3.push(SystemProgram.transfer({
11569
- fromPubkey: payer,
11570
- toPubkey: stakeAddress,
11571
- lamports: stakeRent + minimumDelegation + LAMPORTS_PER_SOL * 1
11572
- }));
11573
- instructions$3.push(SystemProgram.transfer({
11574
- fromPubkey: payer,
11575
- toPubkey: onRampAddress,
11576
- lamports: stakeRent
11577
- }));
11578
- instructions$3.push(SystemProgram.transfer({
11579
- fromPubkey: payer,
11580
- toPubkey: mintAddress,
11581
- lamports: mintRent
11582
- }));
11583
- instructions$3.push(SinglePoolInstruction.initializePool(voteAccountAddress));
11584
- instructions$3.push(SinglePoolInstruction.initializeOnRamp(poolAddress));
11585
- instructions$3.push(await SinglePoolInstruction.createTokenMetadata(poolAddress, payer));
11586
- return instructions$3;
11587
- }
11588
- const createAccountIx = (from, newAccount, lamports, space, programAddress) => {
11589
- const data = Buffer.concat([
11590
- Buffer.from([0]),
11591
- Buffer.from(new BN(lamports).toArray("le", 8)),
11592
- Buffer.from(new BN(space).toArray("le", 8)),
11593
- programAddress.toBuffer()
11594
- ]);
11595
- const accounts$2 = [{
11596
- pubkey: from,
11597
- isSigner: true,
11598
- isWritable: true
11599
- }, {
11600
- pubkey: newAccount,
11601
- isSigner: true,
11602
- isWritable: true
11603
- }];
11604
- return createTransactionInstruction(SYSTEM_PROGRAM_ID, accounts$2, data);
11605
- };
11606
- const createPoolOnrampIx = (voteAccount) => {
11607
- const poolAccount = findPoolAddress(voteAccount);
11608
- const onRampAccount = findPoolOnRampAddress(poolAccount);
11609
- const poolStakeAuthority = findPoolStakeAuthorityAddress(poolAccount);
11610
- const keys = [
11611
- {
11612
- pubkey: poolAccount,
11613
- isSigner: false,
11614
- isWritable: false
11615
- },
11616
- {
11617
- pubkey: onRampAccount,
11618
- isSigner: false,
11619
- isWritable: true
11620
- },
11621
- {
11622
- pubkey: poolStakeAuthority,
11623
- isSigner: false,
11624
- isWritable: false
11625
- },
11626
- {
11627
- pubkey: SYSVAR_RENT_PUBKEY,
11628
- isSigner: false,
11629
- isWritable: false
11630
- },
11631
- {
11632
- pubkey: SystemProgram.programId,
11633
- isSigner: false,
11634
- isWritable: false
11635
- },
11636
- {
11637
- pubkey: StakeProgram.programId,
11638
- isSigner: false,
11639
- isWritable: false
11640
- }
11641
- ];
11642
- const data = Buffer.from(Uint8Array.of(6));
11643
- return new TransactionInstruction({
11644
- keys,
11645
- programId: SINGLE_POOL_PROGRAM_ID,
11646
- data
11647
- });
11648
- };
11649
- const replenishPoolIx = (voteAccount) => {
11650
- const poolAccount = findPoolAddress(voteAccount);
11651
- const stakePool = findPoolStakeAddress(poolAccount);
11652
- const onRampPool = findPoolOnRampAddress(poolAccount);
11653
- const authority = findPoolStakeAuthorityAddress(poolAccount);
11654
- const keys = [
11655
- {
11656
- pubkey: voteAccount,
11657
- isSigner: false,
11658
- isWritable: false
11659
- },
11660
- {
11661
- pubkey: poolAccount,
11662
- isSigner: false,
11663
- isWritable: false
11664
- },
11665
- {
11666
- pubkey: stakePool,
11667
- isSigner: false,
11668
- isWritable: true
11669
- },
11670
- {
11671
- pubkey: onRampPool,
11672
- isSigner: false,
11673
- isWritable: true
11674
- },
11675
- {
11676
- pubkey: authority,
11677
- isSigner: false,
11678
- isWritable: false
11679
- },
11680
- {
11681
- pubkey: SYSVAR_CLOCK_PUBKEY,
11682
- isSigner: false,
11683
- isWritable: false
11684
- },
11685
- {
11686
- pubkey: SYSVAR_STAKE_HISTORY_ID,
11687
- isSigner: false,
11688
- isWritable: false
11689
- },
11690
- {
11691
- pubkey: STAKE_CONFIG_ID$1,
11692
- isSigner: false,
11693
- isWritable: false
11694
- },
11695
- {
11696
- pubkey: StakeProgram.programId,
11697
- isSigner: false,
11698
- isWritable: false
11699
- }
11700
- ];
11701
- const data = Buffer.from(Uint8Array.of(1));
11702
- return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, keys, data);
11703
- };
11728
+ } });
11704
11729
 
11705
11730
  //#endregion
11706
11731
  //#region src/vendor/switchboard_legacy/account.ts
@@ -15998,9 +16023,11 @@ __export(vendor_exports, {
15998
16023
  replenishPoolIx: () => replenishPoolIx,
15999
16024
  switchboardAccountCoder: () => switchboardAccountCoder
16000
16025
  });
16026
+ init_single_spl_pool();
16001
16027
 
16002
16028
  //#endregion
16003
16029
  //#region src/utils.ts
16030
+ init_constants();
16004
16031
  function getBankVaultSeeds(type) {
16005
16032
  switch (type) {
16006
16033
  case BankVaultType.LiquidityVault: return PDA_BANK_LIQUIDITY_VAULT_SEED;
@@ -18732,6 +18759,7 @@ let PriceBias = /* @__PURE__ */ function(PriceBias$1) {
18732
18759
 
18733
18760
  //#endregion
18734
18761
  //#region src/services/price/utils/compute.utils.ts
18762
+ init_constants();
18735
18763
  function getPriceWithConfidence(oraclePrice, weighted) {
18736
18764
  return weighted ? oraclePrice.priceWeighted : oraclePrice.priceRealtime;
18737
18765
  }
@@ -19699,6 +19727,7 @@ function bankConfigRawToDto(bankConfigRaw) {
19699
19727
 
19700
19728
  //#endregion
19701
19729
  //#region src/services/bank/bank.service.ts
19730
+ init_constants();
19702
19731
  async function freezeBankConfigIx(program, bankAddress, bankConfigOpt) {
19703
19732
  if (!bankConfigOpt) {}
19704
19733
  const bankConfigRaw = serializeBankConfigOpt(bankConfigOpt);
@@ -20070,6 +20099,7 @@ async function executeBundleSimulation(rpcEndpoint, encodedTransactions, config)
20070
20099
 
20071
20100
  //#endregion
20072
20101
  //#region src/services/transaction/transaction.service.ts
20102
+ init_constants();
20073
20103
  const DEFAULT_PROCESS_TX_OPTS = {
20074
20104
  broadcastType: "RPC",
20075
20105
  isSequentialTxs: true,
@@ -20666,6 +20696,7 @@ function addTransactionTxTags(transactions) {
20666
20696
 
20667
20697
  //#endregion
20668
20698
  //#region src/services/account/utils/compute.utils.ts
20699
+ init_single_spl_pool();
20669
20700
  /**
20670
20701
  * Lendr Account Computes
20671
20702
  * =========================
@@ -21617,6 +21648,8 @@ function getActiveStaleBanks(balances, banks, additionalBanks, oraclePrices, max
21617
21648
 
21618
21649
  //#endregion
21619
21650
  //#region src/services/group/group.service.ts
21651
+ init_constants();
21652
+ init_single_spl_pool();
21620
21653
  async function makePoolConfigureBankIx(program, bank, args) {
21621
21654
  const ix = await instructions_default.makePoolConfigureBankIx(program, { bank }, { bankConfigOpt: args });
21622
21655
  return {
@@ -21750,6 +21783,8 @@ function dtoToValidatorStakeGroup(validatorStakeGroupDto) {
21750
21783
 
21751
21784
  //#endregion
21752
21785
  //#region src/services/native-stake/utils/fetch.utils.ts
21786
+ init_constants();
21787
+ init_single_spl_pool();
21753
21788
  /**
21754
21789
  * Retrieves all active stake accounts associated with a given public key grouped by validator
21755
21790
  *
@@ -22657,7 +22692,7 @@ var LendrAccount = class LendrAccount {
22657
22692
  keys: []
22658
22693
  };
22659
22694
  }
22660
- async prepareWithdrawInstruction(program, bankMap, mintDatas, bankAddress, withdrawAll = false, withdrawOpts = {}) {
22695
+ async prepareWithdrawInstruction(program, bankMap, mintDatas, bankMetadataMap, bankAddress, withdrawAll = false, withdrawOpts = {}) {
22661
22696
  const bank = bankMap.get(bankAddress.toBase58());
22662
22697
  if (!bank) throw Error(`Bank ${bankAddress.toBase58()} not found`);
22663
22698
  const mintData = mintDatas.get(bankAddress.toBase58());
@@ -22681,9 +22716,23 @@ var LendrAccount = class LendrAccount {
22681
22716
  if (withdrawOpts.observationBanksOverride) {
22682
22717
  remainingAccounts.push(...withdrawOpts.observationBanksOverride);
22683
22718
  } else {
22684
- const accountMetas = computeHealthAccountMetas(healthAccounts);
22719
+ const accountMetas = computeHealthAccountMetas(healthAccounts, bankMetadataMap);
22685
22720
  remainingAccounts.push(...accountMetas);
22686
22721
  }
22722
+ if (withdrawAll) {
22723
+ remainingAccounts.push(bank.address, bank.config.oracleKeys[0]);
22724
+ if (bank.config.assetTag === 2) {
22725
+ const bankMetadata = bankMetadataMap?.[bankAddress.toBase58()];
22726
+ if (!bankMetadata?.validatorVoteAccount) {
22727
+ throw Error(`No validator vote account for staked bank ${bankAddress.toBase58()}`);
22728
+ }
22729
+ const { findPoolAddress: findPoolAddress$1, findPoolStakeAddress: findPoolStakeAddress$1, findPoolMintAddress: findPoolMintAddress$1 } = (init_single_spl_pool(), __toCommonJS(single_spl_pool_exports));
22730
+ const pool = findPoolAddress$1(new PublicKey(bankMetadata.validatorVoteAccount));
22731
+ const solPool = findPoolStakeAddress$1(pool);
22732
+ const lstMint = findPoolMintAddress$1(pool);
22733
+ remainingAccounts.push(lstMint, solPool);
22734
+ }
22735
+ }
22687
22736
  return {
22688
22737
  withdrawIxs,
22689
22738
  wrapAndUnwrapSol,
@@ -22697,8 +22746,8 @@ var LendrAccount = class LendrAccount {
22697
22746
  }))
22698
22747
  };
22699
22748
  }
22700
- async makeWithdrawIx(program, bankMap, mintDatas, amount, bankAddress, withdrawAll = false, withdrawOpts = {}) {
22701
- const { withdrawIxs, wrapAndUnwrapSol, userAta, mintData, bank, remainingAccounts } = await this.prepareWithdrawInstruction(program, bankMap, mintDatas, bankAddress, withdrawAll, withdrawOpts);
22749
+ async makeWithdrawIx(program, bankMap, mintDatas, bankMetadataMap, amount, bankAddress, withdrawAll = false, withdrawOpts = {}) {
22750
+ const { withdrawIxs, wrapAndUnwrapSol, userAta, mintData, bank, remainingAccounts } = await this.prepareWithdrawInstruction(program, bankMap, mintDatas, bankMetadataMap, bankAddress, withdrawAll, withdrawOpts);
22702
22751
  const [bankLiquidityVaultAuthority] = getBankVaultAuthority(BankVaultType.LiquidityVault, bank.address, program.programId);
22703
22752
  const withdrawIx = await instructions_default.makeWithdrawIx(program, {
22704
22753
  lendrAccount: this.address,
@@ -22722,8 +22771,8 @@ var LendrAccount = class LendrAccount {
22722
22771
  keys: []
22723
22772
  };
22724
22773
  }
22725
- async makeWithdrawWithSessionIx(program, bankMap, mintDatas, amount, bankAddress, session, withdrawAll = false, withdrawOpts = {}) {
22726
- const { withdrawIxs, wrapAndUnwrapSol, userAta, mintData, bank, remainingAccounts } = await this.prepareWithdrawInstruction(program, bankMap, mintDatas, bankAddress, withdrawAll, {
22774
+ async makeWithdrawWithSessionIx(program, bankMap, mintDatas, bankMetadataMap, amount, bankAddress, session, withdrawAll = false, withdrawOpts = {}) {
22775
+ const { withdrawIxs, wrapAndUnwrapSol, userAta, mintData, bank, remainingAccounts } = await this.prepareWithdrawInstruction(program, bankMap, mintDatas, bankMetadataMap, bankAddress, withdrawAll, {
22727
22776
  ...withdrawOpts,
22728
22777
  createAtaPayer: session.payer
22729
22778
  });
@@ -23041,6 +23090,7 @@ function isWeightedPrice(reqType) {
23041
23090
 
23042
23091
  //#endregion
23043
23092
  //#region src/models/account/wrapper.ts
23093
+ init_constants();
23044
23094
  var LendrAccountWrapper = class LendrAccountWrapper {
23045
23095
  address;
23046
23096
  _lendrAccount;
@@ -23948,7 +23998,8 @@ var LendrAccountWrapper = class LendrAccountWrapper {
23948
23998
  async makeWithdrawIx(amount, bankAddress, withdrawAll = false, withdrawOpts = {}) {
23949
23999
  const tokenProgramAddress = this.client.mintDatas.get(bankAddress.toBase58())?.tokenProgram;
23950
24000
  if (!tokenProgramAddress) throw Error("Withdraw mint not found");
23951
- return this._lendrAccount.makeWithdrawIx(this._program, this.client.banks, this.client.mintDatas, amount, bankAddress, withdrawAll, withdrawOpts);
24001
+ if (!this.client.bankMetadataMap) throw Error("Bank metadata map not found");
24002
+ return this._lendrAccount.makeWithdrawIx(this._program, this.client.banks, this.client.mintDatas, this.client.bankMetadataMap, amount, bankAddress, withdrawAll, withdrawOpts);
23952
24003
  }
23953
24004
  /**
23954
24005
  * Creates instructions for withdrawing tokens from a lendr bank account.
@@ -23964,7 +24015,8 @@ var LendrAccountWrapper = class LendrAccountWrapper {
23964
24015
  async makeWithdrawWithSessionIx(amount, bankAddress, session, withdrawAll = false, withdrawOpts = {}) {
23965
24016
  const tokenProgramAddress = this.client.mintDatas.get(bankAddress.toBase58())?.tokenProgram;
23966
24017
  if (!tokenProgramAddress) throw Error("Withdraw mint not found");
23967
- return this._lendrAccount.makeWithdrawWithSessionIx(this._program, this.client.banks, this.client.mintDatas, amount, bankAddress, session, withdrawAll, withdrawOpts);
24018
+ if (!this.client.bankMetadataMap) throw Error("Bank metadata map not found");
24019
+ return this._lendrAccount.makeWithdrawWithSessionIx(this._program, this.client.banks, this.client.mintDatas, this.client.bankMetadataMap, amount, bankAddress, session, withdrawAll, withdrawOpts);
23968
24020
  }
23969
24021
  /**
23970
24022
  * Creates a transaction for withdrawing tokens from a lendr bank account and staking them.
@@ -24790,6 +24842,7 @@ var LendrGroup = class LendrGroup {
24790
24842
 
24791
24843
  //#endregion
24792
24844
  //#region src/clients/client.ts
24845
+ init_constants();
24793
24846
  /**
24794
24847
  * Entrypoint to interact with the lendr contract.
24795
24848
  */
@@ -25701,6 +25754,10 @@ var EmodeSettings = class EmodeSettings {
25701
25754
  }
25702
25755
  };
25703
25756
 
25757
+ //#endregion
25758
+ //#region src/index.ts
25759
+ init_constants();
25760
+
25704
25761
  //#endregion
25705
25762
  export { AccountFlags, AccountType, AssetTag, BUNDLE_TX_SIZE, Balance, Bank, BankConfig, BankConfigFlag, BankVaultType, DEFAULT_CLUSTER, DEFAULT_COMMITMENT, DEFAULT_CONFIRM_OPTS, DEFAULT_ORACLE_MAX_AGE, DEFAULT_PROCESS_TX_OPTS, DEFAULT_PROCESS_TX_STRATEGY, DEFAULT_SEND_OPTS, DISABLED_FLAG, DUMMY_USDC_MINT, DataFetcher, DummyMetadataFetcher, EmodeEntryFlags, EmodeFlags, EmodeImpactStatus, EmodeSettings, EmodeTag, FLASHLOAN_ENABLED_FLAG, FogoMetadataFetcher, GROUP_PK, HOURS_PER_YEAR, HealthCache, HealthCacheFlags, HealthCacheSimulationError, JUPITER_V6_PROGRAM, LENDR_IDL, LENDR_PROGRAM, LENDR_SPONSORED_SHARD_ID, LST_MINT, LUT_PROGRAM_AUTHORITY_INDEX, LendrAccount, LendrAccountWrapper, client_default as LendrClient, LendrGroup, LendrRequirementType, MAX_ACCOUNT_KEYS, MAX_CONFIDENCE_INTERVAL_RATIO, MAX_TX_SIZE, MAX_U64, MPL_METADATA_PROGRAM_ID, MetadataService, MetaplexMetadataFetcher, OperationalState, OracleSetup, PDA_BANK_FEE_VAULT_AUTH_SEED, PDA_BANK_FEE_VAULT_SEED, PDA_BANK_INSURANCE_VAULT_AUTH_SEED, PDA_BANK_INSURANCE_VAULT_SEED, PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED, PDA_BANK_LIQUIDITY_VAULT_SEED, PRIORITY_TX_SIZE, PROGRAM_ID, PYTH_PRICE_CONF_INTERVALS, PYTH_PUSH_ORACLE_ID, PYTH_SPONSORED_SHARD_ID, PriceBias, ProcessTransactionError, ProcessTransactionErrorType, RiskTier, SINGLE_POOL_PROGRAM_ID, SKIP_SIMULATION, STAKE_CONFIG_ID, STAKE_PROGRAM_ID, SWB_PRICE_CONF_INTERVALS, SYSTEM_PROGRAM_ID, SYSVAR_CLOCK_ID, SYSVAR_RENT_ID, SYSVAR_STAKE_HISTORY_ID, TRANSFER_ACCOUNT_AUTHORITY_FLAG, USDC_DECIMALS, USDC_MINT, WSOL_EXTENDED_METADATA, WSOL_MINT, accountFlagToBN, addOracleToBanksIx, balanceToDto, bankConfigRawToDto, bankConfigToBankConfigRaw, bankRawToDto, buildFeedIdMap, computeAccountValue, computeActiveEmodePairs, computeAssetUsdValue, computeBalanceUsdValue, computeBaseInterestRate, computeClaimedEmissions, computeEmodeImpacts, computeFreeCollateral, computeFreeCollateralLegacy, computeHealthAccountMetas, computeHealthCheckAccounts, computeHealthComponents, computeHealthComponentsLegacy, computeHealthComponentsWithoutBiasLegacy, computeInterestRates, computeLiabilityUsdValue, computeLoopingParams, computeMaxLeverage, computeNetApy, computeQuantity, computeQuantityUi, computeRemainingCapacity, computeTotalOutstandingEmissions, computeTvl, computeUsdValue, computeUtilizationRate, confirmTransaction, crankPythOracleIx, createLendrAccountTx, createUpdateFeedIx, decodeAccountRaw, decodeBankRaw, dtoToBalance, dtoToBank, dtoToBankConfig, dtoToBankConfigRaw, dtoToBankRaw, dtoToEmodeSettings, dtoToEmodeSettingsRaw, dtoToGroup, dtoToHealthCache, dtoToInterestRateConfig, dtoToLendrAccount, dtoToOraclePrice, dtoToValidatorStakeGroup, emodeSettingsRawToDto, extractPythOracleKeys, feedIdToString, fetchLendrAccountAddresses, fetchLendrAccountData, fetchMultipleBanks, fetchNativeStakeAccounts, fetchOracleData, fetchPythOracleData, fetchStakeAccount, fetchStakePoolActiveStates, fetchStakePoolMev, fetchSwbOracleData, findOracleKey, findPythPushOracleAddress, freezeBankConfigIx, getActiveAccountFlags, getActiveEmodeEntryFlags, getActiveEmodeFlags, getActiveHealthCacheFlags, getActiveStaleBanks, getAssetQuantity, getAssetShares, getAssetWeight, getBalanceUsdValueWithPriceBias, getBankVaultAuthority, getBankVaultSeeds, getConfig, getConfigPda, getHealthCacheStatusDescription, getLiabilityQuantity, getLiabilityShares, getLiabilityWeight, getPrice, getPriceFeedAccountForProgram, getPriceWithConfidence, getTotalAssetQuantity, getTotalLiabilityQuantity, getTreasuryPda, groupToDto, hasAccountFlag, hasEmodeEntryFlag, hasEmodeFlag, hasHealthCacheFlag, healthCacheToDto, instructions_default as instructions, isOracleSetupSupported, isWeightedPrice, lendrAccountToDto, makeAddPermissionlessStakedBankIx, makeBundleTipIx, makePoolAddBankIx, makePoolConfigureBankIx, makePriorityFeeIx, makePriorityFeeMicroIx, makePulseHealthIx, makeTxPriorityIx, makeUnwrapSolIx, makeVersionedTransaction, makeWrapSolIxs, metadataSchema, oraclePriceToDto, parseBalanceRaw, parseBankConfigRaw, parseBankRaw, parseEmodeSettingsRaw, parseEmodeTag, parseErrorFromLogs, parseLendrAccountRaw, parseOperationalState, parseOracleSetup, parseOraclePriceData as parsePriceInfo, parseRiskTier, parseTransactionError, processTransactions, serializeBankConfigOpt, serializeOperationalState, serializeOracleSetup, serializeOracleSetupToIndex, serializeRiskTier, simulateAccountHealthCache, simulateAccountHealthCacheWithFallback, simulateTransactions, toBankConfigDto, toBankDto, toEmodeSettingsDto, toInterestRateConfigDto, validatorStakeGroupToDto, vendor_exports as vendor };
25706
25763
  //# sourceMappingURL=index.js.map