import { type Address, type Hex } from "viem"; import type { CowSwapClosePositionPlanParams, CowSwapCollateralSwapPlanParams, CowSwapOpenPositionPlanParams } from "./executionServiceTypes.js"; export declare const COWSWAP_APPDATA_VERSION = "0.9.0"; export declare const COWSWAP_ORDER_DEADLINE_SECONDS = 900; export declare const COWSWAP_ORDER_POLL_INTERVAL_MS = 3000; export declare const COWSWAP_ORDER_POLL_MAX_DURATION_MS: number; export declare const INBOX_DOMAIN_NAME = "Inbox"; export declare const INBOX_DOMAIN_VERSION = "1"; export type CowSwapOrderKind = "sell" | "buy"; export type CowSwapOrderSigningScheme = "eip712" | "eip1271" | "ethsign" | "presign"; export type CowSwapTokenBalance = "erc20" | "internal" | "external"; export type CowSwapOrderUid = string; export type CowSwapTypedDataRequest = { domain: Record; types: Record; primaryType: string; message: Record; }; export type CowSwapCompetitionOrderStatusType = "open" | "scheduled" | "active" | "solved" | "executing" | "traded" | "cancelled"; export type CowSwapLifecycleOrderStatusType = "presignaturePending" | "open" | "fulfilled" | "cancelled" | "expired"; export type CowSwapOrderStatusType = CowSwapCompetitionOrderStatusType | CowSwapLifecycleOrderStatusType | "unknown"; export type CowSwapTerminalOrderStatus = "traded" | "fulfilled" | "cancelled" | "expired"; export type CowSwapOrderStatus = { type: CowSwapOrderStatusType; competitionType?: CowSwapCompetitionOrderStatusType; orderType?: CowSwapLifecycleOrderStatusType; terminal: boolean; }; export type CowSwapOrderPayload = { sellToken: Address; buyToken: Address; from: Address; receiver: Address; sellAmount: string; buyAmount: string; feeAmount: string; kind: CowSwapOrderKind; partiallyFillable: boolean; validTo: number; sellTokenBalance: CowSwapTokenBalance; buyTokenBalance: CowSwapTokenBalance; signature: string; signingScheme: CowSwapOrderSigningScheme; onchainOrder: boolean; appData: string; appDataHash: Hex; quoteId?: number; }; export type CowSwapChainConfig = { orderbookUrl: string; settlementContract: Address; vaultRelayer: Address; openPositionWrapper: Address; closePositionWrapper: Address; collateralSwapWrapper: Address; }; export declare const COWSWAP_CHAIN_CONFIG: Record; export declare function getCowSwapChainConfig(chainId: number): CowSwapChainConfig | undefined; export declare function getCowSwapOrderExplorerUrl(orderUid: CowSwapOrderUid): string; export declare function computeNonceNamespace(sender: Address): bigint; export declare function buildEvcPermitTypedData(params: { chainId: number; evcAddress: Address; signer: Address; sender: Address; nonceNamespace: bigint; nonce: bigint; deadline: number; value?: bigint; data: Hex; }): { domain: { name: string; chainId: bigint; verifyingContract: `0x${string}`; }; types: { readonly Permit: readonly [{ readonly name: "signer"; readonly type: "address"; }, { readonly name: "sender"; readonly type: "address"; }, { readonly name: "nonceNamespace"; readonly type: "uint256"; }, { readonly name: "nonce"; readonly type: "uint256"; }, { readonly name: "deadline"; readonly type: "uint256"; }, { readonly name: "value"; readonly type: "uint256"; }, { readonly name: "data"; readonly type: "bytes"; }]; }; primaryType: "Permit"; message: { signer: `0x${string}`; sender: `0x${string}`; nonceNamespace: bigint; nonce: bigint; deadline: bigint; value: bigint; data: `0x${string}`; }; }; export declare function buildOpenPositionWrapperData(params: CowSwapOpenPositionPlanParams["wrapper"], permitSignature: Hex): Hex; export declare function buildCollateralSwapWrapperData(params: CowSwapCollateralSwapPlanParams["wrapper"], permitSignature: Hex): Hex; export declare function buildClosePositionWrapperData(params: CowSwapClosePositionPlanParams["wrapper"], permitSignature: Hex): Hex; export declare function buildCowSwapAppData(wrapperData: Hex, wrapperAddress: Address, slippageBips: number, appCode?: string): { appDataString: string; appDataHash: Hex; }; export declare function buildOpenPositionQuoteAppData(params: CowSwapOpenPositionPlanParams["wrapper"], wrapperAddress: Address, slippageBips: number): string; export declare function buildCollateralSwapQuoteAppData(params: CowSwapCollateralSwapPlanParams["wrapper"], wrapperAddress: Address, slippageBips: number): string; export declare function buildClosePositionQuoteAppData(params: CowSwapClosePositionPlanParams["wrapper"], wrapperAddress: Address, slippageBips: number): string; export declare function buildCowSwapOrderTypedData(params: { chainId: number; settlementContract: Address; sellToken: Address; buyToken: Address; receiver: Address; sellAmount: bigint; buyAmount: bigint; validTo: number; appDataHash: Hex; kind?: CowSwapOrderKind; domainName?: string; domainVersion?: string; verifyingContract?: Address; }): { domain: { name: string; version: string; chainId: bigint; verifyingContract: `0x${string}`; }; types: { readonly Order: readonly [{ readonly name: "sellToken"; readonly type: "address"; }, { readonly name: "buyToken"; readonly type: "address"; }, { readonly name: "receiver"; readonly type: "address"; }, { readonly name: "sellAmount"; readonly type: "uint256"; }, { readonly name: "buyAmount"; readonly type: "uint256"; }, { readonly name: "validTo"; readonly type: "uint32"; }, { readonly name: "appData"; readonly type: "bytes32"; }, { readonly name: "feeAmount"; readonly type: "uint256"; }, { readonly name: "kind"; readonly type: "string"; }, { readonly name: "partiallyFillable"; readonly type: "bool"; }, { readonly name: "sellTokenBalance"; readonly type: "string"; }, { readonly name: "buyTokenBalance"; readonly type: "string"; }]; }; primaryType: "Order"; message: { readonly sellToken: `0x${string}`; readonly buyToken: `0x${string}`; readonly receiver: `0x${string}`; readonly sellAmount: bigint; readonly buyAmount: bigint; readonly validTo: number; readonly appData: `0x${string}`; readonly feeAmount: 0n; readonly kind: CowSwapOrderKind; readonly partiallyFillable: false; readonly sellTokenBalance: "erc20"; readonly buyTokenBalance: "erc20"; }; }; export declare function buildCowSwapOrderPayload(typedData: ReturnType, signature: string, from: Address, appDataString: string, appDataHash: Hex, options?: { signingScheme?: CowSwapOrderSigningScheme; quoteId?: number; }): CowSwapOrderPayload; export declare function buildCowSwapCancelOrderTypedData(params: { orderUid: CowSwapOrderUid; chainId: number; settlementContract?: Address; }): CowSwapTypedDataRequest; export declare function normalizeCowSignature(signature: Hex): Hex; export declare function encodeOrderDataForInbox(order: { sellToken: Address; buyToken: Address; receiver: Address; sellAmount: bigint; buyAmount: bigint; validTo: number; appData: Hex; feeAmount: bigint; kind: CowSwapOrderKind; partiallyFillable: boolean; sellTokenBalance: string; buyTokenBalance: string; }): Hex; export declare function buildInboxSignature(ecdsaSignature: Hex, orderEncodeData: Hex): Hex; export declare function verifyInboxDomainSeparator(inboxAddress: Address, chainId: number, expectedDomainSep: Hex): void; export declare function submitCowSwapOrder(payload: CowSwapOrderPayload, orderbookUrl: string): Promise; export declare function resolveCowSwapOrderStatusType(params: { competitionType?: CowSwapCompetitionOrderStatusType; orderType?: CowSwapLifecycleOrderStatusType; }): CowSwapOrderStatusType; export declare function isCowSwapTerminalOrderStatus(type?: CowSwapOrderStatusType): type is CowSwapTerminalOrderStatus; type CowSwapOrderbookArgs = { chainId?: number; orderbookUrl?: string; }; export type FetchCowSwapOrderStatusArgs = CowSwapOrderbookArgs & { orderUid: CowSwapOrderUid; signal?: AbortSignal; }; export declare function fetchCowSwapOrderStatus(args: FetchCowSwapOrderStatusArgs): Promise; export type PollCowSwapOrderStatusArgs = FetchCowSwapOrderStatusArgs & { intervalMs?: number; timeoutMs?: number; onStatus?: (status: CowSwapOrderStatus) => void; }; export declare function pollCowSwapOrderStatus(args: PollCowSwapOrderStatusArgs): Promise; export declare function formatCowSwapExecutionErrorMessage(error: Error): string; export type CancelCowSwapOrderArgs = CowSwapOrderbookArgs & { orderUid: CowSwapOrderUid; chainId: number; settlementContract?: Address; signTypedData: (parameters: CowSwapTypedDataRequest) => Promise; signal?: AbortSignal; }; export declare function cancelCowSwapOrder(args: CancelCowSwapOrderArgs): Promise; export {}; //# sourceMappingURL=cowSwapHelpers.d.ts.map