defichain-wallet icon indicating copy to clipboard operation
defichain-wallet copied to clipboard

Swap Token: negative amount happen we try to add more than the current pooled token amount into the pool

Open fullstackninja864 opened this issue 3 years ago • 3 comments

What happened:

Negative amount happen if we try to add more than the current pooled token amount into the pool. E.g.: current pooled DUSD-DFI has 10k DUSD, if we try to swap 10001 DUSD, the resulting DFI will be negative.

What you expected to happen:

Solution:

  1. Do the swap exactly as how defichain do (batch by batch)
  2. Quick solution slippage = 1 - Math.min(amountToSwap / tokenAReserve, 0.5) (cap the slippage) and put a disclaimer, slippage is estimated and not applicable for extremely huge swap relative to reserve

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

fullstackninja864 avatar Jan 14 '22 09:01 fullstackninja864

@fullstackninja864: Thanks for opening an issue, it is currently awaiting triage.

The triage/accepted label can be added by foundation members by writing /triage accepted in a comment.

Details

I am a bot created to help the DeFiCh developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the DeFiCh/oss-governance-bot repository.

defichain-bot avatar Jan 14 '22 09:01 defichain-bot

@fullstackninja864: There are no 'area' labels on this issue. Adding an appropriate label will greatly expedite the process for us. You can add as many area as you see fit. If you are unsure what to do you can ignore this!

You can add area labels by leaving a /area comment.

Details

I am a bot created to help the DeFiCh developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the DeFiCh/oss-governance-bot repository.

defichain-bot avatar Jan 14 '22 09:01 defichain-bot

Related to #1897

kyleleow avatar Jun 16 '22 06:06 kyleleow