UNPKG

@kamino-finance/kliquidity-sdk

Version:

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

64 lines 5.62 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.ADD_LIQUIDITY_ONE_SIDE_PRECISE_DISCRIMINATOR = void 0; exports.getAddLiquidityOneSidePreciseDiscriminatorBytes = getAddLiquidityOneSidePreciseDiscriminatorBytes; exports.getAddLiquidityOneSidePreciseInstructionDataEncoder = getAddLiquidityOneSidePreciseInstructionDataEncoder; exports.getAddLiquidityOneSidePreciseInstructionDataDecoder = getAddLiquidityOneSidePreciseInstructionDataDecoder; exports.getAddLiquidityOneSidePreciseInstructionDataCodec = getAddLiquidityOneSidePreciseInstructionDataCodec; exports.getAddLiquidityOneSidePreciseInstruction = getAddLiquidityOneSidePreciseInstruction; exports.parseAddLiquidityOneSidePreciseInstruction = parseAddLiquidityOneSidePreciseInstruction; const kit_1 = require("@solana/kit"); const programs_1 = require("../programs"); const shared_1 = require("../shared"); const types_1 = require("../types"); exports.ADD_LIQUIDITY_ONE_SIDE_PRECISE_DISCRIMINATOR = new Uint8Array([161, 194, 103, 84, 171, 71, 250, 154]); function getAddLiquidityOneSidePreciseDiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.ADD_LIQUIDITY_ONE_SIDE_PRECISE_DISCRIMINATOR); } function getAddLiquidityOneSidePreciseInstructionDataEncoder() { return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)], ['bins', (0, kit_1.getArrayEncoder)((0, types_1.getCompressedBinDepositAmountEncoder)())], ['decompressMultiplier', (0, kit_1.getU64Encoder)()]]), (value) => ({ ...value, discriminator: exports.ADD_LIQUIDITY_ONE_SIDE_PRECISE_DISCRIMINATOR })); } function getAddLiquidityOneSidePreciseInstructionDataDecoder() { return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)], ['bins', (0, kit_1.getArrayDecoder)((0, types_1.getCompressedBinDepositAmountDecoder)())], ['decompressMultiplier', (0, kit_1.getU64Decoder)()]]); } function getAddLiquidityOneSidePreciseInstructionDataCodec() { return (0, kit_1.combineCodec)(getAddLiquidityOneSidePreciseInstructionDataEncoder(), getAddLiquidityOneSidePreciseInstructionDataDecoder()); } function getAddLiquidityOneSidePreciseInstruction(input, config) { // Program address. const programAddress = config?.programAddress ?? programs_1.LB_CLMM_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { position: { value: input.position ?? null, isWritable: true }, lbPair: { value: input.lbPair ?? null, isWritable: true }, binArrayBitmapExtension: { value: input.binArrayBitmapExtension ?? null, isWritable: true }, userToken: { value: input.userToken ?? null, isWritable: true }, reserve: { value: input.reserve ?? null, isWritable: true }, tokenMint: { value: input.tokenMint ?? null, isWritable: false }, binArrayLower: { value: input.binArrayLower ?? null, isWritable: true }, binArrayUpper: { value: input.binArrayUpper ?? null, isWritable: true }, sender: { value: input.sender ?? null, isWritable: false }, tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, program: { value: input.program ?? 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.position), getAccountMeta(accounts.lbPair), getAccountMeta(accounts.binArrayBitmapExtension), getAccountMeta(accounts.userToken), getAccountMeta(accounts.reserve), getAccountMeta(accounts.tokenMint), getAccountMeta(accounts.binArrayLower), getAccountMeta(accounts.binArrayUpper), getAccountMeta(accounts.sender), getAccountMeta(accounts.tokenProgram), getAccountMeta(accounts.eventAuthority), getAccountMeta(accounts.program)], data: getAddLiquidityOneSidePreciseInstructionDataEncoder().encode(args), programAddress }); } function parseAddLiquidityOneSidePreciseInstruction(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; }; const getNextOptionalAccount = () => { const accountMeta = getNextAccount(); return accountMeta.address === programs_1.LB_CLMM_PROGRAM_ADDRESS ? undefined : accountMeta; }; return { programAddress: instruction.programAddress, accounts: { position: getNextAccount(), lbPair: getNextAccount(), binArrayBitmapExtension: getNextOptionalAccount(), userToken: getNextAccount(), reserve: getNextAccount(), tokenMint: getNextAccount(), binArrayLower: getNextAccount(), binArrayUpper: getNextAccount(), sender: getNextAccount(), tokenProgram: getNextAccount(), eventAuthority: getNextAccount(), program: getNextAccount() }, data: getAddLiquidityOneSidePreciseInstructionDataDecoder().decode(instruction.data) }; } //# sourceMappingURL=addLiquidityOneSidePrecise.js.map