Overview
Sample Scenario
Here is the sample interaction scenario between a dApp and Rango API:
The user connects a wallet in dApp and gives the wallet address to dApp
dApp optionally calls
getWalletDetails
endpoint from Rango to get balancesUsers or dApp selects to swap 1 x BSC.BNB to TERRA.UST
dApp calls
getBestRoute
endpoint [withcheckPrerequisite 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
The user clicks on confirm to start the swap.
dApp calls
getBestRoute
endpoint [withcheckPrerequisite flag = true
] from Rango. It's a bit slower since it checks balances and fees that are required to perform the swapIf validation fails in the response, dApp shows an error to the user and flow breaks.
If validation is true, repeat steps 9 to 14 for each swap in the
getBestRoute
response.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.dApp calls
checkApproval
endpoint every 5 seconds until the result is approveddApp calls
createTransaction
again to get the real transaction this timedApp sends the tx to the wallet for signing
dApp calls
checkTxStatus
endpoint every 5 seconds to see if the step is successful or failed.If the step is successful dApps repeats the process for the next step
If the step fails, dApp optionally calls
reportTx
endpoint to report the failure
Last updated