Once an order has been executed, meaning a second Broker, the Taker, has filled the order on the Relayer, both the Maker, who placed the order, and the Taker, who filled the order, move to settle the trade.
sparkswap's settlement method is what allows users to trade instantly without giving up control of their assets. To settle trades, the Maker and Taker set up what is called a Payment Channel Network cross-chain atomic swap.
To read more about this settlement method, see Swaps on sparkswap.
Swaps executed over Payment Channel Networks like the Lightning Network take roughly as long as a single payment transaction on such networks.
With the current software, a typical trade takes [1000ms] to settle once it has been executed.
To examine that time in more detail, the following is further breakdown of the swap process:
- Prepare to settle: 3 HTTP/2 calls, 1 Filesystem write; ~[300ms]
- Extend first leg of swap: 2 hop HTLC extension; ~[200ms]
- Translate swap: 2 HTTP/2 calls; ~[150ms]
- Extend second leg of swap: 2 hop HTLC extension; ~[200ms]
- Settle second leg of swap: 2 hop settlement; ~[200ms]
- Translate settlement: 2 HTTP/2 calls; ~[150ms]
- Settle second leg of swap: 2 hop settlement; ~ [200ms]
Worst case settlement
What is described above is settlement in the normal case. However, in the worst case where some parties along the swap route have some sort of dispute, the swap may take significantly longer to settle.
Specifically, with the HTLC construction that sparkswap currently uses, and the swap routes that it uses, it may take up to 96 hours to fully settle.
The worst case settlement time is determined by the number of hops in the swap route. The current sparkswap route used takes 3 hops and includes some time for the final actor. Each hop adds 24 hours of lock-up time.
- Taker to Relayer: 24 hours
- Relayer to Maker: 24 hours
- Maker to Relayer: 24 hours
- Relayer to Taker: 24 hours
To understand how this transaction can be trustless, read about Swaps on sparkswap.
In short, it relies on a transaction that will either complete or fail in its entirety - it will not partially complete so long as both parties are acting in their own self-interest. It does not use an intermediary to ensure that both parties are honest, instead it relies on a particular order of operations and cryptographic guarantees to ensure that both parties can be certain of the outcome without trust. And finally it relies on some transaction primitives built into Payment Channel Networks like the Lightning Network that make these transactions both trustless and nearly instant.