Skip to content

Commit

Permalink
(fix) Added the min_notional field to all market classes. Updated the…
Browse files Browse the repository at this point in the history
… markets initialization logic to parse the min_notional. Added logic to populate the min_notional in the INI files
  • Loading branch information
aarmoa committed Aug 2, 2024
1 parent 7f39b06 commit 734b7e9
Show file tree
Hide file tree
Showing 14 changed files with 1,171 additions and 330 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ async def main() -> None:
fee_recipient = "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"

# set custom denom to bypass ini file load (optional)
denom = Denom(description="desc", base=0, quote=6, min_price_tick_size=1000, min_quantity_tick_size=0.0001)
denom = Denom(
description="desc",
base=0,
quote=6,
min_price_tick_size=1000,
min_quantity_tick_size=0.0001,
min_notional=0,
)

# prepare tx msg
msg = composer.msg_create_binary_options_limit_order(
Expand Down
3 changes: 3 additions & 0 deletions pyinjective/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3324,6 +3324,7 @@ async def _initialize_tokens_and_markets(self):
service_provider_fee=Decimal(market_info["serviceProviderFee"]),
min_price_tick_size=Decimal(market_info["minPriceTickSize"]),
min_quantity_tick_size=Decimal(market_info["minQuantityTickSize"]),
min_notional=Decimal(market_info["minNotional"]),
)

spot_markets[market.id] = market
Expand Down Expand Up @@ -3359,6 +3360,7 @@ async def _initialize_tokens_and_markets(self):
service_provider_fee=Decimal(market_info["serviceProviderFee"]),
min_price_tick_size=Decimal(market_info["minPriceTickSize"]),
min_quantity_tick_size=Decimal(market_info["minQuantityTickSize"]),
min_notional=Decimal(market_info["minNotional"]),
)

derivative_markets[market.id] = market
Expand All @@ -3383,6 +3385,7 @@ async def _initialize_tokens_and_markets(self):
service_provider_fee=Decimal(market_info["serviceProviderFee"]),
min_price_tick_size=Decimal(market_info["minPriceTickSize"]),
min_quantity_tick_size=Decimal(market_info["minQuantityTickSize"]),
min_notional=Decimal(market_info["minNotional"]),
settlement_price=None
if market_info["settlementPrice"] == ""
else Decimal(market_info["settlementPrice"]),
Expand Down
2 changes: 2 additions & 0 deletions pyinjective/composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2484,6 +2484,7 @@ def _initialize_markets_and_tokens_from_files(self):
service_provider_fee=None,
min_price_tick_size=Decimal(str(configuration_section["min_price_tick_size"])),
min_quantity_tick_size=Decimal(str(configuration_section["min_quantity_tick_size"])),
min_notional=Decimal(str(configuration_section.get("min_notional", "0"))),
)
spot_markets[market.id] = market
else:
Expand All @@ -2503,6 +2504,7 @@ def _initialize_markets_and_tokens_from_files(self):
service_provider_fee=None,
min_price_tick_size=Decimal(str(configuration_section["min_price_tick_size"])),
min_quantity_tick_size=Decimal(str(configuration_section["min_quantity_tick_size"])),
min_notional=Decimal(str(configuration_section.get("min_notional", "0"))),
)

derivative_markets[market.id] = market
Expand Down
3 changes: 3 additions & 0 deletions pyinjective/core/market.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class SpotMarket:
service_provider_fee: Decimal
min_price_tick_size: Decimal
min_quantity_tick_size: Decimal
min_notional: Decimal

def quantity_to_chain_format(self, human_readable_value: Decimal) -> Decimal:
chain_formatted_value = human_readable_value * Decimal(f"1e{self.base_token.decimals}")
Expand Down Expand Up @@ -69,6 +70,7 @@ class DerivativeMarket:
service_provider_fee: Decimal
min_price_tick_size: Decimal
min_quantity_tick_size: Decimal
min_notional: Decimal

def quantity_to_chain_format(self, human_readable_value: Decimal) -> Decimal:
# Derivative markets do not have a base market to provide the number of decimals
Expand Down Expand Up @@ -146,6 +148,7 @@ class BinaryOptionMarket:
service_provider_fee: Decimal
min_price_tick_size: Decimal
min_quantity_tick_size: Decimal
min_notional: Decimal
settlement_price: Optional[Decimal] = None

