/** * Private Swap Recipe — Full pipeline: unshield → approve → swap * * Orchestrates the complete private swap: * 1. Derive Railgun keys * 2. Fetch spendable UTXOs → check balance * 3. Get swap quote (0x → Aerodrome fallback) * 4. Calculate unshield amount * 5. Generate ZK proof (client-side Groth16) * 6. Build 3-call multicall: [unshield, approve, swap] * 7. Build UserOp with paymaster signature * 8. Sign UserOp with owner key * 9. Submit to EntryPoint * 10. Wait for confirmation * 11. Return structured receipt */ import { BaseRecipe, type RecipeContext } from './base-recipe'; import type { ExecutionReceipt, RecipeConfig, SwapQuote } from '../types'; export interface SwapDependencies { /** Get swap quote from a provider */ getQuote: (params: { sellToken: string; buyToken: string; sellAmount: bigint; taker: string; slippageBps: number; }) => Promise; /** Derive Railgun keys from owner signature */ deriveKeys: (privateKey: string) => Promise<{ viewingKeyPair: { privateKey: Uint8Array; }; spendingKeyPair: { privateKey: Uint8Array; pubkey: bigint[]; }; nullifyingKey: bigint; masterPublicKey: bigint; }>; /** Fetch spendable UTXOs */ fetchUTXOs: (signerAddress: string, viewingPrivateKey: Uint8Array, masterPublicKey: bigint, nullifyingKey: bigint, tokenAddress: string, chainId: number) => Promise; /** Get total spendable balance for a token */ getBalance: (utxos: any[], tokenAddress: string) => bigint; /** Select UTXOs for a given amount */ selectUTXOs: (utxos: any[], amount: bigint, tokenAddress: string) => any[]; /** Build ZK proof inputs for unshield */ buildProofInputs: (params: any) => any; /** Generate ZK proof */ generateProof: (params: any) => Promise; /** Build unshield transaction calldata */ buildUnshieldTx: (params: any) => { to: string; data: string; }; /** Get nonce for sender from EntryPoint */ getNonce: (sender: string) => Promise; /** Submit UserOp to bundler/EntryPoint */ submitUserOp: (userOp: any) => Promise; /** Wait for transaction confirmation */ waitForTx: (txHash: string) => Promise<{ status: number; }>; /** Get current gas price */ getGasPrice: () => Promise<{ maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; }>; } export declare class PrivateSwapRecipe extends BaseRecipe { private readonly deps; readonly name = "private-swap"; constructor(deps: SwapDependencies); execute(recipeConfig: RecipeConfig, context: RecipeContext): Promise; }