UNPKG

@kamino-finance/kliquidity-sdk

Version:

Typescript SDK for interacting with the Kamino Liquidity (kliquidity) protocol

56 lines 4.66 kB
"use strict"; /** * This code was AUTOGENERATED using the Codama library. * Please DO NOT EDIT THIS FILE, instead use visitors * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ Object.defineProperty(exports, "__esModule", { value: true }); exports.COLLECT_REWARD_V2_DISCRIMINATOR = void 0; exports.getCollectRewardV2DiscriminatorBytes = getCollectRewardV2DiscriminatorBytes; exports.getCollectRewardV2InstructionDataEncoder = getCollectRewardV2InstructionDataEncoder; exports.getCollectRewardV2InstructionDataDecoder = getCollectRewardV2InstructionDataDecoder; exports.getCollectRewardV2InstructionDataCodec = getCollectRewardV2InstructionDataCodec; exports.getCollectRewardV2Instruction = getCollectRewardV2Instruction; exports.parseCollectRewardV2Instruction = parseCollectRewardV2Instruction; const kit_1 = require("@solana/kit"); const programs_1 = require("../programs"); const shared_1 = require("../shared"); const types_1 = require("../types"); exports.COLLECT_REWARD_V2_DISCRIMINATOR = new Uint8Array([177, 107, 37, 180, 160, 19, 49, 209]); function getCollectRewardV2DiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.COLLECT_REWARD_V2_DISCRIMINATOR); } function getCollectRewardV2InstructionDataEncoder() { return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)], ['rewardIndex', (0, kit_1.getU8Encoder)()], ['remainingAccountsInfo', (0, kit_1.getOptionEncoder)((0, types_1.getRemainingAccountsInfoEncoder)())]]), (value) => ({ ...value, discriminator: exports.COLLECT_REWARD_V2_DISCRIMINATOR })); } function getCollectRewardV2InstructionDataDecoder() { return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)], ['rewardIndex', (0, kit_1.getU8Decoder)()], ['remainingAccountsInfo', (0, kit_1.getOptionDecoder)((0, types_1.getRemainingAccountsInfoDecoder)())]]); } function getCollectRewardV2InstructionDataCodec() { return (0, kit_1.combineCodec)(getCollectRewardV2InstructionDataEncoder(), getCollectRewardV2InstructionDataDecoder()); } function getCollectRewardV2Instruction(input, config) { // Program address. const programAddress = config?.programAddress ?? programs_1.WHIRLPOOL_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { whirlpool: { value: input.whirlpool ?? null, isWritable: false }, positionAuthority: { value: input.positionAuthority ?? null, isWritable: false }, position: { value: input.position ?? null, isWritable: true }, positionTokenAccount: { value: input.positionTokenAccount ?? null, isWritable: false }, rewardOwnerAccount: { value: input.rewardOwnerAccount ?? null, isWritable: true }, rewardMint: { value: input.rewardMint ?? null, isWritable: false }, rewardVault: { value: input.rewardVault ?? null, isWritable: true }, rewardTokenProgram: { value: input.rewardTokenProgram ?? null, isWritable: false }, memoProgram: { value: input.memoProgram ?? null, isWritable: false } }; const accounts = originalAccounts; // Original args. const args = { ...input, }; const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId'); return Object.freeze({ accounts: [getAccountMeta(accounts.whirlpool), getAccountMeta(accounts.positionAuthority), getAccountMeta(accounts.position), getAccountMeta(accounts.positionTokenAccount), getAccountMeta(accounts.rewardOwnerAccount), getAccountMeta(accounts.rewardMint), getAccountMeta(accounts.rewardVault), getAccountMeta(accounts.rewardTokenProgram), getAccountMeta(accounts.memoProgram)], data: getCollectRewardV2InstructionDataEncoder().encode(args), programAddress }); } function parseCollectRewardV2Instruction(instruction) { if (instruction.accounts.length < 9) { // TODO: Coded error. throw new Error('Not enough accounts'); } let accountIndex = 0; const getNextAccount = () => { const accountMeta = instruction.accounts[accountIndex]; accountIndex += 1; return accountMeta; }; return { programAddress: instruction.programAddress, accounts: { whirlpool: getNextAccount(), positionAuthority: getNextAccount(), position: getNextAccount(), positionTokenAccount: getNextAccount(), rewardOwnerAccount: getNextAccount(), rewardMint: getNextAccount(), rewardVault: getNextAccount(), rewardTokenProgram: getNextAccount(), memoProgram: getNextAccount() }, data: getCollectRewardV2InstructionDataDecoder().decode(instruction.data) }; } //# sourceMappingURL=collectRewardV2.js.map