async-hyperliquid 0.3.8__tar.gz → 0.3.10__tar.gz
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.
- {async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/PKG-INFO +1 -1
- {async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/pyproject.toml +1 -1
- {async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/src/async_hyperliquid/async_hyperliquid.py +33 -0
- {async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/src/async_hyperliquid/exchange.py +1 -1
- {async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/src/async_hyperliquid/info.py +4 -0
- {async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/src/async_hyperliquid/utils/constants.py +7 -0
- {async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/src/async_hyperliquid/utils/decorators.py +1 -1
- {async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/src/async_hyperliquid/utils/signing.py +16 -3
- {async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/src/async_hyperliquid/utils/types.py +4 -0
- {async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/LICENSE +0 -0
- {async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/README.md +0 -0
- {async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/src/async_hyperliquid/__init__.py +0 -0
- {async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/src/async_hyperliquid/async_api.py +0 -0
- {async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/src/async_hyperliquid/utils/__init__.py +0 -0
- {async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/src/async_hyperliquid/utils/miscs.py +0 -0
{async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/src/async_hyperliquid/async_hyperliquid.py
RENAMED
|
@@ -28,6 +28,7 @@ from async_hyperliquid.utils.types import (
|
|
|
28
28
|
OrderType,
|
|
29
29
|
Portfolio,
|
|
30
30
|
LimitOrder,
|
|
31
|
+
Abstraction,
|
|
31
32
|
UserDeposit,
|
|
32
33
|
AccountState,
|
|
33
34
|
GroupOptions,
|
|
@@ -58,6 +59,7 @@ from async_hyperliquid.utils.signing import (
|
|
|
58
59
|
sign_usd_class_transfer_action,
|
|
59
60
|
sign_approve_builder_fee_action,
|
|
60
61
|
sign_user_dex_abstraction_action,
|
|
62
|
+
sign_user_set_abstraction_action,
|
|
61
63
|
sign_convert_to_multi_sig_user_action,
|
|
62
64
|
)
|
|
63
65
|
from async_hyperliquid.utils.constants import (
|
|
@@ -499,6 +501,18 @@ class AsyncHyperliquid(AsyncAPI):
|
|
|
499
501
|
positions.extend(result)
|
|
500
502
|
return positions
|
|
501
503
|
|
|
504
|
+
async def get_user_dex_abstraction(self, address: str | None) -> bool:
|
|
505
|
+
if not address:
|
|
506
|
+
address = self.address
|
|
507
|
+
return await self.info.get_user_dex_abstraction(address)
|
|
508
|
+
|
|
509
|
+
async def get_user_abstraction_state(
|
|
510
|
+
self, address: str | None = None
|
|
511
|
+
) -> str:
|
|
512
|
+
if not address:
|
|
513
|
+
address = self.address
|
|
514
|
+
return await self.info.get_user_abstraction_state(address)
|
|
515
|
+
|
|
502
516
|
# Exchange API
|
|
503
517
|
async def _round_sz_px(self, coin: str, sz: float, px: float):
|
|
504
518
|
asset = await self.get_coin_asset(coin)
|
|
@@ -1020,5 +1034,24 @@ class AsyncHyperliquid(AsyncAPI):
|
|
|
1020
1034
|
action, vault=self.vault, expires=self.expires
|
|
1021
1035
|
)
|
|
1022
1036
|
|
|
1037
|
+
async def user_set_abstraction(
|
|
1038
|
+
self, abstraction: Abstraction, address: str | None = None
|
|
1039
|
+
):
|
|
1040
|
+
if address is None:
|
|
1041
|
+
address = self.address
|
|
1042
|
+
|
|
1043
|
+
nonce = get_timestamp_ms()
|
|
1044
|
+
action = {
|
|
1045
|
+
"type": "userSetAbstraction",
|
|
1046
|
+
"user": address.lower(),
|
|
1047
|
+
"abstraction": abstraction,
|
|
1048
|
+
"nonce": nonce,
|
|
1049
|
+
}
|
|
1050
|
+
sig = sign_user_set_abstraction_action(
|
|
1051
|
+
self.account, action, self.is_mainnet
|
|
1052
|
+
)
|
|
1053
|
+
|
|
1054
|
+
return await self.exchange.post_action_with_sig(action, sig, nonce)
|
|
1055
|
+
|
|
1023
1056
|
|
|
1024
1057
|
AsyncHyper = AsyncHyperliquid
|
|
@@ -25,7 +25,7 @@ class ExchangeAPI(AsyncAPI):
|
|
|
25
25
|
address: str | None = None,
|
|
26
26
|
):
|
|
27
27
|
self.account = account
|
|
28
|
-
self.address = address or account.address
|
|
28
|
+
self.address = address or account.address
|
|
29
29
|
self.is_mainnet = base_url == MAINNET_API_URL
|
|
30
30
|
super().__init__(Endpoint.EXCHANGE, base_url, session)
|
|
31
31
|
|
|
@@ -183,6 +183,10 @@ class InfoAPI(AsyncAPI):
|
|
|
183
183
|
payload = {"type": "userDexAbstraction", "user": address}
|
|
184
184
|
return await self.post(payload)
|
|
185
185
|
|
|
186
|
+
async def get_user_abstraction_state(self, address: str) -> str:
|
|
187
|
+
payload = {"type": "userAbstraction", "user": address}
|
|
188
|
+
return await self.post(payload)
|
|
189
|
+
|
|
186
190
|
async def get_aligned_quote_token_status(self, token: int):
|
|
187
191
|
payload = {"type": "alignedQuoteTokenInfo", "token": token}
|
|
188
192
|
return await self.post(payload)
|
{async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/src/async_hyperliquid/utils/constants.py
RENAMED
|
@@ -99,3 +99,10 @@ USER_DEX_ABSTRACTION_SIGN_TYPES = [
|
|
|
99
99
|
{"name": "enabled", "type": "bool"},
|
|
100
100
|
{"name": "nonce", "type": "uint64"},
|
|
101
101
|
]
|
|
102
|
+
|
|
103
|
+
USER_SET_ABSTRACTION_SIGN_TYPES = [
|
|
104
|
+
{"name": "hyperliquidChain", "type": "string"},
|
|
105
|
+
{"name": "user", "type": "address"},
|
|
106
|
+
{"name": "abstraction", "type": "string"},
|
|
107
|
+
{"name": "nonce", "type": "uint64"},
|
|
108
|
+
]
|
{async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/src/async_hyperliquid/utils/decorators.py
RENAMED
|
@@ -11,7 +11,7 @@ def private_key_required(
|
|
|
11
11
|
async def wrapper(self, *args, **kwargs) -> T:
|
|
12
12
|
if self.account.address.lower() != self.address.lower():
|
|
13
13
|
raise ValueError(
|
|
14
|
-
f"Private key is required for account {self.address} in {func.__name__}"
|
|
14
|
+
f"Private key is required for account {self.address} in {func.__name__}" # type: ignore
|
|
15
15
|
)
|
|
16
16
|
return await func(self, *args, **kwargs)
|
|
17
17
|
|
|
@@ -28,8 +28,9 @@ from async_hyperliquid.utils.constants import (
|
|
|
28
28
|
STAKING_TRANSFER_SIGN_TYPES,
|
|
29
29
|
MULTI_SIG_ENVELOPE_SIGN_TYPES,
|
|
30
30
|
USD_CLASS_TRANSFER_SIGN_TYPES,
|
|
31
|
-
CONVERT_TO_MULTI_SIG_USER_SIGN_TYPES,
|
|
32
31
|
USER_DEX_ABSTRACTION_SIGN_TYPES,
|
|
32
|
+
USER_SET_ABSTRACTION_SIGN_TYPES,
|
|
33
|
+
CONVERT_TO_MULTI_SIG_USER_SIGN_TYPES,
|
|
33
34
|
)
|
|
34
35
|
|
|
35
36
|
|
|
@@ -40,7 +41,7 @@ def address_to_bytes(address: str) -> bytes:
|
|
|
40
41
|
def hash_action(
|
|
41
42
|
action: dict, vault: str | None, nonce: int, expires: int | None = None
|
|
42
43
|
) -> bytes:
|
|
43
|
-
data: bytes = msgpack.packb(action)
|
|
44
|
+
data: bytes = msgpack.packb(action)
|
|
44
45
|
data += nonce.to_bytes(8, "big")
|
|
45
46
|
|
|
46
47
|
if vault is None:
|
|
@@ -114,7 +115,7 @@ def round_float(x: float) -> str:
|
|
|
114
115
|
|
|
115
116
|
def ensure_order_type(order_type: OrderType) -> OrderType:
|
|
116
117
|
if "limit" in order_type:
|
|
117
|
-
return {"limit": order_type["limit"]}
|
|
118
|
+
return {"limit": order_type["limit"]} # type: ignore
|
|
118
119
|
elif "trigger" in order_type:
|
|
119
120
|
return {
|
|
120
121
|
"trigger": {
|
|
@@ -357,3 +358,15 @@ def sign_user_dex_abstraction_action(
|
|
|
357
358
|
"HyperliquidTransaction:UserDexAbstraction",
|
|
358
359
|
is_mainnet,
|
|
359
360
|
)
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
def sign_user_set_abstraction_action(
|
|
364
|
+
wallet: LocalAccount, action: dict, is_mainnet: bool
|
|
365
|
+
):
|
|
366
|
+
return sign_user_signed_action(
|
|
367
|
+
wallet,
|
|
368
|
+
action,
|
|
369
|
+
USER_SET_ABSTRACTION_SIGN_TYPES,
|
|
370
|
+
"HyperliquidTransaction:UserSetAbstraction",
|
|
371
|
+
is_mainnet,
|
|
372
|
+
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{async_hyperliquid-0.3.8 → async_hyperliquid-0.3.10}/src/async_hyperliquid/utils/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|