@kamino-finance/kliquidity-sdk
Version:
Typescript SDK for interacting with the Kamino Liquidity (kliquidity) protocol
53 lines • 4.25 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.CHANGE_POOL_DISCRIMINATOR = void 0;
exports.getChangePoolDiscriminatorBytes = getChangePoolDiscriminatorBytes;
exports.getChangePoolInstructionDataEncoder = getChangePoolInstructionDataEncoder;
exports.getChangePoolInstructionDataDecoder = getChangePoolInstructionDataDecoder;
exports.getChangePoolInstructionDataCodec = getChangePoolInstructionDataCodec;
exports.getChangePoolInstruction = getChangePoolInstruction;
exports.parseChangePoolInstruction = parseChangePoolInstruction;
const kit_1 = require("@solana/kit");
const programs_1 = require("../programs");
const shared_1 = require("../shared");
exports.CHANGE_POOL_DISCRIMINATOR = new Uint8Array([141, 221, 123, 235, 35, 9, 145, 201]);
function getChangePoolDiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.CHANGE_POOL_DISCRIMINATOR); }
function getChangePoolInstructionDataEncoder() {
return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)]]), (value) => ({ ...value, discriminator: exports.CHANGE_POOL_DISCRIMINATOR }));
}
function getChangePoolInstructionDataDecoder() {
return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)]]);
}
function getChangePoolInstructionDataCodec() {
return (0, kit_1.combineCodec)(getChangePoolInstructionDataEncoder(), getChangePoolInstructionDataDecoder());
}
function getChangePoolInstruction(input, config) {
// Program address.
const programAddress = config?.programAddress ?? programs_1.YVAULTS_PROGRAM_ADDRESS;
// Original accounts.
const originalAccounts = { adminAuthority: { value: input.adminAuthority ?? null, isWritable: true }, strategy: { value: input.strategy ?? null, isWritable: true }, oldPosition: { value: input.oldPosition ?? null, isWritable: false }, baseVaultAuthority: { value: input.baseVaultAuthority ?? null, isWritable: false }, newPool: { value: input.newPool ?? null, isWritable: false }, strategyRewardVault0OrBaseVaultAuthority: { value: input.strategyRewardVault0OrBaseVaultAuthority ?? null, isWritable: false }, strategyRewardVault1OrBaseVaultAuthority: { value: input.strategyRewardVault1OrBaseVaultAuthority ?? null, isWritable: false }, strategyRewardVault2OrBaseVaultAuthority: { value: input.strategyRewardVault2OrBaseVaultAuthority ?? null, isWritable: false } };
const accounts = originalAccounts;
const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId');
return Object.freeze({ accounts: [getAccountMeta(accounts.adminAuthority), getAccountMeta(accounts.strategy), getAccountMeta(accounts.oldPosition), getAccountMeta(accounts.baseVaultAuthority), getAccountMeta(accounts.newPool), getAccountMeta(accounts.strategyRewardVault0OrBaseVaultAuthority), getAccountMeta(accounts.strategyRewardVault1OrBaseVaultAuthority), getAccountMeta(accounts.strategyRewardVault2OrBaseVaultAuthority)], data: getChangePoolInstructionDataEncoder().encode({}), programAddress });
}
function parseChangePoolInstruction(instruction) {
if (instruction.accounts.length < 8) {
// 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: { adminAuthority: getNextAccount(), strategy: getNextAccount(), oldPosition: getNextAccount(), baseVaultAuthority: getNextAccount(), newPool: getNextAccount(), strategyRewardVault0OrBaseVaultAuthority: getNextAccount(), strategyRewardVault1OrBaseVaultAuthority: getNextAccount(), strategyRewardVault2OrBaseVaultAuthority: getNextAccount() }, data: getChangePoolInstructionDataDecoder().decode(instruction.data) };
}
//# sourceMappingURL=changePool.js.map