Skip to content

Commit 855a48e

Browse files
author
abel
committed
Merge branch 'feat/refactor_markets_and_tokens' of https://github.com/InjectiveLabs/sdk-python into feat/refactor_markets_and_tokens
2 parents 115affd + 6e837a8 commit 855a48e

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

pyinjective/composer.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,3 +1048,86 @@ def _initialize_markets_and_tokens_from_files(self):
10481048
self.spot_markets = spot_markets
10491049
self.derivative_markets = derivative_markets
10501050
self.binary_option_markets = dict()
1051+
1052+
def _initialize_markets_and_tokens_from_files(self):
1053+
config: ConfigParser = constant.CONFIGS[self.network]
1054+
spot_markets = dict()
1055+
derivative_markets = dict()
1056+
tokens = dict()
1057+
1058+
for section_name, configuration_section in config.items():
1059+
if section_name.startswith("0x"):
1060+
description = configuration_section["description"]
1061+
1062+
quote_token = Token(
1063+
name="",
1064+
symbol="",
1065+
denom="",
1066+
address="",
1067+
decimals=int(configuration_section["quote"]),
1068+
logo="",
1069+
updated=-1,
1070+
)
1071+
1072+
if "Spot" in description:
1073+
base_token = Token(
1074+
name="",
1075+
symbol="",
1076+
denom="",
1077+
address="",
1078+
decimals=int(configuration_section["base"]),
1079+
logo="",
1080+
updated=-1,
1081+
)
1082+
1083+
market = SpotMarket(
1084+
id=section_name,
1085+
status="",
1086+
ticker=description,
1087+
base_token=base_token,
1088+
quote_token=quote_token,
1089+
maker_fee_rate=None,
1090+
taker_fee_rate=None,
1091+
service_provider_fee=None,
1092+
min_price_tick_size=Decimal(str(configuration_section["min_price_tick_size"])),
1093+
min_quantity_tick_size=Decimal(str(configuration_section["min_quantity_tick_size"]))
1094+
)
1095+
spot_markets[market.id] = market
1096+
else:
1097+
market = DerivativeMarket(
1098+
id=section_name,
1099+
status="",
1100+
ticker=description,
1101+
oracle_base="",
1102+
oracle_quote="",
1103+
oracle_type="",
1104+
oracle_scale_factor=1,
1105+
initial_margin_ratio=None,
1106+
maintenance_margin_ratio=None,
1107+
quote_token=quote_token,
1108+
maker_fee_rate=None,
1109+
taker_fee_rate=None,
1110+
service_provider_fee=None,
1111+
min_price_tick_size=Decimal(str(configuration_section["min_price_tick_size"])),
1112+
min_quantity_tick_size=Decimal(str(configuration_section["min_quantity_tick_size"])),
1113+
)
1114+
1115+
derivative_markets[market.id] = market
1116+
1117+
elif section_name != "DEFAULT":
1118+
token = Token(
1119+
name=section_name,
1120+
symbol=section_name,
1121+
denom=configuration_section["peggy_denom"],
1122+
address="",
1123+
decimals=int(configuration_section["decimals"]),
1124+
logo="",
1125+
updated=-1,
1126+
)
1127+
1128+
tokens[token.symbol] = token
1129+
1130+
self.tokens = tokens
1131+
self.spot_markets = spot_markets
1132+
self.derivative_markets = derivative_markets
1133+
self.binary_option_markets = dict()

tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)