@kamino-finance/kliquidity-sdk
Version:
Typescript SDK for interacting with the Kamino Liquidity (kliquidity) protocol
57 lines • 4.76 kB
JavaScript
;
/**
* 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.CLAIM_FEE_DISCRIMINATOR = void 0;
exports.getClaimFeeDiscriminatorBytes = getClaimFeeDiscriminatorBytes;
exports.getClaimFeeInstructionDataEncoder = getClaimFeeInstructionDataEncoder;
exports.getClaimFeeInstructionDataDecoder = getClaimFeeInstructionDataDecoder;
exports.getClaimFeeInstructionDataCodec = getClaimFeeInstructionDataCodec;
exports.getClaimFeeInstruction = getClaimFeeInstruction;
exports.parseClaimFeeInstruction = parseClaimFeeInstruction;
const kit_1 = require("@solana/kit");
const programs_1 = require("../programs");
const shared_1 = require("../shared");
exports.CLAIM_FEE_DISCRIMINATOR = new Uint8Array([169, 32, 79, 137, 136, 232, 70, 137]);
function getClaimFeeDiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.CLAIM_FEE_DISCRIMINATOR); }
function getClaimFeeInstructionDataEncoder() {
return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)]]), (value) => ({ ...value, discriminator: exports.CLAIM_FEE_DISCRIMINATOR }));
}
function getClaimFeeInstructionDataDecoder() {
return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)]]);
}
function getClaimFeeInstructionDataCodec() {
return (0, kit_1.combineCodec)(getClaimFeeInstructionDataEncoder(), getClaimFeeInstructionDataDecoder());
}
function getClaimFeeInstruction(input, config) {
// Program address.
const programAddress = config?.programAddress ?? programs_1.LB_CLMM_PROGRAM_ADDRESS;
// Original accounts.
const originalAccounts = { lbPair: { value: input.lbPair ?? null, isWritable: true }, position: { value: input.position ?? null, isWritable: true }, binArrayLower: { value: input.binArrayLower ?? null, isWritable: true }, binArrayUpper: { value: input.binArrayUpper ?? null, isWritable: true }, sender: { value: input.sender ?? null, isWritable: false }, reserveX: { value: input.reserveX ?? null, isWritable: true }, reserveY: { value: input.reserveY ?? null, isWritable: true }, userTokenX: { value: input.userTokenX ?? null, isWritable: true }, userTokenY: { value: input.userTokenY ?? null, isWritable: true }, tokenXMint: { value: input.tokenXMint ?? null, isWritable: false }, tokenYMint: { value: input.tokenYMint ?? 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;
// 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.lbPair), getAccountMeta(accounts.position), getAccountMeta(accounts.binArrayLower), getAccountMeta(accounts.binArrayUpper), getAccountMeta(accounts.sender), getAccountMeta(accounts.reserveX), getAccountMeta(accounts.reserveY), getAccountMeta(accounts.userTokenX), getAccountMeta(accounts.userTokenY), getAccountMeta(accounts.tokenXMint), getAccountMeta(accounts.tokenYMint), getAccountMeta(accounts.tokenProgram), getAccountMeta(accounts.eventAuthority), getAccountMeta(accounts.program)], data: getClaimFeeInstructionDataEncoder().encode({}), programAddress });
}
function parseClaimFeeInstruction(instruction) {
if (instruction.accounts.length < 14) {
// 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: { lbPair: getNextAccount(), position: getNextAccount(), binArrayLower: getNextAccount(), binArrayUpper: getNextAccount(), sender: getNextAccount(), reserveX: getNextAccount(), reserveY: getNextAccount(), userTokenX: getNextAccount(), userTokenY: getNextAccount(), tokenXMint: getNextAccount(), tokenYMint: getNextAccount(), tokenProgram: getNextAccount(), eventAuthority: getNextAccount(), program: getNextAccount() }, data: getClaimFeeInstructionDataDecoder().decode(instruction.data) };
}
//# sourceMappingURL=claimFee.js.map