Labels: complexity: high
Implement previewTokenSwap(invoiceId, sourceToken, sourceAmount) that simulates what the DEX would return before calling pay_with_token. Uses the configured DEX contract's simulation interface.
Acceptance criteria:
- Returns
{ estimatedOutput: bigint, priceImpactBps: number, route: string[] }
- Calls
simulate_transaction on the DEX contract rather than submitting
- Returns error with message if no DEX is configured on the invoice
- Exported with full TypeScript types
Labels: complexity: high
Implement
previewTokenSwap(invoiceId, sourceToken, sourceAmount)that simulates what the DEX would return before callingpay_with_token. Uses the configured DEX contract's simulation interface.Acceptance criteria:
{ estimatedOutput: bigint, priceImpactBps: number, route: string[] }simulate_transactionon the DEX contract rather than submitting