export interface ZeroExQuoteRequest { chainId: string buyToken: string sellToken: string sellAmount: string txOrigin?: string swapFeeRecipient?: string swapFeeBps?: number swapFeeToken?: string tradeSurplusRecipient?: string gasPrice?: string slippageBps?: number excludedSources?: string sellEntireBalance?: 'true' | 'false' } interface ZeroExQuoteSuccess { /** When set (non-empty after trim), do not execute the quote (fail closed). */ error?: never data: { rawResponse: { message?: string blockNumber: string buyAmount: string buyToken: string fees: { integratorFee: { amount: string token: string type: string } | null zeroExFee: { amount: string token: string type: string } | null gasFee: { amount: string token: string type: string } | null } issues: { allowance: { actual: string spender: string } balance: { token: string actual: string expected: string } simulationIncomplete: boolean invalidSourcesPassed: any[] } liquidityAvailable: boolean minBuyAmount: string route: { fills: { from: string to: string source: string proportionBps: string }[] tokens: { address: string; symbol: string }[] } sellAmount: string sellToken: string tokenMetadata: { buyToken: { buyTaxBps: string sellTaxBps: string } sellToken: { buyTaxBps: string sellTaxBps: string } } totalNetworkFee: string transaction: { to: string data: string gas: string gasPrice: string value: string } } } metadata: { buyToken: string sellToken: string sellAmount: string chainId: string clientId: string clientEip155Address: string } } interface ZeroExQuoteError { /** When set (non-empty after trim), do not execute the quote (fail closed). */ error: string data?: never metadata?: { buyToken: string sellToken: string sellAmount: string chainId: string clientId: string clientEip155Address: string } } export type ZeroExQuoteResponse = ZeroExQuoteSuccess | ZeroExQuoteError export interface ZeroExSourcesRequest { chainId: string } export interface ZeroExSourcesResponse { metadata: { chainId: string clientId: string } data: { rawResponse: { sources: string[]; zid: string } } } export interface ZeroExPriceRequest { chainId: string buyToken: string sellToken: string sellAmount: string txOrigin?: string swapFeeRecipient?: string swapFeeBps?: number swapFeeToken?: string tradeSurplusRecipient?: string gasPrice?: string slippageBps?: number excludedSources?: string sellEntireBalance?: 'true' | 'false' } export interface ZeroExPriceResponse { data: { rawResponse: { message?: string blockNumber: string buyAmount: string buyToken: string fees: { integratorFee: { amount: string token: string type: string } | null zeroExFee: { amount: string token: string type: string } | null gasFee: { amount: string token: string type: string } | null } gas: string gasPrice: string issues: { allowance: { actual: string spender: string } balance: { token: string actual: string expected: string } simulationIncomplete: boolean invalidSourcesPassed: any[] } liquidityAvailable: boolean minBuyAmount: string route: { fills: { from: string to: string source: string proportionBps: string }[] tokens: { address: string; symbol: string }[] } sellAmount: string sellToken: string tokenMetadata: { buyToken: { buyTaxBps: string sellTaxBps: string } sellToken: { buyTaxBps: string sellTaxBps: string } } totalNetworkFee: string } } metadata: { buyToken: string sellToken: string sellAmount: string chainId: string clientId: string clientEip155Address: string } } export interface ZeroExOptions { zeroXApiKey?: string } // --- High-level 0x trade and progress types --- export type ZeroXTradeAssetProgressStatus = | 'fetching_quote' | 'signing' | 'submitted' | 'confirming' | 'confirmed' | 'failed' export interface ZeroXTradeAssetProgressData { errorMessage?: string buyAmount?: string sellAmount?: string transaction?: unknown txHash?: string } export interface ZeroXTradeAssetParams extends Omit { fromAddress: string onProgress?: ( status: ZeroXTradeAssetProgressStatus, data?: ZeroXTradeAssetProgressData, ) => void zeroXApiKey?: string } /** * **Signer:** per-call → instance (Portal wires default). * **Confirmation:** per-call → instance, or `evmRequestFn` + receipt poll (eip155 only) on Web. * * @remarks * When `waitForConfirmation` is omitted on EVM, the browser package can still confirm via * `eth_getTransactionReceipt` polling by supplying `evmRequestFn` as the JSON-RPC transport. */ export interface ZeroXTradeAssetOptions { signAndSendTransaction?: ( transaction: unknown, network: string, ) => Promise waitForConfirmation?: ( txHash: string, network: string, ) => Promise /** * When `waitForConfirmation` is not set, the built-in EVM receipt poller uses this JSON-RPC * function. Pass `waitForConfirmation` when you need custom confirmation semantics. */ evmRequestFn?: ( method: string, params: unknown[], network: string, ) => Promise /** Tuning for the built-in EVM receipt poller when using `evmRequestFn`. */ evmPollerOptions?: { pollIntervalMs?: number timeoutMs?: number } } export interface ZeroXTradeAssetResult { hashes: string[] }