def quantity_to_chain_format(self, human_readable_value: Decimal, special_denom: Optional[Denom] = None) -> Decimal:
Expand Down
33 changes: 33 additions & 0 deletions pyinjective/denoms_devnet.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ min_price_tick_size = 0.000000000000001
min_display_price_tick_size = 0.001
min_quantity_tick_size = 1000000000000000
min_display_quantity_tick_size = 0.001
min_notional = 0

[0x0511ddc4e6586f3bfe1acb2dd905f8b8a82c97e1edaef654b12ca7e6031ca0fa]
description = 'Devnet Spot ATOM/USDT'
Expand All @@ -15,6 +16,7 @@ min_price_tick_size = 0.001
min_display_price_tick_size = 0.001
min_quantity_tick_size = 1000
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0xd1956e20d74eeb1febe31cd37060781ff1cb266f49e0512b446a5fafa9a16034]
description = 'Devnet Spot WETH/USDT'
Expand All @@ -24,6 +26,7 @@ min_price_tick_size = 0.000000000000001
min_display_price_tick_size = 0.001
min_quantity_tick_size = 1000000000000000
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0xe97ebaf3e2ae3bd00dabe59046fcc28ec58ea969df33a9ce95f4fc285306c2d4]
description = 'Devnet Spot WBTC/USDT'
Expand All @@ -33,6 +36,7 @@ min_price_tick_size = 0.000000000000001
min_display_price_tick_size = 0.001
min_quantity_tick_size = 1000000000000000
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0x26413a70c9b78a495023e5ab8003c9cf963ef963f6755f8b57255feb5744bf31]
description = 'Devnet Spot LINK/USDT'
Expand All @@ -42,6 +46,7 @@ min_price_tick_size = 0.000000000000001
min_display_price_tick_size = 0.001
min_quantity_tick_size = 1000000000000000
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0x28f3c9897e23750bf653889224f93390c467b83c86d736af79431958fff833d1]
description = 'Devnet Spot MATIC/USDT'
Expand All @@ -51,6 +56,7 @@ min_price_tick_size = 0.000000000000001
min_display_price_tick_size = 0.001
min_quantity_tick_size = 1000000000000000
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0x74b17b0d6855feba39f1f7ab1e8bad0363bd510ee1dcc74e40c2adfe1502f781]
description = 'Devnet Spot BNB/USDT'
Expand All @@ -60,6 +66,7 @@ min_price_tick_size = 0.000000000000001
min_display_price_tick_size = 0.001
min_quantity_tick_size = 1000000000000000
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0x572f05fd93a6c2c4611b2eba1a0a36e102b6a592781956f0128a27662d84f112]
description = 'Devnet Spot APE/USDT'
Expand All @@ -69,6 +76,7 @@ min_price_tick_size = 0.000000000000001
min_display_price_tick_size = 0.001
min_quantity_tick_size = 1000000000000000
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0x74ee114ad750f8429a97e07b5e73e145724e9b21670a7666625ddacc03d6758d]
description = 'Devnet Spot YFI/USDT'
Expand All @@ -78,6 +86,7 @@ min_price_tick_size = 0.000000000000001
min_display_price_tick_size = 0.001
min_quantity_tick_size = 1000000000000000
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0x7f71c4fba375c964be8db7fc7a5275d974f8c6cdc4d758f2ac4997f106bb052b]
description = 'Devnet Spot GF/USDT'
Expand All @@ -87,6 +96,7 @@ min_price_tick_size = 0.000000000000001
min_display_price_tick_size = 0.001
min_quantity_tick_size = 100000
min_display_quantity_tick_size = 0.0000000000001
min_notional = 1000000

