Skip to content

exchange demo: Sell swap reverts with InsufficientOutput on testnet (slippage too strict) + no visible error in UI #3

@Alexkoko27

Description

@Alexkoko27

Describe the bug

While running examples/exchange locally (WSL + Vite), Buy swaps succeed (receipt link appears), but Sell often reverts on tempo testnet with:

  • Stablecoin DEX error: InsufficientOutput(InsufficientOutput)

In the default example UI this can look like a no-op (“nothing happens”) because the error isn’t surfaced.

Debugging notes / workaround

1) Surface the error in the UI

Adding basic error handling (e.g. rendering sellSendCalls.error / sellSendCalls.isError, or catching and displaying TransactionExecutionError) makes the revert reason visible instead of looking like nothing happened.

2) Adjust slippage tolerance on testnet

The default slippage tolerance is 0.5% (0.005). On current testnet liquidity this was too strict and caused InsufficientOutput. Increasing it to ~50% made Sell succeed reliably:

// default
const slippageTolerance = 0.005

// workaround (testnet)
const slippageTolerance = 0.5

Suggestion: expose slippage as a UI input (or use a higher default on testnet) and surface errors by default.

Example successful sell tx (after workaround): https://explore.tempo.xyz/tx/0x3e35dfaa6110be7269425e1556706bb8a59dac94e8b5d6f509ee671287b4552b

Steps to reproduce

  1. Clone the example:
    pnpx gitpick tempoxyz/examples/tree/main/examples/exchange exchange
    cd exchange
    pnpm install
    pnpm dev --host 0.0.0.0 --port 5173
  2. Open http://localhost:5173
  3. Sign up / Sign in
  4. Click Fund Account
  5. (Optional) Click Place Order
  6. Click Sell 10 AlphaUSD for BetaUSD
  7. Observe revert: \InsufficientOutput

Logs

TransactionExecutionError: Execution reverted with reason:
Stablecoin DEX error: InsufficientOutput(InsufficientOutput)
viem@2.46.2

Platform(s)

Windows (x86)

Container Type

Other, Not running in a container

What version/commit are you on?

Main branch (pulled from tempoxyz/examples via gitpick from examples/exchange).
No container (running locally on Windows 11 + WSL (Ubuntu)).

If you've built from source, provide the full command you used

pnpx gitpick tempoxyz/examples/tree/main/examples/exchange exchange && cd exchange && pnpm install && pnpm dev --host 0.0.0.0 --port 5173

Code of Conduct

  • I agree to follow the Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions