Slippage in transaction examples
Last updated
Last updated
Imagine you are going to swap 1 TON to PX (NotPixel) tokens. PX/TON pair at the moment of writing was quite highly volatile and actively traded by many of DeDust users. But before we start let's take a brief look at wallet's tokens balances in the Portfolio.
Now go to the Swap page, choose assets and look at the present exchange rate.
As only you enter the amount, the potential result of a swap shows you'll get 25.10708801 PX for 1 TON at a price 0.03982939 TON for 1 PX token. The default slippage is 1%. The minimum amount you would get is ≈24.85601713 PX. Let's go to settings and tune the slippage.
We'll set the slippage to 0.1% to better understand how it works. Tap on the 'Custom %' field and type in the value.
Then press 'Save' to apply your new slippage settings.
Within a minute the price has changed. Now the expected swap result is 25.090239048 PX for 1 TON and at a price 0.039856137 TON for 1 PX. With the slippage now set to 0.1%, the minimum amount you will get is . Even despite that the price of PX moved higher, and the swap estimation (≈25.0902 PX) now gives you potentially compared to previous market conditions (≈25.1071 PX), due to now lower slippage tollerance set, if the price suddenly goes higher, you'll all the same get more PX tokens , than you could get with settings. And now if the price suddenly , then you'll just get your TON back, spending only some fraction of TON to cover the network fee.
To easier monitor the rapid price movements you can also open the token's price chart. Let's use DEX Screener's charts for this case. Just copy the PX (see 'About the coin' to learn how to find it), enter it into the search field on DEX Screener and find the relevant from DeDust.
Press on the 'Chart' in the bottom of the page.
On PX/USD default chart you can see that PX's price is a bit volatile, as during the last three hours the price jumped from ~$0.165 to ~$0.21 (+27.3%) and then also moved half of this path down. Let's set the chart's timeframe to 1 min to better see all the latest price movements.
Now swipe to the right on the chart pannel to switch it to instead of PX/USD.
While we were adjusting the charts, the price again has changed, and now in inverse direction and more substantially. Within just several seconds the price moves down giving you potentially already 25.323312939 PX for 1 TON instead of roughly 25.0902 PX that was proposed a moment before. Check again the available TON balance and the amount in 'Min.receive', and press 'Swap'.
While proceeding to the swap confirmation screen the price falls even more down resulting in almost 25.3624 PX for 1 TON at a price of 0.039428466 TON for 1 PX token. Minimum amount to receive with the set 0.1% slippage tollerance is 25.3370 PX tokens. Exactly these are the conditions at which your swap will be executed (or not). Confirm the swap at DeDust.
Now sign the transaction in your wallet. Additional mount of 0.15 TON is also temporarily withheld from your balance for the Network fee to process your transaction.
Return to DeDust and wait for the transaction to be processed in the blockchain.
Update the page and first check the swap results 👇 As you see, the balance of PX has changed, meaning that this 1 TON -> PX swap was successful. Let's briefly look at the details:
After the swap processing was completed your TON balance changed from 23.93559519 to 22.90104615. So the total amount of TON spent for this swap equals 1.03454904 TON. This amount consists of itself to PX token and the rest 0.03454904 TON was utilized to cover the blockchain fee (from that extra amount of 0.15 TON ).
The amount of PX token received after the swap equals 25.33997997 PX , which is lower than the estimated and expected 25.3624 PX shown at the Step 13, but anyway higher than the specified in .
After we exclude the amount 0.0025 TON of trading fee, we can calculate also the exact rate at which the PX token amount was in fact bought: (1 - 0.0025) / 25.33997997 ≈ 0.039364671 TON for 1 PX token.
Now let's look also at the new market conditions on the same screen for another similar swap.
Estimated amount of tokens to receive after the swap is 25.074491776 PX. The exchange rate is 0.039881167 TON for 1 PX token. 'Min. receive' ≈ 25.04941728 PX. Press 'Swap' to proceed.
Meanwhile go to see the price chart. You now see the confirmation that the price of 1 PX at the moment of previous swap moved first to the level of 0.03943 and then in a few minutes has grown to 0.03989 TON, what is shown on DeDust as the new market price for the swap.
Go back to DeDust.io and check again the final conditions. They have changed again. Estimated is ≈25.0252 PX. The new price is 0.039959762 TON for 1 PX. 'Min. receive' ≈ 25.00014867 PX. Confirm the swap.
Go to the wallet. Check TON amount, including 0.15 TON 'gas' expenses. Sign the transaction.
Return back to DeDust and wait for the transaction to be processed in the blockchain. The wallet balances remain yet unchanged. Update the page in a minute or two.
Meanwhile go to see the price chart. You see that the price of 1 PX in a couple of last minutes has grown more and even surpassed 0.04 level, and at the moment equals to 0.04005 TON. While the confirmed exchange rate at Step 18 was ≈0.03996 TON.
Go back to DeDust.io and update the page. In a minute the balance of TON has changed, but much less than should be enough to execute the swap. And the balance of PX remained the same as before the swap. This is a sign that the swap was not fulfilled.
Go also to the Portfolio to check that the tokens balances left unchanged here too. Due to a high trading activity the price was rapidly changing, and right at the time you confirmed the swap in your wallet, the price several times moved up, resulting in >0.2% growth: (0.04005 - 0.03996) / 0.03996 x 100% = 0.00009 / 0.03996 x 100% ≈ 0.22523%. Considering that your slippage settings allow only 0.1% price change, your TON -> PX swap was canceled because of the price slippage. Here you can see an example of the 1 TON -> PX swap transaction when the slippage occurs: 1 TON -> TON. Let's also look at the details:
TON balance before the swap was 22.90104615. Balance after is .
Amount of 1 TON for the swap to PX token wasn't used and is back to wallet.
0.15 TON amount, from your wallet ballance, was partially utilized for the transaction processing . In this case the amount of was consumed by the blockchain, and the rest 0.1328 TON is returned to the wallet.
Go to see again the price chart. As you see the chart candle right a minute after the swap confirmation (21:29/21:30 UTC) was closed/opened right at a level of 0.04005 TON, which didn't satisfy the swap conditions confirmed by you according to your slippage settings.
To see the transaction status and details go to your wallet app, open the recent transactions and tap on the one you need.
Then press on 'Information' icon of the transaction details in your wallet app and see the transaction record details in the blockchain explorer. Exit code '304' in transaction details also will point to the slippage reason of your failed transaction.