GithubHelp home page GithubHelp logo

arbitrageur's People

Contributors

dalechyn avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

arbitrageur's Issues

Arbitrageur Optimizations

100% of the code written in smart contract was written purely in order to make it work.

After #6 is done, a huge optimization is needed.

Integrate convict

Convict should take:

  1. Base Token address
  2. First Pool Type (V2|V3)
  3. Second Pool Type (V2|V3)
  4. Fees of first pool | second pool (numerator, denominator)

Classes Refactor

Fetcher

The Fetcher should be only aware of fetching pools and should not balance them in any way.

Balancer

  • p{1,2} notations should be renamed to from and to
  • DEXType should be stored in the SupportedPoolWithContract, also think of renaming it as well
  • Direction selection and pools selection should take place in Balancer constructor
  • BalanceResult->BalancerResult

Main

Fetcher and Balancer creation should take place in the main function.

GraphQL DEXes connection

We need to find the GraphQL interfaces to scan the tokens across different swaps.

It's crucial to have all GraphQL statistics for all available DEXes for arbitrage since massive liquidity change can start on any of those.

The Scaling Problem

Currently, there is no logic to jump through DEXes to find profitable opportunities.

https://github.com/h0tw4t3r/arb/blob/b36b6fba64a6acb3b8b686a1fd4357f7fe7c504f/src/fetcher/index.ts#L29
https://github.com/h0tw4t3r/arb/blob/b36b6fba64a6acb3b8b686a1fd4357f7fe7c504f/src/fetcher/index.ts#L36-L45

Hence, some big infrastructure choices are needed to be discussed.

We have several ways to manage the search process.

Option 1: Scale the provider

We can take the power of ethProvider.on('block', <handler>) in order to hook a very large amount of handlers that is equal to DEX_COUNT * TOKENS_COUNT.

As of now, we added 3 DEXes and 6 tokens which would already spawn and would result in 18 block listeners.

Knowing the nature of Event Loop, the more listeners we would have, the more the overall process will slow down. A slight reminder we have around 10-12 seconds to push the data until a new block is produced.

From what I remember, there are around 5-6 DEXes which we can easily connect (as they are UniswapV2 clones), and considering we would have #3 implemented, Just with 1000 tokens to be observed (which is a super-small amount), we would have around 5k-6k listeners on a single provider. Such an amount could flood the Event Loop making it slower than the next option.

Option 2: Scale the nodes, not the code

We can have multiple nodes of the bot running on the same machine, scaled by workers basically.

It will ease the load on every worker's Event Loop but could overload the RPC. Chances of using Alchemy are decaying as we go deeper.

Option 3: Use SaaS to deploy a worker on-demand with a single pair to be observed across all DEXes

A mix of Option 1 and Option 2. If that would be possible with linking to an ETH node, fast enough that would be a self-balancing solution, considered of #3 with automatically token addition when certain liquidity in USD has reached, and token deletion.

Farm the best method names

Just as #8, method names also need optimization.

The more leading zeroes we have - the more gas-efficient the call is.

Basically, we can even write a small tool, or find one. Just small mining over keccak256 with salt in the method name is needed to find the best.

And if we match the ABI, we can even use https://www.4byte.directory

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.