Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create terraformer #175

Merged
merged 41 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
05f228b
Add terraformer
Lesigh-3100 Oct 22, 2023
82599af
Update selectors.py
Lesigh-3100 Oct 22, 2023
dafcd25
Add new click options to main
Lesigh-3100 Oct 22, 2023
b649529
Update run_blockchain_terraformer.py
Lesigh-3100 Oct 22, 2023
d49986f
bugfixes and main loop integration
mikewcasale Oct 23, 2023
7231b09
Update main.py
mikewcasale Oct 23, 2023
33ae1b3
bugfix
mikewcasale Oct 23, 2023
7836d2f
another bugfix
mikewcasale Oct 23, 2023
3d304be
Update run_blockchain_terraformer.py
Lesigh-3100 Oct 23, 2023
625991d
Fix file already exists error
Lesigh-3100 Oct 23, 2023
b227db7
Fix folder creation
Lesigh-3100 Oct 23, 2023
52d465d
removes dependency on hardcoded static data file path at startup
mikewcasale Oct 23, 2023
5f13a93
Merge branch 'create-terraformer' of https://github.com/bancorprotoco…
mikewcasale Oct 23, 2023
b26d3b3
Fix to file path creation
Lesigh-3100 Oct 23, 2023
119fd89
bugfix for typo
mikewcasale Oct 23, 2023
1a6b6c2
Bugfix to terraformer
Lesigh-3100 Oct 23, 2023
75328bc
Fix token symbols
Lesigh-3100 Oct 23, 2023
efe6136
fix case in static pool data
Lesigh-3100 Oct 23, 2023
74ca057
case fix in tokens
NIXBNT Oct 23, 2023
1205ce9
Fix to terraformer
Lesigh-3100 Oct 23, 2023
a5e8492
Fixes to Terraformer
Lesigh-3100 Oct 24, 2023
1228faf
Terraformer speed upgrade
Lesigh-3100 Oct 24, 2023
4518de3
Revert "Terraformer speed upgrade"
Lesigh-3100 Oct 24, 2023
9e3254e
Add full Ethereum static data, add exchange-token filter,, update to …
Lesigh-3100 Oct 24, 2023
01ea834
Change default settings to not use Terraformer or Filter in Main
Lesigh-3100 Oct 25, 2023
4240fb1
Fixes
Lesigh-3100 Oct 25, 2023
b10499b
fixes to terraformer
Lesigh-3100 Oct 25, 2023
522601b
Update tokens.csv
Lesigh-3100 Oct 25, 2023
16c949e
Update contracts.py
Lesigh-3100 Oct 25, 2023
6e300ea
Update tokens.csv
Lesigh-3100 Oct 25, 2023
1c8b04a
Update terraformer
Lesigh-3100 Oct 25, 2023
5f28387
bugfixes for zero liquidity
mikewcasale Oct 25, 2023
d258884
Merge branch 'create-terraformer' of https://github.com/bancorprotoco…
mikewcasale Oct 25, 2023
339c881
bugfix for static_pools update (zero liquidity fix)
mikewcasale Oct 25, 2023
c96dbae
cleanup
mikewcasale Oct 25, 2023
cff2fc4
another bugfix related to zero liquidity issue
mikewcasale Oct 25, 2023
627d7a3
final bugfix for zero liquidity
mikewcasale Oct 25, 2023
4075937
Update default settings
Lesigh-3100 Oct 25, 2023
c5e3473
Cleanup typing for 3.8 support
Lesigh-3100 Oct 25, 2023
9e1966f
fix broken test
mikewcasale Oct 25, 2023
4b6bedb
Merge branch 'main' into create-terraformer
mikewcasale Oct 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions fastlane_bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,16 @@ def _ensure_connection(self, tenderly_fork: str):
self.db.cfg.w3 = Web3(Web3.HTTPProvider(tenderly_uri))
self.ConfigObj.w3 = Web3(Web3.HTTPProvider(tenderly_uri))

def get_tokens_in_exchange(
self,
exchange_name: str,
) -> List[str]:
"""
Gets all tokens that exist in pools on the specified exchange.
:param exchange_name: the exchange name
"""
return self.db.get_tokens_from_exchange(exchange_name=exchange_name)

