Sample Scenario

Here is the sample interaction scenario between a dApp and Rango API:

  1. The user connects a wallet in dApp and gives the wallet address to dApp

  2. dApp optionally calls getWalletDetails endpoint from Rango to get balances

  3. Users or dApp selects to swap 1 x BSC.BNB to TERRA.UST

  4. dApp calls getBestRoute endpoint [with checkPrerequisite flag = false] from Rango. Rango gives a path of:

    • Step 1: Swap BSC.BNB to BSC.UST via 1inch

    • Step 2: Swap BSC.UST to TERRA.UST via 1inch

  5. The user clicks on confirm to start the swap.

  6. dApp calls getBestRoute endpoint [with checkPrerequisite flag = true] from Rango. It's a bit slower since it checks balances and fees that are required to perform the swap

  7. If validation fails in the response, dApp shows an error to the user and flow breaks.

  8. If validation is true, repeat steps 9 to 14 for each swap in the getBestRoute response.

  9. dApp calls createTransaction to get a transaction, if the transaction is an approval tx, determined by a flag in response, dApp sends it to the wallet for signing.

  10. dApp calls checkApproval endpoint every 5 seconds until the result is approved

  11. dApp calls createTransaction again to get the real transaction this time

  12. dApp sends the tx to the wallet for signing

  13. dApp calls checkTxStatus endpoint every 5 seconds to see if the step is successful or failed.

  14. If the step is successful dApps repeats the process for the next step

  15. If the step fails, dApp optionally calls reportTx endpoint to report the failure

Last updated