# Swap lifecycle

From the creation up to the completion step the swap lifecycle goes as follows:&#x20;

<figure><img src="/files/CZkZefqPW17e1VS7500p" alt=""><figcaption><p>Swap Lifecycle</p></figcaption></figure>

### User transfer pending (`user_transfer_pending)`

Whenever the swap is created, either programmatically or from the Layerswap UI, the swap has  `user_transfer_pending` status. At this stage, Layerswap is awaiting the incoming transaction to the deposit address in the source network to match it with the corresponding swap. Users have the option to cancel the swap.

### Cancelled (`cancelled)`

If the user decides to cancel the swap, the swap status will be changed to cancelled. The swap can still be retrieved for historical purposes, however, no incoming transaction will be matched against the swap.&#x20;

### Expired (`expired`)

If the user does not cancel the swap and also does not initiate the transaction in the source network within `4 days`, the Swap status will be changed to expired.

### Layerswap Transfer Pending (`ls_transfer_pending)`

After the user has initiated the transfer to the deposit address in the source network, Layerswap will monitor the blockchain network to verify that a transaction has been received. After receiving the transaction and matching it with the corresponding swap, Layerswap will create an Input transaction object, which will describe the transaction sent by the user and connect it with the corresponding swap. The swap status will be changed to `ls_transfer_pending`.

### Completed (`completed)`

After receiving the transaction and setting the swap status to `ls_transfer_pending`, Layerswap will initiate the outgoing transaction to the user-specified destination address in the destination network and the swap status will be changed to `completed`.

### Failed (`failed)`

If there is an issue with Layerswap and the outgoing transaction to the user-specified destination address could not be initiated, the swap status will be changed to failed.<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.layerswap.io/api/api-integration/swap-lifecycle.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
