UNPKG

fbonds-core

Version:

Banx protocol sdk

47 lines (46 loc) 2.51 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.mintSanctumLst = void 0; const anchor_1 = require("@coral-xyz/anchor"); const constants_1 = require("../../constants"); const common_1 = require("../../../common"); const spl_stake_pool_1 = require("@solana/spl-stake-pool"); const mintSanctumLst = (_a) => __awaiter(void 0, [_a], void 0, function* ({ accounts, args, sendTxn, }) { const instructions = []; // Create token account if not specified const associatedAddress = yield (0, common_1.findAssociatedTokenAddress)(accounts.userPubkey, accounts.lstMint); instructions.push(...(0, common_1.createAssociatedTokenAccountInstructionIdimpotent)(associatedAddress, accounts.userPubkey, accounts.userPubkey, accounts.lstMint)); const [withdrawAuthority] = yield anchor_1.web3.PublicKey.findProgramAddress([accounts.lstPool.toBuffer(), Buffer.from('withdraw')], constants_1.SANCTUM_POOL_PROGRAM); let stakePoolInstr = spl_stake_pool_1.StakePoolInstruction.depositSol({ stakePool: accounts.lstPool, reserveStake: accounts.reserveStakePool, fundingAccount: accounts.userPubkey, destinationPoolAccount: associatedAddress, managerFeeAccount: accounts.managerFeeAccount, referralPoolAccount: associatedAddress, poolMint: accounts.lstMint, lamports: Number(args.amount), withdrawAuthority, }); stakePoolInstr.programId = constants_1.SANCTUM_POOL_PROGRAM; instructions.push(stakePoolInstr); const transaction = new anchor_1.web3.Transaction(); for (let instruction of instructions) transaction.add(instruction); let signers = []; yield sendTxn(transaction, signers); return { instructions, signers, }; }); exports.mintSanctumLst = mintSanctumLst;