Skip to content

Commit

Permalink
Merge pull request #547 from bancorprotocol/release-candidate
Browse files Browse the repository at this point in the history
Release candidate - Linea support and static data
  • Loading branch information
zavelevsky authored Apr 15, 2024
2 parents fc5325b + c7ad17e commit 6424d56
Show file tree
Hide file tree
Showing 33 changed files with 393,535 additions and 309,595 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,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 @@ -11,6 +11,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 @@ -155,7 +156,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 @@ -167,5 +168,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")
3 changes: 3 additions & 0 deletions fastlane_bot/config/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
CARBON_V1_NAME = "carbon_v1"
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"
44 changes: 42 additions & 2 deletions fastlane_bot/config/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class ConfigNetwork(ConfigBase):
# ACCOUNTS SECTION
#######################################################################################
BINANCE8_WALLET_ADDRESS = "0xF977814e90dA44bFA03b6295A0616a897441aceC"
BINANCE14_WALLET_ADDRESS = "0x28c6c06298d514db089934071355e5743bf21d60"
BINANCE14_WALLET_ADDRESS = "0x28C6c06298d514Db089934071355E5743bf21d60"

# EXCHANGE IDENTIFIERS SECTION
#######################################################################################
Expand Down Expand Up @@ -256,7 +256,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 @@ -278,6 +278,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 @@ -292,6 +293,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 @@ -321,6 +323,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 @@ -729,6 +733,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 @@ -101,13 +101,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 @@ -10,6 +10,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
32 changes: 32 additions & 0 deletions fastlane_bot/data/abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,38 @@
"""
)

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 = json.loads(
"""
[{"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"}]
Expand Down
Loading

0 comments on commit 6424d56

Please sign in to comment.