UNPKG

@kamino-finance/kliquidity-sdk

Version:

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

62 lines 5.1 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.CREATE_POOL_DISCRIMINATOR = void 0; exports.getCreatePoolDiscriminatorBytes = getCreatePoolDiscriminatorBytes; exports.getCreatePoolInstructionDataEncoder = getCreatePoolInstructionDataEncoder; exports.getCreatePoolInstructionDataDecoder = getCreatePoolInstructionDataDecoder; exports.getCreatePoolInstructionDataCodec = getCreatePoolInstructionDataCodec; exports.getCreatePoolInstruction = getCreatePoolInstruction; exports.parseCreatePoolInstruction = parseCreatePoolInstruction; const kit_1 = require("@solana/kit"); const programs_1 = require("../programs"); const shared_1 = require("../shared"); exports.CREATE_POOL_DISCRIMINATOR = new Uint8Array([233, 146, 209, 142, 207, 104, 64, 188]); function getCreatePoolDiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.CREATE_POOL_DISCRIMINATOR); } function getCreatePoolInstructionDataEncoder() { return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)], ['sqrtPriceX64', (0, kit_1.getU128Encoder)()], ['openTime', (0, kit_1.getU64Encoder)()]]), (value) => ({ ...value, discriminator: exports.CREATE_POOL_DISCRIMINATOR })); } function getCreatePoolInstructionDataDecoder() { return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)], ['sqrtPriceX64', (0, kit_1.getU128Decoder)()], ['openTime', (0, kit_1.getU64Decoder)()]]); } function getCreatePoolInstructionDataCodec() { return (0, kit_1.combineCodec)(getCreatePoolInstructionDataEncoder(), getCreatePoolInstructionDataDecoder()); } function getCreatePoolInstruction(input, config) { // Program address. const programAddress = config?.programAddress ?? programs_1.AMM_V3_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { poolCreator: { value: input.poolCreator ?? null, isWritable: true }, ammConfig: { value: input.ammConfig ?? null, isWritable: false }, poolState: { value: input.poolState ?? null, isWritable: true }, tokenMint0: { value: input.tokenMint0 ?? null, isWritable: false }, tokenMint1: { value: input.tokenMint1 ?? null, isWritable: false }, tokenVault0: { value: input.tokenVault0 ?? null, isWritable: true }, tokenVault1: { value: input.tokenVault1 ?? null, isWritable: true }, observationState: { value: input.observationState ?? null, isWritable: true }, tickArrayBitmap: { value: input.tickArrayBitmap ?? null, isWritable: true }, tokenProgram0: { value: input.tokenProgram0 ?? null, isWritable: false }, tokenProgram1: { value: input.tokenProgram1 ?? null, isWritable: false }, systemProgram: { value: input.systemProgram ?? null, isWritable: false }, rent: { value: input.rent ?? null, isWritable: false } }; const accounts = originalAccounts; // Original args. const args = { ...input, }; // Resolve default values. if (!accounts.systemProgram.value) { accounts.systemProgram.value = '11111111111111111111111111111111'; } if (!accounts.rent.value) { accounts.rent.value = 'SysvarRent111111111111111111111111111111111'; } const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId'); return Object.freeze({ accounts: [getAccountMeta(accounts.poolCreator), getAccountMeta(accounts.ammConfig), getAccountMeta(accounts.poolState), getAccountMeta(accounts.tokenMint0), getAccountMeta(accounts.tokenMint1), getAccountMeta(accounts.tokenVault0), getAccountMeta(accounts.tokenVault1), getAccountMeta(accounts.observationState), getAccountMeta(accounts.tickArrayBitmap), getAccountMeta(accounts.tokenProgram0), getAccountMeta(accounts.tokenProgram1), getAccountMeta(accounts.systemProgram), getAccountMeta(accounts.rent)], data: getCreatePoolInstructionDataEncoder().encode(args), programAddress }); } function parseCreatePoolInstruction(instruction) { if (instruction.accounts.length < 13) { // 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: { poolCreator: getNextAccount(), ammConfig: getNextAccount(), poolState: getNextAccount(), tokenMint0: getNextAccount(), tokenMint1: getNextAccount(), tokenVault0: getNextAccount(), tokenVault1: getNextAccount(), observationState: getNextAccount(), tickArrayBitmap: getNextAccount(), tokenProgram0: getNextAccount(), tokenProgram1: getNextAccount(), systemProgram: getNextAccount(), rent: getNextAccount() }, data: getCreatePoolInstructionDataDecoder().decode(instruction.data) }; } //# sourceMappingURL=createPool.js.map