import type { AccountsControllerGetAccountByAddressAction } from "@metamask/accounts-controller"; import type { AssetsControllerGetExchangeRatesForBridgeAction } from "@metamask/assets-controller"; import type { CurrencyRateControllerGetStateAction, MultichainAssetsRatesControllerGetStateAction, TokenRatesControllerGetStateAction } from "@metamask/assets-controllers"; import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller"; import type { Messenger } from "@metamask/messenger"; import type { NetworkControllerFindNetworkClientIdByChainIdAction, NetworkControllerGetNetworkClientByIdAction } from "@metamask/network-controller"; import type { AuthenticationControllerGetBearerTokenAction } from "@metamask/profile-sync-controller/auth"; import type { RemoteFeatureFlagControllerGetStateAction } from "@metamask/remote-feature-flag-controller"; import type { SnapControllerHandleRequestAction } from "@metamask/snaps-controllers"; import type { Infer } from "@metamask/superstruct"; import type { CaipAccountId, CaipAssetId, CaipAssetType, CaipChainId, Hex } from "@metamask/utils"; import type { BridgeController } from "./bridge-controller.cjs"; import type { BridgeControllerMethodActions } from "./bridge-controller-method-action-types.cjs"; import type { BRIDGE_CONTROLLER_NAME } from "./constants/bridge.cjs"; import type { BitcoinTradeDataSchema, BridgeAssetSchema, ChainConfigurationSchema, ChainRankingSchema, FeeDataSchema, IntentSchema, PlatformConfigSchema, ProtocolSchema, QuoteResponseSchema, QuoteSchema, StepSchema, TokenFeatureSchema, QuoteStreamCompleteSchema, TronTradeDataSchema, TxDataSchema, BatchSellTradesResponseSchema, GaslessPropertiesSchema, SimulatedGasFeeLimitsSchema, TxFeeGasLimitsSchema } from "./utils/validators.cjs"; export type FetchFunction = (input: RequestInfo | URL | string, init?: RequestInit) => Promise; /** * The types of assets that a user can send */ export declare enum AssetType { /** The native asset for the current network, such as ETH */ native = "NATIVE", /** An ERC20 token */ token = "TOKEN", /** An ERC721 or ERC1155 token. */ NFT = "NFT", /** * A transaction interacting with a contract that isn't a token method * interaction will be marked as dealing with an unknown asset type. */ unknown = "UNKNOWN" } export type ChainConfiguration = Infer; export type ChainRanking = Infer; export type L1GasFees = { l1GasFeesInHexWei?: string; }; export type NonEvmFees = { nonEvmFeesInNative?: string; }; export type InputPrimaryDenomination = 'token_amount' | 'fiat_value'; /** * The types of values for the token amount and its values when converted to the user's selected currency and USD */ export type TokenAmountValues = { /** * The amount of the token * * @example "1.005" */ amount: string; /** * The amount of the token in the user's selected currency * * @example "4.55" */ valueInCurrency: string | null; /** * The amount of the token in USD * * @example "1.234" */ usd: string | null; }; /** * Asset exchange rate values for a given chain and address */ export type ExchangeRate = { exchangeRate?: string; usdExchangeRate?: string; }; /** * Values derived from the quote response */ export type QuoteMetadata = { /** * If gas is included, this is the value of the src or dest token that was used to pay for the gas. * Show this value to indicate transaction fees for gasless quotes. */ includedTxFees?: TokenAmountValues | null; /** * The gas fee for the bridge transaction. * effective is the gas fee that is shown to the user. If this value is not * included in the trade, the calculation falls back to the gasLimit (total) * total is the gas fee that is spent by the user, including refunds. * max is the max gas fee that will be used by the transaction. */ gasFee: Record<'effective' | 'total' | 'max', TokenAmountValues>; /** * The total network fee required to submit the trade and any approvals. This includes * the relayer fee or other native fees. Should be used for balance checks and tx submission. * Note: This is only accurate for non-gasless transactions. Use {@link QuoteMetadata.includedTxFees} to * get the total network fee for gasless transactions. */ totalNetworkFee: TokenAmountValues; totalMaxNetworkFee: TokenAmountValues; /** * The amount that the user will receive (destTokenAmount) */ toTokenAmount: TokenAmountValues; /** * The minimum amount that the user will receive (minDestTokenAmount) */ minToTokenAmount: TokenAmountValues; /** * If gas is included: {@link QuoteMetadata.toTokenAmount} - {@link QuoteMetadata.includedTxFees}. * Otherwise: {@link QuoteMetadata.toTokenAmount} - {@link QuoteMetadata.totalNetworkFee}. */ adjustedReturn: Omit; /** * The amount that the user will send, including fees that are paid in the src token * {@link Quote.srcTokenAmount} + {@link Quote.feeData[FeeType.METABRIDGE].amount} + {@link Quote.feeData[FeeType.TX_FEE].amount} */ sentAmount: TokenAmountValues; /** * The swap rate is the amount that the user will receive per amount sent. Accounts for fees paid in the src or dest token. * This is calculated as {@link QuoteMetadata.toTokenAmount} / {@link QuoteMetadata.sentAmount}. */ swapRate: string; /** * The cost of the trade, which is the difference between the amount sent and the adjusted return. * This is calculated as {@link QuoteMetadata.sentAmount} - {@link QuoteMetadata.adjustedReturn}. */ cost: Omit; }; /** * Sort order set by the user */ export declare enum SortOrder { COST_ASC = "cost_ascending", ETA_ASC = "time_descending" } /** * This is the interface for the asset object returned by the bridge-api * This type is used in the QuoteResponse and in the fetchBridgeTokens response */ export type BridgeAsset = Infer; /** * This is the interface for the token object used in the extension client * In addition to the {@link BridgeAsset} fields, it includes balance information */ export type BridgeToken = { address: string; symbol: string; image: string; decimals: number; chainId: number | Hex | ChainId | CaipChainId; balance: string; string: string | undefined; tokenFiatAmount?: number | null; occurrences?: number; }; type DecimalChainId = string; export type GasMultiplierByChainId = Record; export type FeatureFlagResponse = Infer; /** * This is the interface for the quote request sent to the bridge-api * and should only be used by the fetchBridgeQuotes utility function * Components and redux stores should use the {@link GenericQuoteRequest} type */ export type QuoteRequest = { walletAddress: WalletAddressType; destWalletAddress?: WalletAddressType; srcChainId: ChainIdType; destChainId: ChainIdType; srcTokenAddress: TokenAddressType; destTokenAddress: TokenAddressType; /** * This is the amount sent, in atomic amount */ srcTokenAmount: string; slippage?: number; aggIds?: string[]; bridgeIds?: string[]; insufficientBal?: boolean; resetApproval?: boolean; refuel?: boolean; /** * Whether the response should include gasless swap quotes * This should be true if the user has opted in to STX on the client * and the current network has STX support */ gasIncluded: boolean; /** * Whether to request quotes that use EIP-7702 delegated gasless execution */ gasIncluded7702: boolean; /** * The fee that will be charged by MetaMask */ fee?: number; }; export declare enum StatusTypes { SUBMITTED = "SUBMITTED", UNKNOWN = "UNKNOWN", FAILED = "FAILED", PENDING = "PENDING", COMPLETE = "COMPLETE" } export declare enum FeatureId { UNKNOWN = "unknown", PERPS = "perps", QUICK_BUY_FOLLOW_TRADING = "quick_buy_follow_trading", QUICK_BUY_TOKEN_DETAILS = "quick_buy_token_details", QUICK_BUY_EXPLORE = "quick_buy_explore", DAPP_SWAP = "dapp_swap", BATCH_SELL = "batch_sell", UNIFIED_SWAP_BRIDGE = "unified_swap_bridge" } /** * These are types that components pass in. Since data is a mix of types when coming from the redux store, we need to use a generic type that can cover all the types. * Payloads with this type are transformed into QuoteRequest by fetchBridgeQuotes right before fetching quotes */ export type GenericQuoteRequest = QuoteRequest; export type Protocol = Infer; export type Step = Infer; export type RefuelData = Step; export type FeeData = Infer; export type Quote = Infer; export type TxData = Infer; export type Intent = Infer; export type IntentOrderLike = Intent['order']; export type BitcoinTradeData = Infer; export type TronTradeData = Infer; /** * This is the type for the quote response from the bridge-api * TxDataType can be overriden to be a string when the quote is non-evm * ApprovalType can be overriden when you know the specific approval type (e.g., TxData for EVM-only contexts) */ export type QuoteResponseV1 = Infer & { trade: TxDataType; approval?: ApprovalType; /** * Appended to the quote response based on the quote request */ featureId?: FeatureId; /** * Appended to the quote response based on the quote request resetApproval flag * If defined, the quote's total network fee will include the reset approval's gas limit. */ resetApproval?: TxData; /** * Appended to the quote if there are multiple quote requests in a batch. This * indicates which quoteRequest the quote is for */ quoteRequestIndex?: number; }; export type BatchSellTradesRequest = { quotes: QuoteResponseV1[]; stxEnabled: boolean; }; /** * This is the bridge-api response for the obtainGaslessBatch method */ export type BatchSellTradesResponse = Infer; export type SimulatedGasFeeLimits = Infer; export type TxFeeGasLimits = Infer; export type GaslessProperties = Infer; export type DeepPartial = Type extends string ? Type : { [K in keyof Type]?: Type[K] extends (infer U)[] ? DeepPartial[] : Type[K] extends readonly (infer U)[] ? readonly DeepPartial[] : Type[K] extends object ? DeepPartial : Type[K]; }; export declare enum ChainId { ETH = 1, OPTIMISM = 10, BSC = 56, POLYGON = 137, ZKSYNC = 324, BASE = 8453, ARBITRUM = 42161, AVALANCHE = 43114, LINEA = 59144, SOLANA = 1151111081099710, BTC = 20000000000001, TRON = 728126428, SEI = 1329, MONAD = 143, HYPEREVM = 999, MEGAETH = 4326, ARC = 5042 } export type FeatureFlagsPlatformConfig = Infer; export type TokenFeature = Infer; export type QuoteStreamCompleteData = Infer; export declare enum RequestStatus { LOADING = 0, FETCHED = 1, ERROR = 2 } export type BridgeControllerState = { quoteRequest: Partial[]; quotes: (QuoteResponseV1 & L1GasFees & NonEvmFees)[]; /** * The time elapsed between the initial quote fetch and when the first valid quote was received */ quotesInitialLoadTime: number | null; /** * The timestamp of when the latest quote fetch started */ quotesLastFetched: number | null; /** * The status of the quote fetch, including fee calculations and validations * This is set to * - LOADING when the quote fetch starts * - FETCHED when the process completes successfully, including when quotes are empty * - ERROR when any errors occur * * When SSE is enabled, this is set to LOADING even when a quote is available. It is only * set to FETCHED when the stream is closed and all quotes have been received */ quotesLoadingStatus: RequestStatus | null; quoteFetchError: string | null; /** * The number of times the quotes have been refreshed, starts at 0 and is * incremented at the end of each quote fetch */ quotesRefreshCount: number; /** * Asset exchange rates for EVM and multichain assets that are not indexed by the assets controllers */ assetExchangeRates: Record; /** * When the src token is SOL, this needs to be subtracted from their balance to determine * the max amount that can be sent. */ minimumBalanceForRentExemptionInLamports: string | null; /** * Security alerts for the destination token in the current quote request, * populated from `token_warning` SSE events. */ tokenWarnings: TokenFeature[]; /** * Client-supplied security classification for the destination token in the * current quote request, used as the `token_security_type_destination` * analytics property. Set via the `context` arg of * `updateBridgeQuoteRequestParams` and reset whenever the quote request is * reset. `null` when the client has no security data for the token. */ tokenSecurityTypeDestination: string | null; /** * The denomination currently shown as the primary source amount input. * This is persisted as a user preference so returning to the flow restores * the last selected fiat/token display mode. */ inputPrimaryDenomination: InputPrimaryDenomination; /** * Metadata about the completed quote stream, populated from the `complete` SSE event. * Set to null at the start of each fetch and updated when the complete event is received. */ quoteStreamComplete: QuoteStreamCompleteData | null; /** * Contains gasless transaction data and fees for BatchSell quotes, provided by the obtainGaslessBatch API */ batchSellTrades: BatchSellTradesResponse | null; /** * The status of the batch sell trades fetch, including fee calculations and validations */ batchSellTradesLoadingStatus: RequestStatus | null; }; /** * @deprecated Use the separate method action types (e.g., * `BridgeControllerFetchQuotesAction`) instead. */ export type BridgeControllerAction = { type: `${typeof BRIDGE_CONTROLLER_NAME}:${FunctionName}`; handler: BridgeController[FunctionName]; }; export type BridgeControllerGetStateAction = ControllerGetStateAction; export type BridgeControllerStateChangeEvent = ControllerStateChangeEvent; export type BridgeControllerActions = BridgeControllerGetStateAction | BridgeControllerMethodActions; export type BridgeControllerEvents = BridgeControllerStateChangeEvent; export type AllowedActions = AccountsControllerGetAccountByAddressAction | AuthenticationControllerGetBearerTokenAction | CurrencyRateControllerGetStateAction | TokenRatesControllerGetStateAction | MultichainAssetsRatesControllerGetStateAction | SnapControllerHandleRequestAction | NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerGetNetworkClientByIdAction | RemoteFeatureFlagControllerGetStateAction | AssetsControllerGetExchangeRatesForBridgeAction; export type AllowedEvents = never; /** * The messenger for the BridgeController. */ export type BridgeControllerMessenger = Messenger; export {}; //# sourceMappingURL=types.d.cts.map