UNPKG

@symmetry-hq/baskets-v2-sdk

Version:

Symmetry Baskets V2 SDK

39 lines (38 loc) 2.05 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.initializeWithdrawStateIx = initializeWithdrawStateIx; // Core dependencies const anchor_1 = require("@coral-xyz/anchor"); const web3_js_1 = require("@solana/web3.js"); const withdrawState_1 = require("../../state/withdrawState"); const programAccounts_1 = require("../../utils/programAccounts"); function initializeWithdrawStateIx(params) { return __awaiter(this, void 0, void 0, function* () { // Destructure params const { program, withdrawStateSeed } = params; // Calculate required lamports for rent exemption const lamports = yield program.provider.connection.getMinimumBalanceForRentExemption(8 + withdrawState_1.WITHDRAW_STATE_SIZE); // Get required accounts const withdrawState = (0, programAccounts_1.getWithdrawStateAccount)(withdrawStateSeed); const stateCreator = (0, programAccounts_1.getStateCreatorAccount)(); // Build and return instruction return yield program.methods .initializeWithdrawState(withdrawStateSeed, new anchor_1.BN(lamports)) .accountsStrict({ withdrawState, stateCreator, systemProgram: web3_js_1.SystemProgram.programId, rent: web3_js_1.SYSVAR_RENT_PUBKEY, }) .instruction(); }); }