@pyron-finance/pyron-client 2.0.1 → 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-CpLJbZfZ.js → common-BDgJX75H.js} +93 -61
- package/dist/common-BDgJX75H.js.map +1 -0
- package/dist/{common-D8PG-Y0L.cjs → common-C1TNbOrw.cjs} +112 -59
- package/dist/{index-BovAP8Ts.d.ts → index-BoDaAGQH.d.ts} +43 -40
- package/dist/index-BoDaAGQH.d.ts.map +1 -0
- package/dist/{index-DmnT_tlu.d.cts → index-yftX6Mhj.d.cts} +15 -12
- package/dist/index-yftX6Mhj.d.cts.map +1 -0
- package/dist/index.cjs +590 -512
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +592 -514
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-Cl8Af3a2.js +0 -11
- package/dist/common-CpLJbZfZ.js.map +0 -1
- package/dist/index-BovAP8Ts.d.ts.map +0 -1
- package/dist/index-DmnT_tlu.d.cts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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"));
|
|
5
5
|
const bignumber_js = require_common.__toESM(require("bignumber.js"));
|
|
6
|
-
const bn_js = require_common.__toESM(require("bn.js"));
|
|
7
6
|
const bs58 = require_common.__toESM(require("bs58"));
|
|
8
7
|
const unstorage = require_common.__toESM(require("unstorage"));
|
|
9
8
|
const zod_v4_mini = require_common.__toESM(require("zod/v4-mini"));
|
|
9
|
+
const bn_js = require_common.__toESM(require("bn.js"));
|
|
10
10
|
const __metaplex_foundation_mpl_token_metadata = require_common.__toESM(require("@metaplex-foundation/mpl-token-metadata"));
|
|
11
11
|
const __metaplex_foundation_umi = require_common.__toESM(require("@metaplex-foundation/umi"));
|
|
12
12
|
const __metaplex_foundation_umi_bundle_defaults = require_common.__toESM(require("@metaplex-foundation/umi-bundle-defaults"));
|
|
@@ -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";
|
|
@@ -10103,8 +10105,17 @@ async function makeInitLendrAccountIx(ldProgram, accounts$2) {
|
|
|
10103
10105
|
return ldProgram.methods.lendrAccountInitialize().accounts(accounts$2).instruction();
|
|
10104
10106
|
}
|
|
10105
10107
|
async function makeInitLendrAccountWithSessionIx(ldProgram, { lendrGroup, session, feePayer }, accountIndex, thirdPartyId) {
|
|
10108
|
+
const thirdPartyIdValue = thirdPartyId ?? 0;
|
|
10109
|
+
const [lendrAccount] = __solana_web3_js.PublicKey.findProgramAddressSync([
|
|
10110
|
+
Buffer.from("lendr_account"),
|
|
10111
|
+
lendrGroup.toBuffer(),
|
|
10112
|
+
session.walletPublicKey.toBuffer(),
|
|
10113
|
+
Buffer.from(new Uint16Array([accountIndex]).buffer),
|
|
10114
|
+
Buffer.from(new Uint16Array([thirdPartyIdValue]).buffer)
|
|
10115
|
+
], ldProgram.programId);
|
|
10106
10116
|
return ldProgram.methods.lendrAccountInitializeWithSession(session.walletPublicKey, accountIndex, thirdPartyId ?? null).accounts({
|
|
10107
10117
|
lendrGroup,
|
|
10118
|
+
lendrAccount,
|
|
10108
10119
|
sessionKey: session.sessionPublicKey,
|
|
10109
10120
|
feePayer
|
|
10110
10121
|
}).instruction();
|
|
@@ -10476,6 +10487,7 @@ let AccountType = /* @__PURE__ */ function(AccountType$2) {
|
|
|
10476
10487
|
|
|
10477
10488
|
//#endregion
|
|
10478
10489
|
//#region src/services/bank/utils/deserialize.utils.ts
|
|
10490
|
+
require_common.init_constants();
|
|
10479
10491
|
function decodeBankRaw(encoded, idl) {
|
|
10480
10492
|
const coder = new __coral_xyz_anchor.BorshCoder(idl);
|
|
10481
10493
|
return coder.accounts.decode(AccountType.Bank, encoded);
|
|
@@ -11141,554 +11153,576 @@ const getStakeAccount = (data) => {
|
|
|
11141
11153
|
|
|
11142
11154
|
//#endregion
|
|
11143
11155
|
//#region src/vendor/single-spl-pool/index.ts
|
|
11144
|
-
var
|
|
11145
|
-
|
|
11146
|
-
|
|
11147
|
-
|
|
11148
|
-
|
|
11149
|
-
|
|
11150
|
-
|
|
11151
|
-
|
|
11152
|
-
|
|
11153
|
-
|
|
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
|
-
|
|
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");
|
|
11330
11526
|
}
|
|
11331
|
-
|
|
11332
|
-
|
|
11333
|
-
|
|
11334
|
-
|
|
11335
|
-
|
|
11336
|
-
|
|
11337
|
-
|
|
11338
|
-
|
|
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) => {
|
|
11339
11610
|
const data = Buffer.concat([
|
|
11340
|
-
Buffer.from([
|
|
11341
|
-
|
|
11342
|
-
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()
|
|
11343
11615
|
]);
|
|
11344
|
-
|
|
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 = [
|
|
11345
11632
|
{
|
|
11346
|
-
pubkey:
|
|
11633
|
+
pubkey: poolAccount,
|
|
11347
11634
|
isSigner: false,
|
|
11348
11635
|
isWritable: false
|
|
11349
11636
|
},
|
|
11350
11637
|
{
|
|
11351
|
-
pubkey:
|
|
11638
|
+
pubkey: onRampAccount,
|
|
11352
11639
|
isSigner: false,
|
|
11353
11640
|
isWritable: true
|
|
11354
11641
|
},
|
|
11355
11642
|
{
|
|
11356
|
-
pubkey:
|
|
11357
|
-
isSigner: false,
|
|
11358
|
-
isWritable: true
|
|
11359
|
-
},
|
|
11360
|
-
{
|
|
11361
|
-
pubkey: stakeAuthority,
|
|
11362
|
-
isSigner: false,
|
|
11363
|
-
isWritable: false
|
|
11364
|
-
},
|
|
11365
|
-
{
|
|
11366
|
-
pubkey: mintAuthority,
|
|
11643
|
+
pubkey: poolStakeAuthority,
|
|
11367
11644
|
isSigner: false,
|
|
11368
11645
|
isWritable: false
|
|
11369
11646
|
},
|
|
11370
11647
|
{
|
|
11371
|
-
pubkey:
|
|
11372
|
-
isSigner: false,
|
|
11373
|
-
isWritable: true
|
|
11374
|
-
},
|
|
11375
|
-
{
|
|
11376
|
-
pubkey: userTokenAccount,
|
|
11377
|
-
isSigner: false,
|
|
11378
|
-
isWritable: true
|
|
11379
|
-
},
|
|
11380
|
-
{
|
|
11381
|
-
pubkey: require_common.SYSVAR_CLOCK_ID,
|
|
11648
|
+
pubkey: __solana_web3_js.SYSVAR_RENT_PUBKEY,
|
|
11382
11649
|
isSigner: false,
|
|
11383
11650
|
isWritable: false
|
|
11384
11651
|
},
|
|
11385
11652
|
{
|
|
11386
|
-
pubkey:
|
|
11653
|
+
pubkey: __solana_web3_js.SystemProgram.programId,
|
|
11387
11654
|
isSigner: false,
|
|
11388
11655
|
isWritable: false
|
|
11389
11656
|
},
|
|
11390
11657
|
{
|
|
11391
|
-
pubkey:
|
|
11658
|
+
pubkey: __solana_web3_js.StakeProgram.programId,
|
|
11392
11659
|
isSigner: false,
|
|
11393
11660
|
isWritable: false
|
|
11394
11661
|
}
|
|
11395
|
-
]
|
|
11396
|
-
|
|
11397
|
-
|
|
11398
|
-
|
|
11399
|
-
|
|
11400
|
-
|
|
11401
|
-
|
|
11402
|
-
|
|
11403
|
-
|
|
11404
|
-
|
|
11405
|
-
|
|
11406
|
-
|
|
11407
|
-
|
|
11408
|
-
|
|
11409
|
-
},
|
|
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 = [
|
|
11410
11676
|
{
|
|
11411
|
-
pubkey:
|
|
11677
|
+
pubkey: voteAccount,
|
|
11412
11678
|
isSigner: false,
|
|
11413
11679
|
isWritable: false
|
|
11414
11680
|
},
|
|
11415
11681
|
{
|
|
11416
|
-
pubkey:
|
|
11682
|
+
pubkey: poolAccount,
|
|
11417
11683
|
isSigner: false,
|
|
11418
11684
|
isWritable: false
|
|
11419
11685
|
},
|
|
11420
11686
|
{
|
|
11421
|
-
pubkey:
|
|
11687
|
+
pubkey: stakePool,
|
|
11422
11688
|
isSigner: false,
|
|
11423
|
-
isWritable: false
|
|
11424
|
-
},
|
|
11425
|
-
{
|
|
11426
|
-
pubkey: payer,
|
|
11427
|
-
isSigner: true,
|
|
11428
11689
|
isWritable: true
|
|
11429
11690
|
},
|
|
11430
11691
|
{
|
|
11431
|
-
pubkey:
|
|
11692
|
+
pubkey: onRampPool,
|
|
11432
11693
|
isSigner: false,
|
|
11433
11694
|
isWritable: true
|
|
11434
11695
|
},
|
|
11435
11696
|
{
|
|
11436
|
-
pubkey:
|
|
11697
|
+
pubkey: authority,
|
|
11437
11698
|
isSigner: false,
|
|
11438
11699
|
isWritable: false
|
|
11439
11700
|
},
|
|
11440
11701
|
{
|
|
11441
|
-
pubkey:
|
|
11442
|
-
isSigner: false,
|
|
11443
|
-
isWritable: false
|
|
11444
|
-
}
|
|
11445
|
-
], Buffer.from([SinglePoolInstructionType.CreateTokenMetadata]));
|
|
11446
|
-
},
|
|
11447
|
-
updateTokenMetadata: async (voteAccount, authorizedWithdrawer, tokenName, tokenSymbol, tokenUri = "") => {
|
|
11448
|
-
if (tokenName.length > 32) {
|
|
11449
|
-
throw new Error("maximum token name length is 32 characters");
|
|
11450
|
-
}
|
|
11451
|
-
if (tokenSymbol.length > 10) {
|
|
11452
|
-
throw new Error("maximum token symbol length is 10 characters");
|
|
11453
|
-
}
|
|
11454
|
-
if (tokenUri.length > 200) {
|
|
11455
|
-
throw new Error("maximum token uri length is 200 characters");
|
|
11456
|
-
}
|
|
11457
|
-
const pool = findPoolAddress(voteAccount);
|
|
11458
|
-
const [mint, mplAuthority] = await Promise.all([findPoolMintAddress(pool), findPoolMplAuthorityAddress(pool)]);
|
|
11459
|
-
const mplMetadata = await findMplMetadataAddress(mint);
|
|
11460
|
-
const data = Buffer.concat([
|
|
11461
|
-
Buffer.from([SinglePoolInstructionType.UpdateTokenMetadata]),
|
|
11462
|
-
Buffer.from(new Uint32Array([tokenName.length]).buffer),
|
|
11463
|
-
Buffer.from(tokenName),
|
|
11464
|
-
Buffer.from(new Uint32Array([tokenSymbol.length]).buffer),
|
|
11465
|
-
Buffer.from(tokenSymbol),
|
|
11466
|
-
Buffer.from(new Uint32Array([tokenUri.length]).buffer),
|
|
11467
|
-
Buffer.from(tokenUri)
|
|
11468
|
-
]);
|
|
11469
|
-
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
11470
|
-
{
|
|
11471
|
-
pubkey: voteAccount,
|
|
11702
|
+
pubkey: __solana_web3_js.SYSVAR_CLOCK_PUBKEY,
|
|
11472
11703
|
isSigner: false,
|
|
11473
11704
|
isWritable: false
|
|
11474
11705
|
},
|
|
11475
11706
|
{
|
|
11476
|
-
pubkey:
|
|
11707
|
+
pubkey: require_common.SYSVAR_STAKE_HISTORY_ID,
|
|
11477
11708
|
isSigner: false,
|
|
11478
11709
|
isWritable: false
|
|
11479
11710
|
},
|
|
11480
11711
|
{
|
|
11481
|
-
pubkey:
|
|
11712
|
+
pubkey: __solana_web3_js.STAKE_CONFIG_ID,
|
|
11482
11713
|
isSigner: false,
|
|
11483
11714
|
isWritable: false
|
|
11484
11715
|
},
|
|
11485
11716
|
{
|
|
11486
|
-
pubkey:
|
|
11487
|
-
isSigner: true,
|
|
11488
|
-
isWritable: false
|
|
11489
|
-
},
|
|
11490
|
-
{
|
|
11491
|
-
pubkey: mplMetadata,
|
|
11492
|
-
isSigner: false,
|
|
11493
|
-
isWritable: true
|
|
11494
|
-
},
|
|
11495
|
-
{
|
|
11496
|
-
pubkey: require_common.MPL_METADATA_PROGRAM_ID,
|
|
11717
|
+
pubkey: __solana_web3_js.StakeProgram.programId,
|
|
11497
11718
|
isSigner: false,
|
|
11498
11719
|
isWritable: false
|
|
11499
11720
|
}
|
|
11500
|
-
]
|
|
11501
|
-
|
|
11502
|
-
|
|
11503
|
-
const createTransactionInstruction = (programId, keys, data) => {
|
|
11504
|
-
return {
|
|
11505
|
-
programId,
|
|
11506
|
-
keys,
|
|
11507
|
-
data
|
|
11721
|
+
];
|
|
11722
|
+
const data = Buffer.from(Uint8Array.of(1));
|
|
11723
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, keys, data);
|
|
11508
11724
|
};
|
|
11509
|
-
};
|
|
11510
|
-
const findPda = (baseAddress, prefix, programId = require_common.SINGLE_POOL_PROGRAM_ID) => {
|
|
11511
|
-
const [pda] = __solana_web3_js.PublicKey.findProgramAddressSync([Buffer.from(prefix), baseAddress.toBuffer()], programId);
|
|
11512
|
-
return pda;
|
|
11513
|
-
};
|
|
11514
|
-
const findPoolMintAddressByVoteAccount = (voteAccountAddress) => findPda(findPoolAddress(voteAccountAddress), "mint");
|
|
11515
|
-
const findPoolAddress = (voteAccountAddress) => findPda(voteAccountAddress, "pool");
|
|
11516
|
-
const findPoolMintAddress = (poolAddress) => findPda(poolAddress, "mint");
|
|
11517
|
-
const findPoolStakeAddress = (poolAddress) => findPda(poolAddress, "stake");
|
|
11518
|
-
const findPoolStakeAuthorityAddress = (poolAddress) => findPda(poolAddress, "stake_authority");
|
|
11519
|
-
const findPoolMintAuthorityAddress = (poolAddress) => findPda(poolAddress, "mint_authority");
|
|
11520
|
-
const findPoolMplAuthorityAddress = (poolAddress) => findPda(poolAddress, "mpl_authority");
|
|
11521
|
-
const findPoolOnRampAddress = (poolAddress) => findPda(poolAddress, "onramp");
|
|
11522
|
-
const findMplMetadataAddress = async (poolMintAddress) => {
|
|
11523
|
-
const [pda] = __solana_web3_js.PublicKey.findProgramAddressSync([
|
|
11524
|
-
Buffer.from("metadata"),
|
|
11525
|
-
require_common.MPL_METADATA_PROGRAM_ID.toBuffer(),
|
|
11526
|
-
poolMintAddress.toBuffer()
|
|
11527
|
-
], require_common.MPL_METADATA_PROGRAM_ID);
|
|
11528
|
-
return pda;
|
|
11529
|
-
};
|
|
11530
|
-
const SINGLE_POOL_ACCOUNT_SIZE = BigInt(33);
|
|
11531
|
-
const STAKE_ACCOUNT_SIZE = BigInt(200);
|
|
11532
|
-
const MINT_SIZE = BigInt(82);
|
|
11533
|
-
async function initializeStakedPoolTx(connection, payer, voteAccountAddress) {
|
|
11534
|
-
const instructions$3 = await initializeStakedPoolIxs(connection, payer, voteAccountAddress);
|
|
11535
|
-
const tx = new __solana_web3_js.Transaction().add(...instructions$3);
|
|
11536
|
-
return tx;
|
|
11537
|
-
}
|
|
11538
|
-
async function initializeStakedPoolIxs(connection, payer, voteAccountAddress) {
|
|
11539
|
-
const poolAddress = findPoolAddress(voteAccountAddress);
|
|
11540
|
-
const stakeAddress = findPoolStakeAddress(poolAddress);
|
|
11541
|
-
const mintAddress = findPoolMintAddress(poolAddress);
|
|
11542
|
-
const onRampAddress = findPoolOnRampAddress(poolAddress);
|
|
11543
|
-
const [poolRent, stakeRent, mintRent, minimumDelegationObj] = await Promise.all([
|
|
11544
|
-
connection.getMinimumBalanceForRentExemption(Number(SINGLE_POOL_ACCOUNT_SIZE), "confirmed"),
|
|
11545
|
-
connection.getMinimumBalanceForRentExemption(Number(STAKE_ACCOUNT_SIZE), "confirmed"),
|
|
11546
|
-
connection.getMinimumBalanceForRentExemption(Number(MINT_SIZE), "confirmed"),
|
|
11547
|
-
connection.getStakeMinimumDelegation()
|
|
11548
|
-
]);
|
|
11549
|
-
const minimumDelegation = minimumDelegationObj.value;
|
|
11550
|
-
const instructions$3 = [];
|
|
11551
|
-
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
11552
|
-
fromPubkey: payer,
|
|
11553
|
-
toPubkey: poolAddress,
|
|
11554
|
-
lamports: poolRent
|
|
11555
|
-
}));
|
|
11556
|
-
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
11557
|
-
fromPubkey: payer,
|
|
11558
|
-
toPubkey: stakeAddress,
|
|
11559
|
-
lamports: stakeRent + minimumDelegation + __solana_web3_js.LAMPORTS_PER_SOL * 1
|
|
11560
|
-
}));
|
|
11561
|
-
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
11562
|
-
fromPubkey: payer,
|
|
11563
|
-
toPubkey: onRampAddress,
|
|
11564
|
-
lamports: stakeRent
|
|
11565
|
-
}));
|
|
11566
|
-
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
11567
|
-
fromPubkey: payer,
|
|
11568
|
-
toPubkey: mintAddress,
|
|
11569
|
-
lamports: mintRent
|
|
11570
|
-
}));
|
|
11571
|
-
instructions$3.push(SinglePoolInstruction.initializePool(voteAccountAddress));
|
|
11572
|
-
instructions$3.push(SinglePoolInstruction.initializeOnRamp(poolAddress));
|
|
11573
|
-
instructions$3.push(await SinglePoolInstruction.createTokenMetadata(poolAddress, payer));
|
|
11574
|
-
return instructions$3;
|
|
11575
|
-
}
|
|
11576
|
-
const createAccountIx = (from, newAccount, lamports, space, programAddress) => {
|
|
11577
|
-
const data = Buffer.concat([
|
|
11578
|
-
Buffer.from([0]),
|
|
11579
|
-
Buffer.from(new bn_js.BN(lamports).toArray("le", 8)),
|
|
11580
|
-
Buffer.from(new bn_js.BN(space).toArray("le", 8)),
|
|
11581
|
-
programAddress.toBuffer()
|
|
11582
|
-
]);
|
|
11583
|
-
const accounts$2 = [{
|
|
11584
|
-
pubkey: from,
|
|
11585
|
-
isSigner: true,
|
|
11586
|
-
isWritable: true
|
|
11587
|
-
}, {
|
|
11588
|
-
pubkey: newAccount,
|
|
11589
|
-
isSigner: true,
|
|
11590
|
-
isWritable: true
|
|
11591
|
-
}];
|
|
11592
|
-
return createTransactionInstruction(require_common.SYSTEM_PROGRAM_ID, accounts$2, data);
|
|
11593
|
-
};
|
|
11594
|
-
const createPoolOnrampIx = (voteAccount) => {
|
|
11595
|
-
const poolAccount = findPoolAddress(voteAccount);
|
|
11596
|
-
const onRampAccount = findPoolOnRampAddress(poolAccount);
|
|
11597
|
-
const poolStakeAuthority = findPoolStakeAuthorityAddress(poolAccount);
|
|
11598
|
-
const keys = [
|
|
11599
|
-
{
|
|
11600
|
-
pubkey: poolAccount,
|
|
11601
|
-
isSigner: false,
|
|
11602
|
-
isWritable: false
|
|
11603
|
-
},
|
|
11604
|
-
{
|
|
11605
|
-
pubkey: onRampAccount,
|
|
11606
|
-
isSigner: false,
|
|
11607
|
-
isWritable: true
|
|
11608
|
-
},
|
|
11609
|
-
{
|
|
11610
|
-
pubkey: poolStakeAuthority,
|
|
11611
|
-
isSigner: false,
|
|
11612
|
-
isWritable: false
|
|
11613
|
-
},
|
|
11614
|
-
{
|
|
11615
|
-
pubkey: __solana_web3_js.SYSVAR_RENT_PUBKEY,
|
|
11616
|
-
isSigner: false,
|
|
11617
|
-
isWritable: false
|
|
11618
|
-
},
|
|
11619
|
-
{
|
|
11620
|
-
pubkey: __solana_web3_js.SystemProgram.programId,
|
|
11621
|
-
isSigner: false,
|
|
11622
|
-
isWritable: false
|
|
11623
|
-
},
|
|
11624
|
-
{
|
|
11625
|
-
pubkey: __solana_web3_js.StakeProgram.programId,
|
|
11626
|
-
isSigner: false,
|
|
11627
|
-
isWritable: false
|
|
11628
|
-
}
|
|
11629
|
-
];
|
|
11630
|
-
const data = Buffer.from(Uint8Array.of(6));
|
|
11631
|
-
return new __solana_web3_js.TransactionInstruction({
|
|
11632
|
-
keys,
|
|
11633
|
-
programId: require_common.SINGLE_POOL_PROGRAM_ID,
|
|
11634
|
-
data
|
|
11635
|
-
});
|
|
11636
|
-
};
|
|
11637
|
-
const replenishPoolIx = (voteAccount) => {
|
|
11638
|
-
const poolAccount = findPoolAddress(voteAccount);
|
|
11639
|
-
const stakePool = findPoolStakeAddress(poolAccount);
|
|
11640
|
-
const onRampPool = findPoolOnRampAddress(poolAccount);
|
|
11641
|
-
const authority = findPoolStakeAuthorityAddress(poolAccount);
|
|
11642
|
-
const keys = [
|
|
11643
|
-
{
|
|
11644
|
-
pubkey: voteAccount,
|
|
11645
|
-
isSigner: false,
|
|
11646
|
-
isWritable: false
|
|
11647
|
-
},
|
|
11648
|
-
{
|
|
11649
|
-
pubkey: poolAccount,
|
|
11650
|
-
isSigner: false,
|
|
11651
|
-
isWritable: false
|
|
11652
|
-
},
|
|
11653
|
-
{
|
|
11654
|
-
pubkey: stakePool,
|
|
11655
|
-
isSigner: false,
|
|
11656
|
-
isWritable: true
|
|
11657
|
-
},
|
|
11658
|
-
{
|
|
11659
|
-
pubkey: onRampPool,
|
|
11660
|
-
isSigner: false,
|
|
11661
|
-
isWritable: true
|
|
11662
|
-
},
|
|
11663
|
-
{
|
|
11664
|
-
pubkey: authority,
|
|
11665
|
-
isSigner: false,
|
|
11666
|
-
isWritable: false
|
|
11667
|
-
},
|
|
11668
|
-
{
|
|
11669
|
-
pubkey: __solana_web3_js.SYSVAR_CLOCK_PUBKEY,
|
|
11670
|
-
isSigner: false,
|
|
11671
|
-
isWritable: false
|
|
11672
|
-
},
|
|
11673
|
-
{
|
|
11674
|
-
pubkey: require_common.SYSVAR_STAKE_HISTORY_ID,
|
|
11675
|
-
isSigner: false,
|
|
11676
|
-
isWritable: false
|
|
11677
|
-
},
|
|
11678
|
-
{
|
|
11679
|
-
pubkey: __solana_web3_js.STAKE_CONFIG_ID,
|
|
11680
|
-
isSigner: false,
|
|
11681
|
-
isWritable: false
|
|
11682
|
-
},
|
|
11683
|
-
{
|
|
11684
|
-
pubkey: __solana_web3_js.StakeProgram.programId,
|
|
11685
|
-
isSigner: false,
|
|
11686
|
-
isWritable: false
|
|
11687
|
-
}
|
|
11688
|
-
];
|
|
11689
|
-
const data = Buffer.from(Uint8Array.of(1));
|
|
11690
|
-
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, keys, data);
|
|
11691
|
-
};
|
|
11725
|
+
} });
|
|
11692
11726
|
|
|
11693
11727
|
//#endregion
|
|
11694
11728
|
//#region src/vendor/switchboard_legacy/account.ts
|
|
@@ -15986,9 +16020,11 @@ require_common.__export(vendor_exports, {
|
|
|
15986
16020
|
replenishPoolIx: () => replenishPoolIx,
|
|
15987
16021
|
switchboardAccountCoder: () => switchboardAccountCoder
|
|
15988
16022
|
});
|
|
16023
|
+
init_single_spl_pool();
|
|
15989
16024
|
|
|
15990
16025
|
//#endregion
|
|
15991
16026
|
//#region src/utils.ts
|
|
16027
|
+
require_common.init_constants();
|
|
15992
16028
|
function getBankVaultSeeds(type) {
|
|
15993
16029
|
switch (type) {
|
|
15994
16030
|
case BankVaultType.LiquidityVault: return require_common.PDA_BANK_LIQUIDITY_VAULT_SEED;
|
|
@@ -18720,6 +18756,7 @@ let PriceBias = /* @__PURE__ */ function(PriceBias$1) {
|
|
|
18720
18756
|
|
|
18721
18757
|
//#endregion
|
|
18722
18758
|
//#region src/services/price/utils/compute.utils.ts
|
|
18759
|
+
require_common.init_constants();
|
|
18723
18760
|
function getPriceWithConfidence(oraclePrice, weighted) {
|
|
18724
18761
|
return weighted ? oraclePrice.priceWeighted : oraclePrice.priceRealtime;
|
|
18725
18762
|
}
|
|
@@ -19687,6 +19724,7 @@ function bankConfigRawToDto(bankConfigRaw) {
|
|
|
19687
19724
|
|
|
19688
19725
|
//#endregion
|
|
19689
19726
|
//#region src/services/bank/bank.service.ts
|
|
19727
|
+
require_common.init_constants();
|
|
19690
19728
|
async function freezeBankConfigIx(program, bankAddress, bankConfigOpt) {
|
|
19691
19729
|
if (!bankConfigOpt) {}
|
|
19692
19730
|
const bankConfigRaw = serializeBankConfigOpt(bankConfigOpt);
|
|
@@ -20058,6 +20096,7 @@ async function executeBundleSimulation(rpcEndpoint, encodedTransactions, config)
|
|
|
20058
20096
|
|
|
20059
20097
|
//#endregion
|
|
20060
20098
|
//#region src/services/transaction/transaction.service.ts
|
|
20099
|
+
require_common.init_constants();
|
|
20061
20100
|
const DEFAULT_PROCESS_TX_OPTS = {
|
|
20062
20101
|
broadcastType: "RPC",
|
|
20063
20102
|
isSequentialTxs: true,
|
|
@@ -20654,6 +20693,7 @@ function addTransactionTxTags(transactions) {
|
|
|
20654
20693
|
|
|
20655
20694
|
//#endregion
|
|
20656
20695
|
//#region src/services/account/utils/compute.utils.ts
|
|
20696
|
+
init_single_spl_pool();
|
|
20657
20697
|
/**
|
|
20658
20698
|
* Lendr Account Computes
|
|
20659
20699
|
* =========================
|
|
@@ -21605,6 +21645,8 @@ function getActiveStaleBanks(balances, banks, additionalBanks, oraclePrices, max
|
|
|
21605
21645
|
|
|
21606
21646
|
//#endregion
|
|
21607
21647
|
//#region src/services/group/group.service.ts
|
|
21648
|
+
require_common.init_constants();
|
|
21649
|
+
init_single_spl_pool();
|
|
21608
21650
|
async function makePoolConfigureBankIx(program, bank, args) {
|
|
21609
21651
|
const ix = await instructions_default.makePoolConfigureBankIx(program, { bank }, { bankConfigOpt: args });
|
|
21610
21652
|
return {
|
|
@@ -21738,6 +21780,8 @@ function dtoToValidatorStakeGroup(validatorStakeGroupDto) {
|
|
|
21738
21780
|
|
|
21739
21781
|
//#endregion
|
|
21740
21782
|
//#region src/services/native-stake/utils/fetch.utils.ts
|
|
21783
|
+
require_common.init_constants();
|
|
21784
|
+
init_single_spl_pool();
|
|
21741
21785
|
/**
|
|
21742
21786
|
* Retrieves all active stake accounts associated with a given public key grouped by validator
|
|
21743
21787
|
*
|
|
@@ -22533,7 +22577,7 @@ var LendrAccount = class LendrAccount {
|
|
|
22533
22577
|
group: opts.overrideInferAccounts?.group ?? this.group,
|
|
22534
22578
|
liquidityVault: opts.overrideInferAccounts?.liquidityVault ?? bank.liquidityVault
|
|
22535
22579
|
}, ixArguments, remainingAccounts.map((account) => ({
|
|
22536
|
-
pubkey: account,
|
|
22580
|
+
pubkey: account.pubkey,
|
|
22537
22581
|
isSigner: false,
|
|
22538
22582
|
isWritable: false
|
|
22539
22583
|
})));
|
|
@@ -22545,9 +22589,6 @@ var LendrAccount = class LendrAccount {
|
|
|
22545
22589
|
}
|
|
22546
22590
|
async makeDepositWithSessionIx(program, banks, mintDatas, amount, bankAddress, sessionKey, opts = {}) {
|
|
22547
22591
|
const { depositIxs, ixArguments, userTokenAtaPk, mintData, remainingAccounts } = await this.prepareDepositIx(banks, mintDatas, amount, bankAddress, opts);
|
|
22548
|
-
const PAYMASTER_DESTINATION = new __solana_web3_js.PublicKey("43TSuDshgvKXuQCmDwHXmF4s3hH3nmDNJsvWGhoNnb7v");
|
|
22549
|
-
const transferIx = (0, __solana_spl_token.createTransferInstruction)(userTokenAtaPk, PAYMASTER_DESTINATION, this.authority, 1e4, [], __solana_spl_token.TOKEN_PROGRAM_ID);
|
|
22550
|
-
depositIxs.unshift(transferIx);
|
|
22551
22592
|
const accounts$2 = {
|
|
22552
22593
|
sessionKey,
|
|
22553
22594
|
lendrAccount: this.address,
|
|
@@ -22648,7 +22689,7 @@ var LendrAccount = class LendrAccount {
|
|
|
22648
22689
|
keys: []
|
|
22649
22690
|
};
|
|
22650
22691
|
}
|
|
22651
|
-
async prepareWithdrawInstruction(program, bankMap, mintDatas, bankAddress, withdrawAll = false, withdrawOpts = {}) {
|
|
22692
|
+
async prepareWithdrawInstruction(program, bankMap, mintDatas, bankMetadataMap, bankAddress, withdrawAll = false, withdrawOpts = {}) {
|
|
22652
22693
|
const bank = bankMap.get(bankAddress.toBase58());
|
|
22653
22694
|
if (!bank) throw Error(`Bank ${bankAddress.toBase58()} not found`);
|
|
22654
22695
|
const mintData = mintDatas.get(bankAddress.toBase58());
|
|
@@ -22672,9 +22713,23 @@ var LendrAccount = class LendrAccount {
|
|
|
22672
22713
|
if (withdrawOpts.observationBanksOverride) {
|
|
22673
22714
|
remainingAccounts.push(...withdrawOpts.observationBanksOverride);
|
|
22674
22715
|
} else {
|
|
22675
|
-
const accountMetas = computeHealthAccountMetas(healthAccounts);
|
|
22716
|
+
const accountMetas = computeHealthAccountMetas(healthAccounts, bankMetadataMap);
|
|
22676
22717
|
remainingAccounts.push(...accountMetas);
|
|
22677
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
|
+
}
|
|
22678
22733
|
return {
|
|
22679
22734
|
withdrawIxs,
|
|
22680
22735
|
wrapAndUnwrapSol,
|
|
@@ -22688,8 +22743,8 @@ var LendrAccount = class LendrAccount {
|
|
|
22688
22743
|
}))
|
|
22689
22744
|
};
|
|
22690
22745
|
}
|
|
22691
|
-
async makeWithdrawIx(program, bankMap, mintDatas, amount, bankAddress, withdrawAll = false, withdrawOpts = {}) {
|
|
22692
|
-
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);
|
|
22693
22748
|
const [bankLiquidityVaultAuthority] = getBankVaultAuthority(BankVaultType.LiquidityVault, bank.address, program.programId);
|
|
22694
22749
|
const withdrawIx = await instructions_default.makeWithdrawIx(program, {
|
|
22695
22750
|
lendrAccount: this.address,
|
|
@@ -22713,8 +22768,8 @@ var LendrAccount = class LendrAccount {
|
|
|
22713
22768
|
keys: []
|
|
22714
22769
|
};
|
|
22715
22770
|
}
|
|
22716
|
-
async makeWithdrawWithSessionIx(program, bankMap, mintDatas, amount, bankAddress, session, withdrawAll = false, withdrawOpts = {}) {
|
|
22717
|
-
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, {
|
|
22718
22773
|
...withdrawOpts,
|
|
22719
22774
|
createAtaPayer: session.payer
|
|
22720
22775
|
});
|
|
@@ -23032,6 +23087,7 @@ function isWeightedPrice(reqType) {
|
|
|
23032
23087
|
|
|
23033
23088
|
//#endregion
|
|
23034
23089
|
//#region src/models/account/wrapper.ts
|
|
23090
|
+
require_common.init_constants();
|
|
23035
23091
|
var LendrAccountWrapper = class LendrAccountWrapper {
|
|
23036
23092
|
address;
|
|
23037
23093
|
_lendrAccount;
|
|
@@ -23046,7 +23102,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
23046
23102
|
static async fetch(lendrAccountPk, client, commitment) {
|
|
23047
23103
|
const { config, program } = client;
|
|
23048
23104
|
const _lendrAccountPk = (0, __coral_xyz_anchor.translateAddress)(lendrAccountPk);
|
|
23049
|
-
const accountData = await LendrAccountWrapper.
|
|
23105
|
+
const accountData = await LendrAccountWrapper.fetchAccountData(_lendrAccountPk, config, program, commitment);
|
|
23050
23106
|
const lendrAccount = LendrAccount.fromAccountParsed(_lendrAccountPk, accountData);
|
|
23051
23107
|
const lendrAccountProxy = new LendrAccountWrapper(_lendrAccountPk, client, lendrAccount);
|
|
23052
23108
|
client.logger.debug({ accountPk: _lendrAccountPk }, "[lendr:lendr-account] Loaded lendr account");
|
|
@@ -23939,7 +23995,8 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
23939
23995
|
async makeWithdrawIx(amount, bankAddress, withdrawAll = false, withdrawOpts = {}) {
|
|
23940
23996
|
const tokenProgramAddress = this.client.mintDatas.get(bankAddress.toBase58())?.tokenProgram;
|
|
23941
23997
|
if (!tokenProgramAddress) throw Error("Withdraw mint not found");
|
|
23942
|
-
|
|
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);
|
|
23943
24000
|
}
|
|
23944
24001
|
/**
|
|
23945
24002
|
* Creates instructions for withdrawing tokens from a lendr bank account.
|
|
@@ -23955,7 +24012,8 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
23955
24012
|
async makeWithdrawWithSessionIx(amount, bankAddress, session, withdrawAll = false, withdrawOpts = {}) {
|
|
23956
24013
|
const tokenProgramAddress = this.client.mintDatas.get(bankAddress.toBase58())?.tokenProgram;
|
|
23957
24014
|
if (!tokenProgramAddress) throw Error("Withdraw mint not found");
|
|
23958
|
-
|
|
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);
|
|
23959
24017
|
}
|
|
23960
24018
|
/**
|
|
23961
24019
|
* Creates a transaction for withdrawing tokens from a lendr bank account and staking them.
|
|
@@ -24602,6 +24660,12 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
24602
24660
|
async makePulseHealthIx(mandatoryBanks = [], excludedBanks = []) {
|
|
24603
24661
|
return this._lendrAccount.makePulseHealthIx(this._program, this.client.banks, mandatoryBanks, excludedBanks, this.client.bankMetadataMap || {});
|
|
24604
24662
|
}
|
|
24663
|
+
static async fetchAccountData(accountAddress, config, program, commitment) {
|
|
24664
|
+
const mergedCommitment = commitment ?? program.provider.connection.commitment ?? require_common.DEFAULT_COMMITMENT;
|
|
24665
|
+
const data = await program.account.lendrAccount.fetch(accountAddress, mergedCommitment);
|
|
24666
|
+
if (!data.group.equals(config.groupPk)) throw Error(`Lendr account tied to group ${data.group.toBase58()}. Expected: ${config.groupPk.toBase58()}`);
|
|
24667
|
+
return data;
|
|
24668
|
+
}
|
|
24605
24669
|
static async encode(decoded, idl) {
|
|
24606
24670
|
const coder = new __coral_xyz_anchor.BorshCoder(idl);
|
|
24607
24671
|
return await coder.accounts.encode(AccountType.LendrAccount, decoded);
|
|
@@ -24775,6 +24839,7 @@ var LendrGroup = class LendrGroup {
|
|
|
24775
24839
|
|
|
24776
24840
|
//#endregion
|
|
24777
24841
|
//#region src/clients/client.ts
|
|
24842
|
+
require_common.init_constants();
|
|
24778
24843
|
/**
|
|
24779
24844
|
* Entrypoint to interact with the lendr contract.
|
|
24780
24845
|
*/
|
|
@@ -24906,6 +24971,22 @@ var LendrClient = class LendrClient {
|
|
|
24906
24971
|
});
|
|
24907
24972
|
}
|
|
24908
24973
|
/**
|
|
24974
|
+
* Fetches address lookup tables from the provided addresses
|
|
24975
|
+
* @param connection The Solana connection
|
|
24976
|
+
* @param addressLookupTableAddresses Optional array of address lookup table addresses to fetch
|
|
24977
|
+
* @param logger Optional logger
|
|
24978
|
+
* @returns Array of address lookup table accounts
|
|
24979
|
+
*/
|
|
24980
|
+
static async fetchAddressLookupTables(connection, addressLookupTableAddresses, logger = new NoopLogger()) {
|
|
24981
|
+
if (!addressLookupTableAddresses || addressLookupTableAddresses.length === 0) {
|
|
24982
|
+
logger.debug({}, "[lendr:client] No address lookup table addresses provided");
|
|
24983
|
+
return [];
|
|
24984
|
+
}
|
|
24985
|
+
logger.debug({ for: addressLookupTableAddresses }, "[lendr:client] Fetching address lookup tables");
|
|
24986
|
+
const addressLookupTables = (await Promise.all(addressLookupTableAddresses.map((address$2) => connection.getAddressLookupTable(address$2)))).map((response) => response?.value).filter((table) => table !== null);
|
|
24987
|
+
return addressLookupTables;
|
|
24988
|
+
}
|
|
24989
|
+
/**
|
|
24909
24990
|
* Fetches all data for a group, including banks and oracle prices
|
|
24910
24991
|
* NOTE: If bankAddresses not provided, this will make 2 RPC calls
|
|
24911
24992
|
* @param connection
|
|
@@ -25277,21 +25358,12 @@ var LendrClient = class LendrClient {
|
|
|
25277
25358
|
}
|
|
25278
25359
|
async makeCreateLendrAccountWithSessionIx(session, accountIndex, thirdPartyId) {
|
|
25279
25360
|
this.logger.debug({ for: session.walletPublicKey.toBase58() }, "Generating lendr account init with session ix");
|
|
25280
|
-
const PAYMASTER_DESTINATION = new __solana_web3_js.PublicKey("43TSuDshgvKXuQCmDwHXmF4s3hH3nmDNJsvWGhoNnb7v");
|
|
25281
|
-
const userTokenAtaPk = (0, __solana_spl_token.getAssociatedTokenAddressSync)(__solana_spl_token.NATIVE_MINT, session.walletPublicKey, true);
|
|
25282
|
-
const transferIx = (0, __solana_spl_token.createTransferInstruction)(userTokenAtaPk, PAYMASTER_DESTINATION, session.walletPublicKey, 1e4, [], __solana_spl_token.TOKEN_PROGRAM_ID);
|
|
25283
|
-
this.logger.debug({
|
|
25284
|
-
transferFrom: userTokenAtaPk.toBase58(),
|
|
25285
|
-
transferTo: PAYMASTER_DESTINATION.toBase58(),
|
|
25286
|
-
amount: 1e4,
|
|
25287
|
-
programId: __solana_spl_token.TOKEN_PROGRAM_ID.toBase58()
|
|
25288
|
-
}, "Adding paymaster transfer instruction to initialize tx");
|
|
25289
25361
|
const initLendrAccountIx = await instructions_default.makeInitLendrAccountWithSessionIx(this.program, {
|
|
25290
25362
|
lendrGroup: this.groupAddress,
|
|
25291
25363
|
session,
|
|
25292
25364
|
feePayer: session.payer
|
|
25293
25365
|
}, accountIndex, thirdPartyId);
|
|
25294
|
-
const ixs = [
|
|
25366
|
+
const ixs = [initLendrAccountIx];
|
|
25295
25367
|
this.logger.debug({
|
|
25296
25368
|
numInstructions: ixs.length,
|
|
25297
25369
|
instructions: ixs.map((ix, i) => ({
|
|
@@ -25336,11 +25408,13 @@ var LendrClient = class LendrClient {
|
|
|
25336
25408
|
const tx = await this.createLendrAccountWithSessionTx(session, accountIndex, thirdPartyId);
|
|
25337
25409
|
const txResult = await session.sendTransaction(tx);
|
|
25338
25410
|
this.logger.debug({ txResult }, "Created Lendr account (using session)");
|
|
25411
|
+
const thirdPartyIdValue = thirdPartyId ?? 0;
|
|
25339
25412
|
const [accountPublicKey] = __solana_web3_js.PublicKey.findProgramAddressSync([
|
|
25340
|
-
Buffer.from("
|
|
25341
|
-
session.walletPublicKey.toBuffer(),
|
|
25413
|
+
Buffer.from("lendr_account"),
|
|
25342
25414
|
this.groupAddress.toBuffer(),
|
|
25343
|
-
|
|
25415
|
+
session.walletPublicKey.toBuffer(),
|
|
25416
|
+
Buffer.from(new Uint16Array([accountIndex]).buffer),
|
|
25417
|
+
Buffer.from(new Uint16Array([thirdPartyIdValue]).buffer)
|
|
25344
25418
|
], this.programId);
|
|
25345
25419
|
try {
|
|
25346
25420
|
return {
|
|
@@ -25677,6 +25751,10 @@ var EmodeSettings = class EmodeSettings {
|
|
|
25677
25751
|
}
|
|
25678
25752
|
};
|
|
25679
25753
|
|
|
25754
|
+
//#endregion
|
|
25755
|
+
//#region src/index.ts
|
|
25756
|
+
init_constants();
|
|
25757
|
+
|
|
25680
25758
|
//#endregion
|
|
25681
25759
|
exports.AccountFlags = AccountFlags;
|
|
25682
25760
|
exports.AccountType = AccountType;
|