bittensor-cli 9.7.0__py3-none-any.whl → 9.8.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bittensor_cli/cli.py +339 -23
- bittensor_cli/src/__init__.py +8 -0
- bittensor_cli/src/bittensor/chain_data.py +81 -33
- bittensor_cli/src/bittensor/subtensor_interface.py +33 -15
- bittensor_cli/src/bittensor/utils.py +19 -0
- bittensor_cli/src/commands/liquidity/__init__.py +0 -0
- bittensor_cli/src/commands/liquidity/liquidity.py +628 -0
- bittensor_cli/src/commands/liquidity/utils.py +200 -0
- bittensor_cli/src/commands/stake/add.py +4 -4
- bittensor_cli/src/commands/stake/remove.py +4 -4
- bittensor_cli/src/commands/subnets/subnets.py +6 -0
- bittensor_cli/src/commands/sudo.py +28 -15
- bittensor_cli/src/commands/wallets.py +19 -23
- {bittensor_cli-9.7.0.dist-info → bittensor_cli-9.8.0.dist-info}/METADATA +1 -1
- {bittensor_cli-9.7.0.dist-info → bittensor_cli-9.8.0.dist-info}/RECORD +18 -15
- {bittensor_cli-9.7.0.dist-info → bittensor_cli-9.8.0.dist-info}/WHEEL +0 -0
- {bittensor_cli-9.7.0.dist-info → bittensor_cli-9.8.0.dist-info}/entry_points.txt +0 -0
- {bittensor_cli-9.7.0.dist-info → bittensor_cli-9.8.0.dist-info}/top_level.txt +0 -0
bittensor_cli/cli.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env python3
|
2
2
|
import asyncio
|
3
|
-
import curses
|
4
3
|
import copy
|
4
|
+
import curses
|
5
5
|
import importlib
|
6
6
|
import json
|
7
7
|
import os.path
|
@@ -10,13 +10,13 @@ import ssl
|
|
10
10
|
import sys
|
11
11
|
import traceback
|
12
12
|
import warnings
|
13
|
+
from dataclasses import fields
|
13
14
|
from pathlib import Path
|
14
15
|
from typing import Coroutine, Optional, Union
|
15
|
-
from dataclasses import fields
|
16
16
|
|
17
|
+
import numpy as np
|
17
18
|
import rich
|
18
19
|
import typer
|
19
|
-
import numpy as np
|
20
20
|
from async_substrate_interface.errors import (
|
21
21
|
SubstrateRequestException,
|
22
22
|
ConnectionClosed,
|
@@ -39,21 +39,10 @@ from bittensor_cli.src import (
|
|
39
39
|
COLORS,
|
40
40
|
HYPERPARAMS,
|
41
41
|
)
|
42
|
-
from bittensor_cli.version import __version__, __version_as_int__
|
43
42
|
from bittensor_cli.src.bittensor import utils
|
44
43
|
from bittensor_cli.src.bittensor.balances import Balance
|
45
|
-
from bittensor_cli.src.commands import sudo, wallets, view
|
46
|
-
from bittensor_cli.src.commands import weights as weights_cmds
|
47
|
-
from bittensor_cli.src.commands.subnets import price, subnets
|
48
|
-
from bittensor_cli.src.commands.stake import (
|
49
|
-
children_hotkeys,
|
50
|
-
list as list_stake,
|
51
|
-
move as move_stake,
|
52
|
-
add as add_stake,
|
53
|
-
remove as remove_stake,
|
54
|
-
)
|
55
|
-
from bittensor_cli.src.bittensor.subtensor_interface import SubtensorInterface
|
56
44
|
from bittensor_cli.src.bittensor.chain_data import SubnetHyperparameters
|
45
|
+
from bittensor_cli.src.bittensor.subtensor_interface import SubtensorInterface
|
57
46
|
from bittensor_cli.src.bittensor.utils import (
|
58
47
|
console,
|
59
48
|
err_console,
|
@@ -70,6 +59,22 @@ from bittensor_cli.src.bittensor.utils import (
|
|
70
59
|
prompt_for_subnet_identity,
|
71
60
|
validate_rate_tolerance,
|
72
61
|
)
|
62
|
+
from bittensor_cli.src.commands import sudo, wallets, view
|
63
|
+
from bittensor_cli.src.commands import weights as weights_cmds
|
64
|
+
from bittensor_cli.src.commands.liquidity import liquidity
|
65
|
+
from bittensor_cli.src.commands.liquidity.utils import (
|
66
|
+
prompt_liquidity,
|
67
|
+
prompt_position_id,
|
68
|
+
)
|
69
|
+
from bittensor_cli.src.commands.stake import (
|
70
|
+
children_hotkeys,
|
71
|
+
list as list_stake,
|
72
|
+
move as move_stake,
|
73
|
+
add as add_stake,
|
74
|
+
remove as remove_stake,
|
75
|
+
)
|
76
|
+
from bittensor_cli.src.commands.subnets import price, subnets
|
77
|
+
from bittensor_cli.version import __version__, __version_as_int__
|
73
78
|
|
74
79
|
try:
|
75
80
|
from git import Repo, GitError
|
@@ -656,6 +661,7 @@ class CLIManager:
|
|
656
661
|
self.subnets_app = typer.Typer(epilog=_epilog)
|
657
662
|
self.weights_app = typer.Typer(epilog=_epilog)
|
658
663
|
self.view_app = typer.Typer(epilog=_epilog)
|
664
|
+
self.liquidity_app = typer.Typer(epilog=_epilog)
|
659
665
|
|
660
666
|
# config alias
|
661
667
|
self.app.add_typer(
|
@@ -929,11 +935,13 @@ class CLIManager:
|
|
929
935
|
)(self.view_dashboard)
|
930
936
|
|
931
937
|
# Sub command aliases
|
932
|
-
#
|
938
|
+
# Wallet
|
933
939
|
self.wallet_app.command(
|
934
940
|
"swap_hotkey",
|
935
941
|
hidden=True,
|
936
942
|
)(self.wallet_swap_hotkey)
|
943
|
+
self.wallet_app.command("swap_coldkey", hidden=True)(self.wallet_swap_coldkey)
|
944
|
+
self.wallet_app.command("swap_check", hidden=True)(self.wallet_check_ck_swap)
|
937
945
|
self.wallet_app.command(
|
938
946
|
"regen_coldkey",
|
939
947
|
hidden=True,
|
@@ -962,16 +970,44 @@ class CLIManager:
|
|
962
970
|
"get_identity",
|
963
971
|
hidden=True,
|
964
972
|
)(self.wallet_get_id)
|
973
|
+
self.wallet_app.command("associate_hotkey")(self.wallet_associate_hotkey)
|
965
974
|
|
966
975
|
# Subnets
|
967
976
|
self.subnets_app.command("burn_cost", hidden=True)(self.subnets_burn_cost)
|
968
977
|
self.subnets_app.command("pow_register", hidden=True)(self.subnets_pow_register)
|
978
|
+
self.subnets_app.command("set_identity", hidden=True)(self.subnets_set_identity)
|
979
|
+
self.subnets_app.command("get_identity", hidden=True)(self.subnets_get_identity)
|
980
|
+
self.subnets_app.command("check_start", hidden=True)(self.subnets_check_start)
|
969
981
|
|
970
982
|
# Sudo
|
971
983
|
self.sudo_app.command("senate_vote", hidden=True)(self.sudo_senate_vote)
|
972
984
|
self.sudo_app.command("get_take", hidden=True)(self.sudo_get_take)
|
973
985
|
self.sudo_app.command("set_take", hidden=True)(self.sudo_set_take)
|
974
986
|
|
987
|
+
# Liquidity
|
988
|
+
self.app.add_typer(
|
989
|
+
self.liquidity_app,
|
990
|
+
name="liquidity",
|
991
|
+
short_help="liquidity commands, aliases: `l`",
|
992
|
+
no_args_is_help=True,
|
993
|
+
)
|
994
|
+
self.app.add_typer(
|
995
|
+
self.liquidity_app, name="l", hidden=True, no_args_is_help=True
|
996
|
+
)
|
997
|
+
# liquidity commands
|
998
|
+
self.liquidity_app.command(
|
999
|
+
"add", rich_help_panel=HELP_PANELS["LIQUIDITY"]["LIQUIDITY_MGMT"]
|
1000
|
+
)(self.liquidity_add)
|
1001
|
+
self.liquidity_app.command(
|
1002
|
+
"list", rich_help_panel=HELP_PANELS["LIQUIDITY"]["LIQUIDITY_MGMT"]
|
1003
|
+
)(self.liquidity_list)
|
1004
|
+
self.liquidity_app.command(
|
1005
|
+
"modify", rich_help_panel=HELP_PANELS["LIQUIDITY"]["LIQUIDITY_MGMT"]
|
1006
|
+
)(self.liquidity_modify)
|
1007
|
+
self.liquidity_app.command(
|
1008
|
+
"remove", rich_help_panel=HELP_PANELS["LIQUIDITY"]["LIQUIDITY_MGMT"]
|
1009
|
+
)(self.liquidity_remove)
|
1010
|
+
|
975
1011
|
def generate_command_tree(self) -> Tree:
|
976
1012
|
"""
|
977
1013
|
Generates a rich.Tree of the commands, subcommands, and groups of this app
|
@@ -1603,7 +1639,8 @@ class CLIManager:
|
|
1603
1639
|
wallet_hotkey: Optional[str],
|
1604
1640
|
ask_for: Optional[list[str]] = None,
|
1605
1641
|
validate: WV = WV.WALLET,
|
1606
|
-
|
1642
|
+
return_wallet_and_hotkey: bool = False,
|
1643
|
+
) -> Union[Wallet, tuple[Wallet, str]]:
|
1607
1644
|
"""
|
1608
1645
|
Generates a wallet object based on supplied values, validating the wallet is valid if flag is set
|
1609
1646
|
:param wallet_name: name of the wallet
|
@@ -1611,7 +1648,8 @@ class CLIManager:
|
|
1611
1648
|
:param wallet_hotkey: name of the wallet hotkey file
|
1612
1649
|
:param validate: flag whether to check for the wallet's validity
|
1613
1650
|
:param ask_for: aspect of the wallet (name, path, hotkey) to prompt the user for
|
1614
|
-
:
|
1651
|
+
:param return_wallet_and_hotkey: if specified, will return both the wallet object, and the hotkey SS58
|
1652
|
+
:return: created Wallet object (or wallet, hotkey ss58)
|
1615
1653
|
"""
|
1616
1654
|
ask_for = ask_for or []
|
1617
1655
|
# Prompt for missing attributes specified in ask_for
|
@@ -1636,8 +1674,9 @@ class CLIManager:
|
|
1636
1674
|
)
|
1637
1675
|
else:
|
1638
1676
|
wallet_hotkey = Prompt.ask(
|
1639
|
-
"Enter the [blue]wallet hotkey[/blue]"
|
1640
|
-
|
1677
|
+
"Enter the [blue]wallet hotkey[/blue][dark_sea_green3 italic]"
|
1678
|
+
"(Hint: You can set this with `btcli config set --wallet-hotkey`)"
|
1679
|
+
"[/dark_sea_green3 italic]",
|
1641
1680
|
default=defaults.wallet.hotkey,
|
1642
1681
|
)
|
1643
1682
|
if wallet_path:
|
@@ -1655,7 +1694,8 @@ class CLIManager:
|
|
1655
1694
|
if WO.PATH in ask_for and not wallet_path:
|
1656
1695
|
wallet_path = Prompt.ask(
|
1657
1696
|
"Enter the [blue]wallet path[/blue]"
|
1658
|
-
|
1697
|
+
"[dark_sea_green3 italic](Hint: You can set this with `btcli config set --wallet-path`)"
|
1698
|
+
"[/dark_sea_green3 italic]",
|
1659
1699
|
default=defaults.wallet.path,
|
1660
1700
|
)
|
1661
1701
|
# Create the Wallet object
|
@@ -1679,7 +1719,28 @@ class CLIManager:
|
|
1679
1719
|
f"Please verify your wallet information: {wallet}[/red]"
|
1680
1720
|
)
|
1681
1721
|
raise typer.Exit()
|
1682
|
-
|
1722
|
+
if return_wallet_and_hotkey:
|
1723
|
+
valid = utils.is_valid_wallet(wallet)
|
1724
|
+
if valid[1]:
|
1725
|
+
return wallet, wallet.hotkey.ss58_address
|
1726
|
+
else:
|
1727
|
+
if wallet_hotkey and is_valid_ss58_address(wallet_hotkey):
|
1728
|
+
return wallet, wallet_hotkey
|
1729
|
+
else:
|
1730
|
+
hotkey = (
|
1731
|
+
Prompt.ask(
|
1732
|
+
"Enter the SS58 of the hotkey to use for this transaction."
|
1733
|
+
)
|
1734
|
+
).strip()
|
1735
|
+
if not is_valid_ss58_address(hotkey):
|
1736
|
+
err_console.print(
|
1737
|
+
f"[red]Error: {hotkey} is not valid SS58 address."
|
1738
|
+
)
|
1739
|
+
raise typer.Exit(1)
|
1740
|
+
else:
|
1741
|
+
return wallet, hotkey
|
1742
|
+
else:
|
1743
|
+
return wallet
|
1683
1744
|
|
1684
1745
|
def wallet_list(
|
1685
1746
|
self,
|
@@ -5025,6 +5086,7 @@ class CLIManager:
|
|
5025
5086
|
description: Optional[str] = typer.Option(
|
5026
5087
|
None, "--description", help="Description"
|
5027
5088
|
),
|
5089
|
+
logo_url: Optional[str] = typer.Option(None, "--logo-url", help="Logo URL"),
|
5028
5090
|
additional_info: Optional[str] = typer.Option(
|
5029
5091
|
None, "--additional-info", help="Additional information"
|
5030
5092
|
),
|
@@ -5067,6 +5129,7 @@ class CLIManager:
|
|
5067
5129
|
subnet_url=subnet_url,
|
5068
5130
|
discord=discord,
|
5069
5131
|
description=description,
|
5132
|
+
logo_url=logo_url,
|
5070
5133
|
additional=additional_info,
|
5071
5134
|
)
|
5072
5135
|
self._run_command(
|
@@ -5088,7 +5151,7 @@ class CLIManager:
|
|
5088
5151
|
This command verifies if a subnet's emission schedule can be started based on the subnet's registration block.
|
5089
5152
|
|
5090
5153
|
Example:
|
5091
|
-
[green]$[/green] btcli subnets
|
5154
|
+
[green]$[/green] btcli subnets check-start --netuid 1
|
5092
5155
|
"""
|
5093
5156
|
self.verbosity_handler(quiet, verbose)
|
5094
5157
|
return self._run_command(
|
@@ -5190,6 +5253,7 @@ class CLIManager:
|
|
5190
5253
|
description: Optional[str] = typer.Option(
|
5191
5254
|
None, "--description", help="Description"
|
5192
5255
|
),
|
5256
|
+
logo_url: Optional[str] = typer.Option(None, "--logo-url", help="Logo URL"),
|
5193
5257
|
additional_info: Optional[str] = typer.Option(
|
5194
5258
|
None, "--additional-info", help="Additional information"
|
5195
5259
|
),
|
@@ -5241,6 +5305,7 @@ class CLIManager:
|
|
5241
5305
|
subnet_url=subnet_url,
|
5242
5306
|
discord=discord,
|
5243
5307
|
description=description,
|
5308
|
+
logo_url=logo_url,
|
5244
5309
|
additional=additional_info,
|
5245
5310
|
)
|
5246
5311
|
|
@@ -5752,6 +5817,257 @@ class CLIManager:
|
|
5752
5817
|
)
|
5753
5818
|
)
|
5754
5819
|
|
5820
|
+
def liquidity_add(
|
5821
|
+
self,
|
5822
|
+
network: Optional[list[str]] = Options.network,
|
5823
|
+
wallet_name: str = Options.wallet_name,
|
5824
|
+
wallet_path: str = Options.wallet_path,
|
5825
|
+
wallet_hotkey: str = Options.wallet_hotkey,
|
5826
|
+
netuid: Optional[int] = Options.netuid,
|
5827
|
+
liquidity_: Optional[float] = typer.Option(
|
5828
|
+
None,
|
5829
|
+
"--liquidity",
|
5830
|
+
help="Amount of liquidity to add to the subnet.",
|
5831
|
+
),
|
5832
|
+
price_low: Optional[float] = typer.Option(
|
5833
|
+
None,
|
5834
|
+
"--price-low",
|
5835
|
+
"--price_low",
|
5836
|
+
"--liquidity-price-low",
|
5837
|
+
"--liquidity_price_low",
|
5838
|
+
help="Low price for the adding liquidity position.",
|
5839
|
+
),
|
5840
|
+
price_high: Optional[float] = typer.Option(
|
5841
|
+
None,
|
5842
|
+
"--price-high",
|
5843
|
+
"--price_high",
|
5844
|
+
"--liquidity-price-high",
|
5845
|
+
"--liquidity_price_high",
|
5846
|
+
help="High price for the adding liquidity position.",
|
5847
|
+
),
|
5848
|
+
prompt: bool = Options.prompt,
|
5849
|
+
quiet: bool = Options.quiet,
|
5850
|
+
verbose: bool = Options.verbose,
|
5851
|
+
json_output: bool = Options.json_output,
|
5852
|
+
):
|
5853
|
+
"""Add liquidity to the swap (as a combination of TAO + Alpha)."""
|
5854
|
+
self.verbosity_handler(quiet, verbose, json_output)
|
5855
|
+
if not netuid:
|
5856
|
+
netuid = Prompt.ask(
|
5857
|
+
f"Enter the [{COLORS.G.SUBHEAD_MAIN}]netuid[/{COLORS.G.SUBHEAD_MAIN}] to use",
|
5858
|
+
default=None,
|
5859
|
+
show_default=False,
|
5860
|
+
)
|
5861
|
+
|
5862
|
+
wallet, hotkey = self.wallet_ask(
|
5863
|
+
wallet_name=wallet_name,
|
5864
|
+
wallet_path=wallet_path,
|
5865
|
+
wallet_hotkey=wallet_hotkey,
|
5866
|
+
ask_for=[WO.NAME, WO.HOTKEY, WO.PATH],
|
5867
|
+
validate=WV.WALLET,
|
5868
|
+
return_wallet_and_hotkey=True,
|
5869
|
+
)
|
5870
|
+
# Determine the liquidity amount.
|
5871
|
+
if liquidity_:
|
5872
|
+
liquidity_ = Balance.from_tao(liquidity_)
|
5873
|
+
else:
|
5874
|
+
liquidity_ = prompt_liquidity("Enter the amount of liquidity")
|
5875
|
+
|
5876
|
+
# Determine price range
|
5877
|
+
if price_low:
|
5878
|
+
price_low = Balance.from_tao(price_low)
|
5879
|
+
else:
|
5880
|
+
price_low = prompt_liquidity("Enter liquidity position low price")
|
5881
|
+
|
5882
|
+
if price_high:
|
5883
|
+
price_high = Balance.from_tao(price_high)
|
5884
|
+
else:
|
5885
|
+
price_high = prompt_liquidity(
|
5886
|
+
"Enter liquidity position high price (must be greater than low price)"
|
5887
|
+
)
|
5888
|
+
|
5889
|
+
if price_low >= price_high:
|
5890
|
+
err_console.print("The low price must be lower than the high price.")
|
5891
|
+
return False
|
5892
|
+
|
5893
|
+
return self._run_command(
|
5894
|
+
liquidity.add_liquidity(
|
5895
|
+
subtensor=self.initialize_chain(network),
|
5896
|
+
wallet=wallet,
|
5897
|
+
hotkey_ss58=hotkey,
|
5898
|
+
netuid=netuid,
|
5899
|
+
liquidity=liquidity_,
|
5900
|
+
price_low=price_low,
|
5901
|
+
price_high=price_high,
|
5902
|
+
prompt=prompt,
|
5903
|
+
json_output=json_output,
|
5904
|
+
)
|
5905
|
+
)
|
5906
|
+
|
5907
|
+
def liquidity_list(
|
5908
|
+
self,
|
5909
|
+
network: Optional[list[str]] = Options.network,
|
5910
|
+
wallet_name: str = Options.wallet_name,
|
5911
|
+
wallet_path: str = Options.wallet_path,
|
5912
|
+
wallet_hotkey: str = Options.wallet_hotkey,
|
5913
|
+
netuid: Optional[int] = Options.netuid,
|
5914
|
+
quiet: bool = Options.quiet,
|
5915
|
+
verbose: bool = Options.verbose,
|
5916
|
+
json_output: bool = Options.json_output,
|
5917
|
+
):
|
5918
|
+
"""Displays liquidity positions in given subnet."""
|
5919
|
+
self.verbosity_handler(quiet, verbose, json_output)
|
5920
|
+
if not netuid:
|
5921
|
+
netuid = IntPrompt.ask(
|
5922
|
+
f"Enter the [{COLORS.G.SUBHEAD_MAIN}]netuid[/{COLORS.G.SUBHEAD_MAIN}] to use",
|
5923
|
+
default=None,
|
5924
|
+
show_default=False,
|
5925
|
+
)
|
5926
|
+
|
5927
|
+
wallet = self.wallet_ask(
|
5928
|
+
wallet_name=wallet_name,
|
5929
|
+
wallet_path=wallet_path,
|
5930
|
+
wallet_hotkey=wallet_hotkey,
|
5931
|
+
ask_for=[WO.NAME, WO.PATH],
|
5932
|
+
validate=WV.WALLET,
|
5933
|
+
)
|
5934
|
+
self._run_command(
|
5935
|
+
liquidity.show_liquidity_list(
|
5936
|
+
subtensor=self.initialize_chain(network),
|
5937
|
+
wallet=wallet,
|
5938
|
+
netuid=netuid,
|
5939
|
+
json_output=json_output,
|
5940
|
+
)
|
5941
|
+
)
|
5942
|
+
|
5943
|
+
def liquidity_remove(
|
5944
|
+
self,
|
5945
|
+
network: Optional[list[str]] = Options.network,
|
5946
|
+
wallet_name: str = Options.wallet_name,
|
5947
|
+
wallet_path: str = Options.wallet_path,
|
5948
|
+
wallet_hotkey: str = Options.wallet_hotkey,
|
5949
|
+
netuid: Optional[int] = Options.netuid,
|
5950
|
+
position_id: Optional[int] = typer.Option(
|
5951
|
+
None,
|
5952
|
+
"--position-id",
|
5953
|
+
"--position_id",
|
5954
|
+
help="Position ID for modification or removal.",
|
5955
|
+
),
|
5956
|
+
all_liquidity_ids: Optional[bool] = typer.Option(
|
5957
|
+
False,
|
5958
|
+
"--all",
|
5959
|
+
"--a",
|
5960
|
+
help="Whether to remove all liquidity positions for given subnet.",
|
5961
|
+
),
|
5962
|
+
prompt: bool = Options.prompt,
|
5963
|
+
quiet: bool = Options.quiet,
|
5964
|
+
verbose: bool = Options.verbose,
|
5965
|
+
json_output: bool = Options.json_output,
|
5966
|
+
):
|
5967
|
+
"""Remove liquidity from the swap (as a combination of TAO + Alpha)."""
|
5968
|
+
|
5969
|
+
self.verbosity_handler(quiet, verbose, json_output)
|
5970
|
+
|
5971
|
+
if all_liquidity_ids and position_id:
|
5972
|
+
print_error("Cannot specify both --all and --position-id.")
|
5973
|
+
return
|
5974
|
+
|
5975
|
+
if not position_id and not all_liquidity_ids:
|
5976
|
+
position_id = prompt_position_id()
|
5977
|
+
|
5978
|
+
if not netuid:
|
5979
|
+
netuid = IntPrompt.ask(
|
5980
|
+
f"Enter the [{COLORS.G.SUBHEAD_MAIN}]netuid[/{COLORS.G.SUBHEAD_MAIN}] to use",
|
5981
|
+
default=None,
|
5982
|
+
show_default=False,
|
5983
|
+
)
|
5984
|
+
|
5985
|
+
wallet, hotkey = self.wallet_ask(
|
5986
|
+
wallet_name=wallet_name,
|
5987
|
+
wallet_path=wallet_path,
|
5988
|
+
wallet_hotkey=wallet_hotkey,
|
5989
|
+
ask_for=[WO.NAME, WO.HOTKEY, WO.PATH],
|
5990
|
+
validate=WV.WALLET,
|
5991
|
+
return_wallet_and_hotkey=True,
|
5992
|
+
)
|
5993
|
+
return self._run_command(
|
5994
|
+
liquidity.remove_liquidity(
|
5995
|
+
subtensor=self.initialize_chain(network),
|
5996
|
+
wallet=wallet,
|
5997
|
+
hotkey_ss58=hotkey,
|
5998
|
+
netuid=netuid,
|
5999
|
+
position_id=position_id,
|
6000
|
+
prompt=prompt,
|
6001
|
+
all_liquidity_ids=all_liquidity_ids,
|
6002
|
+
json_output=json_output,
|
6003
|
+
)
|
6004
|
+
)
|
6005
|
+
|
6006
|
+
def liquidity_modify(
|
6007
|
+
self,
|
6008
|
+
network: Optional[list[str]] = Options.network,
|
6009
|
+
wallet_name: str = Options.wallet_name,
|
6010
|
+
wallet_path: str = Options.wallet_path,
|
6011
|
+
wallet_hotkey: str = Options.wallet_hotkey,
|
6012
|
+
netuid: Optional[int] = Options.netuid,
|
6013
|
+
position_id: Optional[int] = typer.Option(
|
6014
|
+
None,
|
6015
|
+
"--position-id",
|
6016
|
+
"--position_id",
|
6017
|
+
help="Position ID for modification or removing.",
|
6018
|
+
),
|
6019
|
+
liquidity_delta: Optional[float] = typer.Option(
|
6020
|
+
None,
|
6021
|
+
"--liquidity-delta",
|
6022
|
+
"--liquidity_delta",
|
6023
|
+
help="Liquidity amount for modification.",
|
6024
|
+
),
|
6025
|
+
prompt: bool = Options.prompt,
|
6026
|
+
quiet: bool = Options.quiet,
|
6027
|
+
verbose: bool = Options.verbose,
|
6028
|
+
json_output: bool = Options.json_output,
|
6029
|
+
):
|
6030
|
+
"""Modifies the liquidity position for the given subnet."""
|
6031
|
+
self.verbosity_handler(quiet, verbose, json_output)
|
6032
|
+
if not netuid:
|
6033
|
+
netuid = IntPrompt.ask(
|
6034
|
+
f"Enter the [{COLORS.G.SUBHEAD_MAIN}]netuid[/{COLORS.G.SUBHEAD_MAIN}] to use",
|
6035
|
+
)
|
6036
|
+
|
6037
|
+
wallet, hotkey = self.wallet_ask(
|
6038
|
+
wallet_name=wallet_name,
|
6039
|
+
wallet_path=wallet_path,
|
6040
|
+
wallet_hotkey=wallet_hotkey,
|
6041
|
+
ask_for=[WO.NAME, WO.HOTKEY, WO.PATH],
|
6042
|
+
validate=WV.WALLET,
|
6043
|
+
return_wallet_and_hotkey=True,
|
6044
|
+
)
|
6045
|
+
|
6046
|
+
if not position_id:
|
6047
|
+
position_id = prompt_position_id()
|
6048
|
+
|
6049
|
+
if liquidity_delta:
|
6050
|
+
liquidity_delta = Balance.from_tao(liquidity_delta)
|
6051
|
+
else:
|
6052
|
+
liquidity_delta = prompt_liquidity(
|
6053
|
+
f"Enter the [blue]liquidity delta[/blue] to modify position with id "
|
6054
|
+
f"[blue]{position_id}[/blue] (can be positive or negative)",
|
6055
|
+
negative_allowed=True,
|
6056
|
+
)
|
6057
|
+
|
6058
|
+
return self._run_command(
|
6059
|
+
liquidity.modify_liquidity(
|
6060
|
+
subtensor=self.initialize_chain(network),
|
6061
|
+
wallet=wallet,
|
6062
|
+
hotkey_ss58=hotkey,
|
6063
|
+
netuid=netuid,
|
6064
|
+
position_id=position_id,
|
6065
|
+
liquidity_delta=liquidity_delta,
|
6066
|
+
prompt=prompt,
|
6067
|
+
json_output=json_output,
|
6068
|
+
)
|
6069
|
+
)
|
6070
|
+
|
5755
6071
|
@staticmethod
|
5756
6072
|
@utils_app.command("convert")
|
5757
6073
|
def convert(
|
bittensor_cli/src/__init__.py
CHANGED
@@ -660,6 +660,11 @@ HYPERPARAMS = {
|
|
660
660
|
),
|
661
661
|
"yuma3_enabled": ("sudo_set_yuma3_enabled", False),
|
662
662
|
"alpha_sigmoid_steepness": ("sudo_set_alpha_sigmoid_steepness", True),
|
663
|
+
"user_liquidity_enabled": ("toggle_user_liquidity", True),
|
664
|
+
}
|
665
|
+
|
666
|
+
HYPERPARAMS_MODULE = {
|
667
|
+
"user_liquidity_enabled": "Swap",
|
663
668
|
}
|
664
669
|
|
665
670
|
# Help Panels for cli help
|
@@ -699,6 +704,9 @@ HELP_PANELS = {
|
|
699
704
|
"VIEW": {
|
700
705
|
"DASHBOARD": "Network Dashboard",
|
701
706
|
},
|
707
|
+
"LIQUIDITY": {
|
708
|
+
"LIQUIDITY_MGMT": "Liquidity Management",
|
709
|
+
},
|
702
710
|
}
|
703
711
|
|
704
712
|
|
@@ -148,13 +148,49 @@ class InfoBase:
|
|
148
148
|
|
149
149
|
@dataclass
|
150
150
|
class SubnetHyperparameters(InfoBase):
|
151
|
-
"""
|
151
|
+
"""
|
152
|
+
This class represents the hyperparameters for a subnet.
|
153
|
+
Attributes:
|
154
|
+
rho (int): The rate of decay of some value.
|
155
|
+
kappa (int): A constant multiplier used in calculations.
|
156
|
+
immunity_period (int): The period during which immunity is active.
|
157
|
+
min_allowed_weights (int): Minimum allowed weights.
|
158
|
+
max_weight_limit (float): Maximum weight limit.
|
159
|
+
tempo (int): The tempo or rate of operation.
|
160
|
+
min_difficulty (int): Minimum difficulty for some operations.
|
161
|
+
max_difficulty (int): Maximum difficulty for some operations.
|
162
|
+
weights_version (int): The version number of the weights used.
|
163
|
+
weights_rate_limit (int): Rate limit for processing weights.
|
164
|
+
adjustment_interval (int): Interval at which adjustments are made.
|
165
|
+
activity_cutoff (int): Activity cutoff threshold.
|
166
|
+
registration_allowed (bool): Indicates if registration is allowed.
|
167
|
+
target_regs_per_interval (int): Target number of registrations per interval.
|
168
|
+
min_burn (int): Minimum burn value.
|
169
|
+
max_burn (int): Maximum burn value.
|
170
|
+
bonds_moving_avg (int): Moving average of bonds.
|
171
|
+
max_regs_per_block (int): Maximum number of registrations per block.
|
172
|
+
serving_rate_limit (int): Limit on the rate of service.
|
173
|
+
max_validators (int): Maximum number of validators.
|
174
|
+
adjustment_alpha (int): Alpha value for adjustments.
|
175
|
+
difficulty (int): Difficulty level.
|
176
|
+
commit_reveal_period (int): Interval for commit-reveal weights.
|
177
|
+
commit_reveal_weights_enabled (bool): Flag indicating if commit-reveal weights are enabled.
|
178
|
+
alpha_high (int): High value of alpha.
|
179
|
+
alpha_low (int): Low value of alpha.
|
180
|
+
liquid_alpha_enabled (bool): Flag indicating if liquid alpha is enabled.
|
181
|
+
alpha_sigmoid_steepness (float):
|
182
|
+
yuma_version (int): Version of yuma.
|
183
|
+
subnet_is_active (bool): Indicates if subnet is active after START CALL.
|
184
|
+
transfers_enabled (bool): Flag indicating if transfers are enabled.
|
185
|
+
bonds_reset_enabled (bool): Flag indicating if bonds are reset enabled.
|
186
|
+
user_liquidity_enabled (bool): Flag indicating if user liquidity is enabled.
|
187
|
+
"""
|
152
188
|
|
153
189
|
rho: int
|
154
190
|
kappa: int
|
155
191
|
immunity_period: int
|
156
192
|
min_allowed_weights: int
|
157
|
-
|
193
|
+
max_weight_limit: float
|
158
194
|
tempo: int
|
159
195
|
min_difficulty: int
|
160
196
|
max_difficulty: int
|
@@ -177,43 +213,53 @@ class SubnetHyperparameters(InfoBase):
|
|
177
213
|
alpha_high: int
|
178
214
|
alpha_low: int
|
179
215
|
liquid_alpha_enabled: bool
|
180
|
-
|
181
|
-
|
216
|
+
alpha_sigmoid_steepness: float
|
217
|
+
yuma_version: int
|
218
|
+
subnet_is_active: bool
|
219
|
+
transfers_enabled: bool
|
220
|
+
bonds_reset_enabled: bool
|
221
|
+
user_liquidity_enabled: bool
|
182
222
|
|
183
223
|
@classmethod
|
184
224
|
def _fix_decoded(
|
185
225
|
cls, decoded: Union[dict, "SubnetHyperparameters"]
|
186
226
|
) -> "SubnetHyperparameters":
|
187
227
|
return cls(
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
max_validators=decoded
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
228
|
+
activity_cutoff=decoded["activity_cutoff"],
|
229
|
+
adjustment_alpha=decoded["adjustment_alpha"],
|
230
|
+
adjustment_interval=decoded["adjustment_interval"],
|
231
|
+
alpha_high=decoded["alpha_high"],
|
232
|
+
alpha_low=decoded["alpha_low"],
|
233
|
+
alpha_sigmoid_steepness=fixed_to_float(
|
234
|
+
decoded["alpha_sigmoid_steepness"], frac_bits=32
|
235
|
+
),
|
236
|
+
bonds_moving_avg=decoded["bonds_moving_avg"],
|
237
|
+
bonds_reset_enabled=decoded["bonds_reset_enabled"],
|
238
|
+
commit_reveal_weights_enabled=decoded["commit_reveal_weights_enabled"],
|
239
|
+
commit_reveal_period=decoded["commit_reveal_period"],
|
240
|
+
difficulty=decoded["difficulty"],
|
241
|
+
immunity_period=decoded["immunity_period"],
|
242
|
+
kappa=decoded["kappa"],
|
243
|
+
liquid_alpha_enabled=decoded["liquid_alpha_enabled"],
|
244
|
+
max_burn=decoded["max_burn"],
|
245
|
+
max_difficulty=decoded["max_difficulty"],
|
246
|
+
max_regs_per_block=decoded["max_regs_per_block"],
|
247
|
+
max_validators=decoded["max_validators"],
|
248
|
+
max_weight_limit=decoded["max_weights_limit"],
|
249
|
+
min_allowed_weights=decoded["min_allowed_weights"],
|
250
|
+
min_burn=decoded["min_burn"],
|
251
|
+
min_difficulty=decoded["min_difficulty"],
|
252
|
+
registration_allowed=decoded["registration_allowed"],
|
253
|
+
rho=decoded["rho"],
|
254
|
+
serving_rate_limit=decoded["serving_rate_limit"],
|
255
|
+
subnet_is_active=decoded["subnet_is_active"],
|
256
|
+
target_regs_per_interval=decoded["target_regs_per_interval"],
|
257
|
+
tempo=decoded["tempo"],
|
258
|
+
transfers_enabled=decoded["transfers_enabled"],
|
259
|
+
user_liquidity_enabled=decoded["user_liquidity_enabled"],
|
260
|
+
weights_rate_limit=decoded["weights_rate_limit"],
|
261
|
+
weights_version=decoded["weights_version"],
|
262
|
+
yuma_version=decoded["yuma_version"],
|
217
263
|
)
|
218
264
|
|
219
265
|
|
@@ -630,6 +676,7 @@ class SubnetIdentity(InfoBase):
|
|
630
676
|
subnet_url: str
|
631
677
|
discord: str
|
632
678
|
description: str
|
679
|
+
logo_url: str
|
633
680
|
additional: str
|
634
681
|
|
635
682
|
@classmethod
|
@@ -641,6 +688,7 @@ class SubnetIdentity(InfoBase):
|
|
641
688
|
subnet_url=bytes(decoded["subnet_url"]).decode(),
|
642
689
|
discord=bytes(decoded["discord"]).decode(),
|
643
690
|
description=bytes(decoded["description"]).decode(),
|
691
|
+
logo_url=bytes(decoded["logo_url"]).decode(),
|
644
692
|
additional=bytes(decoded["additional"]).decode(),
|
645
693
|
)
|
646
694
|
|