Giter VIP home page Giter VIP logo

uniswap-sushiswap-arbitrage's Introduction

uniswap-sushiswap-arbitrage

Smart contract for performing arbitrage between Uniswap and Sushiswap

Features:

The smart contract SimpleArbitrage alows a user to deposit WETH and make an arbitrage between the 2 exchanges and ensures that the operation is always profitable by checking that the price difference is always higher than the payed fees

Usage:

Installation & Setup:

  1. Installing Brownie: Brownie is a python framework for smart contracts development,testing and deployments. It's quit like HardHat but it uses python for writing test and deployements scripts instead of javascript. Here is a simple way to install brownie.

     pip install --user pipx
     pipx ensurepath
     # restart your terminal
     pipx install eth-brownie
    

    Or if you can't get pipx to work, via pip (it's recommended to use pipx)

    pip install eth-brownie
    

    Install ganache-cli:

     npm install -g ganache-cli
  2. Clone the repo:

    git clone https://github.com/kaymen99/uniswap-sushiswap-arbitrage.git
    cd uniswap-sushiswap-arbitrage
  3. Set your environment variables:

    To be able to deploy to real testnets you need to add your PRIVATE_KEY (You can find your PRIVATE_KEY from your ethereum wallet like metamask) and the infura project Id (just create an infura account it's free) to the .env file:

    PRIVATE_KEY=<PRIVATE_KEY>
    WEB3_INFURA_PROJECT_ID=<< YOUR INFURA PROJECT ID >>
    

How to run:

To start an arbitrage on the mainnet fork (for testing purposes only, you can also use the kovan testnet) you just need to run the command :

brownie run scripts/arbitrage.py --network=mainnet-fork

Testing:

The tests for the smart contract can be found in the tests folder

You can run all the tests by :

brownie test

Or you can test each function individualy:

brownie test -k <function name>

uniswap-sushiswap-arbitrage's People

Contributors

kaymen99 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

uniswap-sushiswap-arbitrage's Issues

VirtualMachineError: revert: Arbitrage not profitable

Hi!

I'm having the following error:

Transaction sent: 0x1c1d48dec4082b1f46b5a7b88adf3fac9105229389df25cb9f521d36217c27c3
Gas price: 0.0 gwei Gas limit: 12000000 Nonce: 6
SimpleArbitrage.makeArbitrage confirmed (Arbitrage not profitable) Block: 14762600 Gas used: 44416 (0.37%)

File "brownie/_cli/run.py", line 50, in main
args[""], method_name=args[""] or "main", _include_frame=True
File "brownie/project/scripts.py", line 103, in run
return_value = f_locals[method_name](*args, **kwargs)
File "./scripts/arbitrage.py", line 37, in main
arbitrage_tx = arbitrage.makeArbitrage({"from": account})
File "brownie/network/contract.py", line 1693, in call
return self.transact(*args)
File "brownie/network/contract.py", line 1577, in transact
allow_revert=tx["allow_revert"],
File "brownie/network/account.py", line 680, in transfer
receipt._raise_if_reverted(exc)
File "brownie/network/transaction.py", line 421, in _raise_if_reverted
source=source, revert_msg=self._revert_msg, dev_revert_msg=self._dev_revert_msg
VirtualMachineError: revert: Arbitrage not profitable
Trace step -1, program counter 689:
File "contracts/SimpleArbitrage.sol", line 38, in SimpleArbitrage.withdraw:
}

    modifier onlyOwner() {
        require(msg.sender == owner, "only owner can call this");
        _;
    }

Terminating local RPC client...

The only thing that I haven't done, it's having WETH in my wallet, could be that?

Error in Arbitage

getting follow error on execution of brownie run scripts/arbitrage.py --network=mainnet-fork

**Transaction sent: 0x39d7490c550c040c4a176bd9f06b0733235214d334092ac88461f8814d3a5c76
Gas price: 0.0 gwei Gas limit: 12000000 Nonce: 14
SimpleArbitrage.makeArbitrage confirmed (Arbitrage not profitable) Block: 16938481 Gas used: 44421 (0.37%)

Exception in Arbitrage : int() can't convert non-string with explicit base**

Script execution

Running 'scripts\arbitrage.py::main'...
File "C:\Users\Fabian\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\brownie_cli\run.py", line 49, in main
return_value, frame = run(
File "C:\Users\Fabian\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\brownie\project\scripts.py", line 103, in run
return_value = f_locals[method_name](*args, **kwargs)
File ".\scripts\arbitrage.py", line 15, in main
account = get_account()
File ".\scripts\helper_scripts.py", line 16, in get_account
return accounts[0]
File "C:\Users\Fabian\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\brownie\network\account.py", line 113, in getitem
return self._accounts[key]
IndexError: list index out of range

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.