XY Finance
Comment on page

Bridge : yBridge


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 are still two TXs pertinent to whether users' funds could be transferred onto the target chain with success. Last but not least, yBridge will carry out another TX with regard to pool so as to complete the whole swap circle as illustrated in TX3 below.
  • TX1: Users send assets (quoted price) via the yBridge on Chain A (the source chain DEX).
  • TX2: yBridge (our robot) helps swap on Chain B (the target chain DEX) and transfers tokens back to users.
  • TX3: yBridge will help claim the assets that are temporarily stored on the source chain yBridge during the swaps back and return them to pool. This TX will be conducted using a proof of consensus, and by so doing the whole swap can be closed, good and proper.


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.
A simple flow chart of a swap

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.
➂ A node on ETH run by yBridge will detect TX1 and check if there'a any opportunity of arbitrage at play. If there is, 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.
➃ ➄ 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.
➅ ➆ After transferring either USDT or CAKE to Bob, yBridge could claim 30000 USDT (ETH) by submitting another TX to yBridge with PoW, our consensus algorithm.
Not that if yBridge lacks sufficient funds to underpin the TX,yBridgeand/or Validator Set will arrive at a consensus that either of them is obliged to file a new TX where the equivalent amount of "30000 minus gas fees" USDT(ETH) will be returned to Bob.