def run(
self,
*,
Expand Down
55 changes: 42 additions & 13 deletions fastlane_bot/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import os
from dataclasses import dataclass, field, InitVar, asdict

# from .base import ConfigBase
from . import network as network_, db as db_, logger as logger_, provider as provider_
from .cloaker import CloakerL
Expand All @@ -18,18 +19,23 @@
load_dotenv()
TENDERLY_FORK_ID = os.environ.get("TENDERLY_FORK_ID")
if TENDERLY_FORK_ID is None:
TENDERLY_FORK_ID = ''
TENDERLY_FORK_ID = ""
WEB3_ALCHEMY_PROJECT_ID = os.environ.get("WEB3_ALCHEMY_PROJECT_ID")
PROVIDER_URL = f'https://rpc.tenderly.co/fork/{TENDERLY_FORK_ID}' if TENDERLY_FORK_ID != '' else f"https://eth-mainnet.alchemyapi.io/v2/{WEB3_ALCHEMY_PROJECT_ID}"
NETWORK_ID = 'mainnet' if TENDERLY_FORK_ID == '' else 'tenderly'
NETWORK_NAME = "Ethereum Mainnet" if TENDERLY_FORK_ID == '' else 'Tenderly (Alchemy)'
PROVIDER_URL = (
f"https://rpc.tenderly.co/fork/{TENDERLY_FORK_ID}"
if TENDERLY_FORK_ID != ""
else f"https://eth-mainnet.alchemyapi.io/v2/{WEB3_ALCHEMY_PROJECT_ID}"
)
NETWORK_ID = "mainnet" if TENDERLY_FORK_ID == "" else "tenderly"
NETWORK_NAME = "Ethereum Mainnet" if TENDERLY_FORK_ID == "" else "Tenderly (Alchemy)"


@dataclass
class Config():
class Config:
"""
Fastlane bot configuration object
"""

__VERSION__ = __VERSION__
__DATE__ = __DATE__

Expand All @@ -52,7 +58,17 @@ class Config():
LL_WARN = S.LOGLEVEL_WARNING
LL_ERR = S.LOGLEVEL_ERROR

SUPPORTED_EXCHANGES = ['carbon_v1', 'bancor_v2', 'bancor_v3', 'uniswap_v2', 'uniswap_v3', 'sushiswap_v2', 'bancor_pol', 'pancakeswap_v2', 'pancakeswap_v3']
SUPPORTED_EXCHANGES = [
"carbon_v1",
"bancor_v2",
"bancor_v3",
"uniswap_v2",
"uniswap_v3",
"sushiswap_v2",
"bancor_pol",
"pancakeswap_v2",
"pancakeswap_v3",
]
connection = EthereumNetwork(
network_id=NETWORK_ID,
network_name=NETWORK_NAME,
Expand All @@ -62,11 +78,14 @@ class Config():
connection.connect_network()
w3 = connection.web3

UNI_V2_FORKS = ["uniswap_v2", "sushiswap_v2", "pancakeswap_v2"]
UNI_V3_FORKS = ["uniswap_v3", "pancakeswap_v3"]

@classmethod
def new(cls, *, config=None, loglevel=None, logging_path=None, **kwargs):
"""
Alternative constructor: create and return new Config object

:config: CONFIG_MAINNET(default), CONFIG_TENDERLY, CONFIG_UNITTEST
:loglevel: LOGLEVEL_DEBUG, LOGLEVEL_INFO (default), LOGLEVEL_WARNING, LOGLEVEL_ERROR
"""
Expand All @@ -88,7 +107,9 @@ def new(cls, *, config=None, loglevel=None, logging_path=None, **kwargs):
elif config == cls.CONFIG_UNITTEST:
C_db = db_.ConfigDB.new(db=S.DATABASE_UNITTEST, POSTGRES_DB="unittest")
C_nw = network_.ConfigNetwork.new(network=S.NETWORK_MAINNET)
C_pr = provider_.ConfigProvider.new(network=C_nw, provider=S.PROVIDER_DEFAULT)
C_pr = provider_.ConfigProvider.new(
network=C_nw, provider=S.PROVIDER_DEFAULT
)
return cls(db=C_db, logger=C_log, network=C_nw, provider=C_pr, **kwargs)
raise ValueError(f"Invalid config: {config}")

Expand All @@ -113,22 +134,28 @@ def get_attribute_from_config(self, name: str):
for obj in [self.network, self.db, self.provider, self.logger]:
if hasattr(obj, name):
return getattr(obj, name)
raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'")
raise AttributeError(
f"'{self.__class__.__name__}' object has no attribute '{name}'"
)

def __getattr__(self, name: str):
"""
If of type attribute, return it.
"""
if self.is_config_item(name):
return self.get_attribute_from_config(name)
raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'")
raise AttributeError(
f"'{self.__class__.__name__}' object has no attribute '{name}'"
)

def __post_init__(self):
"""
Post-initialization initialization.
"""
if self.network is None:
self.network = network_.ConfigNetwork.new(network_.ConfigNetwork.NETWORK_ETHEREUM)
self.network = network_.ConfigNetwork.new(
network_.ConfigNetwork.NETWORK_ETHEREUM
)
assert issubclass(type(self.network), network_.ConfigNetwork)

if self.db is None:
Expand All @@ -147,14 +174,16 @@ def __post_init__(self):
self.provider = provider_.ConfigProvider.new(self.network)
assert issubclass(type(self.provider), provider_.ConfigProvider)

assert self.network is self.provider.network, f"Network mismatch: {self.network} != {self.provider.network}"
assert (
self.network is self.provider.network
), f"Network mismatch: {self.network} != {self.provider.network}"

VISIBLE_FIELDS = "network, db, logger, provider, w3, ZERO_ADDRESS"

def cloaked(self, incl=None, excl=None):
"""
returns a cloaked version of the object

:incl: fields to _include_ in the cloaked version (plus those in VISIBLE_FIELDS)
:excl: fields to _exclude_ from the cloaked version
"""
Expand Down
Loading