Skip to content

Commit

Permalink
Merge pull request #545 from bancorprotocol/merge-rc-to-dev
Browse files Browse the repository at this point in the history
Merge rc to dev
  • Loading branch information
zavelevsky authored Apr 15, 2024
2 parents 889307d + f8f9f48 commit f4532bf
Show file tree
Hide file tree
Showing 36 changed files with 393,592 additions and 309,603 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export WEB3_ALCHEMY_PROJECT_ID="0-USE-YOUR-OWN-ALCHEMY-PROJECT-ID-HERE"
export ETH_PRIVATE_KEY_BE_CAREFUL="0x123-USE-YOUR-OWN-PRIVATE-KEY-HERE"
export WEB3_FANTOM="FANTOM-API-KEY-HERE" // "public" can be used in place of a paid API key
export WEB3_MANTLE="MANTLE-API-KEY-HERE"
export WEB3_LINEA="LINEA-API-KEY-HERE" //

#******** For Development - not required to run bot ********#
export ETHERSCAN_TOKEN="ONLY_REQUIRED_IN_DEV"
export TENDERLY_FORK_ID=
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/run-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,19 @@ jobs:
run: |
echo TENDERLY_FORK=$TENDERLY_FORK > .env
echo WEB3_ALCHEMY_PROJECT_ID=$WEB3_ALCHEMY_PROJECT_ID >> .env
echo WEB3_ALCHEMY_BASE=$WEB3_ALCHEMY_BASE >> .env
echo WEB3_FANTOM=$WEB3_FANTOM >> .env
echo WEB3_MANTLE=$WEB3_MANTLE >> .env
echo ETHERSCAN_TOKEN=$ETHERSCAN_TOKEN >> .env
echo DEFAULT_MIN_PROFIT_BNT=$DEFAULT_MIN_PROFIT_BNT >> .env
echo ETH_PRIVATE_KEY_BE_CAREFUL=$ETH_PRIVATE_KEY_BE_CAREFUL >> .env
cd resources/NBTest;ln -s ../../fastlane_bot fastlane_bot;cd ..;cd ..; poetry run ./run_tests
env:
TENDERLY_FORK: '${{ secrets.TENDERLY_FORK }}'
WEB3_ALCHEMY_PROJECT_ID: '${{ secrets.WEB3_ALCHEMY_PROJECT_ID }}'
WEB3_ALCHEMY_BASE: '${{ secrets.WEB3_ALCHEMY_BASE }}'
WEB3_FANTOM: '${{ secrets.WEB3_FANTOM }}'
WEB3_MANTLE: '${{ secrets.WEB3_MANTLE }}'
ETHERSCAN_TOKEN: '${{ secrets.ETHERSCAN_TOKEN }}'
DEFAULT_MIN_PROFIT_BNT: '${{ secrets.DEFAULT_MIN_PROFIT_BNT }}'
ETH_PRIVATE_KEY_BE_CAREFUL: '${{ secrets.ETH_PRIVATE_KEY_BE_CAREFUL }}'
Expand Down
47 changes: 46 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,65 @@

## [Unreleased](https://github.com/bancorprotocol/fastlane-bot/tree/HEAD)