[0x8b1a4d3e8f6b559e30e40922ee3662dd78edf7042330d4d620d188699d1a9715]
description = 'Devnet Spot USDT/USDC'
Expand All @@ -96,6 +106,7 @@ min_price_tick_size = 0.001
min_display_price_tick_size = 0.001
min_quantity_tick_size = 1000
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0]
description = 'Devnet Spot INJ/USDT'
Expand All @@ -105,6 +116,7 @@ min_price_tick_size = 0.000000000000001
min_display_price_tick_size = 0.001
min_quantity_tick_size = 1000000000000000
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0x6fa856bca5a9298ced8da3ef7616e66081ff64e4fdd2bffa38e95cf23c1f2321]
description = 'Devnet Spot PROJ/USDT'
Expand All @@ -114,6 +126,7 @@ min_price_tick_size = 0.001
min_display_price_tick_size = 1000000000
min_quantity_tick_size = 1000
min_display_quantity_tick_size = 0.000000000000001
min_notional = 1000000

[0x0686357b934c761784d58a2b8b12618dfe557de108a220e06f8f6580abb83aab]
description = 'Devnet Spot SOMM/USDT'
Expand All @@ -123,6 +136,7 @@ min_price_tick_size = 0.0001
min_display_price_tick_size = 0.0001
min_quantity_tick_size = 10000000
min_display_quantity_tick_size = 10
min_notional = 1000000

[0x4fa0bd2c2adbfe077f58395c18a72f5cbf89532743e3bddf43bc7aba706b0b74]
description = 'Devnet Spot CHZ/USDC'
Expand All @@ -132,6 +146,7 @@ min_price_tick_size = 0.000001
min_display_price_tick_size = 0.0001
min_quantity_tick_size = 100000000
min_display_quantity_tick_size = 1
min_notional = 1000000

[0x2021159081a88c9a627c66f770fb60c7be78d492509c89b203e1829d0413995a]
description = 'Devnet Spot ETHBTCTrend/USDT'
Expand All @@ -141,6 +156,7 @@ min_price_tick_size = 0.000000000000001
min_display_price_tick_size = 0.001
min_quantity_tick_size = 10000000000000000
min_display_quantity_tick_size = 0.01
min_notional = 1000000

[0xfad0838bf6be7467c6a00d61360f7924afc848e4d0c56cc4261f94e77e124e7a]
description = 'Devnet Spot USDC/USDT'
Expand All @@ -150,6 +166,7 @@ min_price_tick_size = 0.001
min_display_price_tick_size = 0.001
min_quantity_tick_size = 1000
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0xba3101edf6cb94d0b29fd95fb1679f84fe981a98da91a3df1e06809845fab209]
description = 'Devnet Spot WBTC/INJ'
Expand All @@ -159,6 +176,7 @@ min_price_tick_size = 0.001
min_display_price_tick_size = 0.001
min_quantity_tick_size = 10000000000000
min_display_quantity_tick_size = 0.00001
min_notional = 10000000000000000

[0xefc8e0b5bdb799010c9584c59fa14e759009d86c04fa52e0e67b411309096ace]
description = 'Devnet Spot PROJ/INJ'
Expand All @@ -168,6 +186,7 @@ min_price_tick_size = 0.00000001
min_display_price_tick_size = 0.00000001
min_quantity_tick_size = 1000000000000000000000
min_display_quantity_tick_size = 1000
min_notional = 10000000000000000

[0x2d3b8d8833dda54a717adea9119134556848105fd6028e9a4a526e4e5a122a57]
description = 'Devnet Spot KIRA/INJ'
Expand All @@ -177,6 +196,7 @@ min_price_tick_size = 10000
min_display_price_tick_size = 0.00000001
min_quantity_tick_size = 1000000000
min_display_quantity_tick_size = 1000
min_notional = 10000000000000000

[0x42edf70cc37e155e9b9f178e04e18999bc8c404bd7b638cc4cbf41da8ef45a21]
description = 'Devnet Spot QUNT/INJ'
Expand All @@ -186,6 +206,7 @@ min_price_tick_size = 10000
min_display_price_tick_size = 0.00000001
min_quantity_tick_size = 1000000000
min_display_quantity_tick_size = 1000
min_notional = 0

[0xc8fafa1fcab27e16da20e98b4dc9dda45320418c27db80663b21edac72f3b597]
description = 'Devnet Spot HDRO/INJ'
Expand All @@ -195,6 +216,7 @@ min_price_tick_size = 1000000
min_display_price_tick_size = 0.000001
min_quantity_tick_size = 1000000
min_display_quantity_tick_size = 1
min_notional = 10000000000000000

