UNPKG

@kamino-finance/kliquidity-sdk

Version:

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

59 lines 5.87 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.DECREASE_LIQUIDITY_V2_DISCRIMINATOR = void 0; exports.getDecreaseLiquidityV2DiscriminatorBytes = getDecreaseLiquidityV2DiscriminatorBytes; exports.getDecreaseLiquidityV2InstructionDataEncoder = getDecreaseLiquidityV2InstructionDataEncoder; exports.getDecreaseLiquidityV2InstructionDataDecoder = getDecreaseLiquidityV2InstructionDataDecoder; exports.getDecreaseLiquidityV2InstructionDataCodec = getDecreaseLiquidityV2InstructionDataCodec; exports.getDecreaseLiquidityV2Instruction = getDecreaseLiquidityV2Instruction; exports.parseDecreaseLiquidityV2Instruction = parseDecreaseLiquidityV2Instruction; const kit_1 = require("@solana/kit"); const programs_1 = require("../programs"); const shared_1 = require("../shared"); exports.DECREASE_LIQUIDITY_V2_DISCRIMINATOR = new Uint8Array([58, 127, 188, 62, 79, 82, 196, 96]); function getDecreaseLiquidityV2DiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.DECREASE_LIQUIDITY_V2_DISCRIMINATOR); } function getDecreaseLiquidityV2InstructionDataEncoder() { return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)], ['liquidity', (0, kit_1.getU128Encoder)()], ['amount0Min', (0, kit_1.getU64Encoder)()], ['amount1Min', (0, kit_1.getU64Encoder)()]]), (value) => ({ ...value, discriminator: exports.DECREASE_LIQUIDITY_V2_DISCRIMINATOR })); } function getDecreaseLiquidityV2InstructionDataDecoder() { return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)], ['liquidity', (0, kit_1.getU128Decoder)()], ['amount0Min', (0, kit_1.getU64Decoder)()], ['amount1Min', (0, kit_1.getU64Decoder)()]]); } function getDecreaseLiquidityV2InstructionDataCodec() { return (0, kit_1.combineCodec)(getDecreaseLiquidityV2InstructionDataEncoder(), getDecreaseLiquidityV2InstructionDataDecoder()); } function getDecreaseLiquidityV2Instruction(input, config) { // Program address. const programAddress = config?.programAddress ?? programs_1.AMM_V3_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { nftOwner: { value: input.nftOwner ?? null, isWritable: false }, nftAccount: { value: input.nftAccount ?? null, isWritable: false }, personalPosition: { value: input.personalPosition ?? null, isWritable: true }, poolState: { value: input.poolState ?? null, isWritable: true }, protocolPosition: { value: input.protocolPosition ?? null, isWritable: true }, tokenVault0: { value: input.tokenVault0 ?? null, isWritable: true }, tokenVault1: { value: input.tokenVault1 ?? null, isWritable: true }, tickArrayLower: { value: input.tickArrayLower ?? null, isWritable: true }, tickArrayUpper: { value: input.tickArrayUpper ?? null, isWritable: true }, recipientTokenAccount0: { value: input.recipientTokenAccount0 ?? null, isWritable: true }, recipientTokenAccount1: { value: input.recipientTokenAccount1 ?? null, isWritable: true }, tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, tokenProgram2022: { value: input.tokenProgram2022 ?? null, isWritable: false }, memoProgram: { value: input.memoProgram ?? null, isWritable: false }, vault0Mint: { value: input.vault0Mint ?? null, isWritable: false }, vault1Mint: { value: input.vault1Mint ?? null, isWritable: false } }; const accounts = originalAccounts; // Original args. const args = { ...input, }; // Resolve default values. if (!accounts.tokenProgram.value) { accounts.tokenProgram.value = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'; } const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId'); return Object.freeze({ accounts: [getAccountMeta(accounts.nftOwner), getAccountMeta(accounts.nftAccount), getAccountMeta(accounts.personalPosition), getAccountMeta(accounts.poolState), getAccountMeta(accounts.protocolPosition), getAccountMeta(accounts.tokenVault0), getAccountMeta(accounts.tokenVault1), getAccountMeta(accounts.tickArrayLower), getAccountMeta(accounts.tickArrayUpper), getAccountMeta(accounts.recipientTokenAccount0), getAccountMeta(accounts.recipientTokenAccount1), getAccountMeta(accounts.tokenProgram), getAccountMeta(accounts.tokenProgram2022), getAccountMeta(accounts.memoProgram), getAccountMeta(accounts.vault0Mint), getAccountMeta(accounts.vault1Mint)], data: getDecreaseLiquidityV2InstructionDataEncoder().encode(args), programAddress }); } function parseDecreaseLiquidityV2Instruction(instruction) { if (instruction.accounts.length < 16) { // 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: { nftOwner: getNextAccount(), nftAccount: getNextAccount(), personalPosition: getNextAccount(), poolState: getNextAccount(), protocolPosition: getNextAccount(), tokenVault0: getNextAccount(), tokenVault1: getNextAccount(), tickArrayLower: getNextAccount(), tickArrayUpper: getNextAccount(), recipientTokenAccount0: getNextAccount(), recipientTokenAccount1: getNextAccount(), tokenProgram: getNextAccount(), tokenProgram2022: getNextAccount(), memoProgram: getNextAccount(), vault0Mint: getNextAccount(), vault1Mint: getNextAccount() }, data: getDecreaseLiquidityV2InstructionDataDecoder().decode(instruction.data) }; } //# sourceMappingURL=decreaseLiquidityV2.js.map