Skip to content

Commit 158b341

Browse files
author
abel
committed
(feat) Cleaned up the markets initialization logic
1 parent 352cd44 commit 158b341

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

pyinjective/async_client.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import grpc
1010
from google.protobuf import json_format
1111

12-
from pyinjective import constant
1312
from pyinjective.client.chain.grpc.chain_grpc_auth_api import ChainGrpcAuthApi
1413
from pyinjective.client.chain.grpc.chain_grpc_authz_api import ChainGrpcAuthZApi
1514
from pyinjective.client.chain.grpc.chain_grpc_bank_api import ChainGrpcBankApi
@@ -2659,22 +2658,13 @@ async def _initialize_tokens_and_markets(self):
26592658
)
26602659

26612660
for market_info in valid_markets:
2662-
ticker = market_info["ticker"]
2663-
if "/" in ticker:
2664-
base_token_symbol, quote_token_symbol = ticker.split(constant.TICKER_TOKENS_SEPARATOR)
2665-
else:
2666-
base_token_symbol = market_info["baseTokenMeta"]["symbol"]
2667-
quote_token_symbol = market_info["quoteTokenMeta"]["symbol"]
2668-
26692661
base_token = self._token_representation(
2670-
symbol=base_token_symbol,
26712662
token_meta=market_info["baseTokenMeta"],
26722663
denom=market_info["baseDenom"],
26732664
tokens_by_denom=tokens_by_denom,
26742665
tokens_by_symbol=tokens_by_symbol,
26752666
)
26762667
quote_token = self._token_representation(
2677-
symbol=quote_token_symbol,
26782668
token_meta=market_info["quoteTokenMeta"],
26792669
denom=market_info["quoteDenom"],
26802670
tokens_by_denom=tokens_by_denom,
@@ -2704,10 +2694,7 @@ async def _initialize_tokens_and_markets(self):
27042694
)
27052695

27062696
for market_info in valid_markets:
2707-
quote_token_symbol = market_info["quoteTokenMeta"]["symbol"]
2708-
27092697
quote_token = self._token_representation(
2710-
symbol=quote_token_symbol,
27112698
token_meta=market_info["quoteTokenMeta"],
27122699
denom=market_info["quoteDenom"],
27132700
tokens_by_denom=tokens_by_denom,
@@ -2769,22 +2756,21 @@ async def _initialize_tokens_and_markets(self):
27692756

27702757
def _token_representation(
27712758
self,
2772-
symbol: str,
27732759
token_meta: Dict[str, Any],
27742760
denom: str,
27752761
tokens_by_denom: Dict[str, Token],
27762762
tokens_by_symbol: Dict[str, Token],
27772763
) -> Token:
27782764
if denom not in tokens_by_denom:
27792765
unique_symbol = denom
2780-
for symbol_candidate in [symbol, token_meta["symbol"], token_meta["name"]]:
2766+
for symbol_candidate in [token_meta["symbol"], token_meta["name"]]:
27812767
if symbol_candidate not in tokens_by_symbol:
27822768
unique_symbol = symbol_candidate
27832769
break
27842770

27852771
token = Token(
27862772
name=token_meta["name"],
2787-
symbol=symbol,
2773+
symbol=token_meta["symbol"],
27882774
denom=denom,
27892775
address=token_meta["address"],
27902776
decimals=token_meta["decimals"],

0 commit comments

Comments
 (0)