0xProject / 0x-launch-kit-frontend

Apache License 2.0
112 stars 207 forks source link

Wrong amount of wETH needed for a purchase #433

Closed fvictorio closed 5 years ago

fvictorio commented 5 years ago

When a user buys on market and it doesn't have enough ETH wrapped, the computation of the needed amount is assuming a 1 price.

To fix this, we need to know how the purchase is going to be executed (which orders will be filled). We already have this information in startBuySellMarketSteps, since we use this to check if the entered amount can be bought. The quick fix here is to use that information to compute the effective price (weighted average of the prices of the orders that will be filled) and pass that down to createBuySellMarketSteps.