Skip to content

Commit 9a2c97e

Browse files
committed
Refactor margin usage logging and update enum classes to StrEnum
This commit improves the logging format for margin usage in the market maker bot and updates the Network and CompatVersion classes to inherit from StrEnum for better string representation. These changes enhance code clarity and maintainability.
1 parent 061b0da commit 9a2c97e

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

examples/write/market_maker_bot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
from aptos_sdk.ed25519 import PrivateKey
1010

1111
from decibel import (
12+
NAMED_CONFIGS,
1213
BaseSDKOptions,
1314
DecibelWriteDex,
1415
GasPriceManager,
15-
NAMED_CONFIGS,
1616
PlaceOrderSuccess,
1717
TimeInForce,
1818
amount_to_chain_units,
@@ -237,12 +237,12 @@ async def _run_cycle(
237237
print(
238238
f"\n[cycle {cycle}] mid={mid if mid is not None else 'N/A'} "
239239
f"inventory={inventory:+.6f} "
240-
f"margin={margin_usage*100:.2f}% open_orders={len(open_order_ids)}"
240+
f"margin={margin_usage * 100:.2f}% open_orders={len(open_order_ids)}"
241241
)
242242

243243
if margin_usage > settings.max_margin_usage:
244244
print(
245-
f" paused: margin {margin_usage*100:.2f}% > {settings.max_margin_usage*100:.2f}%"
245+
f" paused: margin {margin_usage * 100:.2f}% > {settings.max_margin_usage * 100:.2f}%"
246246
)
247247
return
248248
if mid is None:

src/decibel/_constants.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from dataclasses import dataclass
4-
from enum import Enum
4+
from enum import StrEnum
55

66
from aptos_sdk.account_address import AccountAddress
77

@@ -32,13 +32,13 @@
3232
DEFAULT_TXN_SUBMIT_TIMEOUT = 10.0
3333

3434

35-
class Network(str, Enum):
35+
class Network(StrEnum):
3636
MAINNET = "mainnet"
3737
TESTNET = "testnet"
3838
CUSTOM = "custom"
3939

4040

41-
class CompatVersion(str, Enum):
41+
class CompatVersion(StrEnum):
4242
V0_4 = "v0.4" # decibel-testnet-release-v0.4 - and final version.
4343

4444

0 commit comments

Comments
 (0)