Closed Janaka-Steph closed 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.
The main change here is that
if (bestOrdersV1.length === 0 && bestOrdersV2.length === 0)
we throw. In that case we now returnallPossibleOrdersV2[0] ?? allPossibleOrdersV1[0]
.