gnosis / dex-services

Off-chain services for the Gnosis Protocol v1.
33 stars 9 forks source link

[Price Estimator] Un-reduceable orderbook due to floating point rounding error #1566

Open nlordell opened 4 years ago

nlordell commented 4 years ago

It is possible to craft orders in such a way that a path in the orderbook graph would end up with an empty flow because of rounding errors. This causes issues when reducing the orderbook as it would find a negative cycle with an empty flow, reduce it (which effectively does nothing since all the deducted amounts would be 0) and then go back to finding the same cycle, essentially looping forever.

The correct long term fix for this is to implement arbitrary precision rational numbers for exchange rate and capacity when finding and filling flows. This is already captured by #1381.

In the mean time to prevent infinite loops in the price estimator we can: