@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/chunk-BaU5PcSi.js +28 -0
- package/dist/common/index.cjs +1 -1
- package/dist/common/index.d.cts +1 -1
- package/dist/common/index.d.ts +1 -1
- package/dist/common/index.js +1 -1
- package/dist/{common-ivGgLPrv.js → common-BDgJX75H.js} +92 -60
- package/dist/common-BDgJX75H.js.map +1 -0
- package/dist/{common-DPdmGMEV.cjs → common-C1TNbOrw.cjs} +111 -58
- package/dist/{index-BKemuNnu.d.ts → index-BoDaAGQH.d.ts} +35 -35
- package/dist/index-BoDaAGQH.d.ts.map +1 -0
- package/dist/{index-TJsA7g_H.d.cts → index-yftX6Mhj.d.cts} +35 -35
- package/dist/index-yftX6Mhj.d.cts.map +1 -0
- package/dist/index.cjs +550 -493
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +551 -494
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-Cl8Af3a2.js +0 -11
- package/dist/common-ivGgLPrv.js.map +0 -1
- package/dist/index-BKemuNnu.d.ts.map +0 -1
- package/dist/index-TJsA7g_H.d.cts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_common = require('./common-
|
|
1
|
+
const require_common = require('./common-C1TNbOrw.cjs');
|
|
2
2
|
const __coral_xyz_anchor = require_common.__toESM(require("@coral-xyz/anchor"));
|
|
3
3
|
const __solana_spl_token = require_common.__toESM(require("@solana/spl-token"));
|
|
4
4
|
const __solana_web3_js = require_common.__toESM(require("@solana/web3.js"));
|
|
@@ -229,6 +229,7 @@ var FogoMetadataFetcher = class {
|
|
|
229
229
|
|
|
230
230
|
//#endregion
|
|
231
231
|
//#region src/config.ts
|
|
232
|
+
require_common.init_constants();
|
|
232
233
|
function getConfig({ environment = "production", overrides } = {}) {
|
|
233
234
|
return {
|
|
234
235
|
environment,
|
|
@@ -9880,6 +9881,7 @@ const LENDR_IDL = lendr_0_1_6_default;
|
|
|
9880
9881
|
|
|
9881
9882
|
//#endregion
|
|
9882
9883
|
//#region src/errors.ts
|
|
9884
|
+
require_common.init_constants();
|
|
9883
9885
|
let ProcessTransactionErrorType = /* @__PURE__ */ function(ProcessTransactionErrorType$1) {
|
|
9884
9886
|
ProcessTransactionErrorType$1[ProcessTransactionErrorType$1["TransactionBuildingError"] = 0] = "TransactionBuildingError";
|
|
9885
9887
|
ProcessTransactionErrorType$1[ProcessTransactionErrorType$1["TransactionSendingError"] = 1] = "TransactionSendingError";
|
|
@@ -10485,6 +10487,7 @@ let AccountType = /* @__PURE__ */ function(AccountType$2) {
|
|
|
10485
10487
|
|
|
10486
10488
|
//#endregion
|
|
10487
10489
|
//#region src/services/bank/utils/deserialize.utils.ts
|
|
10490
|
+
require_common.init_constants();
|
|
10488
10491
|
function decodeBankRaw(encoded, idl) {
|
|
10489
10492
|
const coder = new __coral_xyz_anchor.BorshCoder(idl);
|
|
10490
10493
|
return coder.accounts.decode(AccountType.Bank, encoded);
|
|
@@ -11150,554 +11153,576 @@ const getStakeAccount = (data) => {
|
|
|
11150
11153
|
|
|
11151
11154
|
//#endregion
|
|
11152
11155
|
//#region src/vendor/single-spl-pool/index.ts
|
|
11153
|
-
var
|
|
11154
|
-
|
|
11155
|
-
|
|
11156
|
-
|
|
11157
|
-
|
|
11158
|
-
|
|
11159
|
-
|
|
11160
|
-
|
|
11161
|
-
|
|
11162
|
-
|
|
11163
|
-
|
|
11164
|
-
|
|
11165
|
-
|
|
11166
|
-
|
|
11167
|
-
|
|
11168
|
-
|
|
11169
|
-
|
|
11170
|
-
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
|
|
11175
|
-
|
|
11176
|
-
|
|
11177
|
-
|
|
11178
|
-
|
|
11179
|
-
|
|
11180
|
-
|
|
11181
|
-
|
|
11182
|
-
|
|
11183
|
-
|
|
11184
|
-
|
|
11185
|
-
|
|
11186
|
-
|
|
11187
|
-
|
|
11188
|
-
|
|
11189
|
-
|
|
11190
|
-
|
|
11191
|
-
|
|
11192
|
-
|
|
11193
|
-
|
|
11194
|
-
|
|
11195
|
-
|
|
11196
|
-
|
|
11197
|
-
|
|
11198
|
-
|
|
11199
|
-
|
|
11200
|
-
|
|
11201
|
-
|
|
11202
|
-
|
|
11203
|
-
|
|
11204
|
-
|
|
11205
|
-
|
|
11206
|
-
|
|
11207
|
-
|
|
11208
|
-
|
|
11209
|
-
|
|
11210
|
-
|
|
11211
|
-
|
|
11212
|
-
|
|
11213
|
-
|
|
11214
|
-
|
|
11215
|
-
|
|
11216
|
-
|
|
11217
|
-
|
|
11218
|
-
|
|
11219
|
-
|
|
11220
|
-
|
|
11221
|
-
|
|
11222
|
-
|
|
11223
|
-
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
|
-
|
|
11228
|
-
|
|
11229
|
-
|
|
11230
|
-
|
|
11231
|
-
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
|
|
11238
|
-
|
|
11239
|
-
|
|
11240
|
-
|
|
11241
|
-
|
|
11242
|
-
|
|
11243
|
-
|
|
11244
|
-
|
|
11245
|
-
|
|
11246
|
-
|
|
11247
|
-
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
11251
|
-
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
11255
|
-
|
|
11256
|
-
|
|
11257
|
-
|
|
11258
|
-
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
|
|
11273
|
-
|
|
11274
|
-
|
|
11275
|
-
|
|
11276
|
-
|
|
11277
|
-
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
|
|
11294
|
-
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
|
|
11299
|
-
|
|
11300
|
-
|
|
11301
|
-
|
|
11302
|
-
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11316
|
-
|
|
11317
|
-
|
|
11318
|
-
|
|
11319
|
-
|
|
11320
|
-
|
|
11321
|
-
|
|
11322
|
-
|
|
11323
|
-
|
|
11324
|
-
|
|
11325
|
-
|
|
11326
|
-
|
|
11327
|
-
|
|
11328
|
-
|
|
11329
|
-
|
|
11330
|
-
|
|
11331
|
-
|
|
11332
|
-
|
|
11333
|
-
|
|
11334
|
-
|
|
11335
|
-
|
|
11336
|
-
|
|
11337
|
-
|
|
11338
|
-
|
|
11156
|
+
var single_spl_pool_exports = {};
|
|
11157
|
+
require_common.__export(single_spl_pool_exports, {
|
|
11158
|
+
SinglePoolInstruction: () => SinglePoolInstruction,
|
|
11159
|
+
createAccountIx: () => createAccountIx,
|
|
11160
|
+
createPoolOnrampIx: () => createPoolOnrampIx,
|
|
11161
|
+
findMplMetadataAddress: () => findMplMetadataAddress,
|
|
11162
|
+
findPoolAddress: () => findPoolAddress,
|
|
11163
|
+
findPoolMintAddress: () => findPoolMintAddress,
|
|
11164
|
+
findPoolMintAddressByVoteAccount: () => findPoolMintAddressByVoteAccount,
|
|
11165
|
+
findPoolMintAuthorityAddress: () => findPoolMintAuthorityAddress,
|
|
11166
|
+
findPoolMplAuthorityAddress: () => findPoolMplAuthorityAddress,
|
|
11167
|
+
findPoolOnRampAddress: () => findPoolOnRampAddress,
|
|
11168
|
+
findPoolStakeAddress: () => findPoolStakeAddress,
|
|
11169
|
+
findPoolStakeAuthorityAddress: () => findPoolStakeAuthorityAddress,
|
|
11170
|
+
initializeStakedPoolIxs: () => initializeStakedPoolIxs,
|
|
11171
|
+
initializeStakedPoolTx: () => initializeStakedPoolTx,
|
|
11172
|
+
replenishPoolIx: () => replenishPoolIx
|
|
11173
|
+
});
|
|
11174
|
+
async function initializeStakedPoolTx(connection, payer, voteAccountAddress) {
|
|
11175
|
+
const instructions$3 = await initializeStakedPoolIxs(connection, payer, voteAccountAddress);
|
|
11176
|
+
const tx = new __solana_web3_js.Transaction().add(...instructions$3);
|
|
11177
|
+
return tx;
|
|
11178
|
+
}
|
|
11179
|
+
async function initializeStakedPoolIxs(connection, payer, voteAccountAddress) {
|
|
11180
|
+
const poolAddress = findPoolAddress(voteAccountAddress);
|
|
11181
|
+
const stakeAddress = findPoolStakeAddress(poolAddress);
|
|
11182
|
+
const mintAddress = findPoolMintAddress(poolAddress);
|
|
11183
|
+
const onRampAddress = findPoolOnRampAddress(poolAddress);
|
|
11184
|
+
const [poolRent, stakeRent, mintRent, minimumDelegationObj] = await Promise.all([
|
|
11185
|
+
connection.getMinimumBalanceForRentExemption(Number(SINGLE_POOL_ACCOUNT_SIZE), "confirmed"),
|
|
11186
|
+
connection.getMinimumBalanceForRentExemption(Number(STAKE_ACCOUNT_SIZE), "confirmed"),
|
|
11187
|
+
connection.getMinimumBalanceForRentExemption(Number(MINT_SIZE), "confirmed"),
|
|
11188
|
+
connection.getStakeMinimumDelegation()
|
|
11189
|
+
]);
|
|
11190
|
+
const minimumDelegation = minimumDelegationObj.value;
|
|
11191
|
+
const instructions$3 = [];
|
|
11192
|
+
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
11193
|
+
fromPubkey: payer,
|
|
11194
|
+
toPubkey: poolAddress,
|
|
11195
|
+
lamports: poolRent
|
|
11196
|
+
}));
|
|
11197
|
+
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
11198
|
+
fromPubkey: payer,
|
|
11199
|
+
toPubkey: stakeAddress,
|
|
11200
|
+
lamports: stakeRent + minimumDelegation + __solana_web3_js.LAMPORTS_PER_SOL * 1
|
|
11201
|
+
}));
|
|
11202
|
+
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
11203
|
+
fromPubkey: payer,
|
|
11204
|
+
toPubkey: onRampAddress,
|
|
11205
|
+
lamports: stakeRent
|
|
11206
|
+
}));
|
|
11207
|
+
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
11208
|
+
fromPubkey: payer,
|
|
11209
|
+
toPubkey: mintAddress,
|
|
11210
|
+
lamports: mintRent
|
|
11211
|
+
}));
|
|
11212
|
+
instructions$3.push(SinglePoolInstruction.initializePool(voteAccountAddress));
|
|
11213
|
+
instructions$3.push(SinglePoolInstruction.initializeOnRamp(poolAddress));
|
|
11214
|
+
instructions$3.push(await SinglePoolInstruction.createTokenMetadata(poolAddress, payer));
|
|
11215
|
+
return instructions$3;
|
|
11216
|
+
}
|
|
11217
|
+
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;
|
|
11218
|
+
var init_single_spl_pool = require_common.__esm({ "src/vendor/single-spl-pool/index.ts"() {
|
|
11219
|
+
require_common.init_constants();
|
|
11220
|
+
SinglePoolInstructionType = /* @__PURE__ */ function(SinglePoolInstructionType$1) {
|
|
11221
|
+
SinglePoolInstructionType$1[SinglePoolInstructionType$1["InitializePool"] = 0] = "InitializePool";
|
|
11222
|
+
SinglePoolInstructionType$1[SinglePoolInstructionType$1["ReplenishPool"] = 1] = "ReplenishPool";
|
|
11223
|
+
SinglePoolInstructionType$1[SinglePoolInstructionType$1["DepositStake"] = 2] = "DepositStake";
|
|
11224
|
+
SinglePoolInstructionType$1[SinglePoolInstructionType$1["WithdrawStake"] = 3] = "WithdrawStake";
|
|
11225
|
+
SinglePoolInstructionType$1[SinglePoolInstructionType$1["CreateTokenMetadata"] = 4] = "CreateTokenMetadata";
|
|
11226
|
+
SinglePoolInstructionType$1[SinglePoolInstructionType$1["UpdateTokenMetadata"] = 5] = "UpdateTokenMetadata";
|
|
11227
|
+
SinglePoolInstructionType$1[SinglePoolInstructionType$1["InitializeOnRamp"] = 6] = "InitializeOnRamp";
|
|
11228
|
+
return SinglePoolInstructionType$1;
|
|
11229
|
+
}(SinglePoolInstructionType || {});
|
|
11230
|
+
SinglePoolInstruction = {
|
|
11231
|
+
initializePool: (voteAccount) => {
|
|
11232
|
+
const pool = findPoolAddress(voteAccount);
|
|
11233
|
+
const stake = findPoolStakeAddress(pool);
|
|
11234
|
+
const mint = findPoolMintAddress(pool);
|
|
11235
|
+
const stakeAuthority = findPoolStakeAuthorityAddress(pool);
|
|
11236
|
+
const mintAuthority = findPoolMintAuthorityAddress(pool);
|
|
11237
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
11238
|
+
{
|
|
11239
|
+
pubkey: voteAccount,
|
|
11240
|
+
isSigner: false,
|
|
11241
|
+
isWritable: false
|
|
11242
|
+
},
|
|
11243
|
+
{
|
|
11244
|
+
pubkey: pool,
|
|
11245
|
+
isSigner: false,
|
|
11246
|
+
isWritable: true
|
|
11247
|
+
},
|
|
11248
|
+
{
|
|
11249
|
+
pubkey: stake,
|
|
11250
|
+
isSigner: false,
|
|
11251
|
+
isWritable: true
|
|
11252
|
+
},
|
|
11253
|
+
{
|
|
11254
|
+
pubkey: mint,
|
|
11255
|
+
isSigner: false,
|
|
11256
|
+
isWritable: true
|
|
11257
|
+
},
|
|
11258
|
+
{
|
|
11259
|
+
pubkey: stakeAuthority,
|
|
11260
|
+
isSigner: false,
|
|
11261
|
+
isWritable: false
|
|
11262
|
+
},
|
|
11263
|
+
{
|
|
11264
|
+
pubkey: mintAuthority,
|
|
11265
|
+
isSigner: false,
|
|
11266
|
+
isWritable: false
|
|
11267
|
+
},
|
|
11268
|
+
{
|
|
11269
|
+
pubkey: require_common.SYSVAR_RENT_ID,
|
|
11270
|
+
isSigner: false,
|
|
11271
|
+
isWritable: false
|
|
11272
|
+
},
|
|
11273
|
+
{
|
|
11274
|
+
pubkey: require_common.SYSVAR_CLOCK_ID,
|
|
11275
|
+
isSigner: false,
|
|
11276
|
+
isWritable: false
|
|
11277
|
+
},
|
|
11278
|
+
{
|
|
11279
|
+
pubkey: require_common.SYSVAR_STAKE_HISTORY_ID,
|
|
11280
|
+
isSigner: false,
|
|
11281
|
+
isWritable: false
|
|
11282
|
+
},
|
|
11283
|
+
{
|
|
11284
|
+
pubkey: __solana_web3_js.STAKE_CONFIG_ID,
|
|
11285
|
+
isSigner: false,
|
|
11286
|
+
isWritable: false
|
|
11287
|
+
},
|
|
11288
|
+
{
|
|
11289
|
+
pubkey: require_common.SYSTEM_PROGRAM_ID,
|
|
11290
|
+
isSigner: false,
|
|
11291
|
+
isWritable: false
|
|
11292
|
+
},
|
|
11293
|
+
{
|
|
11294
|
+
pubkey: __solana_spl_token.TOKEN_PROGRAM_ID,
|
|
11295
|
+
isSigner: false,
|
|
11296
|
+
isWritable: false
|
|
11297
|
+
},
|
|
11298
|
+
{
|
|
11299
|
+
pubkey: require_common.STAKE_PROGRAM_ID,
|
|
11300
|
+
isSigner: false,
|
|
11301
|
+
isWritable: false
|
|
11302
|
+
}
|
|
11303
|
+
], Buffer.from([SinglePoolInstructionType.InitializePool]));
|
|
11304
|
+
},
|
|
11305
|
+
initializeOnRamp: (pool) => {
|
|
11306
|
+
const onRamp = findPoolOnRampAddress(pool);
|
|
11307
|
+
const stakeAuthority = findPoolStakeAuthorityAddress(pool);
|
|
11308
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
11309
|
+
{
|
|
11310
|
+
pubkey: pool,
|
|
11311
|
+
isSigner: false,
|
|
11312
|
+
isWritable: false
|
|
11313
|
+
},
|
|
11314
|
+
{
|
|
11315
|
+
pubkey: onRamp,
|
|
11316
|
+
isSigner: false,
|
|
11317
|
+
isWritable: true
|
|
11318
|
+
},
|
|
11319
|
+
{
|
|
11320
|
+
pubkey: stakeAuthority,
|
|
11321
|
+
isSigner: false,
|
|
11322
|
+
isWritable: false
|
|
11323
|
+
},
|
|
11324
|
+
{
|
|
11325
|
+
pubkey: require_common.SYSVAR_RENT_ID,
|
|
11326
|
+
isSigner: false,
|
|
11327
|
+
isWritable: false
|
|
11328
|
+
},
|
|
11329
|
+
{
|
|
11330
|
+
pubkey: require_common.SYSTEM_PROGRAM_ID,
|
|
11331
|
+
isSigner: false,
|
|
11332
|
+
isWritable: false
|
|
11333
|
+
},
|
|
11334
|
+
{
|
|
11335
|
+
pubkey: require_common.STAKE_PROGRAM_ID,
|
|
11336
|
+
isSigner: false,
|
|
11337
|
+
isWritable: false
|
|
11338
|
+
}
|
|
11339
|
+
], Buffer.from([SinglePoolInstructionType.InitializeOnRamp]));
|
|
11340
|
+
},
|
|
11341
|
+
depositStake: async (pool, userStakeAccount, userTokenAccount, userLamportAccount) => {
|
|
11342
|
+
const stake = findPoolStakeAddress(pool);
|
|
11343
|
+
const mint = findPoolMintAddress(pool);
|
|
11344
|
+
const stakeAuthority = findPoolStakeAuthorityAddress(pool);
|
|
11345
|
+
const mintAuthority = findPoolMintAuthorityAddress(pool);
|
|
11346
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
11347
|
+
{
|
|
11348
|
+
pubkey: pool,
|
|
11349
|
+
isSigner: false,
|
|
11350
|
+
isWritable: false
|
|
11351
|
+
},
|
|
11352
|
+
{
|
|
11353
|
+
pubkey: stake,
|
|
11354
|
+
isSigner: false,
|
|
11355
|
+
isWritable: true
|
|
11356
|
+
},
|
|
11357
|
+
{
|
|
11358
|
+
pubkey: mint,
|
|
11359
|
+
isSigner: false,
|
|
11360
|
+
isWritable: true
|
|
11361
|
+
},
|
|
11362
|
+
{
|
|
11363
|
+
pubkey: stakeAuthority,
|
|
11364
|
+
isSigner: false,
|
|
11365
|
+
isWritable: false
|
|
11366
|
+
},
|
|
11367
|
+
{
|
|
11368
|
+
pubkey: mintAuthority,
|
|
11369
|
+
isSigner: false,
|
|
11370
|
+
isWritable: false
|
|
11371
|
+
},
|
|
11372
|
+
{
|
|
11373
|
+
pubkey: userStakeAccount,
|
|
11374
|
+
isSigner: false,
|
|
11375
|
+
isWritable: true
|
|
11376
|
+
},
|
|
11377
|
+
{
|
|
11378
|
+
pubkey: userTokenAccount,
|
|
11379
|
+
isSigner: false,
|
|
11380
|
+
isWritable: true
|
|
11381
|
+
},
|
|
11382
|
+
{
|
|
11383
|
+
pubkey: userLamportAccount,
|
|
11384
|
+
isSigner: false,
|
|
11385
|
+
isWritable: true
|
|
11386
|
+
},
|
|
11387
|
+
{
|
|
11388
|
+
pubkey: require_common.SYSVAR_CLOCK_ID,
|
|
11389
|
+
isSigner: false,
|
|
11390
|
+
isWritable: false
|
|
11391
|
+
},
|
|
11392
|
+
{
|
|
11393
|
+
pubkey: require_common.SYSVAR_STAKE_HISTORY_ID,
|
|
11394
|
+
isSigner: false,
|
|
11395
|
+
isWritable: false
|
|
11396
|
+
},
|
|
11397
|
+
{
|
|
11398
|
+
pubkey: __solana_spl_token.TOKEN_PROGRAM_ID,
|
|
11399
|
+
isSigner: false,
|
|
11400
|
+
isWritable: false
|
|
11401
|
+
},
|
|
11402
|
+
{
|
|
11403
|
+
pubkey: require_common.STAKE_PROGRAM_ID,
|
|
11404
|
+
isSigner: false,
|
|
11405
|
+
isWritable: false
|
|
11406
|
+
}
|
|
11407
|
+
], Buffer.from([SinglePoolInstructionType.DepositStake]));
|
|
11408
|
+
},
|
|
11409
|
+
withdrawStake: async (pool, userStakeAccount, userStakeAuthority, userTokenAccount, tokenAmount) => {
|
|
11410
|
+
const stake = findPoolStakeAddress(pool);
|
|
11411
|
+
const mint = findPoolMintAddress(pool);
|
|
11412
|
+
const stakeAuthority = findPoolStakeAuthorityAddress(pool);
|
|
11413
|
+
const mintAuthority = findPoolMintAuthorityAddress(pool);
|
|
11414
|
+
const rawAmount = BigInt(tokenAmount.multipliedBy(1e9).toString());
|
|
11415
|
+
const data = Buffer.concat([
|
|
11416
|
+
Buffer.from([SinglePoolInstructionType.WithdrawStake]),
|
|
11417
|
+
userStakeAuthority.toBuffer(),
|
|
11418
|
+
Buffer.from(new bn_js.BN(rawAmount.toString()).toArray("le", 8))
|
|
11419
|
+
]);
|
|
11420
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
11421
|
+
{
|
|
11422
|
+
pubkey: pool,
|
|
11423
|
+
isSigner: false,
|
|
11424
|
+
isWritable: false
|
|
11425
|
+
},
|
|
11426
|
+
{
|
|
11427
|
+
pubkey: stake,
|
|
11428
|
+
isSigner: false,
|
|
11429
|
+
isWritable: true
|
|
11430
|
+
},
|
|
11431
|
+
{
|
|
11432
|
+
pubkey: mint,
|
|
11433
|
+
isSigner: false,
|
|
11434
|
+
isWritable: true
|
|
11435
|
+
},
|
|
11436
|
+
{
|
|
11437
|
+
pubkey: stakeAuthority,
|
|
11438
|
+
isSigner: false,
|
|
11439
|
+
isWritable: false
|
|
11440
|
+
},
|
|
11441
|
+
{
|
|
11442
|
+
pubkey: mintAuthority,
|
|
11443
|
+
isSigner: false,
|
|
11444
|
+
isWritable: false
|
|
11445
|
+
},
|
|
11446
|
+
{
|
|
11447
|
+
pubkey: userStakeAccount,
|
|
11448
|
+
isSigner: false,
|
|
11449
|
+
isWritable: true
|
|
11450
|
+
},
|
|
11451
|
+
{
|
|
11452
|
+
pubkey: userTokenAccount,
|
|
11453
|
+
isSigner: false,
|
|
11454
|
+
isWritable: true
|
|
11455
|
+
},
|
|
11456
|
+
{
|
|
11457
|
+
pubkey: require_common.SYSVAR_CLOCK_ID,
|
|
11458
|
+
isSigner: false,
|
|
11459
|
+
isWritable: false
|
|
11460
|
+
},
|
|
11461
|
+
{
|
|
11462
|
+
pubkey: __solana_spl_token.TOKEN_PROGRAM_ID,
|
|
11463
|
+
isSigner: false,
|
|
11464
|
+
isWritable: false
|
|
11465
|
+
},
|
|
11466
|
+
{
|
|
11467
|
+
pubkey: require_common.STAKE_PROGRAM_ID,
|
|
11468
|
+
isSigner: false,
|
|
11469
|
+
isWritable: false
|
|
11470
|
+
}
|
|
11471
|
+
], data);
|
|
11472
|
+
},
|
|
11473
|
+
createTokenMetadata: async (pool, payer) => {
|
|
11474
|
+
const mint = findPoolMintAddress(pool);
|
|
11475
|
+
const [mintAuthority, mplAuthority, mplMetadata] = await Promise.all([
|
|
11476
|
+
findPoolMintAuthorityAddress(pool),
|
|
11477
|
+
findPoolMplAuthorityAddress(pool),
|
|
11478
|
+
findMplMetadataAddress(mint)
|
|
11479
|
+
]);
|
|
11480
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
11481
|
+
{
|
|
11482
|
+
pubkey: pool,
|
|
11483
|
+
isSigner: false,
|
|
11484
|
+
isWritable: false
|
|
11485
|
+
},
|
|
11486
|
+
{
|
|
11487
|
+
pubkey: mint,
|
|
11488
|
+
isSigner: false,
|
|
11489
|
+
isWritable: false
|
|
11490
|
+
},
|
|
11491
|
+
{
|
|
11492
|
+
pubkey: mintAuthority,
|
|
11493
|
+
isSigner: false,
|
|
11494
|
+
isWritable: false
|
|
11495
|
+
},
|
|
11496
|
+
{
|
|
11497
|
+
pubkey: mplAuthority,
|
|
11498
|
+
isSigner: false,
|
|
11499
|
+
isWritable: false
|
|
11500
|
+
},
|
|
11501
|
+
{
|
|
11502
|
+
pubkey: payer,
|
|
11503
|
+
isSigner: true,
|
|
11504
|
+
isWritable: true
|
|
11505
|
+
},
|
|
11506
|
+
{
|
|
11507
|
+
pubkey: mplMetadata,
|
|
11508
|
+
isSigner: false,
|
|
11509
|
+
isWritable: true
|
|
11510
|
+
},
|
|
11511
|
+
{
|
|
11512
|
+
pubkey: require_common.MPL_METADATA_PROGRAM_ID,
|
|
11513
|
+
isSigner: false,
|
|
11514
|
+
isWritable: false
|
|
11515
|
+
},
|
|
11516
|
+
{
|
|
11517
|
+
pubkey: require_common.SYSTEM_PROGRAM_ID,
|
|
11518
|
+
isSigner: false,
|
|
11519
|
+
isWritable: false
|
|
11520
|
+
}
|
|
11521
|
+
], Buffer.from([SinglePoolInstructionType.CreateTokenMetadata]));
|
|
11522
|
+
},
|
|
11523
|
+
updateTokenMetadata: async (voteAccount, authorizedWithdrawer, tokenName, tokenSymbol, tokenUri = "") => {
|
|
11524
|
+
if (tokenName.length > 32) {
|
|
11525
|
+
throw new Error("maximum token name length is 32 characters");
|
|
11339
11526
|
}
|
|
11340
|
-
|
|
11341
|
-
|
|
11342
|
-
|
|
11343
|
-
|
|
11344
|
-
|
|
11345
|
-
|
|
11346
|
-
|
|
11347
|
-
|
|
11527
|
+
if (tokenSymbol.length > 10) {
|
|
11528
|
+
throw new Error("maximum token symbol length is 10 characters");
|
|
11529
|
+
}
|
|
11530
|
+
if (tokenUri.length > 200) {
|
|
11531
|
+
throw new Error("maximum token uri length is 200 characters");
|
|
11532
|
+
}
|
|
11533
|
+
const pool = findPoolAddress(voteAccount);
|
|
11534
|
+
const [mint, mplAuthority] = await Promise.all([findPoolMintAddress(pool), findPoolMplAuthorityAddress(pool)]);
|
|
11535
|
+
const mplMetadata = await findMplMetadataAddress(mint);
|
|
11536
|
+
const data = Buffer.concat([
|
|
11537
|
+
Buffer.from([SinglePoolInstructionType.UpdateTokenMetadata]),
|
|
11538
|
+
Buffer.from(new Uint32Array([tokenName.length]).buffer),
|
|
11539
|
+
Buffer.from(tokenName),
|
|
11540
|
+
Buffer.from(new Uint32Array([tokenSymbol.length]).buffer),
|
|
11541
|
+
Buffer.from(tokenSymbol),
|
|
11542
|
+
Buffer.from(new Uint32Array([tokenUri.length]).buffer),
|
|
11543
|
+
Buffer.from(tokenUri)
|
|
11544
|
+
]);
|
|
11545
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
11546
|
+
{
|
|
11547
|
+
pubkey: voteAccount,
|
|
11548
|
+
isSigner: false,
|
|
11549
|
+
isWritable: false
|
|
11550
|
+
},
|
|
11551
|
+
{
|
|
11552
|
+
pubkey: pool,
|
|
11553
|
+
isSigner: false,
|
|
11554
|
+
isWritable: false
|
|
11555
|
+
},
|
|
11556
|
+
{
|
|
11557
|
+
pubkey: mplAuthority,
|
|
11558
|
+
isSigner: false,
|
|
11559
|
+
isWritable: false
|
|
11560
|
+
},
|
|
11561
|
+
{
|
|
11562
|
+
pubkey: authorizedWithdrawer,
|
|
11563
|
+
isSigner: true,
|
|
11564
|
+
isWritable: false
|
|
11565
|
+
},
|
|
11566
|
+
{
|
|
11567
|
+
pubkey: mplMetadata,
|
|
11568
|
+
isSigner: false,
|
|
11569
|
+
isWritable: true
|
|
11570
|
+
},
|
|
11571
|
+
{
|
|
11572
|
+
pubkey: require_common.MPL_METADATA_PROGRAM_ID,
|
|
11573
|
+
isSigner: false,
|
|
11574
|
+
isWritable: false
|
|
11575
|
+
}
|
|
11576
|
+
], data);
|
|
11577
|
+
}
|
|
11578
|
+
};
|
|
11579
|
+
createTransactionInstruction = (programId, keys, data) => {
|
|
11580
|
+
return {
|
|
11581
|
+
programId,
|
|
11582
|
+
keys,
|
|
11583
|
+
data
|
|
11584
|
+
};
|
|
11585
|
+
};
|
|
11586
|
+
findPda = (baseAddress, prefix, programId = require_common.SINGLE_POOL_PROGRAM_ID) => {
|
|
11587
|
+
const [pda] = __solana_web3_js.PublicKey.findProgramAddressSync([Buffer.from(prefix), baseAddress.toBuffer()], programId);
|
|
11588
|
+
return pda;
|
|
11589
|
+
};
|
|
11590
|
+
findPoolMintAddressByVoteAccount = (voteAccountAddress) => findPda(findPoolAddress(voteAccountAddress), "mint");
|
|
11591
|
+
findPoolAddress = (voteAccountAddress) => findPda(voteAccountAddress, "pool");
|
|
11592
|
+
findPoolMintAddress = (poolAddress) => findPda(poolAddress, "mint");
|
|
11593
|
+
findPoolStakeAddress = (poolAddress) => findPda(poolAddress, "stake");
|
|
11594
|
+
findPoolStakeAuthorityAddress = (poolAddress) => findPda(poolAddress, "stake_authority");
|
|
11595
|
+
findPoolMintAuthorityAddress = (poolAddress) => findPda(poolAddress, "mint_authority");
|
|
11596
|
+
findPoolMplAuthorityAddress = (poolAddress) => findPda(poolAddress, "mpl_authority");
|
|
11597
|
+
findPoolOnRampAddress = (poolAddress) => findPda(poolAddress, "onramp");
|
|
11598
|
+
findMplMetadataAddress = async (poolMintAddress) => {
|
|
11599
|
+
const [pda] = __solana_web3_js.PublicKey.findProgramAddressSync([
|
|
11600
|
+
Buffer.from("metadata"),
|
|
11601
|
+
require_common.MPL_METADATA_PROGRAM_ID.toBuffer(),
|
|
11602
|
+
poolMintAddress.toBuffer()
|
|
11603
|
+
], require_common.MPL_METADATA_PROGRAM_ID);
|
|
11604
|
+
return pda;
|
|
11605
|
+
};
|
|
11606
|
+
SINGLE_POOL_ACCOUNT_SIZE = BigInt(33);
|
|
11607
|
+
STAKE_ACCOUNT_SIZE = BigInt(200);
|
|
11608
|
+
MINT_SIZE = BigInt(82);
|
|
11609
|
+
createAccountIx = (from, newAccount, lamports, space, programAddress) => {
|
|
11348
11610
|
const data = Buffer.concat([
|
|
11349
|
-
Buffer.from([
|
|
11350
|
-
|
|
11351
|
-
Buffer.from(new bn_js.BN(
|
|
11611
|
+
Buffer.from([0]),
|
|
11612
|
+
Buffer.from(new bn_js.BN(lamports).toArray("le", 8)),
|
|
11613
|
+
Buffer.from(new bn_js.BN(space).toArray("le", 8)),
|
|
11614
|
+
programAddress.toBuffer()
|
|
11352
11615
|
]);
|
|
11353
|
-
|
|
11616
|
+
const accounts$2 = [{
|
|
11617
|
+
pubkey: from,
|
|
11618
|
+
isSigner: true,
|
|
11619
|
+
isWritable: true
|
|
11620
|
+
}, {
|
|
11621
|
+
pubkey: newAccount,
|
|
11622
|
+
isSigner: true,
|
|
11623
|
+
isWritable: true
|
|
11624
|
+
}];
|
|
11625
|
+
return createTransactionInstruction(require_common.SYSTEM_PROGRAM_ID, accounts$2, data);
|
|
11626
|
+
};
|
|
11627
|
+
createPoolOnrampIx = (voteAccount) => {
|
|
11628
|
+
const poolAccount = findPoolAddress(voteAccount);
|
|
11629
|
+
const onRampAccount = findPoolOnRampAddress(poolAccount);
|
|
11630
|
+
const poolStakeAuthority = findPoolStakeAuthorityAddress(poolAccount);
|
|
11631
|
+
const keys = [
|
|
11354
11632
|
{
|
|
11355
|
-
pubkey:
|
|
11633
|
+
pubkey: poolAccount,
|
|
11356
11634
|
isSigner: false,
|
|
11357
11635
|
isWritable: false
|
|
11358
11636
|
},
|
|
11359
11637
|
{
|
|
11360
|
-
pubkey:
|
|
11361
|
-
isSigner: false,
|
|
11362
|
-
isWritable: true
|
|
11363
|
-
},
|
|
11364
|
-
{
|
|
11365
|
-
pubkey: mint,
|
|
11638
|
+
pubkey: onRampAccount,
|
|
11366
11639
|
isSigner: false,
|
|
11367
11640
|
isWritable: true
|
|
11368
11641
|
},
|
|
11369
11642
|
{
|
|
11370
|
-
pubkey:
|
|
11643
|
+
pubkey: poolStakeAuthority,
|
|
11371
11644
|
isSigner: false,
|
|
11372
11645
|
isWritable: false
|
|
11373
11646
|
},
|
|
11374
11647
|
{
|
|
11375
|
-
pubkey:
|
|
11376
|
-
isSigner: false,
|
|
11377
|
-
isWritable: false
|
|
11378
|
-
},
|
|
11379
|
-
{
|
|
11380
|
-
pubkey: userStakeAccount,
|
|
11381
|
-
isSigner: false,
|
|
11382
|
-
isWritable: true
|
|
11383
|
-
},
|
|
11384
|
-
{
|
|
11385
|
-
pubkey: userTokenAccount,
|
|
11386
|
-
isSigner: false,
|
|
11387
|
-
isWritable: true
|
|
11388
|
-
},
|
|
11389
|
-
{
|
|
11390
|
-
pubkey: require_common.SYSVAR_CLOCK_ID,
|
|
11648
|
+
pubkey: __solana_web3_js.SYSVAR_RENT_PUBKEY,
|
|
11391
11649
|
isSigner: false,
|
|
11392
11650
|
isWritable: false
|
|
11393
11651
|
},
|
|
11394
11652
|
{
|
|
11395
|
-
pubkey:
|
|
11653
|
+
pubkey: __solana_web3_js.SystemProgram.programId,
|
|
11396
11654
|
isSigner: false,
|
|
11397
11655
|
isWritable: false
|
|
11398
11656
|
},
|
|
11399
11657
|
{
|
|
11400
|
-
pubkey:
|
|
11658
|
+
pubkey: __solana_web3_js.StakeProgram.programId,
|
|
11401
11659
|
isSigner: false,
|
|
11402
11660
|
isWritable: false
|
|
11403
11661
|
}
|
|
11404
|
-
]
|
|
11405
|
-
|
|
11406
|
-
|
|
11407
|
-
|
|
11408
|
-
|
|
11409
|
-
|
|
11410
|
-
|
|
11411
|
-
|
|
11412
|
-
|
|
11413
|
-
|
|
11414
|
-
|
|
11415
|
-
|
|
11416
|
-
|
|
11417
|
-
|
|
11418
|
-
},
|
|
11662
|
+
];
|
|
11663
|
+
const data = Buffer.from(Uint8Array.of(6));
|
|
11664
|
+
return new __solana_web3_js.TransactionInstruction({
|
|
11665
|
+
keys,
|
|
11666
|
+
programId: require_common.SINGLE_POOL_PROGRAM_ID,
|
|
11667
|
+
data
|
|
11668
|
+
});
|
|
11669
|
+
};
|
|
11670
|
+
replenishPoolIx = (voteAccount) => {
|
|
11671
|
+
const poolAccount = findPoolAddress(voteAccount);
|
|
11672
|
+
const stakePool = findPoolStakeAddress(poolAccount);
|
|
11673
|
+
const onRampPool = findPoolOnRampAddress(poolAccount);
|
|
11674
|
+
const authority = findPoolStakeAuthorityAddress(poolAccount);
|
|
11675
|
+
const keys = [
|
|
11419
11676
|
{
|
|
11420
|
-
pubkey:
|
|
11677
|
+
pubkey: voteAccount,
|
|
11421
11678
|
isSigner: false,
|
|
11422
11679
|
isWritable: false
|
|
11423
11680
|
},
|
|
11424
11681
|
{
|
|
11425
|
-
pubkey:
|
|
11682
|
+
pubkey: poolAccount,
|
|
11426
11683
|
isSigner: false,
|
|
11427
11684
|
isWritable: false
|
|
11428
11685
|
},
|
|
11429
11686
|
{
|
|
11430
|
-
pubkey:
|
|
11687
|
+
pubkey: stakePool,
|
|
11431
11688
|
isSigner: false,
|
|
11432
|
-
isWritable: false
|
|
11433
|
-
},
|
|
11434
|
-
{
|
|
11435
|
-
pubkey: payer,
|
|
11436
|
-
isSigner: true,
|
|
11437
11689
|
isWritable: true
|
|
11438
11690
|
},
|
|
11439
11691
|
{
|
|
11440
|
-
pubkey:
|
|
11692
|
+
pubkey: onRampPool,
|
|
11441
11693
|
isSigner: false,
|
|
11442
11694
|
isWritable: true
|
|
11443
11695
|
},
|
|
11444
11696
|
{
|
|
11445
|
-
pubkey:
|
|
11697
|
+
pubkey: authority,
|
|
11446
11698
|
isSigner: false,
|
|
11447
11699
|
isWritable: false
|
|
11448
11700
|
},
|
|
11449
11701
|
{
|
|
11450
|
-
pubkey:
|
|
11451
|
-
isSigner: false,
|
|
11452
|
-
isWritable: false
|
|
11453
|
-
}
|
|
11454
|
-
], Buffer.from([SinglePoolInstructionType.CreateTokenMetadata]));
|
|
11455
|
-
},
|
|
11456
|
-
updateTokenMetadata: async (voteAccount, authorizedWithdrawer, tokenName, tokenSymbol, tokenUri = "") => {
|
|
11457
|
-
if (tokenName.length > 32) {
|
|
11458
|
-
throw new Error("maximum token name length is 32 characters");
|
|
11459
|
-
}
|
|
11460
|
-
if (tokenSymbol.length > 10) {
|
|
11461
|
-
throw new Error("maximum token symbol length is 10 characters");
|
|
11462
|
-
}
|
|
11463
|
-
if (tokenUri.length > 200) {
|
|
11464
|
-
throw new Error("maximum token uri length is 200 characters");
|
|
11465
|
-
}
|
|
11466
|
-
const pool = findPoolAddress(voteAccount);
|
|
11467
|
-
const [mint, mplAuthority] = await Promise.all([findPoolMintAddress(pool), findPoolMplAuthorityAddress(pool)]);
|
|
11468
|
-
const mplMetadata = await findMplMetadataAddress(mint);
|
|
11469
|
-
const data = Buffer.concat([
|
|
11470
|
-
Buffer.from([SinglePoolInstructionType.UpdateTokenMetadata]),
|
|
11471
|
-
Buffer.from(new Uint32Array([tokenName.length]).buffer),
|
|
11472
|
-
Buffer.from(tokenName),
|
|
11473
|
-
Buffer.from(new Uint32Array([tokenSymbol.length]).buffer),
|
|
11474
|
-
Buffer.from(tokenSymbol),
|
|
11475
|
-
Buffer.from(new Uint32Array([tokenUri.length]).buffer),
|
|
11476
|
-
Buffer.from(tokenUri)
|
|
11477
|
-
]);
|
|
11478
|
-
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
11479
|
-
{
|
|
11480
|
-
pubkey: voteAccount,
|
|
11702
|
+
pubkey: __solana_web3_js.SYSVAR_CLOCK_PUBKEY,
|
|
11481
11703
|
isSigner: false,
|
|
11482
11704
|
isWritable: false
|
|
11483
11705
|
},
|
|
11484
11706
|
{
|
|
11485
|
-
pubkey:
|
|
11707
|
+
pubkey: require_common.SYSVAR_STAKE_HISTORY_ID,
|
|
11486
11708
|
isSigner: false,
|
|
11487
11709
|
isWritable: false
|
|
11488
11710
|
},
|
|
11489
11711
|
{
|
|
11490
|
-
pubkey:
|
|
11712
|
+
pubkey: __solana_web3_js.STAKE_CONFIG_ID,
|
|
11491
11713
|
isSigner: false,
|
|
11492
11714
|
isWritable: false
|
|
11493
11715
|
},
|
|
11494
11716
|
{
|
|
11495
|
-
pubkey:
|
|
11496
|
-
isSigner: true,
|
|
11497
|
-
isWritable: false
|
|
11498
|
-
},
|
|
11499
|
-
{
|
|
11500
|
-
pubkey: mplMetadata,
|
|
11501
|
-
isSigner: false,
|
|
11502
|
-
isWritable: true
|
|
11503
|
-
},
|
|
11504
|
-
{
|
|
11505
|
-
pubkey: require_common.MPL_METADATA_PROGRAM_ID,
|
|
11717
|
+
pubkey: __solana_web3_js.StakeProgram.programId,
|
|
11506
11718
|
isSigner: false,
|
|
11507
11719
|
isWritable: false
|
|
11508
11720
|
}
|
|
11509
|
-
]
|
|
11510
|
-
|
|
11511
|
-
|
|
11512
|
-
const createTransactionInstruction = (programId, keys, data) => {
|
|
11513
|
-
return {
|
|
11514
|
-
programId,
|
|
11515
|
-
keys,
|
|
11516
|
-
data
|
|
11721
|
+
];
|
|
11722
|
+
const data = Buffer.from(Uint8Array.of(1));
|
|
11723
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, keys, data);
|
|
11517
11724
|
};
|
|
11518
|
-
};
|
|
11519
|
-
const findPda = (baseAddress, prefix, programId = require_common.SINGLE_POOL_PROGRAM_ID) => {
|
|
11520
|
-
const [pda] = __solana_web3_js.PublicKey.findProgramAddressSync([Buffer.from(prefix), baseAddress.toBuffer()], programId);
|
|
11521
|
-
return pda;
|
|
11522
|
-
};
|
|
11523
|
-
const findPoolMintAddressByVoteAccount = (voteAccountAddress) => findPda(findPoolAddress(voteAccountAddress), "mint");
|
|
11524
|
-
const findPoolAddress = (voteAccountAddress) => findPda(voteAccountAddress, "pool");
|
|
11525
|
-
const findPoolMintAddress = (poolAddress) => findPda(poolAddress, "mint");
|
|
11526
|
-
const findPoolStakeAddress = (poolAddress) => findPda(poolAddress, "stake");
|
|
11527
|
-
const findPoolStakeAuthorityAddress = (poolAddress) => findPda(poolAddress, "stake_authority");
|
|
11528
|
-
const findPoolMintAuthorityAddress = (poolAddress) => findPda(poolAddress, "mint_authority");
|
|
11529
|
-
const findPoolMplAuthorityAddress = (poolAddress) => findPda(poolAddress, "mpl_authority");
|
|
11530
|
-
const findPoolOnRampAddress = (poolAddress) => findPda(poolAddress, "onramp");
|
|
11531
|
-
const findMplMetadataAddress = async (poolMintAddress) => {
|
|
11532
|
-
const [pda] = __solana_web3_js.PublicKey.findProgramAddressSync([
|
|
11533
|
-
Buffer.from("metadata"),
|
|
11534
|
-
require_common.MPL_METADATA_PROGRAM_ID.toBuffer(),
|
|
11535
|
-
poolMintAddress.toBuffer()
|
|
11536
|
-
], require_common.MPL_METADATA_PROGRAM_ID);
|
|
11537
|
-
return pda;
|
|
11538
|
-
};
|
|
11539
|
-
const SINGLE_POOL_ACCOUNT_SIZE = BigInt(33);
|
|
11540
|
-
const STAKE_ACCOUNT_SIZE = BigInt(200);
|
|
11541
|
-
const MINT_SIZE = BigInt(82);
|
|
11542
|
-
async function initializeStakedPoolTx(connection, payer, voteAccountAddress) {
|
|
11543
|
-
const instructions$3 = await initializeStakedPoolIxs(connection, payer, voteAccountAddress);
|
|
11544
|
-
const tx = new __solana_web3_js.Transaction().add(...instructions$3);
|
|
11545
|
-
return tx;
|
|
11546
|
-
}
|
|
11547
|
-
async function initializeStakedPoolIxs(connection, payer, voteAccountAddress) {
|
|
11548
|
-
const poolAddress = findPoolAddress(voteAccountAddress);
|
|
11549
|
-
const stakeAddress = findPoolStakeAddress(poolAddress);
|
|
11550
|
-
const mintAddress = findPoolMintAddress(poolAddress);
|
|
11551
|
-
const onRampAddress = findPoolOnRampAddress(poolAddress);
|
|
11552
|
-
const [poolRent, stakeRent, mintRent, minimumDelegationObj] = await Promise.all([
|
|
11553
|
-
connection.getMinimumBalanceForRentExemption(Number(SINGLE_POOL_ACCOUNT_SIZE), "confirmed"),
|
|
11554
|
-
connection.getMinimumBalanceForRentExemption(Number(STAKE_ACCOUNT_SIZE), "confirmed"),
|
|
11555
|
-
connection.getMinimumBalanceForRentExemption(Number(MINT_SIZE), "confirmed"),
|
|
11556
|
-
connection.getStakeMinimumDelegation()
|
|
11557
|
-
]);
|
|
11558
|
-
const minimumDelegation = minimumDelegationObj.value;
|
|
11559
|
-
const instructions$3 = [];
|
|
11560
|
-
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
11561
|
-
fromPubkey: payer,
|
|
11562
|
-
toPubkey: poolAddress,
|
|
11563
|
-
lamports: poolRent
|
|
11564
|
-
}));
|
|
11565
|
-
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
11566
|
-
fromPubkey: payer,
|
|
11567
|
-
toPubkey: stakeAddress,
|
|
11568
|
-
lamports: stakeRent + minimumDelegation + __solana_web3_js.LAMPORTS_PER_SOL * 1
|
|
11569
|
-
}));
|
|
11570
|
-
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
11571
|
-
fromPubkey: payer,
|
|
11572
|
-
toPubkey: onRampAddress,
|
|
11573
|
-
lamports: stakeRent
|
|
11574
|
-
}));
|
|
11575
|
-
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
11576
|
-
fromPubkey: payer,
|
|
11577
|
-
toPubkey: mintAddress,
|
|
11578
|
-
lamports: mintRent
|
|
11579
|
-
}));
|
|
11580
|
-
instructions$3.push(SinglePoolInstruction.initializePool(voteAccountAddress));
|
|
11581
|
-
instructions$3.push(SinglePoolInstruction.initializeOnRamp(poolAddress));
|
|
11582
|
-
instructions$3.push(await SinglePoolInstruction.createTokenMetadata(poolAddress, payer));
|
|
11583
|
-
return instructions$3;
|
|
11584
|
-
}
|
|
11585
|
-
const createAccountIx = (from, newAccount, lamports, space, programAddress) => {
|
|
11586
|
-
const data = Buffer.concat([
|
|
11587
|
-
Buffer.from([0]),
|
|
11588
|
-
Buffer.from(new bn_js.BN(lamports).toArray("le", 8)),
|
|
11589
|
-
Buffer.from(new bn_js.BN(space).toArray("le", 8)),
|
|
11590
|
-
programAddress.toBuffer()
|
|
11591
|
-
]);
|
|
11592
|
-
const accounts$2 = [{
|
|
11593
|
-
pubkey: from,
|
|
11594
|
-
isSigner: true,
|
|
11595
|
-
isWritable: true
|
|
11596
|
-
}, {
|
|
11597
|
-
pubkey: newAccount,
|
|
11598
|
-
isSigner: true,
|
|
11599
|
-
isWritable: true
|
|
11600
|
-
}];
|
|
11601
|
-
return createTransactionInstruction(require_common.SYSTEM_PROGRAM_ID, accounts$2, data);
|
|
11602
|
-
};
|
|
11603
|
-
const createPoolOnrampIx = (voteAccount) => {
|
|
11604
|
-
const poolAccount = findPoolAddress(voteAccount);
|
|
11605
|
-
const onRampAccount = findPoolOnRampAddress(poolAccount);
|
|
11606
|
-
const poolStakeAuthority = findPoolStakeAuthorityAddress(poolAccount);
|
|
11607
|
-
const keys = [
|
|
11608
|
-
{
|
|
11609
|
-
pubkey: poolAccount,
|
|
11610
|
-
isSigner: false,
|
|
11611
|
-
isWritable: false
|
|
11612
|
-
},
|
|
11613
|
-
{
|
|
11614
|
-
pubkey: onRampAccount,
|
|
11615
|
-
isSigner: false,
|
|
11616
|
-
isWritable: true
|
|
11617
|
-
},
|
|
11618
|
-
{
|
|
11619
|
-
pubkey: poolStakeAuthority,
|
|
11620
|
-
isSigner: false,
|
|
11621
|
-
isWritable: false
|
|
11622
|
-
},
|
|
11623
|
-
{
|
|
11624
|
-
pubkey: __solana_web3_js.SYSVAR_RENT_PUBKEY,
|
|
11625
|
-
isSigner: false,
|
|
11626
|
-
isWritable: false
|
|
11627
|
-
},
|
|
11628
|
-
{
|
|
11629
|
-
pubkey: __solana_web3_js.SystemProgram.programId,
|
|
11630
|
-
isSigner: false,
|
|
11631
|
-
isWritable: false
|
|
11632
|
-
},
|
|
11633
|
-
{
|
|
11634
|
-
pubkey: __solana_web3_js.StakeProgram.programId,
|
|
11635
|
-
isSigner: false,
|
|
11636
|
-
isWritable: false
|
|
11637
|
-
}
|
|
11638
|
-
];
|
|
11639
|
-
const data = Buffer.from(Uint8Array.of(6));
|
|
11640
|
-
return new __solana_web3_js.TransactionInstruction({
|
|
11641
|
-
keys,
|
|
11642
|
-
programId: require_common.SINGLE_POOL_PROGRAM_ID,
|
|
11643
|
-
data
|
|
11644
|
-
});
|
|
11645
|
-
};
|
|
11646
|
-
const replenishPoolIx = (voteAccount) => {
|
|
11647
|
-
const poolAccount = findPoolAddress(voteAccount);
|
|
11648
|
-
const stakePool = findPoolStakeAddress(poolAccount);
|
|
11649
|
-
const onRampPool = findPoolOnRampAddress(poolAccount);
|
|
11650
|
-
const authority = findPoolStakeAuthorityAddress(poolAccount);
|
|
11651
|
-
const keys = [
|
|
11652
|
-
{
|
|
11653
|
-
pubkey: voteAccount,
|
|
11654
|
-
isSigner: false,
|
|
11655
|
-
isWritable: false
|
|
11656
|
-
},
|
|
11657
|
-
{
|
|
11658
|
-
pubkey: poolAccount,
|
|
11659
|
-
isSigner: false,
|
|
11660
|
-
isWritable: false
|
|
11661
|
-
},
|
|
11662
|
-
{
|
|
11663
|
-
pubkey: stakePool,
|
|
11664
|
-
isSigner: false,
|
|
11665
|
-
isWritable: true
|
|
11666
|
-
},
|
|
11667
|
-
{
|
|
11668
|
-
pubkey: onRampPool,
|
|
11669
|
-
isSigner: false,
|
|
11670
|
-
isWritable: true
|
|
11671
|
-
},
|
|
11672
|
-
{
|
|
11673
|
-
pubkey: authority,
|
|
11674
|
-
isSigner: false,
|
|
11675
|
-
isWritable: false
|
|
11676
|
-
},
|
|
11677
|
-
{
|
|
11678
|
-
pubkey: __solana_web3_js.SYSVAR_CLOCK_PUBKEY,
|
|
11679
|
-
isSigner: false,
|
|
11680
|
-
isWritable: false
|
|
11681
|
-
},
|
|
11682
|
-
{
|
|
11683
|
-
pubkey: require_common.SYSVAR_STAKE_HISTORY_ID,
|
|
11684
|
-
isSigner: false,
|
|
11685
|
-
isWritable: false
|
|
11686
|
-
},
|
|
11687
|
-
{
|
|
11688
|
-
pubkey: __solana_web3_js.STAKE_CONFIG_ID,
|
|
11689
|
-
isSigner: false,
|
|
11690
|
-
isWritable: false
|
|
11691
|
-
},
|
|
11692
|
-
{
|
|
11693
|
-
pubkey: __solana_web3_js.StakeProgram.programId,
|
|
11694
|
-
isSigner: false,
|
|
11695
|
-
isWritable: false
|
|
11696
|
-
}
|
|
11697
|
-
];
|
|
11698
|
-
const data = Buffer.from(Uint8Array.of(1));
|
|
11699
|
-
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, keys, data);
|
|
11700
|
-
};
|
|
11725
|
+
} });
|
|
11701
11726
|
|
|
11702
11727
|
//#endregion
|
|
11703
11728
|
//#region src/vendor/switchboard_legacy/account.ts
|
|
@@ -15995,9 +16020,11 @@ require_common.__export(vendor_exports, {
|
|
|
15995
16020
|
replenishPoolIx: () => replenishPoolIx,
|
|
15996
16021
|
switchboardAccountCoder: () => switchboardAccountCoder
|
|
15997
16022
|
});
|
|
16023
|
+
init_single_spl_pool();
|
|
15998
16024
|
|
|
15999
16025
|
//#endregion
|
|
16000
16026
|
//#region src/utils.ts
|
|
16027
|
+
require_common.init_constants();
|
|
16001
16028
|
function getBankVaultSeeds(type) {
|
|
16002
16029
|
switch (type) {
|
|
16003
16030
|
case BankVaultType.LiquidityVault: return require_common.PDA_BANK_LIQUIDITY_VAULT_SEED;
|
|
@@ -18729,6 +18756,7 @@ let PriceBias = /* @__PURE__ */ function(PriceBias$1) {
|
|
|
18729
18756
|
|
|
18730
18757
|
//#endregion
|
|
18731
18758
|
//#region src/services/price/utils/compute.utils.ts
|
|
18759
|
+
require_common.init_constants();
|
|
18732
18760
|
function getPriceWithConfidence(oraclePrice, weighted) {
|
|
18733
18761
|
return weighted ? oraclePrice.priceWeighted : oraclePrice.priceRealtime;
|
|
18734
18762
|
}
|
|
@@ -19696,6 +19724,7 @@ function bankConfigRawToDto(bankConfigRaw) {
|
|
|
19696
19724
|
|
|
19697
19725
|
//#endregion
|
|
19698
19726
|
//#region src/services/bank/bank.service.ts
|
|
19727
|
+
require_common.init_constants();
|
|
19699
19728
|
async function freezeBankConfigIx(program, bankAddress, bankConfigOpt) {
|
|
19700
19729
|
if (!bankConfigOpt) {}
|
|
19701
19730
|
const bankConfigRaw = serializeBankConfigOpt(bankConfigOpt);
|
|
@@ -20067,6 +20096,7 @@ async function executeBundleSimulation(rpcEndpoint, encodedTransactions, config)
|
|
|
20067
20096
|
|
|
20068
20097
|
//#endregion
|
|
20069
20098
|
//#region src/services/transaction/transaction.service.ts
|
|
20099
|
+
require_common.init_constants();
|
|
20070
20100
|
const DEFAULT_PROCESS_TX_OPTS = {
|
|
20071
20101
|
broadcastType: "RPC",
|
|
20072
20102
|
isSequentialTxs: true,
|
|
@@ -20663,6 +20693,7 @@ function addTransactionTxTags(transactions) {
|
|
|
20663
20693
|
|
|
20664
20694
|
//#endregion
|
|
20665
20695
|
//#region src/services/account/utils/compute.utils.ts
|
|
20696
|
+
init_single_spl_pool();
|
|
20666
20697
|
/**
|
|
20667
20698
|
* Lendr Account Computes
|
|
20668
20699
|
* =========================
|
|
@@ -21614,6 +21645,8 @@ function getActiveStaleBanks(balances, banks, additionalBanks, oraclePrices, max
|
|
|
21614
21645
|
|
|
21615
21646
|
//#endregion
|
|
21616
21647
|
//#region src/services/group/group.service.ts
|
|
21648
|
+
require_common.init_constants();
|
|
21649
|
+
init_single_spl_pool();
|
|
21617
21650
|
async function makePoolConfigureBankIx(program, bank, args) {
|
|
21618
21651
|
const ix = await instructions_default.makePoolConfigureBankIx(program, { bank }, { bankConfigOpt: args });
|
|
21619
21652
|
return {
|
|
@@ -21747,6 +21780,8 @@ function dtoToValidatorStakeGroup(validatorStakeGroupDto) {
|
|
|
21747
21780
|
|
|
21748
21781
|
//#endregion
|
|
21749
21782
|
//#region src/services/native-stake/utils/fetch.utils.ts
|
|
21783
|
+
require_common.init_constants();
|
|
21784
|
+
init_single_spl_pool();
|
|
21750
21785
|
/**
|
|
21751
21786
|
* Retrieves all active stake accounts associated with a given public key grouped by validator
|
|
21752
21787
|
*
|
|
@@ -22654,7 +22689,7 @@ var LendrAccount = class LendrAccount {
|
|
|
22654
22689
|
keys: []
|
|
22655
22690
|
};
|
|
22656
22691
|
}
|
|
22657
|
-
async prepareWithdrawInstruction(program, bankMap, mintDatas, bankAddress, withdrawAll = false, withdrawOpts = {}) {
|
|
22692
|
+
async prepareWithdrawInstruction(program, bankMap, mintDatas, bankMetadataMap, bankAddress, withdrawAll = false, withdrawOpts = {}) {
|
|
22658
22693
|
const bank = bankMap.get(bankAddress.toBase58());
|
|
22659
22694
|
if (!bank) throw Error(`Bank ${bankAddress.toBase58()} not found`);
|
|
22660
22695
|
const mintData = mintDatas.get(bankAddress.toBase58());
|
|
@@ -22678,9 +22713,23 @@ var LendrAccount = class LendrAccount {
|
|
|
22678
22713
|
if (withdrawOpts.observationBanksOverride) {
|
|
22679
22714
|
remainingAccounts.push(...withdrawOpts.observationBanksOverride);
|
|
22680
22715
|
} else {
|
|
22681
|
-
const accountMetas = computeHealthAccountMetas(healthAccounts);
|
|
22716
|
+
const accountMetas = computeHealthAccountMetas(healthAccounts, bankMetadataMap);
|
|
22682
22717
|
remainingAccounts.push(...accountMetas);
|
|
22683
22718
|
}
|
|
22719
|
+
if (withdrawAll) {
|
|
22720
|
+
remainingAccounts.push(bank.address, bank.config.oracleKeys[0]);
|
|
22721
|
+
if (bank.config.assetTag === 2) {
|
|
22722
|
+
const bankMetadata = bankMetadataMap?.[bankAddress.toBase58()];
|
|
22723
|
+
if (!bankMetadata?.validatorVoteAccount) {
|
|
22724
|
+
throw Error(`No validator vote account for staked bank ${bankAddress.toBase58()}`);
|
|
22725
|
+
}
|
|
22726
|
+
const { findPoolAddress: findPoolAddress$1, findPoolStakeAddress: findPoolStakeAddress$1, findPoolMintAddress: findPoolMintAddress$1 } = (init_single_spl_pool(), require_common.__toCommonJS(single_spl_pool_exports));
|
|
22727
|
+
const pool = findPoolAddress$1(new __solana_web3_js.PublicKey(bankMetadata.validatorVoteAccount));
|
|
22728
|
+
const solPool = findPoolStakeAddress$1(pool);
|
|
22729
|
+
const lstMint = findPoolMintAddress$1(pool);
|
|
22730
|
+
remainingAccounts.push(lstMint, solPool);
|
|
22731
|
+
}
|
|
22732
|
+
}
|
|
22684
22733
|
return {
|
|
22685
22734
|
withdrawIxs,
|
|
22686
22735
|
wrapAndUnwrapSol,
|
|
@@ -22694,8 +22743,8 @@ var LendrAccount = class LendrAccount {
|
|
|
22694
22743
|
}))
|
|
22695
22744
|
};
|
|
22696
22745
|
}
|
|
22697
|
-
async makeWithdrawIx(program, bankMap, mintDatas, amount, bankAddress, withdrawAll = false, withdrawOpts = {}) {
|
|
22698
|
-
const { withdrawIxs, wrapAndUnwrapSol, userAta, mintData, bank, remainingAccounts } = await this.prepareWithdrawInstruction(program, bankMap, mintDatas, bankAddress, withdrawAll, withdrawOpts);
|
|
22746
|
+
async makeWithdrawIx(program, bankMap, mintDatas, bankMetadataMap, amount, bankAddress, withdrawAll = false, withdrawOpts = {}) {
|
|
22747
|
+
const { withdrawIxs, wrapAndUnwrapSol, userAta, mintData, bank, remainingAccounts } = await this.prepareWithdrawInstruction(program, bankMap, mintDatas, bankMetadataMap, bankAddress, withdrawAll, withdrawOpts);
|
|
22699
22748
|
const [bankLiquidityVaultAuthority] = getBankVaultAuthority(BankVaultType.LiquidityVault, bank.address, program.programId);
|
|
22700
22749
|
const withdrawIx = await instructions_default.makeWithdrawIx(program, {
|
|
22701
22750
|
lendrAccount: this.address,
|
|
@@ -22719,8 +22768,8 @@ var LendrAccount = class LendrAccount {
|
|
|
22719
22768
|
keys: []
|
|
22720
22769
|
};
|
|
22721
22770
|
}
|
|
22722
|
-
async makeWithdrawWithSessionIx(program, bankMap, mintDatas, amount, bankAddress, session, withdrawAll = false, withdrawOpts = {}) {
|
|
22723
|
-
const { withdrawIxs, wrapAndUnwrapSol, userAta, mintData, bank, remainingAccounts } = await this.prepareWithdrawInstruction(program, bankMap, mintDatas, bankAddress, withdrawAll, {
|
|
22771
|
+
async makeWithdrawWithSessionIx(program, bankMap, mintDatas, bankMetadataMap, amount, bankAddress, session, withdrawAll = false, withdrawOpts = {}) {
|
|
22772
|
+
const { withdrawIxs, wrapAndUnwrapSol, userAta, mintData, bank, remainingAccounts } = await this.prepareWithdrawInstruction(program, bankMap, mintDatas, bankMetadataMap, bankAddress, withdrawAll, {
|
|
22724
22773
|
...withdrawOpts,
|
|
22725
22774
|
createAtaPayer: session.payer
|
|
22726
22775
|
});
|
|
@@ -23038,6 +23087,7 @@ function isWeightedPrice(reqType) {
|
|
|
23038
23087
|
|
|
23039
23088
|
//#endregion
|
|
23040
23089
|
//#region src/models/account/wrapper.ts
|
|
23090
|
+
require_common.init_constants();
|
|
23041
23091
|
var LendrAccountWrapper = class LendrAccountWrapper {
|
|
23042
23092
|
address;
|
|
23043
23093
|
_lendrAccount;
|
|
@@ -23945,7 +23995,8 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
23945
23995
|
async makeWithdrawIx(amount, bankAddress, withdrawAll = false, withdrawOpts = {}) {
|
|
23946
23996
|
const tokenProgramAddress = this.client.mintDatas.get(bankAddress.toBase58())?.tokenProgram;
|
|
23947
23997
|
if (!tokenProgramAddress) throw Error("Withdraw mint not found");
|
|
23948
|
-
|
|
23998
|
+
if (!this.client.bankMetadataMap) throw Error("Bank metadata map not found");
|
|
23999
|
+
return this._lendrAccount.makeWithdrawIx(this._program, this.client.banks, this.client.mintDatas, this.client.bankMetadataMap, amount, bankAddress, withdrawAll, withdrawOpts);
|
|
23949
24000
|
}
|
|
23950
24001
|
/**
|
|
23951
24002
|
* Creates instructions for withdrawing tokens from a lendr bank account.
|
|
@@ -23961,7 +24012,8 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
23961
24012
|
async makeWithdrawWithSessionIx(amount, bankAddress, session, withdrawAll = false, withdrawOpts = {}) {
|
|
23962
24013
|
const tokenProgramAddress = this.client.mintDatas.get(bankAddress.toBase58())?.tokenProgram;
|
|
23963
24014
|
if (!tokenProgramAddress) throw Error("Withdraw mint not found");
|
|
23964
|
-
|
|
24015
|
+
if (!this.client.bankMetadataMap) throw Error("Bank metadata map not found");
|
|
24016
|
+
return this._lendrAccount.makeWithdrawWithSessionIx(this._program, this.client.banks, this.client.mintDatas, this.client.bankMetadataMap, amount, bankAddress, session, withdrawAll, withdrawOpts);
|
|
23965
24017
|
}
|
|
23966
24018
|
/**
|
|
23967
24019
|
* Creates a transaction for withdrawing tokens from a lendr bank account and staking them.
|
|
@@ -24787,6 +24839,7 @@ var LendrGroup = class LendrGroup {
|
|
|
24787
24839
|
|
|
24788
24840
|
//#endregion
|
|
24789
24841
|
//#region src/clients/client.ts
|
|
24842
|
+
require_common.init_constants();
|
|
24790
24843
|
/**
|
|
24791
24844
|
* Entrypoint to interact with the lendr contract.
|
|
24792
24845
|
*/
|
|
@@ -25698,6 +25751,10 @@ var EmodeSettings = class EmodeSettings {
|
|
|
25698
25751
|
}
|
|
25699
25752
|
};
|
|
25700
25753
|
|
|
25754
|
+
//#endregion
|
|
25755
|
+
//#region src/index.ts
|
|
25756
|
+
init_constants();
|
|
25757
|
+
|
|
25701
25758
|
//#endregion
|
|
25702
25759
|
exports.AccountFlags = AccountFlags;
|
|
25703
25760
|
exports.AccountType = AccountType;
|