/**
 * 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 {
  addDecoderSizePrefix,
  addEncoderSizePrefix,
  combineCodec,
  getAddressDecoder,
  getAddressEncoder,
  getBytesDecoder,
  getBytesEncoder,
  getStructDecoder,
  getStructEncoder,
  getU32Decoder,
  getU32Encoder,
  getU64Decoder,
  getU64Encoder,
  getU8Decoder,
  getU8Encoder,
  type Address,
  type Codec,
  type Decoder,
  type Encoder,
  type ReadonlyUint8Array,
} from "@solana/kit";

export type SponsoredDepositForBurn = {
  quoteNonce: ReadonlyUint8Array;
  originSender: Address;
  finalRecipient: Address;
  quoteDeadline: bigint;
  maxBpsToSponsor: bigint;
  maxUserSlippageBps: bigint;
  finalToken: Address;
  destinationDex: number;
  accountCreationMode: number;
  signature: ReadonlyUint8Array;
};

export type SponsoredDepositForBurnArgs = {
  quoteNonce: ReadonlyUint8Array;
  originSender: Address;
  finalRecipient: Address;
  quoteDeadline: number | bigint;
  maxBpsToSponsor: number | bigint;
  maxUserSlippageBps: number | bigint;
  finalToken: Address;
  destinationDex: number;
  accountCreationMode: number;
  signature: ReadonlyUint8Array;
};

export function getSponsoredDepositForBurnEncoder(): Encoder<SponsoredDepositForBurnArgs> {
  return getStructEncoder([
    ["quoteNonce", addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())],
    ["originSender", getAddressEncoder()],
    ["finalRecipient", getAddressEncoder()],
    ["quoteDeadline", getU64Encoder()],
    ["maxBpsToSponsor", getU64Encoder()],
    ["maxUserSlippageBps", getU64Encoder()],
    ["finalToken", getAddressEncoder()],
    ["destinationDex", getU32Encoder()],
    ["accountCreationMode", getU8Encoder()],
    ["signature", addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())],
  ]);
}

export function getSponsoredDepositForBurnDecoder(): Decoder<SponsoredDepositForBurn> {
  return getStructDecoder([
    ["quoteNonce", addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())],
    ["originSender", getAddressDecoder()],
    ["finalRecipient", getAddressDecoder()],
    ["quoteDeadline", getU64Decoder()],
    ["maxBpsToSponsor", getU64Decoder()],
    ["maxUserSlippageBps", getU64Decoder()],
    ["finalToken", getAddressDecoder()],
    ["destinationDex", getU32Decoder()],
    ["accountCreationMode", getU8Decoder()],
    ["signature", addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())],
  ]);
}

export function getSponsoredDepositForBurnCodec(): Codec<
  SponsoredDepositForBurnArgs,
  SponsoredDepositForBurn
> {
  return combineCodec(
    getSponsoredDepositForBurnEncoder(),
    getSponsoredDepositForBurnDecoder(),
  );
}
