UNPKG

@kamino-finance/kliquidity-sdk

Version:

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

62 lines 7.25 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.SINGLE_TOKEN_DEPOSIT_WITH_MIN_DISCRIMINATOR = void 0; exports.getSingleTokenDepositWithMinDiscriminatorBytes = getSingleTokenDepositWithMinDiscriminatorBytes; exports.getSingleTokenDepositWithMinInstructionDataEncoder = getSingleTokenDepositWithMinInstructionDataEncoder; exports.getSingleTokenDepositWithMinInstructionDataDecoder = getSingleTokenDepositWithMinInstructionDataDecoder; exports.getSingleTokenDepositWithMinInstructionDataCodec = getSingleTokenDepositWithMinInstructionDataCodec; exports.getSingleTokenDepositWithMinInstruction = getSingleTokenDepositWithMinInstruction; exports.parseSingleTokenDepositWithMinInstruction = parseSingleTokenDepositWithMinInstruction; const kit_1 = require("@solana/kit"); const programs_1 = require("../programs"); const shared_1 = require("../shared"); exports.SINGLE_TOKEN_DEPOSIT_WITH_MIN_DISCRIMINATOR = new Uint8Array([250, 142, 102, 160, 72, 12, 83, 139]); function getSingleTokenDepositWithMinDiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.SINGLE_TOKEN_DEPOSIT_WITH_MIN_DISCRIMINATOR); } function getSingleTokenDepositWithMinInstructionDataEncoder() { return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)], ['tokenAMinPostDepositBalance', (0, kit_1.getU64Encoder)()], ['tokenBMinPostDepositBalance', (0, kit_1.getU64Encoder)()]]), (value) => ({ ...value, discriminator: exports.SINGLE_TOKEN_DEPOSIT_WITH_MIN_DISCRIMINATOR })); } function getSingleTokenDepositWithMinInstructionDataDecoder() { return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)], ['tokenAMinPostDepositBalance', (0, kit_1.getU64Decoder)()], ['tokenBMinPostDepositBalance', (0, kit_1.getU64Decoder)()]]); } function getSingleTokenDepositWithMinInstructionDataCodec() { return (0, kit_1.combineCodec)(getSingleTokenDepositWithMinInstructionDataEncoder(), getSingleTokenDepositWithMinInstructionDataDecoder()); } function getSingleTokenDepositWithMinInstruction(input, config) { // Program address. const programAddress = config?.programAddress ?? programs_1.YVAULTS_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { user: { value: input.user ?? null, isWritable: true }, strategy: { value: input.strategy ?? null, isWritable: true }, globalConfig: { value: input.globalConfig ?? null, isWritable: false }, pool: { value: input.pool ?? null, isWritable: false }, position: { value: input.position ?? null, isWritable: false }, tickArrayLower: { value: input.tickArrayLower ?? null, isWritable: false }, tickArrayUpper: { value: input.tickArrayUpper ?? null, isWritable: false }, tokenAVault: { value: input.tokenAVault ?? null, isWritable: true }, tokenBVault: { value: input.tokenBVault ?? null, isWritable: true }, baseVaultAuthority: { value: input.baseVaultAuthority ?? null, isWritable: false }, tokenAAta: { value: input.tokenAAta ?? null, isWritable: true }, tokenBAta: { value: input.tokenBAta ?? null, isWritable: true }, tokenAMint: { value: input.tokenAMint ?? null, isWritable: false }, tokenBMint: { value: input.tokenBMint ?? null, isWritable: false }, userSharesAta: { value: input.userSharesAta ?? null, isWritable: true }, sharesMint: { value: input.sharesMint ?? null, isWritable: true }, sharesMintAuthority: { value: input.sharesMintAuthority ?? null, isWritable: false }, scopePricesA: { value: input.scopePricesA ?? null, isWritable: false }, scopePricesB: { value: input.scopePricesB ?? null, isWritable: false }, tokenInfos: { value: input.tokenInfos ?? null, isWritable: false }, tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, tokenATokenProgram: { value: input.tokenATokenProgram ?? null, isWritable: false }, tokenBTokenProgram: { value: input.tokenBTokenProgram ?? null, isWritable: false }, instructionSysvarAccount: { value: input.instructionSysvarAccount ?? null, isWritable: false } }; const accounts = originalAccounts; // Original args. const args = { ...input, }; // Resolve default values. if (!accounts.tokenProgram.value) { accounts.tokenProgram.value = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'; } if (!accounts.instructionSysvarAccount.value) { accounts.instructionSysvarAccount.value = 'Sysvar1nstructions1111111111111111111111111'; } const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId'); return Object.freeze({ accounts: [getAccountMeta(accounts.user), getAccountMeta(accounts.strategy), getAccountMeta(accounts.globalConfig), getAccountMeta(accounts.pool), getAccountMeta(accounts.position), getAccountMeta(accounts.tickArrayLower), getAccountMeta(accounts.tickArrayUpper), getAccountMeta(accounts.tokenAVault), getAccountMeta(accounts.tokenBVault), getAccountMeta(accounts.baseVaultAuthority), getAccountMeta(accounts.tokenAAta), getAccountMeta(accounts.tokenBAta), getAccountMeta(accounts.tokenAMint), getAccountMeta(accounts.tokenBMint), getAccountMeta(accounts.userSharesAta), getAccountMeta(accounts.sharesMint), getAccountMeta(accounts.sharesMintAuthority), getAccountMeta(accounts.scopePricesA), getAccountMeta(accounts.scopePricesB), getAccountMeta(accounts.tokenInfos), getAccountMeta(accounts.tokenProgram), getAccountMeta(accounts.tokenATokenProgram), getAccountMeta(accounts.tokenBTokenProgram), getAccountMeta(accounts.instructionSysvarAccount)], data: getSingleTokenDepositWithMinInstructionDataEncoder().encode(args), programAddress }); } function parseSingleTokenDepositWithMinInstruction(instruction) { if (instruction.accounts.length < 24) { // 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: { user: getNextAccount(), strategy: getNextAccount(), globalConfig: getNextAccount(), pool: getNextAccount(), position: getNextAccount(), tickArrayLower: getNextAccount(), tickArrayUpper: getNextAccount(), tokenAVault: getNextAccount(), tokenBVault: getNextAccount(), baseVaultAuthority: getNextAccount(), tokenAAta: getNextAccount(), tokenBAta: getNextAccount(), tokenAMint: getNextAccount(), tokenBMint: getNextAccount(), userSharesAta: getNextAccount(), sharesMint: getNextAccount(), sharesMintAuthority: getNextAccount(), scopePricesA: getNextAccount(), scopePricesB: getNextAccount(), tokenInfos: getNextAccount(), tokenProgram: getNextAccount(), tokenATokenProgram: getNextAccount(), tokenBTokenProgram: getNextAccount(), instructionSysvarAccount: getNextAccount() }, data: getSingleTokenDepositWithMinInstructionDataDecoder().decode(instruction.data) }; } //# sourceMappingURL=singleTokenDepositWithMin.js.map