0xProject / 0x-monorepo

0x protocol monorepo - includes our smart contracts and many developer tools
Other
1.41k stars 467 forks source link

asset-swapper: Fix worst case asset amount calculations. #2615

Closed dorothy-zbornak closed 4 years ago

dorothy-zbornak commented 4 years ago

Description

Worst case asset amount calculations were off by a lot because the fill simulator made the assumption that optimized orders were always sorted. Frequently this would result in worst case buy estimates being better than best case buy estimates. Temporarily sorting the orders before simulating a worst case fill gives us a more realistic lower-bound.

In the Forwarder/Exchange Proxy this manifested as a revert since we were not providing enough input tokens to fill the orders.

Testing instructions

Types of changes

Checklist: