angeris / cfmm-routing-code

Convex optimization for fun and profit.
253 stars 47 forks source link

Solver fails with large range of values (real world reserve sizes) #5

Open Granger7 opened 2 years ago

Granger7 commented 2 years ago

When attempting to apply the code to real reserve sizes it has become apparent that the distribution of these values presents a significant problem for the underlying numerical solver, namely that the values tend to deviate by several orders of magnitude and thus cannot be normalised by an overall factor to produce a set of O(1) values. This is causing the solver to fail, although it works very well for the example numbers in the code files.

Has the code been used / tested with real world reserve values over a sizable selection of markets or is it considered more of a theoretical / reference implementation?

Is there a recommended normalisation to be used when using real reserve values that may deviate by many orders of magnitude?

Many thanks

dzmitry-lahoda commented 9 months ago

As I understand there are 2 answers. First is to use their julia code. Which supposed to work.

dzmitry-lahoda commented 9 months ago

Second, try other engine. Afaik default was ECOS, which seems not great. I think of SCIP(compiled with GMP/Boost MP), but for prove try proprietary engine.

We got same error, I thought it was our modification so, until I got there.

dzmitry-lahoda commented 9 months ago

Also option is to scale down assets against USD or to smallerrange of floats (each assets to its reserves).

dzmitry-lahoda commented 9 months ago

also can try tune tolerances.

dzmitry-lahoda commented 9 months ago

some failure exists on julia too https://github.com/bcc-research/CFMMRouter.jl/issues/12

dzmitry-lahoda commented 8 months ago

works for me with this https://github.com/angeris/cfmm-routing-code/pull/9

liewmanchoi commented 19 hours ago

@dzmitry-lahoda Hello, Sir. I have raised an issue Numerical Stability Challenges in Uniswap V3 and Curve Pools on the numeric scale problem. Looking for your kind reply.