XY Finance


At the hub of the swapping process is Swapper; this swap communicator/processor is deployed on every supported chain to interact with users and XY Protocol.
Swapper is effectively deployed on every blockchain supported by XY Protocol. XY Protocol stores users' assets and relocates them to Swapper as liquidity to facilitate cross-chain swaps.
Imagine XY Protocol putting a large sum of stable crypto-assets into Swapper on ETH, BNB, and Polygon chains, one can swap their funds among these three chains through Swapper freely without having to experience the lengthy bridging process. Instead, with only two transactions conducted on sourceChain and targetChain, one gets the assets they desire (yes there are two transactions from the user's point of view, but note only one on the source chain truly requires them to operate manually).
As one of the major smart contracts administered by XY Protocol, Swapper is not only used to transfer assets from chain to chain in a split second like we just mentioned but it is also employed to manage assets. Swapper consists of three core functionalities: one is user-related, and the other two are to do with XY Protocol.
Major components of Swapper
To users, Swapper is the very starting point for a cross-chain swapping process. Users trigger the function swap to transfer their assets onto Swapper; whichever asset is being transferred there, it will be swapped for stablecoins (i.e. USDT, USDC, etc.) via the internal utility DexAggregator immediately.
With regard to which stablecoin will be employed to proceed with the following bridging steps, well, it largely depends on the liquidity balance in our Y Pool. In this phase of swapping, the assets (the amount equivalent to the quoted prices) are securely stored at tempWalletOfUser pending XY Protocol finalizing or closing the transaction on the target chain (Chain B).
As stated above, to XY Protocol, however, Swapper also plays a large part in the completion of a cross-chain swap that is activated by users. To achieve this, XY Protocol will need to first store the assets onto walletOfXYProtocol to make good use of the assets on each chain (Chain A & B) efficiently.
Once users have "placed an order" and then initiated a swap from the source chain, the public function closeSwap of Swapper on the target chain will thus be set in motion and then the deal will be closed accordingly.
XY Protocol takes over the stable crypto-assets from users according to their transactions (quoted prices) on the source chain. closeSwap is then triggered and the assets are transferred via the route (incurring the least gas fees and hence the best price) according to the quote provided by DexAggregator. Shortly afterward Swapper will transfer either the target tokens or stablecoins back to users depending on whether or not there are enough tokens to trade.
Whenever a swap is closed on the target chain, XY Protocol will bring the proof of consensus back to Swapper on the source chain to claim the stable crypto-assets stored in tempWalletOfUser by triggering the function claim.
Last modified 10mo ago