@kamino-finance/kliquidity-sdk
Version:
Typescript SDK for interacting with the Kamino Liquidity (kliquidity) protocol
37 lines (28 loc) • 3.36 kB
text/typescript
/**
* 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
*/
import { combineCodec, getDiscriminatedUnionDecoder, getDiscriminatedUnionEncoder, getI32Decoder, getI32Encoder, getStructDecoder, getStructEncoder, getTupleDecoder, getTupleEncoder, getU64Decoder, getU64Encoder, type Codec, type Decoder, type Encoder, type GetDiscriminatedUnionVariant, type GetDiscriminatedUnionVariantContent } from '@solana/kit';
export type BinAddLiquidityStrategy = { __kind: "Uniform", currentBinIndex: number; lowerBinIndex: number; upperBinIndex: number; amountXToDeposit: bigint; amountYToDeposit: bigint; xCurrentBin: bigint; yCurrentBin: bigint; } | { __kind: "CurrentTick", fields: readonly [number]; };
export type BinAddLiquidityStrategyArgs = { __kind: "Uniform", currentBinIndex: number; lowerBinIndex: number; upperBinIndex: number; amountXToDeposit: number | bigint; amountYToDeposit: number | bigint; xCurrentBin: number | bigint; yCurrentBin: number | bigint; } | { __kind: "CurrentTick", fields: readonly [number]; };
export function getBinAddLiquidityStrategyEncoder(): Encoder<BinAddLiquidityStrategyArgs> {
return getDiscriminatedUnionEncoder([['Uniform', getStructEncoder([['currentBinIndex', getI32Encoder()], ['lowerBinIndex', getI32Encoder()], ['upperBinIndex', getI32Encoder()], ['amountXToDeposit', getU64Encoder()], ['amountYToDeposit', getU64Encoder()], ['xCurrentBin', getU64Encoder()], ['yCurrentBin', getU64Encoder()]])], ['CurrentTick', getStructEncoder([['fields', getTupleEncoder([getI32Encoder()])]])]]);
}
export function getBinAddLiquidityStrategyDecoder(): Decoder<BinAddLiquidityStrategy> {
return getDiscriminatedUnionDecoder([['Uniform', getStructDecoder([['currentBinIndex', getI32Decoder()], ['lowerBinIndex', getI32Decoder()], ['upperBinIndex', getI32Decoder()], ['amountXToDeposit', getU64Decoder()], ['amountYToDeposit', getU64Decoder()], ['xCurrentBin', getU64Decoder()], ['yCurrentBin', getU64Decoder()]])], ['CurrentTick', getStructDecoder([['fields', getTupleDecoder([getI32Decoder()])]])]]);
}
export function getBinAddLiquidityStrategyCodec(): Codec<BinAddLiquidityStrategyArgs, BinAddLiquidityStrategy> {
return combineCodec(getBinAddLiquidityStrategyEncoder(), getBinAddLiquidityStrategyDecoder());
}
// Data Enum Helpers.
export function binAddLiquidityStrategy(kind: 'Uniform', data: GetDiscriminatedUnionVariantContent<BinAddLiquidityStrategyArgs, '__kind', 'Uniform'>): GetDiscriminatedUnionVariant<BinAddLiquidityStrategyArgs, '__kind', 'Uniform'>;
export function binAddLiquidityStrategy(kind: 'CurrentTick', data: GetDiscriminatedUnionVariantContent<BinAddLiquidityStrategyArgs, '__kind', 'CurrentTick'>['fields']): GetDiscriminatedUnionVariant<BinAddLiquidityStrategyArgs, '__kind', 'CurrentTick'>;
export function binAddLiquidityStrategy<K extends BinAddLiquidityStrategyArgs['__kind'], Data>(kind: K, data?: Data) {
return Array.isArray(data) ? { __kind: kind, fields: data } : { __kind: kind, ...(data ?? {}) };
}
export function isBinAddLiquidityStrategy<K extends BinAddLiquidityStrategy['__kind']>(kind: K, value: BinAddLiquidityStrategy): value is BinAddLiquidityStrategy & { __kind: K } {
return value.__kind === kind;
};