/// import { Address } from "@coral-xyz/anchor"; import { Commitment, Connection, PublicKey, Transaction, VersionedTransaction } from "@solana/web3.js"; import { ZebecCardInstructions } from "./instructions"; import { TransactionPayload } from "./payload"; import { BigIntString, DecimalString, EmailString, PercentString, PublicKeyString } from "./types"; /** * Jupiter quote routes info */ export type RouteInfo = { swapInfo: { ammKey: PublicKeyString; label: string; inputMint: PublicKeyString; outputMint: PublicKeyString; inAmount: BigIntString; outAmount: BigIntString; feeAmount: BigIntString; feeMint: PublicKeyString; }; percent: number; }; /** * Juptier quote info */ export type QuoteInfo = { inputMint: PublicKeyString; inAmount: BigIntString; outputMint: PublicKeyString; outAmount: BigIntString; otherAmountThreshold: BigIntString; swapMode: "ExactIn" | "ExactOut"; slippageBps: number; platformFee: string | null; priceImpactPct: PercentString; routePlan: RouteInfo[]; contextSlot: number; timeTaken: number; } | { error: string; }; /** * Info stored in buyerPda */ export type CardPurchaseInfo = { address: PublicKeyString; index: bigint; buyerAddress: PublicKeyString; amount: DecimalString; purchaseAt: number; }; export type FeeTier = { minAmount: DecimalString; maxAmount: DecimalString; feePercent: PercentString; }; export type ProviderConfig = { minCardAmount: DecimalString; maxCardAmount: DecimalString; feeTiers: FeeTier[]; }; /** * Info stored in cardPda */ export type CardConfigInfo = { address: PublicKeyString; index: bigint; zicOwner: PublicKeyString; nativeFeePercent: PercentString; nonNativeFeePercent: PercentString; revenueFeePercent: PercentString; usdcMint: PublicKeyString; revenueVault: PublicKeyString; commissionVault: PublicKeyString; cardVault: PublicKeyString; totalCardSold: DecimalString; providerConfig: ProviderConfig; dailyCardPurchaseLimit: DecimalString; }; export type TokenFeeRecord = { tokenAddress: PublicKeyString; fee: PercentString; }; export type TokenFeeRecordList = TokenFeeRecord[]; export type UserPurchaseRecordInfo = { address: PublicKeyString; owner: PublicKeyString; lastCardBoughtTimestamp: number; totalCardBoughtPerDay: DecimalString; }; export type CardBotConfigInfo = { botAdmin: PublicKeyString; }; export type BotUserCustodyInfo = { userId: string; lastCardBoughtTimestamp: number; totalCardBoughtPerDay: DecimalString; }; export type OnRampConfigInfo = { onRampAdmin: PublicKeyString; zbcnToken: PublicKeyString; }; export type OnRampUserCustodyInfo = { userId: string; }; export type InitCardConfigParams = { zicOwnerAddress: Address; cardVaultAddress: Address; revenueVaultAddress: Address; commissionVaultAddress: Address; usdcAddress: Address; revenueFeePercent: PercentString; nativeFeePercent: PercentString; nonNativeFeePercent: PercentString; minCardAmount: DecimalString; maxCardAmount: DecimalString; dailyCardPurchaseLimit: DecimalString; feeTiers: Array; }; export type SetCardConfigParams = { zicOwnerAddress: Address; newZicOwnerAddress: Address; cardVaultAddress: Address; revenueVaultAddress: Address; commissionVaultAddress: Address; revenueFeePercent: PercentString; nativeFeePercent: PercentString; nonNativeFeePercent: PercentString; minCardAmount: DecimalString; maxCardAmount: DecimalString; dailyCardPurchaseLimit: DecimalString; feeTiers: Array; }; export type SetCustomFeesParams = { zicOwnerAddress: PublicKeyString; tokenFeeList: TokenFeeRecordList; }; export type DeleteCustomFeesParams = { zicOwnerAddress: PublicKeyString; tokenAddressList: PublicKeyString[]; }; export type SwapMode = "ExactOut" | "ExactIn"; export type SwapAndDepositParams = { userAddress: Address; quoteInfo: QuoteInfo; }; export type DepositParams = { userAddress: Address; mintAddress: Address; amount: DecimalString; }; export type WithdrawParams = { userAddress: Address; mintAddress: Address; amount: DecimalString; }; export type CardType = "silver" | "carbon"; export type BuyCardParams = { mintAddress: Address; buyerAddress: Address; nextBuyerCounter: bigint; amount: DecimalString; cardType: CardType; buyerEmail: EmailString; }; export type BuyCardDirectParams = { buyerAddress: Address; nextBuyerCounter: bigint; amount: DecimalString; cardType: CardType; buyerEmail: EmailString; mintAddress: Address; }; export type SwapAndBuyCardDirectParams = { quoteInfo: QuoteInfo; buyerAddress: Address; nextBuyerCounter: bigint; cardType: CardType; buyerEmail: EmailString; }; export type GetQuoteInfoParams = { inputMintAddress: Address; outputMintAddress: Address; inputAmount: DecimalString; slippagePercent: PercentString; swapMode?: SwapMode; }; export type GenerateYieldParams = { userAddress: Address; mintAddress: Address; amount: DecimalString; }; export type WithdrawYieldParams = { userAddress: Address; mintAddress: Address; amount: DecimalString; withdrawAll?: boolean; }; export type InitBotConfigParams = { zicOwnerAddress: PublicKeyString; botAdminAddress: PublicKeyString; }; export type InitBotUserCustodyParams = { botAdminAddress: PublicKeyString; usdcMintAddress: PublicKeyString; userId: string; }; export type SetNewBotAdminParams = { newBotAdminAddress: PublicKeyString; zicOwnerAddress: PublicKeyString; }; export type BuyCardThroughBotParams = { botAdminAddress: PublicKeyString; usdcMintAddress: PublicKeyString; userId: string; cardType: CardType; amount: DecimalString; }; export type InitOnRampConfigParams = { zicOwnerAddress: PublicKeyString; onRampAdminAddress: PublicKeyString; zbcnAddress: PublicKeyString; }; export type InitOnRampUserCustodyParams = { onRampAdminAddress: PublicKeyString; userId: string; }; export type SetNewOnRampAdminParams = { zicOwnerAddress: PublicKeyString; newOnRampAdminAddress: PublicKeyString; }; export type OnRampTransferZbcnParams = { onRampAdminAddress: PublicKeyString; senderUserId: string; receiverAddress: PublicKeyString; amount: DecimalString; durationInDays: number; }; /** * Data emitted from Deposit Event */ export type DepositToUserPdaEvent = { from: PublicKeyString; to: PublicKeyString; amount: DecimalString; }; export type CardPurchaseEvent = { index: bigint; from: PublicKeyString; to: PublicKeyString; amount: DecimalString; }; /** * Zebec card service for interacting with zebec instant card program * * @example * * ``` * const connection = new Connection(process.env.RPC_URL || clusterApiUrl("mainnet-beta")); * const wallet = useWallet(); * const provider = getAnchorProvider(connection, wallet); * const program = ZebecCardProgramFactory.getProgram(provider); * const instructions = new ZebecCardInstructions(program); * const service = new ZebecCardService(instructions, connection, wallet.signTranaction); * * // or * const provider = getZebecConnectionProvider(connection); * const program = ZebecCardProgramFactory.getProgram(provider); * const instructions = new ZebecCardInstructions(program); * const service = new ZebecCardService(instructions, connection); * ``` */ export declare class ZebecCardService { readonly instructions: ZebecCardInstructions; private readonly _connection; private readonly _signTransaction?; static deriveCardConfigPda(cardProgramId: Address): PublicKey; static deriveTokenFeeMapPda(cardProgramId: Address): PublicKey; static deriveCardPurchaseInfoPda(buyerAddress: Address, cardProgramId: Address, buyerCounter: bigint): PublicKey; static deriveUserVaultPda(userAddress: Address, cardProgramId: Address): PublicKey; static deriveUserPurchaseRecordPda(userAddress: Address, cardProgramId: Address): PublicKey; static deriveFlexlendUserPda(userAddress: Address, flexlendProgramId: Address): PublicKey; static deriveFlexlendPromotionReservePda(reserveAdminAddress: Address, flexlendProgramId: Address): PublicKey; static deriveCardBotConfigPda(cardProgramId: Address): PublicKey; static deriveBotUserCustodyPda(userId: string, cardProgramId: Address): PublicKey; static deriveOnRampConfigPda(cardProgramId: Address): PublicKey; static deriveOnRampUserCustodyPda(userId: string, cardProgramId: Address): PublicKey; static deriveReloadableCardPda(cardProgramId: Address): PublicKey; private readonly _programId; constructor(instructions: ZebecCardInstructions, _connection: Connection, _signTransaction?: ((transaction: T) => Promise) | undefined); private _createPayload; initCardConfig(params: InitCardConfigParams): Promise; setCardConfig(params: SetCardConfigParams): Promise; setCustomFees(params: SetCustomFeesParams): Promise; deleteCustomFees(params: DeleteCustomFeesParams): Promise; swapAndDeposit(params: SwapAndDepositParams): Promise; deposit(params: DepositParams): Promise; withdraw(params: WithdrawParams): Promise; buyCard(params: BuyCardParams): Promise; swapAndBuyCardDirect(params: SwapAndBuyCardDirectParams): Promise; buyCardDirect(params: BuyCardDirectParams): Promise; private _checkAmountIsWithinDailyCardLimit; private _checkAmountIsWithinProviderRange; initBotConfig(params: InitBotConfigParams): Promise; initBotUserCustody(params: InitBotUserCustodyParams): Promise; setBotAdmin(params: SetNewBotAdminParams): Promise; buyCardThroughBot(params: BuyCardThroughBotParams): Promise; private _checkAmountIsWithinDailyCardLimitForBot; generateYield(params: GenerateYieldParams): Promise; withdrawYield(params: WithdrawYieldParams): Promise; initOnRampConfig(params: InitOnRampConfigParams): Promise; setOnRampAdmin(params: SetNewOnRampAdminParams): Promise; initOnRampUserCustody(params: InitOnRampUserCustodyParams): Promise; onRampTransferZbcn(params: OnRampTransferZbcnParams): Promise; getQuoteInfo(params: GetQuoteInfoParams): Promise; getUserVaultBalance(userAddress: Address, mintAddress: Address, commitment?: Commitment): Promise; getNextBuyerCounter(): Promise; getCardConfigInfo(commitment?: Commitment): Promise; getCardPurchaseInfo(cardPurchaseInfoPda: Address, commitment?: Commitment): Promise; getUserPurchaseRecord(userPurchaseRecordKey: Address, commitment?: Commitment): Promise; getCustomTokenFees(commitment?: Commitment): Promise; getCardBotConfigInfo(commitment?: Commitment): Promise; getBotUserCustodyInfo(userCustody: Address, commitment?: Commitment): Promise; getOnRampConfigInfo(commitment?: Commitment): Promise; getOnRampUserCustodyInfo(onRampUserCustody: Address, commitment?: Commitment): Promise; getAllCardPurchaseInfo(buyerAddress: Address): Promise>; addDepositToUserPdaEventLister(callback: (event: DepositToUserPdaEvent, slot: number, signature: string) => void): number; addCardPurchaseEventLister(callback: (event: CardPurchaseEvent, slot: number, signature: string) => void): number; removeEventLister(eventListener: number): Promise; }