Euclidswap: Factory error handling

Euclid Swap’s testnet is built on Euclid Protocol. In the protocol’s documented Factory workflow, a returned error acknowledgment triggers a refund to the user and reversal of all state changes for the failed swap.

The Factory and its dependencies

Factory
Euclid’s architecture places a Factory contract on each integrated chain. It receives user requests and forwards them to the Router. Its operations include swaps, adding liquidity, and removing liquidity.
Router and Virtual Settlement Layer
The Router passes the swap request to the Virtual Settlement Layer (VSL), where swap calculations occur. It then relays the returned acknowledgment to the Factory.
Escrow contracts
Each escrow holds one token type on an integrated chain. In the documented native-token escrow flow, successful execution stores the input token in one escrow and releases the output token from another, following the instruction that the relevant Factory forwards.

The Factory coordinates requests and their results. The VSL performs the settlement calculation, while escrows hold and release the assets on individual chains.

Slippage failures, timeouts, and partial routes

The Escrow documentation identifies high-slippage failures and timeouts as cases in which the input tokens return to the user.

A partially failing MultiDEX route has a separate documented outcome. Euclid Protocol’s voucher FAQ of May 9, 2025, written for the testnet, describes vouchers covering the missing portion when a MultiDEX route partially fails. Vouchers issued during swaps are credited on the input chain. They represent swap output within Euclid, so receiving them differs from receiving a refund of the original input asset.

Hypothetical case: Interpreting an acknowledgment

A request reaching the VSL does not by itself establish that output tokens have been released. For this hypothetical example, assume a swap from input token A to output token B has reached the VSL through a Factory and the Router. Assume the full output is requested as native token B and the destination escrow holds enough token B to pay it. Consider two hypothetical acknowledgment results for that same request:

  • If the acknowledgment reports success, the relevant Factory forwards the release instruction to the output-token escrow, which releases token B to the specified destination.
  • If the acknowledgment reports an error, the user receives a refund and all state changes for the failed request are reverted.

Changing the acknowledgment from success to error changes the documented outcome from output release to refund and rollback; the earlier submission alone establishes neither result.

Hypothetical case: Interpreting an acknowledgment (Euclidswap) - illustration
Hypothetical case: Interpreting an acknowledgment, illustrated

View image file

Last updated ·