UNPKG

@kamino-finance/kliquidity-sdk

Version:

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

59 lines 4.35 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.SET_REWARD_PARAMS_DISCRIMINATOR = void 0; exports.getSetRewardParamsDiscriminatorBytes = getSetRewardParamsDiscriminatorBytes; exports.getSetRewardParamsInstructionDataEncoder = getSetRewardParamsInstructionDataEncoder; exports.getSetRewardParamsInstructionDataDecoder = getSetRewardParamsInstructionDataDecoder; exports.getSetRewardParamsInstructionDataCodec = getSetRewardParamsInstructionDataCodec; exports.getSetRewardParamsInstruction = getSetRewardParamsInstruction; exports.parseSetRewardParamsInstruction = parseSetRewardParamsInstruction; const kit_1 = require("@solana/kit"); const programs_1 = require("../programs"); const shared_1 = require("../shared"); exports.SET_REWARD_PARAMS_DISCRIMINATOR = new Uint8Array([112, 52, 167, 75, 32, 201, 211, 137]); function getSetRewardParamsDiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.SET_REWARD_PARAMS_DISCRIMINATOR); } function getSetRewardParamsInstructionDataEncoder() { return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)], ['rewardIndex', (0, kit_1.getU8Encoder)()], ['emissionsPerSecondX64', (0, kit_1.getU128Encoder)()], ['openTime', (0, kit_1.getU64Encoder)()], ['endTime', (0, kit_1.getU64Encoder)()]]), (value) => ({ ...value, discriminator: exports.SET_REWARD_PARAMS_DISCRIMINATOR })); } function getSetRewardParamsInstructionDataDecoder() { return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)], ['rewardIndex', (0, kit_1.getU8Decoder)()], ['emissionsPerSecondX64', (0, kit_1.getU128Decoder)()], ['openTime', (0, kit_1.getU64Decoder)()], ['endTime', (0, kit_1.getU64Decoder)()]]); } function getSetRewardParamsInstructionDataCodec() { return (0, kit_1.combineCodec)(getSetRewardParamsInstructionDataEncoder(), getSetRewardParamsInstructionDataDecoder()); } function getSetRewardParamsInstruction(input, config) { // Program address. const programAddress = config?.programAddress ?? programs_1.AMM_V3_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { authority: { value: input.authority ?? null, isWritable: false }, ammConfig: { value: input.ammConfig ?? null, isWritable: false }, poolState: { value: input.poolState ?? null, isWritable: true }, operationState: { value: input.operationState ?? null, isWritable: false }, tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, tokenProgram2022: { value: input.tokenProgram2022 ?? 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.authority), getAccountMeta(accounts.ammConfig), getAccountMeta(accounts.poolState), getAccountMeta(accounts.operationState), getAccountMeta(accounts.tokenProgram), getAccountMeta(accounts.tokenProgram2022)], data: getSetRewardParamsInstructionDataEncoder().encode(args), programAddress }); } function parseSetRewardParamsInstruction(instruction) { if (instruction.accounts.length < 6) { // 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: { authority: getNextAccount(), ammConfig: getNextAccount(), poolState: getNextAccount(), operationState: getNextAccount(), tokenProgram: getNextAccount(), tokenProgram2022: getNextAccount() }, data: getSetRewardParamsInstructionDataDecoder().decode(instruction.data) }; } //# sourceMappingURL=setRewardParams.js.map