Layerswap V8 Atomic Bridging protocol’s specification.
This document specifies the Layerswap V8 Atomic Bridging protocol, a permissionless and trustless cross-chain asset transfer system based on improved Hashed Timelock Contracts (PreHTLCs). The protocol aims to facilitate seamless asset movement across multiple blockchain networks without relying on third parties or oracles.
Presents a series of diagrams illustrating different transaction flows within the protocol, covering both standard scenarios and edge cases.
Visualizes the typical sequence of actions in a successful atomic swap transaction using the protocol.
sequenceDiagram
participant P1 as Party 1
participant SC as Source Chain
participant P2 as Party 2
participant DC as Destination Chain
P1->>SC: commit()
SC-->>P2: TokenCommitted
P2->>DC: lock()
DC-->>P1: TokenLocked
P1->>SC: lockCommitment()
SC-->>P2: TokenLocked
P2->>DC: redeem()
DC-->>P1: TokenRedeemed
P2->>SC: redeem()
SC-->>P2: TokenRedeemed
When transferring funds from a source chain to a destination chain isn't possible due to a lack of liquidity providers (LPs) directly linking the two, the swap is completed using a multi-hop approach (with chain length $n$). In this setup, the user initially commits funds on the source chain to the first LP. Each LP calls commit
so committing funds for the next LP in the sequence, with the final LP on the destination chain calls lock
, locking the funds with a hashlock
and the longest timelock
, set to $T + 2^{n-1}\Delta$ .
Subsequently, each LP from the second-to-last in the chain back to the source performs the addLock
function with the same hashlock
as used on the destination chain, but with progressively shorter timelock
s—starting from $T + 2^{0}\Delta$ for the second-to-last LP. This process continues recursively, with each LP adding a lock using the hashlock
and timelock
specific to its position in the chain.
Finally, the user on the source chain calls addLock
with the hashlock
and timelock
$T+2^{n-2}\Delta$. At this point, all LPs have locked funds with both a hashlock
and timelock
.
When the LP on the destination chain calls redeem
, revealing the secret, he transfers the user’s funds and redeems the locked funds for himself. This secret revelation allows each preceding LP, one by one, to redeem
their funds back through the chain, completing the multi-hop swap.
sequenceDiagram
participant P1 as Party 1
participant SC as Source Chain
participant P2 as Party 2
participant IC as Intermediary Chain
participant P3 as Party 3
participant DC as Destination Chain
P1->>SC: commit()
SC-->>P2: TokenCommitted
P2->>IC: commit()
IC-->>P3: TokenCommitted
P3->>DC: lock()
DC-->>P1: TokenLocked
P1->>SC: lockCommitment()
DC-->>P2: TokenLocked
P2->>IC: lockCommitment()
IC-->>P3: TokenLocked
P3->>DC: redeem()
DC-->P1: TokenRedeemed
P3->>IC: redeem()
IC-->>P2: TokenRedeemed
P2->>SC: redeem()
Explores potential failure scenarios and how the protocol handles them to ensure fund safety and transaction integrity.