# Bridge : yBridge

### Mechanism

There will be at most three transactions involved in the `circle` of the swapping process. Under normal circumstances and as previously noted, users will only have to engage in ONE transaction (hereinafter abbreviated as "*TX*") for the swap to get closed, which is **TX1**. However, it's worth noting that there is still one TXs pertinent to whether users' funds could be transferred onto the target chain with success.

* **TX1**: Users send assets (quoted price) via the yBridge on Chain A (the source chain DEX).
* **TX2**: yBridge (our executor) helps swap on Chain B (the target chain DEX) and transfers tokens back to users. This TX will be conducted using a proof of [consensus](broken://pages/-Mf2CmT5CnIATIVo90EA), and by so doing the whole swap can be closed, good and proper.

### Example

Suppose Bob would like to swap 1 **`wBTC on ETH`** for some **`CAKE on BSC`**. With the assistance of yBridge, Bob simply needs to give us permission to access their assets in his wallet (i.e. TX 1 as  ➀ below), and the rest of the swap process will thenceforth be well taken care of. From his viewpoint, he will be able to receive his desired CAKE on BSC with only two TXs that are pertinent to his swap (➀ & ➄). The next section will give the breakdown of the full swapping process.&#x20;

![ A simple flow chart of a swap](/files/-Mgsi4Vw00fColmmlcpu)

### Swap Breakdown

Please refer to the flow chart above for reference.

➀ Firstly, Bob will receive a quotation by interacting with our APIs, which have been instructed to search for and single out the best route for Bob. For instance, `1 wBTC (ETH)` could be swapped for 3000 CAKE (BNB) in return and with a **1%** slippage tolerance. If Bob accepts the quoted price, he can file a TX request, namely **TX1**, by sending `1 wBTC` to yBridge

➁ Our **yBridge** on Ethereum will trade `1 wBTC` on Chain A (Dex1) for the best offer **30000 USDT**.

➂ yBridge will charge some fees, say **20 USDT**, and then submits a transaction request to swap **29980** **USDT** to yBridge for `CAKE on BNB`. Should you wish to learn more about how the fees are calculated, feel free to check the section attached below.

{% content-ref url="/pages/R6ZNeJGabWH2sUpAkY3H" %}
[yBridge Fee Information](/fee-structure/ybridge-fee-information.md)
{% endcontent-ref %}

➃ ➄ yBridge on BNB will swap USDT for CAKE via DEXs such as *Pancake*. Once successfully traded, CAKE will be transferred to Bob right after. However, if, unfortunately, the price of `CAKE on BNB` suddenly fluctuates following **TX1** and a trading failure results, which means the swap fails to swap **2970** **CAKE** (at least) to Bob, then yBridge will instead transfer **29980 USDT** (BSC) from yBridge to Mr. Bob, who still gets his assets back, safe and sound.

{% hint style="info" %}
If yBridge is unable to successfully complete the transaction on the destination chain due to force majeure, yBridge and/or the Validator Set will reach a consensus that one of them is required to initiate a new transaction in which the equivalent amount of "30000 minus gas fees" USDT (ETH) will be returned to Bob.
{% endhint %}


---

# 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://docs.xy.finance/products/y-pool.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.
