Skip to main content
Executes a token swap on behalf of the signed-in user. The backend atomically quotes, signs Permit2 (if needed), simulates, and submits the transaction. Returns immediately with a transaction hash (EOA) or user operation hash (smart account).

Parameters

Returns

Promise<ExecuteSwapResult> A discriminated union result with the transaction/operation hash and swap details.

Throws

An InputValidationError if parameters are invalid.

Throws

A SwapError for known failures (insufficient liquidity/balance/allowance, simulation failure).

Throws

An APIError for auth, network, or server errors.

Example