/** * 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, getStructDecoder, getStructEncoder, getTupleDecoder, getTupleEncoder, getU16Decoder, getU16Encoder, getUnitDecoder, getUnitEncoder, type Codec, type Decoder, type Encoder, type GetDiscriminatedUnionVariant, type GetDiscriminatedUnionVariantContent, } from "@solana/kit"; export type RefPriceToleranceOrTwapSource = | { __kind: "None" } | { __kind: "RefPriceToleranceBps"; fields: readonly [number] } | { __kind: "TwapSource"; fields: readonly [number] }; export type RefPriceToleranceOrTwapSourceArgs = RefPriceToleranceOrTwapSource; export function getRefPriceToleranceOrTwapSourceEncoder(): Encoder { return getDiscriminatedUnionEncoder([ ["None", getUnitEncoder()], [ "RefPriceToleranceBps", getStructEncoder([["fields", getTupleEncoder([getU16Encoder()])]]), ], [ "TwapSource", getStructEncoder([["fields", getTupleEncoder([getU16Encoder()])]]), ], ]); } export function getRefPriceToleranceOrTwapSourceDecoder(): Decoder { return getDiscriminatedUnionDecoder([ ["None", getUnitDecoder()], [ "RefPriceToleranceBps", getStructDecoder([["fields", getTupleDecoder([getU16Decoder()])]]), ], [ "TwapSource", getStructDecoder([["fields", getTupleDecoder([getU16Decoder()])]]), ], ]); } export function getRefPriceToleranceOrTwapSourceCodec(): Codec< RefPriceToleranceOrTwapSourceArgs, RefPriceToleranceOrTwapSource > { return combineCodec( getRefPriceToleranceOrTwapSourceEncoder(), getRefPriceToleranceOrTwapSourceDecoder(), ); } // Data Enum Helpers. export function refPriceToleranceOrTwapSource( kind: "None", ): GetDiscriminatedUnionVariant< RefPriceToleranceOrTwapSourceArgs, "__kind", "None" >; export function refPriceToleranceOrTwapSource( kind: "RefPriceToleranceBps", data: GetDiscriminatedUnionVariantContent< RefPriceToleranceOrTwapSourceArgs, "__kind", "RefPriceToleranceBps" >["fields"], ): GetDiscriminatedUnionVariant< RefPriceToleranceOrTwapSourceArgs, "__kind", "RefPriceToleranceBps" >; export function refPriceToleranceOrTwapSource( kind: "TwapSource", data: GetDiscriminatedUnionVariantContent< RefPriceToleranceOrTwapSourceArgs, "__kind", "TwapSource" >["fields"], ): GetDiscriminatedUnionVariant< RefPriceToleranceOrTwapSourceArgs, "__kind", "TwapSource" >; export function refPriceToleranceOrTwapSource< K extends RefPriceToleranceOrTwapSourceArgs["__kind"], Data, >(kind: K, data?: Data) { return Array.isArray(data) ? { __kind: kind, fields: data } : { __kind: kind, ...(data ?? {}) }; } export function isRefPriceToleranceOrTwapSource< K extends RefPriceToleranceOrTwapSource["__kind"], >( kind: K, value: RefPriceToleranceOrTwapSource, ): value is RefPriceToleranceOrTwapSource & { __kind: K } { return value.__kind === kind; }