XY Finance

Please kindly note that we have updated the latest API version v1 now. The Endpoints of v0 will be deprecated as of June.



How to integrate X Swap API into your Dapp?

(1) The first thing to do is easy-peasy: Make sure the target chain that users choose is supported by XY Finance.
(2) X Swap API fetches the feasible routes and returns the best quotations.
By the time users have selected the tokens on both the source and the target chains on our interface, we will comb through all the possible routes between the two chains and fetch the most efficient feasible routes and return the best quote. The data acquired will be displayed to users for reference.
(2.25) Make sure users allow X Swap to access/spend the token they enter on the source chain.
Once users accept the route for the transaction to go through, Smart Contracts will need the approval to access/spend users’ tokens, while users will need to check if the amount of tokens on the source chain remains the same as it was. Suppose there are changes made to the amount after the quote has been returned, another round of quote elicitation will result.
(2.50) If the allowance is insufficient, approve the contracts first to gain access to more allowance (approval) and then proceed with the token spend.
(2.75) Send the approval transaction via web3 technologies if needs be.
(3) X Swap API returns the swap/transaction data for users’ reference.
Once the contract has users’ approval to access/spend their token on the source chain, users can request X Swap the settled quote, and next a feasible route will be fetched.
(4) X Swap API executes the swap transaction on behalf of users via web3 technologies.
(5) Check if the request for the cross-chain swap has gone through via the polling API.