App: DEX - LTC swap mismatches

Created on 1 Feb 2021  ·  20Comments  ·  Source: DeFiCh/app

Preflight Checklist

Issue Details

  • Current DeFi App Version:

    • 2.1.15

  • Previous DeFi App Version:

    • 2.1.14

  • Operating System (OS):

    • Debian 11

Screenshot(s) / screen recording(s) of issue


defi

Actual Behavior

I swapped 990 DFI to LTC.

Looking the transaction
https://mainnet.defichain.io/#/DFI/mainnet/tx/33c74f2c1bc9d33e472d77a3107f746e13ce09150d36c6ac757003a493f5406b
I see:

Amount from 990.55986089
Max price 0 0.01649239

So I think I'll received around 16 LTC, but as you can see in screenshot, I recevied only 4.

Now, tryng to sell them, I view this:

defi2

I think selling 5.75 LTC at 125.67 DFI x 1 LTC I need to receive 722 DFI...why the app i saying 434 ?

Is there something wrong or I didn't understand DEX properly ?

Most helpful comment

@uzyn when I submit the swap after validation in the app ... the amounts I get from the change must be the same as they are shown before confirmation. otherwise I had to get an error!

All 20 comments

there was not enough liqudity in the pool, it cost me some nice DFI's to learn that... -.-

Hi @scegliau , what was the amount the app displayed before you clicked swap?

I didn't save that screenshot so, sadly, I don't know.
But yesterday I tried another transaction and I can give you screenshots.

This is what I see before click swap:

defi3

and this is the transaction seen after:

defi4

Transaction:
https://mainnet.defichain.io/#/DFI/mainnet/tx/0a5246e6dd27513c7175568784103b10a8a5df58a61735ffca6f7b5258aab02c

Technical INFO for the developers to find and kill the bug:

  • Maybe the first reason of the bug is, that the app is missing the real price of LTC ... (because of the missing balance from the TVL at DOGE-DFI and LTC-DFI - see LM-overview app & https://dex.defichain.com/pool )
  • The second one is maybe a wrong max price within an LTC to DFI swap transaction (e.g. the one of @scegliau transaction in the last comment):
    Bildschirmfoto 2021-02-02 um 11 08 21
  • The third is the wrong calculation of the price of the swap - because it is depending on the size of the swap and this moves the converting rate
  • the fourth is, that the committed swap is executed without a error-message at a total different swap-rate than the committed one
  • the fifth is - the bug allows people to steal money from the pool, when the swap-rate is wrong (more than 1% different to market)

Commenting here for a response. I understand that this can be described as 'the nature of a dex' but I lost a sizeable amount of LTC last night, so interested on a response if there is possibly a bug here that could provide a sliver of hope in recovering some of those lost LTC. not holding my breath and taking it as a lesson learned but still interested in the outcome of this thread.

....and same happened to me with DOGE one day before (off course I can give transactionId, but I haven't any screenshot)

@izzycsy please tag this as bug and fix it. I will help you, if you want.

Hi @scegliau @eMDi101 @sloth8871 @gsi2help , It's not an app's bug. The current slippage protection doesn't function so well when it comes to multiple transactions in a block, especially for smaller pools that are just starting to accumulate liquidity. We appreciate your feedbacks and the team is working on an improved slippage protection that is expected to be roll out at the next consensus upgrade targeted for later this month. For now, we urge that you take caution when performing swaps for smaller pools and perform smaller swaps to minimize the effect of the issue.

Thanks @gsi2help for the technical feedback.

hi @izzycsy - your comment is total wrong. it is one of the greatest bugs in the system.

one example (with added balances in USD):
Bildschirmfoto 2021-02-02 um 16 52 33

and the swap-rate at this transactions was totally other

@gsi2help We have traced the issue and It has been fixed. Will link to PR soon. It's a slippage protection on the consensus side when it comes to mulitple swaps ina block.

@uzyn the pre-version 2.1.16 does not fix this issue

For small liquidity pool and yet very high swap activities, the rates are really crazy. Next upgrade will improve the slippage protection better.

@gsi2help it's a blockchain consensus upgrade, not app bug.

@uzyn Both bugs. price calculation in app is wrong and blockchain too

@uzyn when I submit the swap after validation in the app ... the amounts I get from the change must be the same as they are shown before confirmation. otherwise I had to get an error!

@uzyn if it is possible as show in my example screenshot - then some swaps will get more money out of the pool, than they gave in and some swaps do the opposite. both is wrong. in one case the pool looses money, in the other one the people who is swapping.

@uzyn in my example I gave 355 USD to the pool (3 swaps) and get 173 USD back... So I lost 182 USD at this 3 swaps. and I can show you the confirmation screenshots too - before pressing the button swap - I think this is worth for your bug bounty program

@uzyn if it is possible as show in my example screenshot - then some swaps will get more money out of the pool, than they gave in and some swaps do the opposite. both is wrong. in one case the pool looses money, in the other one the people who is swapping.

...I think that if monies loosed are still in pools they could be refoundable...am I wrong ?

Just to understand....no chance to have monies back, right ?

Hi @scegliau , yes I'm sorry for your loss, and thank you for your understanding.

Was this page helpful?
0 / 5 - 0 ratings