Skip to content

Commit

Permalink
Merge pull request #155 from bancorprotocol/137-fix-or-replace-browni…
Browse files Browse the repository at this point in the history
…e-multicall-functionality
  • Loading branch information
mikewcasale authored Sep 29, 2023
2 parents 26d56ea + 8678bd3 commit d0ced08
Show file tree
Hide file tree
Showing 77 changed files with 6,596 additions and 4,551 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/release-and-pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt --force-reinstall
pip install bumpversion
brownie networks import ./brownie-config.yaml true
brownie networks delete mainnet
brownie networks add "Ethereum Mainnet" "mainnet" host="https://eth-mainnet.alchemyapi.io/v2/$WEB3_ALCHEMY_PROJECT_ID" chainid=1
brownie networks set_provider alchemy
env:
TENDERLY_FORK: '${{ secrets.TENDERLY_FORK }}'
WEB3_ALCHEMY_PROJECT_ID: '${{ secrets.WEB3_ALCHEMY_PROJECT_ID }}'
Expand Down
12 changes: 1 addition & 11 deletions .github/workflows/run-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,8 @@ jobs:
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install jupytext
pip install jupytext pytest
pip install -r requirements.txt --force-reinstall
- name: Setup Brownie
run: |
brownie networks import ./brownie-config.yaml true
brownie networks delete mainnet
brownie networks add "Ethereum Mainnet" "mainnet" host="https://eth-mainnet.alchemyapi.io/v2/$WEB3_ALCHEMY_PROJECT_ID" chainid=1
brownie networks set_provider alchemy
env:
TENDERLY_FORK: '${{ secrets.TENDERLY_FORK }}'
WEB3_ALCHEMY_PROJECT_ID: '${{ secrets.WEB3_ALCHEMY_PROJECT_ID }}'
ETHERSCAN_TOKEN: '${{ secrets.ETHERSCAN_TOKEN }}'
- name: Run Tests
run: |
echo TENDERLY_FORK=$TENDERLY_FORK > .env
Expand Down
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,6 @@ If you encounter import errors or `ModuleNotFound` exceptions, try:
python <absolute_path>/main.py
```

The Fastlane Arbitrage Bot uses Brownie with Alchemy for Ethereum network calls. If you need to manually configure Brownie, follow these steps:

```bash
brownie networks update_provider alchemy https://eth-{}.alchemyapi.io/v2/$WEB3_ALCHEMY_PROJECT_ID
brownie networks modify mainnet provider=alchemy
brownie networks set_provider alchemy
```

For further issues, check the [Brownie documentation][bdoc].

[bdoc]:https://eth-brownie.readthedocs.io/en/stable/install.html

## Change Log

We follow [semantic versioning][semver] (`major.minor.patch`), updating the major number for backward incompatible API changes, minor for compatible changes, and patch for minor patches.
Expand Down
1 change: 0 additions & 1 deletion apple-silicon-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ else
exit 1
fi

# Run setup.py to configure brownie
if [ -f setup.py ]; then
python setup.py install
else
Expand Down
8 changes: 0 additions & 8 deletions brownie-config.yaml

This file was deleted.

71 changes: 0 additions & 71 deletions brownie_setup.py

This file was deleted.

19 changes: 3 additions & 16 deletions fastlane_bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
from typing import List, Dict, Tuple, Any, Callable
from typing import Optional

from web3 import Web3
from web3.datastructures import AttributeDict

from fastlane_bot.config import Config
Expand Down Expand Up @@ -1344,24 +1345,10 @@ def _ensure_connection(self, tenderly_fork: str):
The Tenderly fork ID
"""
from fastlane_bot.config.connect import EthereumNetwork

tenderly_uri = f"https://rpc.tenderly.co/fork/{tenderly_fork}"
connection = EthereumNetwork(
network_id="tenderly",
network_name="Tenderly (Alchemy)",
provider_url=tenderly_uri,
provider_name="alchemy",
)
connection.connect_network()
self.db.cfg.w3 = connection.web3
self.ConfigObj.w3 = connection.web3

assert (
self.db.cfg.w3.provider.endpoint_uri
== self.ConfigObj.w3.provider.endpoint_uri
== tenderly_uri
), f"Failed to connect to Tenderly fork at {tenderly_uri} - got {self.db.cfg.w3.provider.endpoint_uri} instead"
self.db.cfg.w3 = Web3(Web3.HTTPProvider(tenderly_uri))
self.ConfigObj.w3 = Web3(Web3.HTTPProvider(tenderly_uri))

def run(
self,
Expand Down
48 changes: 0 additions & 48 deletions fastlane_bot/config/brownie_setup_tenderly.py

This file was deleted.

29 changes: 3 additions & 26 deletions fastlane_bot/config/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
import subprocess
from abc import ABCMeta, ABC

from brownie import network, Contract, accounts # type: ignore
from eth_typing import HexStr
from hexbytes import HexBytes
from web3 import Web3
from web3.types import TxReceipt

import os
from dotenv import load_dotenv

from fastlane_bot.config import network

load_dotenv()

import logging
Expand Down Expand Up @@ -104,9 +106,6 @@ def __init__(
nonce: int = 0,
):
"""
Note that Tenderly here must be configured in brownie - you can do this in the Terminal using the following command:
brownie networks add [environment] [id] host=[host] [KEY=VALUE, ...]. For example:
brownie networks add "Ethereum" "tenderly" host=https://rpc.tenderly.co/fork/7fd3f956-5409-4496-be95 chainid=1
:param network_id: the name of the network to connect to
:param network_name: the name of the network to connect to
Expand Down Expand Up @@ -168,28 +167,6 @@ def connect_network(self):
if self.is_connected:
return

# add_tenderly = f'brownie networks add "Ethereum" "{self.network_id}" host="{self.provider_url}"'
# mod_tenderly = f'brownie networks modify "{self.network_id}" host="{self.provider_url}" name="{self.network_name}" chainid={self.chain_id}'
# set_tenderly = f'brownie networks set_provider "{self.provider_name}"'

# cmds = [add_tenderly, mod_tenderly, set_tenderly]
# for cmd in cmds:
# p = subprocess.Popen(
# cmd,
# stdout=subprocess.PIPE,
# stderr=subprocess.PIPE,
# stdin=subprocess.PIPE,
# shell=True,
# )

# stdout, stderr = p.communicate()

# if "already exists" in stderr.decode("utf-8"):
# logger.debug(f"network {self.network_id} already exists")

self.network = network
self.network.connect(self.network_id)
self._is_connected = True
self.web3 = Web3(Web3.HTTPProvider(self.provider_url))
logger.info(f"Connected to {self.network_id} network")
logger.info(f"Connected to {self.web3.provider.endpoint_uri} network")
Loading

0 comments on commit d0ced08

Please sign in to comment.