tdex-network / tdex-app

📱 Mobile app for making trades on TDEX
11 stars 10 forks source link

Fix order selection #596

Closed Janaka-Steph closed 1 year ago

Janaka-Steph commented 1 year ago

The main change here is that if (bestOrdersV1.length === 0 && bestOrdersV2.length === 0) we throw. In that case we now return allPossibleOrdersV2[0] ?? allPossibleOrdersV1[0].

altafan commented 1 year ago

This is indeed the right call, but I don't think this solves the problem we discussed offline still.

The real problem is that the discoverBestOrder function returns a single provider, while it maybe should return a list of them. This function could be used to order the providers by price so that we can loop over them and try making the trade requested by the user. Only if we fail to make the trade against all providers we should return an error to the user.