export type Address = `0x${string}`; export type BaseUnits = string; export type EvmBridgeChain = 1 | 8453 | 42161; export type Product = 'same-chain' | 'cross-chain' | 'fiat-buy' | 'fiat-sell'; export type Execution = 'czr-router' | '0x-direct'; export interface EthereumProvider { request(args: {method:string;params?:readonly unknown[] | object}):Promise; } export interface WalletChoice { id:string; name:string; provider:EthereumProvider; } export interface QuoteOptions { signal?:AbortSignal; } export interface SameChainInput { product:'same-chain'; chainId?:1; taker:Address; sellAmount:BaseUnits; sellToken?:Address; buyToken?:Address; execution?:'czr-router'; slippagePpm?:number; } export interface CrossChainInput { product:'cross-chain'; originChain:EvmBridgeChain; destinationChain:EvmBridgeChain; originAddress:Address; sellAmount:BaseUnits; } export interface BitcoinQuoteInput { product:'bitcoin'; direction:'eth-to-btc'|'btc-to-eth'; sellAsset?:'ETH'|'USDC'|'USDT'; originAddress:string; destinationAddress:string; sellAmount:BaseUnits; } export interface FiatOrderIntent { product:'fiat-buy'|'fiat-sell'; amount:string; asset:'ETH'|'USDC'; currency:'USD'|'EUR'|'GBP'; country:string; chainId:1; } export interface BitcoinEstimate { provider:'CZR Trade'; product:'bitcoin'; mode:'estimate'; direction:'eth-to-btc'|'btc-to-eth'; sellAsset:'ETH'|'USDC'|'USDT'|'BTC'; buyAsset:'ETH'|'BTC'; sellAmount:BaseUnits; buyAmount:BaseUnits; minBuyAmount:BaseUnits; fee:{amount:BaseUnits;asset:'ETH'|'USDC'|'USDT'|'BTC';recipient:string;bps:number}|null; feeStatus:'quoted'|'not_returned'|'below_minimum'; bridgeProviders:string[]; estimatedTimeSeconds:number|null; sellToken:string; bridgeNativeFee:BaseUnits|null; gasEstimateWei:BaseUnits|null; routes?:Omit[]; } export interface BitcoinExecution extends Omit { mode:'wallet_execution'; direction:'eth-to-btc'; execution:'0x-direct'; chainId:1; originAddress:Address; destinationAddress:string; quoteId:string; expiresAt:number; approval:{token:Address;spender:Address;amount:BaseUnits}|null; transaction:{from:Address;to:Address;data:Address;value:Address}; routes:Omit[]; } export interface Fee { amount:BaseUnits; token:Address; bps:number; recipient:Address; } export interface SwapQuote { provider:'CZR Trade'; product:'same-chain'; chainId:1; execution:Execution; executionLabel:string; taker:Address; sellToken:Address; buyToken:Address; sellAmount:BaseUnits; buyAmount:BaseUnits; minBuyAmount:BaseUnits; expiresAt:number; fee:Fee; providerFee:{amount:BaseUnits;token:Address}|null; liquiditySources:string[]; gasCostWei:BaseUnits|null; slippagePpm:number|null; approval:{token:Address;spender:Address}|null; transaction:{from:Address;to:Address;data:Address;value:Address}; } export interface BridgeEstimate { provider:'CZR Trade'; product:'cross-chain'; mode:'estimate'; originChainId:EvmBridgeChain; destinationChainId:EvmBridgeChain; sellToken:Address; buyToken:Address; sellAmount:BaseUnits; buyAmount:BaseUnits; minBuyAmount:BaseUnits; fee:Fee|null; bridgeProviders:string[]; estimatedTimeSeconds:number|null; } export interface NetworkCapabilities { provider:'CZR Trade'; capabilities:{ sameChain:{mode:'wallet_execution';chainId:1;strictExecution:'czr-router';network:string;tokenCatalog:string;slippagePpmMaximum:number; router:{name:string;address:Address;explorerUrl:string};fee:{bps:number;asset:string;recipient:Address}; sellAssets:{symbol:string;address:Address;decimals:number}[];supportsCustomSellToken:boolean}; crossChain:{mode:'estimates_and_tracking';executionEnabled:false;assets:string[]; chains:{chainId:EvmBridgeChain;name:string;address:Address;decimals:number}[]}; bitcoin:{mode:'estimates_and_wallet_execution';executionEnabled:true;directions:BitcoinQuoteInput['direction'][]; execution:'0x-direct';executionDirections:['eth-to-btc'];ethereumSellAssets:('ETH'|'USDC'|'USDT')[];routeComparison:boolean;bitcoinReceiveAddressTypes:string[]; bitcoinAddressTypes:string[];fees:{bps:number;btcRecipient:string;ethRecipient:Address;btcDustSats:number}}; fiatBuy:{mode:'unavailable';paymentProviderConfigured:false}; fiatSell:{mode:'unavailable';paymentProviderConfigured:false}; }; } export interface SwapStatus { provider:'CZR Trade'; product:'same-chain'; state:'pending'|'confirmed'|'reverted'; hash:Address; execution?:Execution; fee?:{amount:BaseUnits|null;token:Address}|null; } export interface BridgeStatus { provider:'CZR Trade'; product:'cross-chain'; state:string; hash:Address; originChainId:EvmBridgeChain; transactions:{chainId:EvmBridgeChain;hash:Address}[]; terminal:boolean; settledBuyAmount:BaseUnits|null; recoveryState:string|null; } export class CZRTradeError extends Error { constructor(message:string,code:string,status?:number,retryAfter?:string|null); code:string; status?:number; retryAfter?:string|null; } export interface CZRTradeClient { capabilities(options?:QuoteOptions):Promise; quote(input:SameChainInput,options?:QuoteOptions):Promise; quote(input:CrossChainInput,options?:QuoteOptions):Promise; quote(input:BitcoinQuoteInput & {direction:'eth-to-btc';execution:'0x-direct'},options?:QuoteOptions):Promise; quote(input:BitcoinQuoteInput,options?:QuoteOptions):Promise; /** Rejects with PRODUCT_UNAVAILABLE until a fiat provider is connected. */ quote(input:FiatOrderIntent,options?:QuoteOptions):Promise; status(input:{product:'same-chain';hash:Address;taker?:Address;feeToken?:Address},options?:QuoteOptions):Promise; status(input:{product:'bitcoin';hash:Address;quoteId:string},options?:QuoteOptions):Promise & {product:'bitcoin';transactions:{chainId:number;hash:string}[]}>; status(input:{product:'cross-chain';hash:Address;originChain:EvmBridgeChain;quoteId?:string},options?:QuoteOptions):Promise; } export function createCZRTradeClient(options?:{baseUrl?:string;fetch?:typeof globalThis.fetch}):CZRTradeClient; export function watchInjectedWallets(target:Window,onWallets:(wallets:WalletChoice[])=>void):{refresh():void;stop():void}; export function connectCZRWallet(provider:EthereumProvider,options?:{chainId?:number}):Promise<{address:Address;chainId:number;provider:EthereumProvider}>;