aeternity / dex-ui

Superhero DEX - the official UI for the first automated market maker (AMM) on æternity.
https://dex.superhero.com
ISC License
6 stars 4 forks source link

What is the minimum output amount? #482

Closed brainiacfive closed 1 year ago

brainiacfive commented 2 years ago

What happened?

I get an error

AedexV2Router: INSUFFICIENT_OUTPUT_AMOUNT

and the swap reverts.

See

https://explorer.aeternity.io/transactions/th_9sQK7YqxVE8pd7fQBVU4tHFQQE7BHSjg5M1vviSJyrJFVSAKf

How can we reproduce it?

  1. create a token
  2. build a pool vs AE
  3. swap

Which device did this issue occur on?

Desktop

What browsers are you seeing the problem on?

Firefox

Anything else you want us to know?

No response

bogdan-manole commented 2 years ago

This happens when you try to exchange too much amount in relation to how much liquidity is in the pool.

I've just bought 0.00001 of your T2X token.

in the pool is ~100 AE vs ~100 T2X ( if I'm right)

So try to make swaps with lower amounts, and tell us if you have the same result

image
brainiacfive commented 2 years ago

Thank you! Can you share what the relationship / formula is?

bogdan-manole commented 2 years ago

It's also directly related to your slippage, so If you want to succeed, you can increase the slippage, but it will not be to your advantage.

For simpler usage, please monitor always the price impact shown in the swap confirmation window. The bigger the price impact is fewer tokens you will receive

Regularly I'm doing swaps with price impact < 1%.

Screenshot 2022-09-22 at 14 37 09

If you want to read an article on how the price impact relates to the exchange rate, here is a good example https://dailydefi.org/articles/price-impact-and-how-to-calculate/

kenodressel commented 2 years ago

@bogdan-manole thx for answering. Maybe we should consider this as a hint that the error UX might be not sufficient. I will have a look at the error messages and try to improve them a bit.

kenodressel commented 1 year ago

@bogdan-manole Check if the error mapping works as intended for this error.

bogdan-manole commented 1 year ago

After conducting some tests, I can confirm that in the DEX-UI, error codes are correctly mapped to their respective messages. The AedexV2Router: INSUFFICIENT_OUTPUT_AMOUNT error code can only be found in the transaction details on the explorer.

The message indicates that the amount of the intended swap (minus slippage%) is greater than the actual swapped amount.

Image

kenodressel commented 1 year ago

Lets overwrite the error message in the dex