@kamino-finance/kliquidity-sdk
Version:
Typescript SDK for interacting with the Kamino Liquidity (kliquidity) protocol
59 lines • 6.64 kB
JavaScript
"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.FLASH_SWAP_UNEVEN_VAULTS_START_DISCRIMINATOR = void 0;
exports.getFlashSwapUnevenVaultsStartDiscriminatorBytes = getFlashSwapUnevenVaultsStartDiscriminatorBytes;
exports.getFlashSwapUnevenVaultsStartInstructionDataEncoder = getFlashSwapUnevenVaultsStartInstructionDataEncoder;
exports.getFlashSwapUnevenVaultsStartInstructionDataDecoder = getFlashSwapUnevenVaultsStartInstructionDataDecoder;
exports.getFlashSwapUnevenVaultsStartInstructionDataCodec = getFlashSwapUnevenVaultsStartInstructionDataCodec;
exports.getFlashSwapUnevenVaultsStartInstruction = getFlashSwapUnevenVaultsStartInstruction;
exports.parseFlashSwapUnevenVaultsStartInstruction = parseFlashSwapUnevenVaultsStartInstruction;
const kit_1 = require("@solana/kit");
const programs_1 = require("../programs");
const shared_1 = require("../shared");
exports.FLASH_SWAP_UNEVEN_VAULTS_START_DISCRIMINATOR = new Uint8Array([129, 111, 174, 12, 10, 60, 149, 193]);
function getFlashSwapUnevenVaultsStartDiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.FLASH_SWAP_UNEVEN_VAULTS_START_DISCRIMINATOR); }
function getFlashSwapUnevenVaultsStartInstructionDataEncoder() {
return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)], ['amount', (0, kit_1.getU64Encoder)()], ['aToB', (0, kit_1.getBooleanEncoder)()]]), (value) => ({ ...value, discriminator: exports.FLASH_SWAP_UNEVEN_VAULTS_START_DISCRIMINATOR }));
}
function getFlashSwapUnevenVaultsStartInstructionDataDecoder() {
return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)], ['amount', (0, kit_1.getU64Decoder)()], ['aToB', (0, kit_1.getBooleanDecoder)()]]);
}
function getFlashSwapUnevenVaultsStartInstructionDataCodec() {
return (0, kit_1.combineCodec)(getFlashSwapUnevenVaultsStartInstructionDataEncoder(), getFlashSwapUnevenVaultsStartInstructionDataDecoder());
}
function getFlashSwapUnevenVaultsStartInstruction(input, config) {
// Program address.
const programAddress = config?.programAddress ?? programs_1.YVAULTS_PROGRAM_ADDRESS;
// Original accounts.
const originalAccounts = { swapper: { value: input.swapper ?? null, isWritable: true }, strategy: { value: input.strategy ?? null, isWritable: true }, globalConfig: { value: input.globalConfig ?? null, isWritable: false }, tokenAVault: { value: input.tokenAVault ?? null, isWritable: true }, tokenBVault: { value: input.tokenBVault ?? null, isWritable: true }, tokenAAta: { value: input.tokenAAta ?? null, isWritable: true }, tokenBAta: { value: input.tokenBAta ?? null, isWritable: true }, baseVaultAuthority: { value: input.baseVaultAuthority ?? null, isWritable: true }, pool: { value: input.pool ?? null, isWritable: true }, position: { value: input.position ?? null, isWritable: true }, scopePricesA: { value: input.scopePricesA ?? null, isWritable: false }, scopePricesB: { value: input.scopePricesB ?? null, isWritable: false }, tokenInfos: { value: input.tokenInfos ?? null, isWritable: false }, tickArrayLower: { value: input.tickArrayLower ?? null, isWritable: false }, tickArrayUpper: { value: input.tickArrayUpper ?? null, isWritable: false }, tokenAMint: { value: input.tokenAMint ?? null, isWritable: false }, tokenBMint: { value: input.tokenBMint ?? null, isWritable: false }, tokenATokenProgram: { value: input.tokenATokenProgram ?? null, isWritable: false }, tokenBTokenProgram: { value: input.tokenBTokenProgram ?? null, isWritable: false }, instructionSysvarAccount: { value: input.instructionSysvarAccount ?? null, isWritable: false }, consensusAccount: { value: input.consensusAccount ?? null, isWritable: false } };
const accounts = originalAccounts;
// Original args.
const args = { ...input, };
// Resolve default values.
if (!accounts.instructionSysvarAccount.value) {
accounts.instructionSysvarAccount.value = 'Sysvar1nstructions1111111111111111111111111';
}
const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId');
return Object.freeze({ accounts: [getAccountMeta(accounts.swapper), getAccountMeta(accounts.strategy), getAccountMeta(accounts.globalConfig), getAccountMeta(accounts.tokenAVault), getAccountMeta(accounts.tokenBVault), getAccountMeta(accounts.tokenAAta), getAccountMeta(accounts.tokenBAta), getAccountMeta(accounts.baseVaultAuthority), getAccountMeta(accounts.pool), getAccountMeta(accounts.position), getAccountMeta(accounts.scopePricesA), getAccountMeta(accounts.scopePricesB), getAccountMeta(accounts.tokenInfos), getAccountMeta(accounts.tickArrayLower), getAccountMeta(accounts.tickArrayUpper), getAccountMeta(accounts.tokenAMint), getAccountMeta(accounts.tokenBMint), getAccountMeta(accounts.tokenATokenProgram), getAccountMeta(accounts.tokenBTokenProgram), getAccountMeta(accounts.instructionSysvarAccount), getAccountMeta(accounts.consensusAccount)], data: getFlashSwapUnevenVaultsStartInstructionDataEncoder().encode(args), programAddress });
}
function parseFlashSwapUnevenVaultsStartInstruction(instruction) {
if (instruction.accounts.length < 21) {
// 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: { swapper: getNextAccount(), strategy: getNextAccount(), globalConfig: getNextAccount(), tokenAVault: getNextAccount(), tokenBVault: getNextAccount(), tokenAAta: getNextAccount(), tokenBAta: getNextAccount(), baseVaultAuthority: getNextAccount(), pool: getNextAccount(), position: getNextAccount(), scopePricesA: getNextAccount(), scopePricesB: getNextAccount(), tokenInfos: getNextAccount(), tickArrayLower: getNextAccount(), tickArrayUpper: getNextAccount(), tokenAMint: getNextAccount(), tokenBMint: getNextAccount(), tokenATokenProgram: getNextAccount(), tokenBTokenProgram: getNextAccount(), instructionSysvarAccount: getNextAccount(), consensusAccount: getNextAccount() }, data: getFlashSwapUnevenVaultsStartInstructionDataDecoder().decode(instruction.data) };
}
//# sourceMappingURL=flashSwapUnevenVaultsStart.js.map