ekmanss / arbiter

A simple price data monitoring tool for uniswap V3 Pools written in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Arbiter (In Progress)

Github Actions

A stand-alone Rust program to events on UniswapV3 pools and...

Motivation:

Arbitrage takes advantage of price discrepancies in the buy and sell prices of different markets for the same assets. Right now, searchers can detect differences in reported prices between markets and execute pure profit1 trades, which we call atomic arbitrage. The environment for arbitrage is competitive, but for less popular token pairs, there is room for new searchers to equilibrate the prices of different markets.

We want to develop a Rust program capable of detecting and executing arbitrage opportunities between exchanges. Our goal is to lower the barrier to entry for searching in hopes that it can help level the playing field for capturing arbitrage.

Features (in development):

TODOs:

  • Library of popular tokens includes symbols, addresses, and decimals.
  • Takes user input of token addresses and finds the corresponding PoolIDs for UniswapV3.
  • Monitors the UniswapV3 pool prices continuously.
  • Allow users to input an Etherscan API key to pull token info from the chain.
  • Integrate with user-selected RPC endpoint.
  • Concurrent pool monitoring for multiple pools.
  • Additional exchanges.
  • Announces when an arbitrage trade with profit exceeding the no-arbitrage bounds + gas cost is found between two exchanges.
  • Executes atomic transactions between pools to capture arbitrage.

Build From Source

First, clone the repository to your local environment so

git clone https://github.com/primitivefinance/arbiter.git
cd arbiter

arbiter takes in three command line arguments. To see the available arguments, run the following:

cargo run -- -h

This will display the help menu

arbiter 0.0.1

USAGE:
    arbiter [FLAGS] [OPTIONS]

FLAGS:
        --api_key    Provide an Etherscan API key if function calls require it (e.g., providing a token that is not in
                     the database).
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
        --fee <fee>          Specifies the basis points for the pool. [1, 5, 30, 100] [default: 5]
        --token0 <token0>    Specifies the first token for a token pair. [default: ETH]
        --token1 <token1>    Specifies the second token for a token pair which will be the numeraire. [default: USDC]

In the above, token0 and token1 will be the token pair used to find the corresponding UniswapV3 pools. Upon running

cargo run

we default to token0=ETH, token1=USDC, and fee=5. arbiter will return results

Uniswap Pool Result: Uniswap Pool Result: 0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640

which is the 5BP pool for the pair ETH/USDC on Uniswap. The program runs and streams transactions (swaps) that update the pool's price like so:

------------New Swap------------
From pool 0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640
Sender: 0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45, Recipient: 0x1019bf2d607cc646a94a194f7a79e0b385065cff
amount_0 -5235133099
amount_1 4335000000000000000
liquidity 23260193077241608585
tick 205351
price "1.208239460504000000000000000000000000000e+3"

If you would like the price to be in terms of ETH rather than USD for a one basis point pool, you can run

cargo run -- --token0 USDC --token1 ETH --fee 30

Which will return the pool address and then log swaps on this pool with the price now denominated in ETH

Uniswap Pool Result: 0xe0554a476a092703abdb3ef35c80e0d76d32939f
------------New Swap------------
From pool 0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640
Sender: 0x1111111254fb6c44bac0bed2854e76f90643097d, Recipient: 0x1111111254fb6c44bac0bed2854e76f90643097d
amount_0 -101468592
amount_1 89212500000000000
liquidity 311910915919265257014
tick 205950
price "8.787733459338501273578338843507650768997e-4"

You may also build the executable with cargo build, which will output a binary in target/

Contributing

If you want to see a specific feature, open an issue! See our Contributing Guidlines

Footnotes

  1. 'Pure profit' refers to the fact that atomic arbitrage does not require arbitrageurs to put any capital at risk other than an upfront cost on building the strategy and gas cost to get their transaction included. This contributes to the lucrative nature of atomic arbitrage when done effectively

About

A simple price data monitoring tool for uniswap V3 Pools written in Rust

License:MIT License


Languages

Language:Rust 78.2%Language:Solidity 21.8%