UNPKG

@kamino-finance/kliquidity-sdk

Version:

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

56 lines 5.2 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_PROTOCOL_FEES_V2_DISCRIMINATOR = void 0; exports.getCollectProtocolFeesV2DiscriminatorBytes = getCollectProtocolFeesV2DiscriminatorBytes; exports.getCollectProtocolFeesV2InstructionDataEncoder = getCollectProtocolFeesV2InstructionDataEncoder; exports.getCollectProtocolFeesV2InstructionDataDecoder = getCollectProtocolFeesV2InstructionDataDecoder; exports.getCollectProtocolFeesV2InstructionDataCodec = getCollectProtocolFeesV2InstructionDataCodec; exports.getCollectProtocolFeesV2Instruction = getCollectProtocolFeesV2Instruction; exports.parseCollectProtocolFeesV2Instruction = parseCollectProtocolFeesV2Instruction; const kit_1 = require("@solana/kit"); const programs_1 = require("../programs"); const shared_1 = require("../shared"); const types_1 = require("../types"); exports.COLLECT_PROTOCOL_FEES_V2_DISCRIMINATOR = new Uint8Array([103, 128, 222, 134, 114, 200, 22, 200]); function getCollectProtocolFeesV2DiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.COLLECT_PROTOCOL_FEES_V2_DISCRIMINATOR); } function getCollectProtocolFeesV2InstructionDataEncoder() { return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)], ['remainingAccountsInfo', (0, kit_1.getOptionEncoder)((0, types_1.getRemainingAccountsInfoEncoder)())]]), (value) => ({ ...value, discriminator: exports.COLLECT_PROTOCOL_FEES_V2_DISCRIMINATOR })); } function getCollectProtocolFeesV2InstructionDataDecoder() { return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)], ['remainingAccountsInfo', (0, kit_1.getOptionDecoder)((0, types_1.getRemainingAccountsInfoDecoder)())]]); } function getCollectProtocolFeesV2InstructionDataCodec() { return (0, kit_1.combineCodec)(getCollectProtocolFeesV2InstructionDataEncoder(), getCollectProtocolFeesV2InstructionDataDecoder()); } function getCollectProtocolFeesV2Instruction(input, config) { // Program address. const programAddress = config?.programAddress ?? programs_1.WHIRLPOOL_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { whirlpoolsConfig: { value: input.whirlpoolsConfig ?? null, isWritable: false }, whirlpool: { value: input.whirlpool ?? null, isWritable: true }, collectProtocolFeesAuthority: { value: input.collectProtocolFeesAuthority ?? null, isWritable: false }, tokenMintA: { value: input.tokenMintA ?? null, isWritable: false }, tokenMintB: { value: input.tokenMintB ?? null, isWritable: false }, tokenVaultA: { value: input.tokenVaultA ?? null, isWritable: true }, tokenVaultB: { value: input.tokenVaultB ?? null, isWritable: true }, tokenDestinationA: { value: input.tokenDestinationA ?? null, isWritable: true }, tokenDestinationB: { value: input.tokenDestinationB ?? null, isWritable: true }, tokenProgramA: { value: input.tokenProgramA ?? null, isWritable: false }, tokenProgramB: { value: input.tokenProgramB ?? 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.whirlpoolsConfig), getAccountMeta(accounts.whirlpool), getAccountMeta(accounts.collectProtocolFeesAuthority), getAccountMeta(accounts.tokenMintA), getAccountMeta(accounts.tokenMintB), getAccountMeta(accounts.tokenVaultA), getAccountMeta(accounts.tokenVaultB), getAccountMeta(accounts.tokenDestinationA), getAccountMeta(accounts.tokenDestinationB), getAccountMeta(accounts.tokenProgramA), getAccountMeta(accounts.tokenProgramB), getAccountMeta(accounts.memoProgram)], data: getCollectProtocolFeesV2InstructionDataEncoder().encode(args), programAddress }); } function parseCollectProtocolFeesV2Instruction(instruction) { if (instruction.accounts.length < 12) { // 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: { whirlpoolsConfig: getNextAccount(), whirlpool: getNextAccount(), collectProtocolFeesAuthority: getNextAccount(), tokenMintA: getNextAccount(), tokenMintB: getNextAccount(), tokenVaultA: getNextAccount(), tokenVaultB: getNextAccount(), tokenDestinationA: getNextAccount(), tokenDestinationB: getNextAccount(), tokenProgramA: getNextAccount(), tokenProgramB: getNextAccount(), memoProgram: getNextAccount() }, data: getCollectProtocolFeesV2InstructionDataDecoder().decode(instruction.data) }; } //# sourceMappingURL=collectProtocolFeesV2.js.map