@kamino-finance/farms-sdk
Version:
102 lines • 4.67 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_UNSTAKED_DEPOSITS_DISCRIMINATOR = void 0;
exports.getWithdrawUnstakedDepositsDiscriminatorBytes = getWithdrawUnstakedDepositsDiscriminatorBytes;
exports.getWithdrawUnstakedDepositsInstructionDataEncoder = getWithdrawUnstakedDepositsInstructionDataEncoder;
exports.getWithdrawUnstakedDepositsInstructionDataDecoder = getWithdrawUnstakedDepositsInstructionDataDecoder;
exports.getWithdrawUnstakedDepositsInstructionDataCodec = getWithdrawUnstakedDepositsInstructionDataCodec;
exports.getWithdrawUnstakedDepositsInstruction = getWithdrawUnstakedDepositsInstruction;
exports.parseWithdrawUnstakedDepositsInstruction = parseWithdrawUnstakedDepositsInstruction;
const kit_1 = require("@solana/kit");
const programs_1 = require("../programs");
const shared_1 = require("../shared");
exports.WITHDRAW_UNSTAKED_DEPOSITS_DISCRIMINATOR = new Uint8Array([
36, 102, 187, 49, 220, 36, 132, 67,
]);
function getWithdrawUnstakedDepositsDiscriminatorBytes() {
return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.WITHDRAW_UNSTAKED_DEPOSITS_DISCRIMINATOR);
}
function getWithdrawUnstakedDepositsInstructionDataEncoder() {
return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([["discriminator", (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)]]), (value) => ({
...value,
discriminator: exports.WITHDRAW_UNSTAKED_DEPOSITS_DISCRIMINATOR,
}));
}
function getWithdrawUnstakedDepositsInstructionDataDecoder() {
return (0, kit_1.getStructDecoder)([
["discriminator", (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)],
]);
}
function getWithdrawUnstakedDepositsInstructionDataCodec() {
return (0, kit_1.combineCodec)(getWithdrawUnstakedDepositsInstructionDataEncoder(), getWithdrawUnstakedDepositsInstructionDataDecoder());
}
function getWithdrawUnstakedDepositsInstruction(input, config) {
// Program address.
const programAddress = config?.programAddress ?? programs_1.FARMS_PROGRAM_ADDRESS;
// Original accounts.
const originalAccounts = {
owner: { value: input.owner ?? null, isWritable: true },
userState: { value: input.userState ?? null, isWritable: true },
farmState: { value: input.farmState ?? null, isWritable: true },
userAta: { value: input.userAta ?? null, isWritable: true },
farmVault: { value: input.farmVault ?? null, isWritable: true },
farmVaultsAuthority: {
value: input.farmVaultsAuthority ?? null,
isWritable: false,
},
tokenProgram: { value: input.tokenProgram ?? 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.owner),
getAccountMeta(accounts.userState),
getAccountMeta(accounts.farmState),
getAccountMeta(accounts.userAta),
getAccountMeta(accounts.farmVault),
getAccountMeta(accounts.farmVaultsAuthority),
getAccountMeta(accounts.tokenProgram),
],
data: getWithdrawUnstakedDepositsInstructionDataEncoder().encode({}),
programAddress,
});
}
function parseWithdrawUnstakedDepositsInstruction(instruction) {
if (instruction.accounts.length < 7) {
// 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: {
owner: getNextAccount(),
userState: getNextAccount(),
farmState: getNextAccount(),
userAta: getNextAccount(),
farmVault: getNextAccount(),
farmVaultsAuthority: getNextAccount(),
tokenProgram: getNextAccount(),
},
data: getWithdrawUnstakedDepositsInstructionDataDecoder().decode(instruction.data),
};
}
//# sourceMappingURL=withdrawUnstakedDeposits.js.map