Skip to content

Commit

Permalink
Merge pull request #615 from mraniki/dev
Browse files Browse the repository at this point in the history
♻️ update contract_utils.py
  • Loading branch information
mraniki authored Apr 8, 2024
2 parents 14dcaf1 + 40de9e9 commit 981c678
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions dxsp/utils/contract_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ async def get_tokenlist_data(self, symbol):
if keyval["symbol"] == symbol and keyval["chainId"] == self.chain:
logger.debug("token data found {}", keyval)
return keyval
elif keyval["address"] == symbol and keyval["chainId"] == 1:
logger.debug("token data found {}", keyval)
return keyval
logger.warning(f"Token {symbol} not found on list")
except Exception as e:
logger.error("get_token_data: {}", e)
Expand Down Expand Up @@ -233,11 +236,13 @@ async def get_cg_data(self, token):
str or None: The data for the token on the specified platform,
or None if the token is not found or an error occurs.
"""
# todo: add support for address search
try:
if self.platform is None:
return None
search_results = self.cg.search(query=token)
search_dict = search_results["coins"]
# logger.debug("Coingecko search results: {}", search_dict)
filtered_dict = [x for x in search_dict if x["symbol"] == token.upper()]
api_dict = [sub["api_symbol"] for sub in filtered_dict]
for i in api_dict:
Expand Down
4 changes: 3 additions & 1 deletion examples/example.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"""
DXSP Example
"""

import asyncio

from dxsp import DexSwap


async def main():
dex = DexSwap()
symbol = "BTC"
# symbol = "LINK"
symbol = "0x514910771af9ca656af840dff83e8264ecf986ca"

quote = await dex.get_quotes(symbol)
print("quote ", quote)
Expand Down

0 comments on commit 981c678

Please sign in to comment.