@kamino-finance/kliquidity-sdk
Version:
Typescript SDK for interacting with the Kamino Liquidity (kliquidity) protocol
59 lines • 4.69 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.WITHDRAW_INELIGIBLE_REWARD_DISCRIMINATOR = void 0;
exports.getWithdrawIneligibleRewardDiscriminatorBytes = getWithdrawIneligibleRewardDiscriminatorBytes;
exports.getWithdrawIneligibleRewardInstructionDataEncoder = getWithdrawIneligibleRewardInstructionDataEncoder;
exports.getWithdrawIneligibleRewardInstructionDataDecoder = getWithdrawIneligibleRewardInstructionDataDecoder;
exports.getWithdrawIneligibleRewardInstructionDataCodec = getWithdrawIneligibleRewardInstructionDataCodec;
exports.getWithdrawIneligibleRewardInstruction = getWithdrawIneligibleRewardInstruction;
exports.parseWithdrawIneligibleRewardInstruction = parseWithdrawIneligibleRewardInstruction;
const kit_1 = require("@solana/kit");
const programs_1 = require("../programs");
const shared_1 = require("../shared");
exports.WITHDRAW_INELIGIBLE_REWARD_DISCRIMINATOR = new Uint8Array([148, 206, 42, 195, 247, 49, 103, 8]);
function getWithdrawIneligibleRewardDiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.WITHDRAW_INELIGIBLE_REWARD_DISCRIMINATOR); }
function getWithdrawIneligibleRewardInstructionDataEncoder() {
return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)], ['rewardIndex', (0, kit_1.getU64Encoder)()]]), (value) => ({ ...value, discriminator: exports.WITHDRAW_INELIGIBLE_REWARD_DISCRIMINATOR }));
}
function getWithdrawIneligibleRewardInstructionDataDecoder() {
return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)], ['rewardIndex', (0, kit_1.getU64Decoder)()]]);
}
function getWithdrawIneligibleRewardInstructionDataCodec() {
return (0, kit_1.combineCodec)(getWithdrawIneligibleRewardInstructionDataEncoder(), getWithdrawIneligibleRewardInstructionDataDecoder());
}
function getWithdrawIneligibleRewardInstruction(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 }, rewardVault: { value: input.rewardVault ?? null, isWritable: true }, rewardMint: { value: input.rewardMint ?? null, isWritable: false }, funderTokenAccount: { value: input.funderTokenAccount ?? null, isWritable: true }, funder: { value: input.funder ?? null, isWritable: false }, binArray: { value: input.binArray ?? null, isWritable: true }, 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.lbPair), getAccountMeta(accounts.rewardVault), getAccountMeta(accounts.rewardMint), getAccountMeta(accounts.funderTokenAccount), getAccountMeta(accounts.funder), getAccountMeta(accounts.binArray), getAccountMeta(accounts.tokenProgram), getAccountMeta(accounts.eventAuthority), getAccountMeta(accounts.program)], data: getWithdrawIneligibleRewardInstructionDataEncoder().encode(args), programAddress });
}
function parseWithdrawIneligibleRewardInstruction(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: { lbPair: getNextAccount(), rewardVault: getNextAccount(), rewardMint: getNextAccount(), funderTokenAccount: getNextAccount(), funder: getNextAccount(), binArray: getNextAccount(), tokenProgram: getNextAccount(), eventAuthority: getNextAccount(), program: getNextAccount() }, data: getWithdrawIneligibleRewardInstructionDataDecoder().decode(instruction.data) };
}
//# sourceMappingURL=withdrawIneligibleReward.js.map