@kamino-finance/kliquidity-sdk
Version:
Typescript SDK for interacting with the Kamino Liquidity (kliquidity) protocol
56 lines • 5.81 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.INCREASE_LIQUIDITY_V2_DISCRIMINATOR = void 0;
exports.getIncreaseLiquidityV2DiscriminatorBytes = getIncreaseLiquidityV2DiscriminatorBytes;
exports.getIncreaseLiquidityV2InstructionDataEncoder = getIncreaseLiquidityV2InstructionDataEncoder;
exports.getIncreaseLiquidityV2InstructionDataDecoder = getIncreaseLiquidityV2InstructionDataDecoder;
exports.getIncreaseLiquidityV2InstructionDataCodec = getIncreaseLiquidityV2InstructionDataCodec;
exports.getIncreaseLiquidityV2Instruction = getIncreaseLiquidityV2Instruction;
exports.parseIncreaseLiquidityV2Instruction = parseIncreaseLiquidityV2Instruction;
const kit_1 = require("@solana/kit");
const programs_1 = require("../programs");
const shared_1 = require("../shared");
const types_1 = require("../types");
exports.INCREASE_LIQUIDITY_V2_DISCRIMINATOR = new Uint8Array([133, 29, 89, 223, 69, 238, 176, 10]);
function getIncreaseLiquidityV2DiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.INCREASE_LIQUIDITY_V2_DISCRIMINATOR); }
function getIncreaseLiquidityV2InstructionDataEncoder() {
return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)], ['liquidityAmount', (0, kit_1.getU128Encoder)()], ['tokenMaxA', (0, kit_1.getU64Encoder)()], ['tokenMaxB', (0, kit_1.getU64Encoder)()], ['remainingAccountsInfo', (0, kit_1.getOptionEncoder)((0, types_1.getRemainingAccountsInfoEncoder)())]]), (value) => ({ ...value, discriminator: exports.INCREASE_LIQUIDITY_V2_DISCRIMINATOR }));
}
function getIncreaseLiquidityV2InstructionDataDecoder() {
return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)], ['liquidityAmount', (0, kit_1.getU128Decoder)()], ['tokenMaxA', (0, kit_1.getU64Decoder)()], ['tokenMaxB', (0, kit_1.getU64Decoder)()], ['remainingAccountsInfo', (0, kit_1.getOptionDecoder)((0, types_1.getRemainingAccountsInfoDecoder)())]]);
}
function getIncreaseLiquidityV2InstructionDataCodec() {
return (0, kit_1.combineCodec)(getIncreaseLiquidityV2InstructionDataEncoder(), getIncreaseLiquidityV2InstructionDataDecoder());
}
function getIncreaseLiquidityV2Instruction(input, config) {
// Program address.
const programAddress = config?.programAddress ?? programs_1.WHIRLPOOL_PROGRAM_ADDRESS;
// Original accounts.
const originalAccounts = { whirlpool: { value: input.whirlpool ?? null, isWritable: true }, tokenProgramA: { value: input.tokenProgramA ?? null, isWritable: false }, tokenProgramB: { value: input.tokenProgramB ?? null, isWritable: false }, memoProgram: { value: input.memoProgram ?? null, isWritable: false }, positionAuthority: { value: input.positionAuthority ?? null, isWritable: false }, position: { value: input.position ?? null, isWritable: true }, positionTokenAccount: { value: input.positionTokenAccount ?? null, isWritable: false }, tokenMintA: { value: input.tokenMintA ?? null, isWritable: false }, tokenMintB: { value: input.tokenMintB ?? null, isWritable: false }, tokenOwnerAccountA: { value: input.tokenOwnerAccountA ?? null, isWritable: true }, tokenOwnerAccountB: { value: input.tokenOwnerAccountB ?? null, isWritable: true }, tokenVaultA: { value: input.tokenVaultA ?? null, isWritable: true }, tokenVaultB: { value: input.tokenVaultB ?? null, isWritable: true }, tickArrayLower: { value: input.tickArrayLower ?? null, isWritable: true }, tickArrayUpper: { value: input.tickArrayUpper ?? null, isWritable: true } };
const accounts = originalAccounts;
// Original args.
const args = { ...input, };
const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId');
return Object.freeze({ accounts: [getAccountMeta(accounts.whirlpool), getAccountMeta(accounts.tokenProgramA), getAccountMeta(accounts.tokenProgramB), getAccountMeta(accounts.memoProgram), getAccountMeta(accounts.positionAuthority), getAccountMeta(accounts.position), getAccountMeta(accounts.positionTokenAccount), getAccountMeta(accounts.tokenMintA), getAccountMeta(accounts.tokenMintB), getAccountMeta(accounts.tokenOwnerAccountA), getAccountMeta(accounts.tokenOwnerAccountB), getAccountMeta(accounts.tokenVaultA), getAccountMeta(accounts.tokenVaultB), getAccountMeta(accounts.tickArrayLower), getAccountMeta(accounts.tickArrayUpper)], data: getIncreaseLiquidityV2InstructionDataEncoder().encode(args), programAddress });
}
function parseIncreaseLiquidityV2Instruction(instruction) {
if (instruction.accounts.length < 15) {
// 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: { whirlpool: getNextAccount(), tokenProgramA: getNextAccount(), tokenProgramB: getNextAccount(), memoProgram: getNextAccount(), positionAuthority: getNextAccount(), position: getNextAccount(), positionTokenAccount: getNextAccount(), tokenMintA: getNextAccount(), tokenMintB: getNextAccount(), tokenOwnerAccountA: getNextAccount(), tokenOwnerAccountB: getNextAccount(), tokenVaultA: getNextAccount(), tokenVaultB: getNextAccount(), tickArrayLower: getNextAccount(), tickArrayUpper: getNextAccount() }, data: getIncreaseLiquidityV2InstructionDataDecoder().decode(instruction.data) };
}
//# sourceMappingURL=increaseLiquidityV2.js.map