import type { Dnum } from 'dnum'; import { type ConvertBalances } from './balances'; import { type ConvertQuote } from './quote'; import type { ConvertResolvedAsset } from './types'; /** Why a submit stopped before signing. Nothing was sent. */ export type ConvertSubmitBlockReason = /** The fresh balance read failed or left this asset out. */ 'balanceUnavailable' /** A native EVM source's gas price hasn't loaded, so Max is unknown. */ | 'feeReserveLoading' /** The amount is above the fresh balance less its fee reserve. */ | 'insufficientBalance' /** The quote doesn't say what the user receives. */ | 'quoteMissingReceiveAmount' /** The quote doesn't spend the amount on screen, or doesn't say what it spends. */ | 'quoteAmountMismatch' /** The quote prices the source in different decimals than the SDK resolved. */ | 'decimalsMismatch'; /** * The pre-sign check's outcome. Only `ready` may sign, and it signs the quote * on screen, like withdrawal. Nothing here edits the amount: an over-balance * amount is reported with the fresh Max, for the screen to offer like * checkout's "Deposit max balance". */ export type ConvertSubmitPreparation = { status: 'ready'; quote: ConvertQuote; } /** `maxBaseUnits` is 0 when nothing is left after the fee reserve. */ | { status: 'blocked'; reason: 'insufficientBalance'; maxBaseUnits: bigint; } | { status: 'blocked'; reason: Exclude; error?: unknown; }; /** * The source decimals Relay priced the quote in, when it reports them. A * mismatch means the amount and the host's balance were both scaled with the * wrong decimals, which the balance check can't see. */ export declare function getQuoteSourceDecimals(quote: ConvertQuote): number | undefined; export declare function hasQuoteDecimalsMismatch({ quote, sourceAsset, }: { quote: ConvertQuote; sourceAsset: ConvertResolvedAsset; }): boolean; /** * The pre-sign check, run on every submit before the first source step: check * the quote being converted, re-read the source balance and check the amount * against the fresh Max. Returns `ready` with the quote to execute, or why not * to sign yet. Like withdrawal, it doesn't requote. Never signs, sends, or * edits the amount. */ export declare function prepareConvertSubmit({ sourceAsset, amountBaseUnits, quote, isFeeReserveLoading, getMaxSpendable, refetchBalances, }: { sourceAsset: ConvertResolvedAsset; amountBaseUnits: bigint; /** The quote on screen; it's the one signed. */ quote: ConvertQuote; /** A native EVM source's gas price is loading, so Max is unknown. */ isFeeReserveLoading: boolean; /** The balance less its fee reserve. */ getMaxSpendable: (balance: Dnum) => Dnum; /** Called with only the source asset. */ refetchBalances: (assets: ConvertResolvedAsset[]) => Promise; }): Promise;