UNPKG

@frakters/nft-lending-v2

Version:

Client library for interacting with nft lenging solana program

410 lines (409 loc) 21.3 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.claimInstruction = exports.purchaseInstruction = exports.claim = exports.purchase = exports.findAssociatedIdoCheckAddress = exports.findAssociatedIdoInfoAddress = exports.IDO_LOTTERY_SNAPSHOT_DATA_LAYOUT = exports.IDO_LOTTERY_USER_INFO_LAYOUT = exports.IDO_USER_INFO_LAYOUT = exports.IDO_LOTTERY_POOL_INFO_LAYOUT = exports.IDO_POOL_INFO_LAYOUT = exports.getIdoPoolById = exports.IDO_POOLS = void 0; // @ts-ignore const buffer_layout_1 = require("buffer-layout"); const lodash_1 = require("lodash"); const borsh_1 = require("@project-serum/borsh"); const web3_js_1 = require("@solana/web3.js"); const ids_1 = require("./ids"); const layouts_1 = require("./layouts"); const safe_math_1 = require("./safe-math"); const tokens_1 = require("./tokens"); const web3_1 = require("./web3"); exports.IDO_POOLS = [ { base: Object.assign({}, tokens_1.TOKENS.GRAPE), quote: Object.assign({}, tokens_1.TOKENS.USDC), price: new safe_math_1.TokenAmount(0.02, tokens_1.TOKENS.USDC.decimals, false), raise: new safe_math_1.TokenAmount(30000000, tokens_1.TOKENS.GRAPE.decimals, false), version: 3, programId: ids_1.IDO_PROGRAM_ID_V3, snapshotProgramId: '4kCccBVdQpsonm2jL2TRV1noMdarsWR2mhwwkxUTqW3W', isRayPool: true, isPrivate: false, idoId: 'E4CvLEhwih2BekPtoAExKg4hFDxAnKGehC8nsEiKVoJy', baseVault: 'HGGGN5EW85q2b65ANC7PibnwY6cUBabmnZStiXQWa1g8', quoteVault: '6oW75ZhEpi7Xf4FFihtdkKsuMYw4peX6VtvWLVKq88dQ', seedId: 'H5uXejEcXqQgtcfkqaCnwY3vTjTaNvJwyrWxmpk7ipzM', }, { base: Object.assign({}, tokens_1.TOKENS.ATLAS), quote: Object.assign({}, tokens_1.TOKENS.USDC), price: new safe_math_1.TokenAmount(0.00138, tokens_1.TOKENS.USDC.decimals, false), raise: new safe_math_1.TokenAmount(180000000, tokens_1.TOKENS.ATLAS.decimals, false), version: 3, programId: ids_1.IDO_PROGRAM_ID_V3, snapshotProgramId: '4kCccBVdQpsonm2jL2TRV1noMdarsWR2mhwwkxUTqW3W', isRayPool: true, isPrivate: false, idoId: '5VUvtxLeEZhqw22gLb47oKT4zi9MfnD9Lm8wtoXoxXe2', baseVault: 'EjrYFq71uhywEEKu5t1Pug5hnuASyXCGJTvU4h9Pirov', quoteVault: 'DvAB5zNynTwYfjrz3XkgrrXvNxuBr1dZKfv82XvhKZkv', seedId: 'Gez2YfnhhSY2aUphAfK7GDWLaDN9b4z2dfe7jH2oi7Xj', }, { base: Object.assign({}, tokens_1.TOKENS.POLIS), quote: Object.assign({}, tokens_1.TOKENS.USDC), price: new safe_math_1.TokenAmount(0.138, tokens_1.TOKENS.USDC.decimals, false), raise: new safe_math_1.TokenAmount(1800000, tokens_1.TOKENS.POLIS.decimals, false), version: 3, programId: ids_1.IDO_PROGRAM_ID_V3, snapshotProgramId: '4kCccBVdQpsonm2jL2TRV1noMdarsWR2mhwwkxUTqW3W', isRayPool: true, isPrivate: false, idoId: 'FzwVZtojkp2PMhReaqmw1a42pz9rvk9vE9MunCNUkDvM', baseVault: 'GXcxqbecKQYe7t9Vk5EtGJmQEbyT8D2JwFRAeysUPysT', quoteVault: 'ABoVH9ya22W7ghER3NHCvrJoBeKXXunccaJpBacAtWop', seedId: 'Gez2YfnhhSY2aUphAfK7GDWLaDN9b4z2dfe7jH2oi7Xj', }, { base: Object.assign({}, tokens_1.TOKENS.LIKE), quote: Object.assign({}, tokens_1.TOKENS.USDC), price: new safe_math_1.TokenAmount(0.06, tokens_1.TOKENS.USDC.decimals, false), raise: new safe_math_1.TokenAmount(1666667, tokens_1.TOKENS.LIKE.decimals, false), version: 3, programId: ids_1.IDO_PROGRAM_ID_V3, snapshotProgramId: '4kCccBVdQpsonm2jL2TRV1noMdarsWR2mhwwkxUTqW3W', isRayPool: true, isPrivate: false, idoId: '6tVhfpkvg4JTYpDCrDgjb5tAEFSzvpZXLgPtAos5xThD', baseVault: '91MgsAE7qotAtYAd9k7YVZqjs2RfW44zJMQ3gLxAGEur', quoteVault: 'PsqkXYFRAM5PjWgyVSjYMMJGG2dqkfaWe2whUXHtEAh', seedId: 'H8yyqemdjWgD2zkhhaMRsoWKUJSGWSb7kDaCEG16WH63', }, { base: Object.assign({}, tokens_1.TOKENS.SLRS), quote: Object.assign({}, tokens_1.TOKENS.USDC), price: new safe_math_1.TokenAmount(0.05, tokens_1.TOKENS.USDC.decimals, false), raise: new safe_math_1.TokenAmount(2000000, tokens_1.TOKENS.SLRS.decimals, false), version: 3, programId: ids_1.IDO_PROGRAM_ID_V3, snapshotProgramId: '4kCccBVdQpsonm2jL2TRV1noMdarsWR2mhwwkxUTqW3W', isRayPool: true, isPrivate: false, idoId: '6djgqw4EXwjGJMPuxH43RdCih5DQgwop1UK5Wk2FDvWt', baseVault: 'E6A985RSVzJYhfEzW9B7e86xtYfHz5h9wxRe2KLHWnTZ', quoteVault: '8Q8xr7X7asGL82SdniAcrN8f9hTa1DjDcbJVLNVN38zg', seedId: 'APDE8Mc9abyigJb9cWcS95mMCyyA4QN4kv5Zi4YePygt', }, { base: Object.assign({}, tokens_1.TOKENS.SLRS), quote: Object.assign({}, tokens_1.TOKENS.USDC), price: new safe_math_1.TokenAmount(0.05, tokens_1.TOKENS.USDC.decimals, false), raise: new safe_math_1.TokenAmount(480000, tokens_1.TOKENS.SLRS.decimals, false), version: 2, programId: ids_1.IDO_PROGRAM_ID_V2, snapshotProgramId: '4kCccBVdQpsonm2jL2TRV1noMdarsWR2mhwwkxUTqW3W', isRayPool: false, isPrivate: true, idoId: '7nJQCQFNNqrp2VXQM5u9CZ98LBH2EYk62V2zuKRBvw8G', baseVault: 'C3qE7ErgGDWKiz8h9Pv6FBjfnfzJFDrF5Ubb3zacMnbL', quoteVault: '5AmMZChuCAw8XWCF6RRhWTaaosemKzHc6HV89nx2Qp6z', seedId: 'FUbckyz9EKqTYvoPPRF3A2JpGJTJHRbHi2J6rJYhqCay', }, { base: Object.assign({}, tokens_1.TOKENS.SNY), quote: Object.assign({}, tokens_1.TOKENS.USDC), price: new safe_math_1.TokenAmount(1.5, tokens_1.TOKENS.USDC.decimals, false), raise: new safe_math_1.TokenAmount(700000, tokens_1.TOKENS.SNY.decimals, false), version: 3, programId: ids_1.IDO_PROGRAM_ID_V3, snapshotProgramId: '4kCccBVdQpsonm2jL2TRV1noMdarsWR2mhwwkxUTqW3W', isRayPool: true, isPrivate: false, idoId: '9aAMMBcRVfPEa7quoRyofR3rG7qF4QJTehUhV3o1mPzf', baseVault: 'D9X5KoDgC9sKFwPQcjYySGkHpe7akMvSSVDsorRgXYER', quoteVault: 'Emuu4LH3Y2c7RmC97RWw944foRUSU28QbAyx9ocyMJsS', seedId: 'AjLbEuXP49PTx1Hwb93gNC4EbeCSATWDbDoo2nyAzVrT', }, { base: Object.assign({}, tokens_1.TOKENS.MER), quote: Object.assign({}, tokens_1.TOKENS.USDC), price: new safe_math_1.TokenAmount(0.125, tokens_1.TOKENS.USDC.decimals, false), raise: new safe_math_1.TokenAmount(1000000, tokens_1.TOKENS.MER.decimals, false), version: 2, programId: ids_1.IDO_PROGRAM_ID_V2, snapshotProgramId: '4kCccBVdQpsonm2jL2TRV1noMdarsWR2mhwwkxUTqW3W', isRayPool: true, isPrivate: false, idoId: '3GANPMCSLb1NeQZZ1VNKXHrH5jCyK3DQLr4tmhvkaYng', baseVault: 'Hw41WUxQjuEbNK21nBRdoefqVhgWFe6vjJ1CTJXtXryo', quoteVault: 'AdeaHKgjYDfvzdmiaj3WSTRh6rGUF5Rf2bdgm6c9DEni', seedId: 'CAQi1pkhRPsCi24uyF6NnGm5Two1Bq2AhrDZrM9Mtfjs', }, { base: Object.assign({}, tokens_1.TOKENS.MER), quote: Object.assign({}, tokens_1.TOKENS.USDC), price: new safe_math_1.TokenAmount(0.125, tokens_1.TOKENS.USDC.decimals, false), raise: new safe_math_1.TokenAmount(1000000, tokens_1.TOKENS.MER.decimals, false), version: 2, programId: ids_1.IDO_PROGRAM_ID_V2, snapshotProgramId: '4kCccBVdQpsonm2jL2TRV1noMdarsWR2mhwwkxUTqW3W', isRayPool: true, isPrivate: false, idoId: 'F5Rk8Eht3JU69146uc9piwmMGCdPwAmYgJKRUaWxhwim', baseVault: '3CDLcsVhRReJ4otXhfi2kD2FrppRUqQYtXXZ7LgQrNy5', quoteVault: 'HrKrc1mh6jQr6Sa1DAZ9JBbpKDvTTrgkEkAHSp28tven', seedId: 'CAQi1pkhRPsCi24uyF6NnGm5Two1Bq2AhrDZrM9Mtfjs', }, { base: Object.assign({}, tokens_1.TOKENS.MEDIA), quote: Object.assign({}, tokens_1.TOKENS.USDC), price: new safe_math_1.TokenAmount(10, tokens_1.TOKENS.USDC.decimals, false), raise: new safe_math_1.TokenAmount(50000, tokens_1.TOKENS.MEDIA.decimals, false), version: 1, programId: ids_1.IDO_PROGRAM_ID, snapshotProgramId: '4kCccBVdQpsonm2jL2TRV1noMdarsWR2mhwwkxUTqW3W', isRayPool: true, isPrivate: false, idoId: 'EFnvwDxehFLycdUp6DiwcyBTz88qcZFP3KUDfmPU4Fdc', baseVault: '2WCoJRu1w6awJR7PvCc1mWKR9XpPNZDFyBDBX713k8ng', quoteVault: '21XBxBZn3tX8aaJKm1KKm6sWsLUxsMedV3a1CvNBW2m9', }, { base: Object.assign({}, tokens_1.TOKENS.MEDIA), quote: Object.assign({}, tokens_1.TOKENS.USDC), price: new safe_math_1.TokenAmount(10, tokens_1.TOKENS.USDC.decimals, false), raise: new safe_math_1.TokenAmount(50000, tokens_1.TOKENS.MEDIA.decimals, false), version: 1, programId: ids_1.IDO_PROGRAM_ID, snapshotProgramId: '11111111111111111111111111111111', isRayPool: false, isPrivate: false, idoId: '3phgXrkHbMmVLUbUvXPXsnot9WxkdyvVEyiA8odyWY8s', baseVault: '2Gxcw4Vo7zGGNg9JxksrWYazcpQTWNi8JdQkF3bF5yaN', quoteVault: '6TyVHwiEaDRQCf398QjvC6JLqPzK9REvMiS6DsCWG5o4', }, ]; function getIdoPoolById(idoId) { const pool = exports.IDO_POOLS.find((pool) => pool.idoId === idoId); if (pool) { return lodash_1.cloneDeep(pool); } return pool; } exports.getIdoPoolById = getIdoPoolById; exports.IDO_POOL_INFO_LAYOUT = buffer_layout_1.struct([ borsh_1.u64('status'), borsh_1.u64('nonce'), borsh_1.u64('startTime'), borsh_1.u64('endTime'), borsh_1.u64('startWithdrawTime'), borsh_1.u64('numerator'), borsh_1.u64('denominator'), borsh_1.u64('quoteTokenDeposited'), borsh_1.u64('baseTokenSupply'), borsh_1.u64('minDepositLimit'), borsh_1.u64('maxDepositLimit'), borsh_1.u64('minStakeLimit'), borsh_1.publicKey('quoteTokenMint'), borsh_1.publicKey('baseTokenMint'), borsh_1.publicKey('quoteTokenVault'), borsh_1.publicKey('baseTokenVault'), borsh_1.publicKey('stakePoolId'), borsh_1.publicKey('stakeProgramId'), borsh_1.publicKey('checkProgramId'), borsh_1.publicKey('idoOwner'), ]); exports.IDO_LOTTERY_POOL_INFO_LAYOUT = buffer_layout_1.struct([ borsh_1.u64('status'), borsh_1.u64('nonce'), borsh_1.u64('startTime'), borsh_1.u64('endTime'), borsh_1.u64('startWithdrawTime'), borsh_1.u64('numerator'), borsh_1.u64('denominator'), borsh_1.u64('quoteTokenDeposited'), borsh_1.u64('baseTokenSupply'), borsh_1.u64('perUserMaxLottery'), borsh_1.u64('perUserMinLottery'), borsh_1.u64('perLotteryNeedMinStake'), borsh_1.u64('perLotteryWorthQuoteAmount'), borsh_1.u64('totalWinLotteryLimit'), borsh_1.u64('totalDepositUserNumber'), borsh_1.u64('currentLotteryNumber'), buffer_layout_1.seq(buffer_layout_1.struct([borsh_1.u64('luckyTailDigits'), borsh_1.u64('luckyTailNumber'), borsh_1.u64('luckyWithinNumber'), borsh_1.u64('luckyNumberExist')]), 10, 'luckyInfos'), borsh_1.publicKey('quoteTokenMint'), borsh_1.publicKey('baseTokenMint'), borsh_1.publicKey('quoteTokenVault'), borsh_1.publicKey('baseTokenVault'), borsh_1.publicKey('stakePoolId'), borsh_1.publicKey('stakeProgramId'), borsh_1.publicKey('checkProgramId'), borsh_1.publicKey('idoOwner'), borsh_1.publicKey('poolSeedId'), ]); exports.IDO_USER_INFO_LAYOUT = buffer_layout_1.struct([ borsh_1.u64('state'), borsh_1.publicKey('idoPoolId'), borsh_1.publicKey('owner'), borsh_1.u64('quoteTokenDeposited'), ]); exports.IDO_LOTTERY_USER_INFO_LAYOUT = buffer_layout_1.struct([ borsh_1.u64('state'), borsh_1.publicKey('idoPoolId'), borsh_1.publicKey('owner'), borsh_1.u64('quoteTokenDeposited'), borsh_1.u64('quoteTokenWithdrawn'), borsh_1.u64('baseTokenWithdrawn'), borsh_1.u64('lotteryBeginNumber'), borsh_1.u64('lotteryEndNumber'), ]); exports.IDO_LOTTERY_SNAPSHOT_DATA_LAYOUT = buffer_layout_1.struct([borsh_1.u64('eligibleTicketAmount')]); function findAssociatedIdoInfoAddress(idoId, walletAddress, programId) { return __awaiter(this, void 0, void 0, function* () { const { publicKey } = yield web3_1.findProgramAddress([idoId.toBuffer(), walletAddress.toBuffer(), new Uint8Array(Buffer.from('ido_associated_seed', 'utf-8'))], programId); return publicKey; }); } exports.findAssociatedIdoInfoAddress = findAssociatedIdoInfoAddress; function findAssociatedIdoCheckAddress(idoId, walletAddress, snapshotProgramId) { return __awaiter(this, void 0, void 0, function* () { const { publicKey } = yield web3_1.findProgramAddress([idoId.toBuffer(), walletAddress.toBuffer(), snapshotProgramId.toBuffer()], snapshotProgramId); return publicKey; }); } exports.findAssociatedIdoCheckAddress = findAssociatedIdoCheckAddress; function purchase({ connection, wallet, poolInfo, userQuoteTokenAccount, stakeInfoAccount, amount, }) { var _a; return __awaiter(this, void 0, void 0, function* () { if (!connection || !wallet) throw new Error('Miss connection'); if (!poolInfo) throw new Error('Miss pool infomations'); if (!amount) throw new Error('Miss amount infomations'); const transaction = new web3_js_1.Transaction(); const signers = []; const owner = wallet.publicKey; const { publicKey: idoAuthority } = yield web3_1.findProgramAddress([new web3_js_1.PublicKey(poolInfo.idoId).toBuffer()], new web3_js_1.PublicKey(poolInfo.programId)); const userIdoInfo = yield findAssociatedIdoInfoAddress(new web3_js_1.PublicKey(poolInfo.idoId), owner, new web3_js_1.PublicKey(poolInfo.programId)); const userIdoCheck = poolInfo.version === 1 ? yield findAssociatedIdoCheckAddress(new web3_js_1.PublicKey(poolInfo.idoId), owner, new web3_js_1.PublicKey(poolInfo.snapshotProgramId)) : yield findAssociatedIdoCheckAddress(new web3_js_1.PublicKey((_a = poolInfo.seedId) !== null && _a !== void 0 ? _a : 'CAQi1pkhRPsCi24uyF6NnGm5Two1Bq2AhrDZrM9Mtfjs'), owner, new web3_js_1.PublicKey(poolInfo.snapshotProgramId)); transaction.add(poolInfo.version === 3 // transaction point to lottery ? purchaseInstruction({ programId: new web3_js_1.PublicKey(poolInfo.programId), amount }, { idoId: new web3_js_1.PublicKey(poolInfo.idoId), authority: idoAuthority, poolQuoteTokenAccount: new web3_js_1.PublicKey(poolInfo.quoteVault), userQuoteTokenAccount: new web3_js_1.PublicKey(userQuoteTokenAccount), userIdoInfo, userOwner: owner, userIdoCheck, }) : poolInfo.isPrivate ? purchaseInstruction({ programId: new web3_js_1.PublicKey(poolInfo.programId), amount: layouts_1.getBigNumber(new safe_math_1.TokenAmount(amount, poolInfo.quote.decimals, false).wei), }, { idoId: new web3_js_1.PublicKey(poolInfo.idoId), authority: idoAuthority, poolQuoteTokenAccount: new web3_js_1.PublicKey(poolInfo.quoteVault), userQuoteTokenAccount: new web3_js_1.PublicKey(userQuoteTokenAccount), userIdoInfo, userOwner: owner, userIdoCheck, }) : purchaseInstruction({ programId: new web3_js_1.PublicKey(poolInfo.programId), amount: layouts_1.getBigNumber(new safe_math_1.TokenAmount(amount, poolInfo.quote.decimals, false).wei), }, { idoId: new web3_js_1.PublicKey(poolInfo.idoId), authority: idoAuthority, poolQuoteTokenAccount: new web3_js_1.PublicKey(poolInfo.quoteVault), userQuoteTokenAccount: new web3_js_1.PublicKey(userQuoteTokenAccount), userIdoInfo, userOwner: owner, userStakeInfo: new web3_js_1.PublicKey(stakeInfoAccount), userIdoCheck, })); return yield web3_1.sendTransaction(connection, wallet, transaction, signers); }); } exports.purchase = purchase; function claim({ connection, wallet, poolInfo, userBaseTokenAccount, userQuoteTokenAccount, aim, }) { return __awaiter(this, void 0, void 0, function* () { if (!connection || !wallet) throw new Error('Miss connection'); if (!poolInfo) throw new Error('Miss pool infomations'); const transaction = new web3_js_1.Transaction(); const signers = []; const owner = wallet.publicKey; const newUserBaseTokenAccount = userBaseTokenAccount ? new web3_js_1.PublicKey(userBaseTokenAccount) : yield web3_1.createAssociatedTokenAccount(new web3_js_1.PublicKey(poolInfo.base.mintAddress), owner, transaction); const newUserQuoteTokenAccount = userQuoteTokenAccount ? new web3_js_1.PublicKey(userQuoteTokenAccount) : yield web3_1.createAssociatedTokenAccount(new web3_js_1.PublicKey(poolInfo.quote.mintAddress), owner, transaction); const { publicKey: idoAuthority } = yield web3_1.findProgramAddress([new web3_js_1.PublicKey(poolInfo.idoId).toBuffer()], new web3_js_1.PublicKey(poolInfo.programId)); const userIdoInfo = yield findAssociatedIdoInfoAddress(new web3_js_1.PublicKey(poolInfo.idoId), owner, new web3_js_1.PublicKey(poolInfo.programId)); transaction.add(poolInfo.version === 3 // transaction point to lottery ? claimInstruction({ programId: new web3_js_1.PublicKey(poolInfo.programId) }, { idoId: new web3_js_1.PublicKey(poolInfo.idoId), authority: idoAuthority, poolTokenAccount: new web3_js_1.PublicKey(aim === 'base' ? poolInfo.baseVault : poolInfo.quoteVault), userTokenAccount: aim === 'base' ? newUserBaseTokenAccount : newUserQuoteTokenAccount, userIdoInfo, userOwner: owner, }) : claimInstruction({ programId: new web3_js_1.PublicKey(poolInfo.programId) }, { idoId: new web3_js_1.PublicKey(poolInfo.idoId), authority: idoAuthority, poolQuoteTokenAccount: new web3_js_1.PublicKey(poolInfo.quoteVault), poolBaseTokenAccount: new web3_js_1.PublicKey(poolInfo.baseVault), userQuoteTokenAccount: newUserQuoteTokenAccount, userBaseTokenAccount: newUserBaseTokenAccount, userIdoInfo, userOwner: owner, })); return yield web3_1.sendTransaction(connection, wallet, transaction, signers); }); } exports.claim = claim; function purchaseInstruction({ programId, amount }, instructionKeys) { const dataLayout = buffer_layout_1.struct([buffer_layout_1.u8('instruction'), buffer_layout_1.nu64('amount')]); const keys = [ // system { pubkey: ids_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false }, { pubkey: ids_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }, { pubkey: ids_1.RENT_PROGRAM_ID, isSigner: false, isWritable: false }, { pubkey: ids_1.CLOCK_PROGRAM_ID, isSigner: false, isWritable: false }, // pubkeys ...Object.entries(instructionKeys).map(([name, pubkey]) => ({ pubkey, isSigner: name === 'userOwner', isWritable: !['authority', 'userOwner', 'userIdoCheck', 'userStakeInfo'].includes(name), })), ]; const data = Buffer.alloc(dataLayout.span); dataLayout.encode({ instruction: 1, amount: Number(amount) }, data); return new web3_js_1.TransactionInstruction({ keys, programId, data }); } exports.purchaseInstruction = purchaseInstruction; function claimInstruction({ programId }, instructionKeys) { const dataLayout = buffer_layout_1.struct([buffer_layout_1.u8('instruction')]); const keys = [ { pubkey: ids_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }, { pubkey: ids_1.CLOCK_PROGRAM_ID, isSigner: false, isWritable: false }, ...Object.entries(instructionKeys).map(([name, pubkey]) => ({ pubkey, isSigner: name === 'userOwner', isWritable: !['authority', 'userOwner'].includes(name), })), ]; const data = Buffer.alloc(dataLayout.span); dataLayout.encode({ instruction: 2 }, data); return new web3_js_1.TransactionInstruction({ keys, programId, data }); } exports.claimInstruction = claimInstruction;