[Full Changelog](https://github.com/bancorprotocol/fastlane-bot/compare/v3.1.4...HEAD)
[Full Changelog](https://github.com/bancorprotocol/fastlane-bot/compare/v3.1.8...HEAD)

- WEB3\_ALCHEMY\_BASE, WEB3\_FANTOM and WEB3\_MANTLE are missing in the test-suite configuration [\#520](https://github.com/bancorprotocol/fastlane-bot/issues/520)
- Wrong fee resolution used for Solidly forks [\#403](https://github.com/bancorprotocol/fastlane-bot/issues/403)

## [v3.1.8](https://github.com/bancorprotocol/fastlane-bot/tree/v3.1.8) (2024-04-13)

[Full Changelog](https://github.com/bancorprotocol/fastlane-bot/compare/v3.1.7...v3.1.8)

- Transaction Creation [\#428](https://github.com/bancorprotocol/fastlane-bot/issues/428)

Merged pull requests

- github action support for testing more networks [\#536](https://github.com/bancorprotocol/fastlane-bot/pull/536) ([zavelevsky](https://github.com/zavelevsky))

## [v3.1.7](https://github.com/bancorprotocol/fastlane-bot/tree/v3.1.7) (2024-04-11)

[Full Changelog](https://github.com/bancorprotocol/fastlane-bot/compare/v3.1.6...v3.1.7)

- supernova not found in exchange [\#539](https://github.com/bancorprotocol/fastlane-bot/issues/539)
- Transactions occasionally revert with error-message `Too little received` [\#383](https://github.com/bancorprotocol/fastlane-bot/issues/383)
- Hotfix - Fix native token address for Mantle [\#541](https://github.com/bancorprotocol/fastlane-bot/pull/541) ([Lesigh-3100](https://github.com/Lesigh-3100))

- Remove unused code in `submithandler.py` [\#350](https://github.com/bancorprotocol/fastlane-bot/issues/350)

Closed issues

- `*args, **kwargs` -\> `argsf1, argsf2` [\#493](https://github.com/bancorprotocol/fastlane-bot/issues/493)
- Can get rid of the if '-' in cid [\#466](https://github.com/bancorprotocol/fastlane-bot/issues/466)

## [v3.1.6](https://github.com/bancorprotocol/fastlane-bot/tree/v3.1.6) (2024-04-10)

[Full Changelog](https://github.com/bancorprotocol/fastlane-bot/compare/v3.1.5...v3.1.6)

Merged pull requests

- Update fusionx details info [\#525](https://github.com/bancorprotocol/fastlane-bot/pull/525) ([NIXBNT](https://github.com/NIXBNT))

## [v3.1.5](https://github.com/bancorprotocol/fastlane-bot/tree/v3.1.5) (2024-04-09)

[Full Changelog](https://github.com/bancorprotocol/fastlane-bot/compare/v3.1.4...v3.1.5)

- Carbon strategies are duplicated from events [\#521](https://github.com/bancorprotocol/fastlane-bot/issues/521)

- Add support for puffs\_penthouse uniswap\_v3 fork [\#524](https://github.com/bancorprotocol/fastlane-bot/pull/524) ([NIXBNT](https://github.com/NIXBNT))

## [v3.1.4](https://github.com/bancorprotocol/fastlane-bot/tree/v3.1.4) (2024-04-08)

[Full Changelog](https://github.com/bancorprotocol/fastlane-bot/compare/v3.1.3...v3.1.4)

- GPU token external liquidity not found [\#515](https://github.com/bancorprotocol/fastlane-bot/issues/515)
- Hotfix - Carbon strategies duplicated [\#522](https://github.com/bancorprotocol/fastlane-bot/pull/522) ([Lesigh-3100](https://github.com/Lesigh-3100))

## [v3.1.3](https://github.com/bancorprotocol/fastlane-bot/tree/v3.1.3) (2024-04-04)

[Full Changelog](https://github.com/bancorprotocol/fastlane-bot/compare/v3.1.2...v3.1.3)

- gpu external sources added to event mapping [\#517](https://github.com/bancorprotocol/fastlane-bot/pull/517) ([NIXBNT](https://github.com/NIXBNT))

Closed issues

- All files should have doc strings [\#438](https://github.com/bancorprotocol/fastlane-bot/issues/438)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export ETH_PRIVATE_KEY_BE_CAREFUL="0x9c..."
export WEB3_ALCHEMY_BASE="api_key_here"
export WEB3_FANTOM="api_key_here"
export WEB3_MANTLE="api_key_here"

export WEB3_LINEA="api_key_here"
```
**Note:** To use the Fantom public RPC, write "public" in place of the API key.

Expand Down
7 changes: 6 additions & 1 deletion fastlane_bot/config/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from eth_typing import HexStr
from hexbytes import HexBytes
from web3 import Web3, AsyncWeb3
from web3.middleware import geth_poa_middleware
from web3.types import TxReceipt

import os
Expand Down Expand Up @@ -156,7 +157,7 @@ def increment_nonce(self) -> None:
"""
self.nonce += 1

def connect_network(self):
def connect_network(self, inject_poa_middleware):
"""
Connect to the network
"""
Expand All @@ -168,5 +169,9 @@ def connect_network(self):
self.web3 = Web3(Web3.HTTPProvider(self.provider_url, request_kwargs={'timeout': 60}))
self.w3_async = AsyncWeb3(AsyncWeb3.AsyncHTTPProvider(self.provider_url))

if inject_poa_middleware:
self.web3.middleware_onion.inject(geth_poa_middleware, layer=0)
self.w3_async.middleware_onion.inject(geth_poa_middleware, layer=0)

logger.info(f"Connected to {self.network_id} network")
logger.info(f"Connected to {self.web3.provider.endpoint_uri} network")
4 changes: 3 additions & 1 deletion fastlane_bot/config/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
FUSIONX_V3_NAME = "fusionx_v3"
CLEOPATRA_V3_NAME = "cleopatra_v3"
CARBON_V1_NAME = "carbon_v1"
CARBON_V1_FORK1_NAME = "altered_carbon"
VELOCIMETER_V2_NAME = "velocimeter_v2"
SOLIDLY_V2_NAME = "solidly_v2"
ECHODEX_V3_NAME = "echodex_v3"
SECTA_V3_NAME = "secta_v3"
METAVAULT_V3_NAME = "metavault_v3"
51 changes: 44 additions & 7 deletions fastlane_bot/config/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from . import selectors as S
from .base import ConfigBase
from .constants import CARBON_V1_FORK1_NAME, CARBON_V1_NAME
from .constants import CARBON_V1_NAME
load_dotenv()

from decimal import Decimal
Expand Down Expand Up @@ -204,7 +204,7 @@ class ConfigNetwork(ConfigBase):
# ACCOUNTS SECTION
#######################################################################################
BINANCE8_WALLET_ADDRESS = "0xF977814e90dA44bFA03b6295A0616a897441aceC"
BINANCE14_WALLET_ADDRESS = "0x28c6c06298d514db089934071355e5743bf21d60"
BINANCE14_WALLET_ADDRESS = "0x28C6c06298d514Db089934071355E5743bf21d60"

# EXCHANGE IDENTIFIERS SECTION
#######################################################################################
Expand All @@ -216,7 +216,6 @@ class ConfigNetwork(ConfigBase):
SUSHISWAP_V2_NAME = "sushiswap_v2"
SUSHISWAP_V3_NAME = "sushiswap_v3"
CARBON_V1_NAME = CARBON_V1_NAME
CARBON_V1_X2_NAME = CARBON_V1_FORK1_NAME
BANCOR_POL_NAME = "bancor_pol"
BALANCER_NAME = "balancer"
PANCAKESWAP_V2_NAME = "pancakeswap_v2"
Expand Down Expand Up @@ -244,8 +243,6 @@ class ConfigNetwork(ConfigBase):

GAS_ORACLE_ADDRESS = None

CARBON_V1_FORKS = [CARBON_V1_NAME, CARBON_V1_X2_NAME]

MULTICALLABLE_EXCHANGES = [BANCOR_V3_NAME, BANCOR_POL_NAME, BALANCER_NAME]
# BANCOR POL
BANCOR_POL_START_BLOCK = 18184448
Expand All @@ -266,7 +263,7 @@ class ConfigNetwork(ConfigBase):

# DEFAULT VALUES SECTION
#######################################################################################
UNIV3_FEE_LIST = [80, 100, 250, 450, 500, 2500, 3000, 10000]
UNIV3_FEE_LIST = [8, 10, 40, 80, 100, 250, 300, 450, 500, 1000, 2500, 3000, 10000]
MIN_BNT_LIQUIDITY = 2_000_000_000_000_000_000
DEFAULT_GAS = 950_000
DEFAULT_GAS_PRICE = 0
Expand All @@ -288,6 +285,7 @@ class ConfigNetwork(ConfigBase):
LIMIT_BANCOR3_FLASHLOAN_TOKENS = True
DEFAULT_MIN_PROFIT_GAS_TOKEN = Decimal("0.02")

IS_INJECT_POA_MIDDLEWARE = False
# SUNDRY SECTION
#######################################################################################
COINGECKO_URL = "https://tokens.coingecko.com/uniswap/all.json"
Expand All @@ -302,6 +300,7 @@ class ConfigNetwork(ConfigBase):
NETWORK_OPTIMISM = S.NETWORK_OPTIMISM
NETWORK_FANTOM = S.NETWORK_FANTOM
NETWORK_MANTLE = S.NETWORK_MANTLE
NETWORK_LINEA = S.NETWORK_LINEA

# FLAGS
#######################################################################################
Expand Down Expand Up @@ -331,6 +330,8 @@ def new(cls, network=None):
return _ConfigNetworkFantom(_direct=False)
elif network == cls.NETWORK_MANTLE:
return _ConfigNetworkMantle(_direct=False)
elif network == cls.NETWORK_LINEA:
return _ConfigNetworkLinea(_direct=False)
elif network == cls.NETWORK_TENDERLY:
return _ConfigNetworkTenderly(_direct=False)
else:
Expand Down Expand Up @@ -723,7 +724,7 @@ class _ConfigNetworkMantle(ConfigNetwork):
# WRAPPED_GAS_TOKEN_KEY = "WETH-0006"
# STABLECOIN_KEY = "USDC-2913"

NATIVE_GAS_TOKEN_ADDRESS = "0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000"
NATIVE_GAS_TOKEN_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
WRAPPED_GAS_TOKEN_ADDRESS = "0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8"
NATIVE_GAS_TOKEN_SYMBOL = "MNT"
WRAPPED_GAS_TOKEN_SYMBOL = "WMNT"
Expand All @@ -739,6 +740,42 @@ class _ConfigNetworkMantle(ConfigNetwork):
# Add any exchanges unique to the chain here
CHAIN_SPECIFIC_EXCHANGES = []

class _ConfigNetworkLinea(ConfigNetwork):
"""
Fastlane bot config -- network [Base Mainnet]
"""

NETWORK = S.NETWORK_LINEA
NETWORK_ID = "59144"
NETWORK_NAME = "linea"
DEFAULT_PROVIDER = S.PROVIDER_ALCHEMY
RPC_ENDPOINT = "https://linea.blockpi.network/v1/rpc/"
WEB3_ALCHEMY_PROJECT_ID = os.environ.get("WEB3_LINEA")

network_df = get_multichain_addresses(network=NETWORK_NAME)
FASTLANE_CONTRACT_ADDRESS = "0xC7Dd38e64822108446872c5C2105308058c5C55C"
MULTICALL_CONTRACT_ADDRESS = "0xcA11bde05977b3631167028862bE2a173976CA11"

CARBON_CONTROLLER_ADDRESS = "0x0000000000000000000000000000000000000000" #TODO - UPDATE WITH ACTUAL DEPLOYMENT WHEN THERE IS ONE
CARBON_CONTROLLER_VOUCHER = "0x0000000000000000000000000000000000000000" #TODO - UPDATE WITH ACTUAL DEPLOYMENT WHEN THERE IS ONE

NATIVE_GAS_TOKEN_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
WRAPPED_GAS_TOKEN_ADDRESS = "0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f"
NATIVE_GAS_TOKEN_SYMBOL = "ETH"
WRAPPED_GAS_TOKEN_SYMBOL = "WETH"
STABLECOIN_ADDRESS = "0x176211869ca2b568f2a7d4ee941e073a821ee1ff"

IS_INJECT_POA_MIDDLEWARE = True
# Balancer
BALANCER_VAULT_ADDRESS = "0x1d0188c4B276A09366D05d6Be06aF61a73bC7535" # velocore

CHAIN_FLASHLOAN_TOKENS = {
"0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f": "WETH",
"0x176211869ca2b568f2a7d4ee941e073a821ee1ff": "USDC",
}
# Add any exchanges unique to the chain here
CHAIN_SPECIFIC_EXCHANGES = []

class _ConfigNetworkTenderly(ConfigNetwork):
"""
Fastlane bot config -- network [Ethereum Tenderly]
Expand Down
4 changes: 2 additions & 2 deletions fastlane_bot/config/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ def __init__(self, network: ConfigNetwork, **kwargs):
provider_url=self.RPC_URL,
provider_name="alchemy",
)
self.connection.connect_network()
self.connection.connect_network(network.IS_INJECT_POA_MIDDLEWARE)
self.w3 = self.connection.web3
self.w3_async = self.connection.w3_async
self.LOCAL_ACCOUNT = self.w3.eth.account.from_key(ETH_PRIVATE_KEY_BE_CAREFUL)


if network.NETWORK in [N.NETWORK_BASE, N.NETWORK_ETHEREUM, N.NETWORK_FANTOM, N.NETWORK_MANTLE]:
if network.NETWORK in [N.NETWORK_BASE, N.NETWORK_ETHEREUM, N.NETWORK_FANTOM, N.NETWORK_MANTLE, N.NETWORK_LINEA]:
self.CARBON_CONTROLLER_CONTRACT = self.w3.eth.contract(
address=network.CARBON_CONTROLLER_ADDRESS,
abi=CARBON_CONTROLLER_ABI,
Expand Down
1 change: 1 addition & 0 deletions fastlane_bot/config/selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
NETWORK_OPTIMISM = "optimism"
NETWORK_CANTO = "canto"
NETWORK_FANTOM = "fantom"
NETWORK_LINEA = "linea"
NETWORK_MANTLE = "mantle"
NETWORK_SCROLL = "scroll"
NETWORK_BSC = "binance_smart_chain"
Expand Down
34 changes: 34 additions & 0 deletions fastlane_bot/data/abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,40 @@
}
]

LYNEX_V2_FACTORY_ABI = [
{
"type": "event",
"name": "PairCreated",
"anonymous": False,
"inputs": [{"indexed": True, "internalType": "address", "name": "token0", "type": "address"}, {"indexed": True, "internalType": "address", "name": "token1", "type": "address"}, {"indexed": False, "internalType": "bool", "name": "stable", "type": "bool"}, {"indexed": False, "internalType": "address", "name": "pair", "type": "address"}, {"indexed": False, "internalType": "uint256", "name": "", "type": "uint256"}]
},
{
"type": "function",
"name": "getFee",
"stateMutability": "view",
"inputs": [{"internalType": "bool", "name": "_stable", "type": "bool"}],
"outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}]
}
]

NILE_V2_FACTORY_ABI = [
{
"type": "event",
"name": "PairCreated",
"anonymous": False,
"inputs": [{"indexed": True, "internalType": "address", "name": "token0", "type": "address"}, {"indexed": True, "internalType": "address", "name": "token1", "type": "address"}, {"indexed": False, "internalType": "bool", "name": "stable", "type": "bool"}, {"indexed": False, "internalType": "address", "name": "pair", "type": "address"}, {"indexed": False, "internalType": "uint256", "name": "", "type": "uint256"}]
},
{
"type": "function",
"name": "pairFee",
"stateMutability": "view",
"inputs": [{"internalType": "address", "name": "_pool", "type": "address"}],
"outputs": [{"internalType": "uint256", "name": "fee", "type": "uint256"}]
}
]

PANCAKESWAP_V2_FACTORY_ABI = [{"inputs":[{"internalType":"address","name":"_feeToSetter","type":"address"}],"payable":False,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":False,"inputs":[{"indexed":True,"internalType":"address","name":"token0","type":"address"},{"indexed":True,"internalType":"address","name":"token1","type":"address"},{"indexed":False,"internalType":"address","name":"pair","type":"address"},{"indexed":False,"internalType":"uint256","name":"","type":"uint256"}],"name":"PairCreated","type":"event"},{"constant":True,"inputs":[],"name":"INIT_CODE_PAIR_HASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":False,"stateMutability":"view","type":"function"},{"constant":True,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allPairs","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":False,"stateMutability":"view","type":"function"},{"constant":True,"inputs":[],"name":"allPairsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":False,"stateMutability":"view","type":"function"},{"constant":False,"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"}],"name":"createPair","outputs":[{"internalType":"address","name":"pair","type":"address"}],"payable":False,"stateMutability":"nonpayable","type":"function"},{"constant":True,"inputs":[],"name":"feeTo","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":False,"stateMutability":"view","type":"function"},{"constant":True,"inputs":[],"name":"feeToSetter","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":False,"stateMutability":"view","type":"function"},{"constant":True,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"getPair","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":False,"stateMutability":"view","type":"function"},{"constant":False,"inputs":[{"internalType":"address","name":"_feeTo","type":"address"}],"name":"setFeeTo","outputs":[],"payable":False,"stateMutability":"nonpayable","type":"function"},{"constant":False,"inputs":[{"internalType":"address","name":"_feeToSetter","type":"address"}],"name":"setFeeToSetter","outputs":[],"payable":False,"stateMutability":"nonpayable","type":"function"}]

UNISWAP_V2_POOL_ABI = [
{
"type": "event",
Expand Down
Loading

0 comments on commit f4532bf

Please sign in to comment.