[0xd166688623206f9931307285678e9ff17cecd80a27d7b781dd88cecfba3b1839]
description = 'Devnet Spot BLACK/INJ'
Expand All @@ -204,6 +226,7 @@ min_price_tick_size = 1000000
min_display_price_tick_size = 0.000001
min_quantity_tick_size = 1000000
min_display_quantity_tick_size = 1
min_notional = 10000000000000000

[0x1422a13427d5eabd4d8de7907c8340f7e58cb15553a9fd4ad5c90406561886f9]
description = 'Devnet Derivative COMP/USDT PERP'
Expand All @@ -213,6 +236,7 @@ min_price_tick_size = 1000
min_display_price_tick_size = 0.001
min_quantity_tick_size = 0.001
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0x1c284820f24dff4c60fecd521a9df3df9c745d23dd585d45bf418653c2d73ab4]
description = 'Devnet Derivative SNX/USDT PERP'
Expand All @@ -222,6 +246,7 @@ min_price_tick_size = 1000
min_display_price_tick_size = 0.001
min_quantity_tick_size = 0.001
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0x1f73e21972972c69c03fb105a5864592ac2b47996ffea3c500d1ea2d20138717]
description = 'Devnet Derivative LINK/USDT PERP'
Expand All @@ -231,6 +256,7 @@ min_price_tick_size = 1000
min_display_price_tick_size = 0.001
min_quantity_tick_size = 0.001
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce]
description = 'Devnet Derivative BTC/USDT PERP'
Expand All @@ -240,6 +266,7 @@ min_price_tick_size = 1000
min_display_price_tick_size = 0.001
min_quantity_tick_size = 0.001
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0x7cc8b10d7deb61e744ef83bdec2bbcf4a056867e89b062c6a453020ca82bd4e4]
description = 'Devnet Derivative INJ/USDT PERP'
Expand All @@ -249,6 +276,7 @@ min_price_tick_size = 1000
min_display_price_tick_size = 0.001
min_quantity_tick_size = 0.001
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0x56d0c0293c4415e2d48fc2c8503a56a0c7389247396a2ef9b0a48c01f0646705]
description = 'Devnet Derivative ATOM/USDT PERP'
Expand All @@ -258,6 +286,7 @@ min_price_tick_size = 1000
min_display_price_tick_size = 0.001
min_quantity_tick_size = 0.01
min_display_quantity_tick_size = 0.01
min_notional = 1000000

[0x979731deaaf17d26b2e256ad18fecd0ac742b3746b9ea5382bac9bd0b5e58f74]
description = 'Devnet Derivative ETH/USDT PERP'
Expand All @@ -267,6 +296,7 @@ min_price_tick_size = 1000
min_display_price_tick_size = 0.001
min_quantity_tick_size = 0.001
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0xb64332daa987dcb200c26965bc9adaf8aa301fe3a0aecb0232fadbd3dfccd0d8]
description = 'Devnet Derivative UNI/USDT PERP'
Expand All @@ -276,6 +306,7 @@ min_price_tick_size = 1000
min_display_price_tick_size = 0.001
min_quantity_tick_size = 0.001
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0xccd6723224cae013827668ad1e7f361cde694adbb7a87f62a6d547cc464ba9b5]
description = 'Devnet Derivative GRT/USDT PERP'
Expand All @@ -285,6 +316,7 @@ min_price_tick_size = 1000
min_display_price_tick_size = 0.001
min_quantity_tick_size = 0.001
min_display_quantity_tick_size = 0.001
min_notional = 1000000

[0x3b7fb1d9351f7fa2e6e0e5a11b3639ee5e0486c33a6a74f629c3fc3c3043efd5]
description = 'Devnet Derivative BONK/USDT PERP'
Expand All @@ -294,6 +326,7 @@ min_price_tick_size = 0.0001
min_display_price_tick_size = 0.0000000001
min_quantity_tick_size = 0.1
min_display_quantity_tick_size = 0.1
min_notional = 1000000

[$ALIEN]
peggy_denom = factory/inj1mly2ykhf6f9tdj58pvndjf4q8dzdl4myjqm9t6/$alien
Expand Down
Loading

0 comments on commit 734b7e9

Please sign in to comment.