Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

fix: isQuoteSellAmountBelowMinimum #1235

Merged
merged 1 commit into from
Apr 10, 2023
Merged

Conversation

0xApotheosis
Copy link
Contributor

Existing logic incorrectly assumes that the sellAmountCryptoBaseUnit is the amount not including fees.

In reality, CoW Swap subtracts any trading fees from the sellAmountCryptoBaseUnit value in the returned response, so we need to add them back on to get the true "sell amount" of the sell asset.

This is causing the UI to show that the "sell amount is lower than the fee" when the sell amount is above the minimum by less than the fee amount.

To test, attempt to use CoW swap to trade, say, $21 - this should now work, whereas previously is would not until you sold $20 plus the fee amount.

Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested against develop web with current lib version, both with the TradeRates flag on and off

With TradeRates on and manual CoW selection:

This lib diff

image

image

develop's lib, note the "Insufficient sell amount" which is indeed incorrect

image

image

With TradeRates off and monkey patched ZrxSwapperEthereum off in web

This lib diff

image

image

develops lib

image

image

I wasn't able to reproduce the sad behavior with the TradeRates flag off, though turning the TradeRates flag on confirmed adding back the CoW fees (i.e the fees taken from the sell asset and effectively occurring on the buy asset) for the minimum is now correct.

@gomesalexandre gomesalexandre merged commit ac5f2c6 into main Apr 10, 2023
@gomesalexandre gomesalexandre deleted the cowswap-min-amount-fix branch April 10, 2023 07:59
shapeshift-ci-bot pushed a commit that referenced this pull request Apr 10, 2023
# [@shapeshiftoss/swapper-v17.6.3](https://github.com/shapeshift/lib/compare/@shapeshiftoss/swapper-v17.6.2...@shapeshiftoss/swapper-v17.6.3) (2023-04-10)

### Bug Fixes

* isQuoteSellAmountBelowMinimum ([#1235](#1235)) ([ac5f2c6](ac5f2c6))
@shapeshift-ci-bot
Copy link
Member

🎉 This PR is included in version @shapeshiftoss/swapper-v17.6.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

gomesalexandre added a commit to shapeshift/web that referenced this pull request Apr 10, 2023
Diff manually re-applied from shapeshift/lib#1235 after monorail
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants