UNPKG

@kamino-finance/kliquidity-sdk

Version:

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

56 lines 7.66 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.TWO_HOP_SWAP_V2_DISCRIMINATOR = void 0; exports.getTwoHopSwapV2DiscriminatorBytes = getTwoHopSwapV2DiscriminatorBytes; exports.getTwoHopSwapV2InstructionDataEncoder = getTwoHopSwapV2InstructionDataEncoder; exports.getTwoHopSwapV2InstructionDataDecoder = getTwoHopSwapV2InstructionDataDecoder; exports.getTwoHopSwapV2InstructionDataCodec = getTwoHopSwapV2InstructionDataCodec; exports.getTwoHopSwapV2Instruction = getTwoHopSwapV2Instruction; exports.parseTwoHopSwapV2Instruction = parseTwoHopSwapV2Instruction; const kit_1 = require("@solana/kit"); const programs_1 = require("../programs"); const shared_1 = require("../shared"); const types_1 = require("../types"); exports.TWO_HOP_SWAP_V2_DISCRIMINATOR = new Uint8Array([186, 143, 209, 29, 254, 2, 194, 117]); function getTwoHopSwapV2DiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.TWO_HOP_SWAP_V2_DISCRIMINATOR); } function getTwoHopSwapV2InstructionDataEncoder() { return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)], ['amount', (0, kit_1.getU64Encoder)()], ['otherAmountThreshold', (0, kit_1.getU64Encoder)()], ['amountSpecifiedIsInput', (0, kit_1.getBooleanEncoder)()], ['aToBOne', (0, kit_1.getBooleanEncoder)()], ['aToBTwo', (0, kit_1.getBooleanEncoder)()], ['sqrtPriceLimitOne', (0, kit_1.getU128Encoder)()], ['sqrtPriceLimitTwo', (0, kit_1.getU128Encoder)()], ['remainingAccountsInfo', (0, kit_1.getOptionEncoder)((0, types_1.getRemainingAccountsInfoEncoder)())]]), (value) => ({ ...value, discriminator: exports.TWO_HOP_SWAP_V2_DISCRIMINATOR })); } function getTwoHopSwapV2InstructionDataDecoder() { return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)], ['amount', (0, kit_1.getU64Decoder)()], ['otherAmountThreshold', (0, kit_1.getU64Decoder)()], ['amountSpecifiedIsInput', (0, kit_1.getBooleanDecoder)()], ['aToBOne', (0, kit_1.getBooleanDecoder)()], ['aToBTwo', (0, kit_1.getBooleanDecoder)()], ['sqrtPriceLimitOne', (0, kit_1.getU128Decoder)()], ['sqrtPriceLimitTwo', (0, kit_1.getU128Decoder)()], ['remainingAccountsInfo', (0, kit_1.getOptionDecoder)((0, types_1.getRemainingAccountsInfoDecoder)())]]); } function getTwoHopSwapV2InstructionDataCodec() { return (0, kit_1.combineCodec)(getTwoHopSwapV2InstructionDataEncoder(), getTwoHopSwapV2InstructionDataDecoder()); } function getTwoHopSwapV2Instruction(input, config) { // Program address. const programAddress = config?.programAddress ?? programs_1.WHIRLPOOL_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { whirlpoolOne: { value: input.whirlpoolOne ?? null, isWritable: true }, whirlpoolTwo: { value: input.whirlpoolTwo ?? null, isWritable: true }, tokenMintInput: { value: input.tokenMintInput ?? null, isWritable: false }, tokenMintIntermediate: { value: input.tokenMintIntermediate ?? null, isWritable: false }, tokenMintOutput: { value: input.tokenMintOutput ?? null, isWritable: false }, tokenProgramInput: { value: input.tokenProgramInput ?? null, isWritable: false }, tokenProgramIntermediate: { value: input.tokenProgramIntermediate ?? null, isWritable: false }, tokenProgramOutput: { value: input.tokenProgramOutput ?? null, isWritable: false }, tokenOwnerAccountInput: { value: input.tokenOwnerAccountInput ?? null, isWritable: true }, tokenVaultOneInput: { value: input.tokenVaultOneInput ?? null, isWritable: true }, tokenVaultOneIntermediate: { value: input.tokenVaultOneIntermediate ?? null, isWritable: true }, tokenVaultTwoIntermediate: { value: input.tokenVaultTwoIntermediate ?? null, isWritable: true }, tokenVaultTwoOutput: { value: input.tokenVaultTwoOutput ?? null, isWritable: true }, tokenOwnerAccountOutput: { value: input.tokenOwnerAccountOutput ?? null, isWritable: true }, tokenAuthority: { value: input.tokenAuthority ?? null, isWritable: false }, tickArrayOne0: { value: input.tickArrayOne0 ?? null, isWritable: true }, tickArrayOne1: { value: input.tickArrayOne1 ?? null, isWritable: true }, tickArrayOne2: { value: input.tickArrayOne2 ?? null, isWritable: true }, tickArrayTwo0: { value: input.tickArrayTwo0 ?? null, isWritable: true }, tickArrayTwo1: { value: input.tickArrayTwo1 ?? null, isWritable: true }, tickArrayTwo2: { value: input.tickArrayTwo2 ?? null, isWritable: true }, oracleOne: { value: input.oracleOne ?? null, isWritable: true }, oracleTwo: { value: input.oracleTwo ?? null, isWritable: true }, memoProgram: { value: input.memoProgram ?? null, isWritable: false } }; const accounts = originalAccounts; // Original args. const args = { ...input, }; const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId'); return Object.freeze({ accounts: [getAccountMeta(accounts.whirlpoolOne), getAccountMeta(accounts.whirlpoolTwo), getAccountMeta(accounts.tokenMintInput), getAccountMeta(accounts.tokenMintIntermediate), getAccountMeta(accounts.tokenMintOutput), getAccountMeta(accounts.tokenProgramInput), getAccountMeta(accounts.tokenProgramIntermediate), getAccountMeta(accounts.tokenProgramOutput), getAccountMeta(accounts.tokenOwnerAccountInput), getAccountMeta(accounts.tokenVaultOneInput), getAccountMeta(accounts.tokenVaultOneIntermediate), getAccountMeta(accounts.tokenVaultTwoIntermediate), getAccountMeta(accounts.tokenVaultTwoOutput), getAccountMeta(accounts.tokenOwnerAccountOutput), getAccountMeta(accounts.tokenAuthority), getAccountMeta(accounts.tickArrayOne0), getAccountMeta(accounts.tickArrayOne1), getAccountMeta(accounts.tickArrayOne2), getAccountMeta(accounts.tickArrayTwo0), getAccountMeta(accounts.tickArrayTwo1), getAccountMeta(accounts.tickArrayTwo2), getAccountMeta(accounts.oracleOne), getAccountMeta(accounts.oracleTwo), getAccountMeta(accounts.memoProgram)], data: getTwoHopSwapV2InstructionDataEncoder().encode(args), programAddress }); } function parseTwoHopSwapV2Instruction(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: { whirlpoolOne: getNextAccount(), whirlpoolTwo: getNextAccount(), tokenMintInput: getNextAccount(), tokenMintIntermediate: getNextAccount(), tokenMintOutput: getNextAccount(), tokenProgramInput: getNextAccount(), tokenProgramIntermediate: getNextAccount(), tokenProgramOutput: getNextAccount(), tokenOwnerAccountInput: getNextAccount(), tokenVaultOneInput: getNextAccount(), tokenVaultOneIntermediate: getNextAccount(), tokenVaultTwoIntermediate: getNextAccount(), tokenVaultTwoOutput: getNextAccount(), tokenOwnerAccountOutput: getNextAccount(), tokenAuthority: getNextAccount(), tickArrayOne0: getNextAccount(), tickArrayOne1: getNextAccount(), tickArrayOne2: getNextAccount(), tickArrayTwo0: getNextAccount(), tickArrayTwo1: getNextAccount(), tickArrayTwo2: getNextAccount(), oracleOne: getNextAccount(), oracleTwo: getNextAccount(), memoProgram: getNextAccount() }, data: getTwoHopSwapV2InstructionDataDecoder().decode(instruction.data) }; } //# sourceMappingURL=twoHopSwapV2.js.map