Skip to content

Commit

Permalink
Merge pull request #216 from bancorprotocol/215-handle-token-decimals…
Browse files Browse the repository at this point in the history
…-of-none-type

adds handling for decimals of None type
  • Loading branch information
mikewcasale authored Nov 20, 2023
2 parents d85c17a + f79de47 commit b018e54
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions fastlane_bot/events/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

@dataclass
class Token:

__VERSION__ = "0.0.1"
__DATE__ = "2023-07-03"

Expand All @@ -32,7 +31,6 @@ def __hash__(self):

@dataclass
class Pool(PoolAndTokens):

__VERSION__ = "0.0.1"
__DATE__ = "2023-07-03"

Expand All @@ -56,6 +54,7 @@ class QueryInterface:
uniswap_v2_event_mappings: Dict[str, str] = field(default_factory=dict)
uniswap_v3_event_mappings: Dict[str, str] = field(default_factory=dict)
exchanges: List[str] = field(default_factory=list)

@property
def cfg(self) -> Config:
return self.ConfigObj
Expand Down Expand Up @@ -124,7 +123,6 @@ def has_balance(self, pool: Dict[str, Any], keys: List[str]) -> bool:
return True
return False


def get_tokens_from_exchange(self, exchange_name: str) -> List[str]:
"""
This token gets all tokens that exist in pools on the specified exchange.
Expand Down Expand Up @@ -173,7 +171,9 @@ def filter_pools(self, exchange_name: str, keys: List[str] = "") -> List[Dict[st
pool
for pool in self.state
if pool["exchange_name"] == exchange_name
and self.has_balance(pool, keys)
and self.has_balance(pool, keys)
and pool['tkn0_decimals'] is not None
and pool['tkn1_decimals'] is not None
]
else:
return [
Expand Down Expand Up @@ -260,10 +260,10 @@ def remove_unmapped_uniswap_v2_pools(self) -> None:
pool
for pool in self.state
if pool["exchange_name"] != "uniswap_v2"
or (
pool["exchange_name"] in self.cfg.UNI_V2_FORKS
and pool["address"] in self.uniswap_v2_event_mappings
)
or (
pool["exchange_name"] in self.cfg.UNI_V2_FORKS
and pool["address"] in self.uniswap_v2_event_mappings
)
]
self.cfg.logger.info(
f"Removed {len(initial_state) - len(self.state)} unmapped uniswap_v2/sushi pools. {len(self.state)} uniswap_v2/sushi pools remaining"
Expand All @@ -279,10 +279,10 @@ def remove_unmapped_uniswap_v3_pools(self) -> None:
pool
for pool in self.state
if pool["exchange_name"] != "uniswap_v3"
or (
pool["exchange_name"] in self.cfg.UNI_V3_FORKS
and pool["address"] in self.uniswap_v3_event_mappings
)
or (
pool["exchange_name"] in self.cfg.UNI_V3_FORKS
and pool["address"] in self.uniswap_v3_event_mappings
)
]
self.cfg.logger.info(
f"Removed {len(initial_state) - len(self.state)} unmapped uniswap_v2/sushi pools. {len(self.state)} uniswap_v2/sushi pools remaining"
Expand All @@ -297,7 +297,7 @@ def log_umapped_pools_by_exchange(self, initial_state):
# uniswap_v3_unmapped = [
# pool for pool in unmapped_pools if pool["exchange_name"] == "uniswap_v3"
# ]
#self.log_pool_numbers(uniswap_v3_unmapped, "uniswap_v3")
# self.log_pool_numbers(uniswap_v3_unmapped, "uniswap_v3")
uniswap_v2_unmapped = [
pool for pool in unmapped_pools if pool["exchange_name"] == "uniswap_v2"
]
Expand All @@ -307,9 +307,6 @@ def log_umapped_pools_by_exchange(self, initial_state):
]
self.log_pool_numbers(sushiswap_v2_unmapped, "sushiswap_v2")




def remove_faulty_token_pools(self) -> None:
"""
Remove pools with faulty tokens
Expand Down

0 comments on commit b018e54

Please sign in to comment.