Giter Club home page Giter Club logo

cow-dex-solver's People

Contributors

dharmendrakariya avatar fleupold avatar gmonty030 avatar josojo avatar martinquaxd avatar nlordell avatar poolpitako avatar robriks avatar sunce86 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cow-dex-solver's Issues

Fix Flacky Test Due to Lack Of HashMap Ordering Guarantees.

Hashmap makes no guarantees about order which includes not guaranteeing true randomness which means we could loop forever. I'm wondering if you could refactor the input to that function in a way that makes it deterministic.
For example instead of &HashMap<(H160, H160), (U256, U256)> there could be

struct SingleInput {
    token0: H160,
    token1: H160,
    sell0Buy1Amounts: Option<(U256, U256)>,
    sell1Buy0Amounts: Option<(U256, U256)>,
}

(can probably make it nicer)

and the function takes an iterator of these. This should work because the function only ever looks at a pair and the reverse together.

Originally posted by @vkgnosis in #28 (comment)

Runtime Panic in Slippage Computation

There appears to be a runtime panic introduced in the slippage computation:

2022-11-04T12:38:43.557Z ERROR cowdexsolver::tracing_helper: thread 'tokio-runtime-worker' panicked at 'denominator == 0', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/num-rational-0.4.0/src/lib.rs:132:13:
thread 'tokio-runtime-worker' panicked at 'denominator == 0', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/num-rational-0.4.0/src/lib.rs:132:13
stack backtrace:
   0: std::panicking::begin_panic
             at ./rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:616:12
   1: num_rational::Ratio<T>::reduce
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/num-rational-0.4.0/src/lib.rs:132:13
   2: num_rational::Ratio<T>::new
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/num-rational-0.4.0/src/lib.rs:105:9
   3: <num_rational::Ratio<T> as core::ops::arith::Div<T>>::div
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/num-rational-0.4.0/src/lib.rs:739:9
   4: <num_rational::Ratio<T> as core::ops::arith::Div<&T>>::div
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/num-rational-0.4.0/src/lib.rs:666:17
   5: cowdexsolver::slippage::SlippageCalculator::compute_inner
             at ./usr/src/cowdexsolver/src/slippage.rs:108:67
   6: cowdexsolver::slippage::SlippageCalculator::compute
             at ./usr/src/cowdexsolver/src/slippage.rs:78:36
   7: cowdexsolver::slippage::SlippageContext::relative
             at ./usr/src/cowdexsolver/src/slippage.rs:41:12
   8: cowdexsolver::solve::get_swaps_for_left_over_amounts::{{closure}}::{{closure}}::{{closure}}
             at ./usr/src/cowdexsolver/src/solve.rs:394:42
   9: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at ./rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/future/mod.rs:91:19
  10: <futures_util::future::maybe_done::MaybeDone<Fut> as core::future::future::Future>::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.21/src/future/maybe_done.rs:95:38
  11: <futures_util::future::join_all::JoinAll<F> as core::future::future::Future>::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.21/src/future/join_all.rs:143:24
  12: cowdexsolver::solve::get_swaps_for_left_over_amounts::{{closure}}
             at ./usr/src/cowdexsolver/src/solve.rs:407:48
  13: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at ./rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/future/mod.rs:91:19
  14: cowdexsolver::solve::solve::{{closure}}
             at ./usr/src/cowdexsolver/src/solve.rs:131:14
  15: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at ./rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/future/mod.rs:91:19
  16: cowdexsolver::api::solve::get_solve::{{closure}}::{{closure}}
             at ./usr/src/cowdexsolver/src/api/solve.rs:76:66
  17: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at ./rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/future/mod.rs:91:19
  18: <F as futures_core::future::TryFuture>::try_poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.21/src/future.rs:82:9
  19: <warp::filter::and_then::State<T,F> as core::future::future::Future>::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/warp-0.3.2/src/filter/and_then.rs:99:44
  20: <warp::filter::and_then::AndThenFuture<T,F> as core::future::future::Future>::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/warp-0.3.2/src/filter/and_then.rs:74:9
  21: <F as futures_core::future::TryFuture>::try_poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.21/src/future.rs:82:9
  22: <warp::filter::recover::RecoverFuture<T,F> as core::future::future::Future>::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/warp-0.3.2/src/filter/recover.rs:91:65
  23: <F as futures_core::future::TryFuture>::try_poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.21/src/future.rs:82:9
  24: <warp::filters::cors::internal::WrappedFuture<F> as core::future::future::Future>::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/warp-0.3.2/src/filters/cors.rs:578:26
  25: <futures_util::future::either::Either<A,B> as core::future::future::Future>::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.21/src/future/either.rs:90:33
  26: <F as futures_core::future::TryFuture>::try_poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.21/src/future.rs:82:9
  27: <warp::filter::service::FilteredFuture<F> as core::future::future::Future>::poll::{{closure}}
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/warp-0.3.2/src/filter/service.rs:128:40
  28: scoped_tls::ScopedKey<T>::set
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9
  29: warp::route::set
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/warp-0.3.2/src/route.rs:16:5
  30: <warp::filter::service::FilteredFuture<F> as core::future::future::Future>::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/warp-0.3.2/src/filter/service.rs:128:15
  31: <hyper::proto::h1::dispatch::Server<S,hyper::body::body::Body> as hyper::proto::h1::dispatch::Dispatch>::poll_msg
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.19/src/proto/h1/dispatch.rs:491:35
  32: hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_write
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.19/src/proto/h1/dispatch.rs:297:43
  33: hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_loop
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.19/src/proto/h1/dispatch.rs:161:21
  34: hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_inner
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.19/src/proto/h1/dispatch.rs:137:16
  35: hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_catch
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.19/src/proto/h1/dispatch.rs:120:28
  36: <hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T> as core::future::future::Future>::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.19/src/proto/h1/dispatch.rs:424:9
  37: <hyper::server::conn::ProtoServer<T,B,S,E> as core::future::future::Future>::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.19/src/server/conn.rs:952:47
  38: <hyper::server::conn::upgrades::UpgradeableConnection<I,S,E> as core::future::future::Future>::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.19/src/server/conn.rs:1012:30
  39: <hyper::server::server::new_svc::NewSvcTask<I,N,S,E,W> as core::future::future::Future>::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.19/src/server/server.rs:728:36
  40: tokio::runtime::task::core::CoreStage<T>::poll::{{closure}}
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/task/core.rs:165:17
  41: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/loom/std/unsafe_cell.rs:14:9
  42: tokio::runtime::task::core::CoreStage<T>::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/task/core.rs:155:13
  43: tokio::runtime::task::harness::poll_future::{{closure}}
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/task/harness.rs:470:19
  44: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at ./rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panic/unwind_safe.rs:271:9
  45: std::panicking::try::do_call
             at ./rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:492:40
  46: std::panicking::try
             at ./rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:456:19
  47: std::panic::catch_unwind
             at ./rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panic.rs:137:14
  48: tokio::runtime::task::harness::poll_future
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/task/harness.rs:458:18
  49: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/task/harness.rs:104:27
  50: tokio::runtime::task::harness::Harness<T,S>::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/task/harness.rs:57:15
  51: tokio::runtime::task::raw::RawTask::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/task/raw.rs:84:18
  52: tokio::runtime::task::LocalNotified<S>::run
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/task/mod.rs:376:9
  53: tokio::runtime::thread_pool::worker::Context::run_task::{{closure}}
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/thread_pool/worker.rs:458:21
  54: tokio::coop::with_budget::{{closure}}
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/coop.rs:102:9
  55: std::thread::local::LocalKey<T>::try_with
             at ./rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/thread/local.rs:445:16
  56: std::thread::local::LocalKey<T>::with
             at ./rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/thread/local.rs:421:9
  57: tokio::coop::with_budget
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/coop.rs:95:5
  58: tokio::coop::budget
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/coop.rs:72:5
  59: tokio::runtime::thread_pool::worker::Context::run_task
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/thread_pool/worker.rs:434:9
  60: tokio::runtime::thread_pool::worker::Context::run
  61: tokio::runtime::thread_pool::worker::run::{{closure}}
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/thread_pool/worker.rs:386:17
  62: tokio::macros::scoped_tls::ScopedKey<T>::set
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/macros/scoped_tls.rs:61:9
  63: tokio::runtime::thread_pool::worker::run
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/thread_pool/worker.rs:383:5
  64: tokio::runtime::thread_pool::worker::Launch::launch::{{closure}}
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/thread_pool/worker.rs:362:45
  65: <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/blocking/task.rs:42:21
  66: tokio::runtime::task::core::CoreStage<T>::poll::{{closure}}
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/task/core.rs:165:17
  67: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/loom/std/unsafe_cell.rs:14:9
  68: tokio::runtime::task::core::CoreStage<T>::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/task/core.rs:155:13
  69: tokio::runtime::task::harness::poll_future::{{closure}}
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/task/harness.rs:470:19
  70: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at ./rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panic/unwind_safe.rs:271:9
  71: std::panicking::try::do_call
             at ./rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:492:40
  72: std::panicking::try
             at ./rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:456:19
  73: std::panic::catch_unwind
             at ./rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panic.rs:137:14
  74: tokio::runtime::task::harness::poll_future
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/task/harness.rs:458:18
  75: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/task/harness.rs:104:27
  76: tokio::runtime::task::harness::Harness<T,S>::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/task/harness.rs:57:15
  77: tokio::runtime::task::raw::RawTask::poll
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/task/raw.rs:84:18
  78: tokio::runtime::task::UnownedTask<S>::run
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/task/mod.rs:413:9
  79: tokio::runtime::blocking::pool::Task::run
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/blocking/pool.rs:91:9
  80: tokio::runtime::blocking::pool::Inner::run
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/blocking/pool.rs:325:17
  81: tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}
             at ./root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.19.2/src/runtime/blocking/pool.rs:300:13

linker error during build on macos

Hi,

I ran cargo build on my macos and got the following error:

โžœ  cow-dex-solver git:(main) cargo build
   Compiling ethcontract-derive v0.15.3
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "-arch" "x86_64" "/Users/...
...
  = note: ld: reference to symbol (which has not been assigned an address) __ZN4curl4init9INIT_CTOR17h32bbb45c3dd2c85aE in '__ZN4curl4init17h65fffcaa4ea77c83E' from /Users/david/projects/crypto/cow-dex-solver/target/debug/deps/libcurl-4fcdd02a82e2cd5f.rlib(curl-4fcdd02a82e2cd5f.curl.779571c0-cgu.15.rcgu.o) for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)


error: could not compile `ethcontract-derive` due to previous error

Any ideas what's the issue / how to fix?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.