Skip to content

Commit 7ee976d

Browse files
authored
Version 0.23.0 (#289)
1 parent 67902e1 commit 7ee976d

5 files changed

Lines changed: 42 additions & 4 deletions

File tree

examples/priority_fees.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import example_utils
2+
3+
from hyperliquid.utils import constants
4+
5+
6+
def main():
7+
address, info, exchange = example_utils.setup(base_url=constants.TESTNET_API_URL, skip_ws=True, perp_dexs=["test"])
8+
9+
# Place a bid on gossip priority slot 0
10+
bid_result = exchange.gossip_priority_bid(0, "8.8.8.8", 1)
11+
print(bid_result)
12+
13+
# Place an order with priority fee that should be rejected by setting the price very low
14+
order = {
15+
"coin": "test:ABC",
16+
"is_buy": True,
17+
"sz": 100,
18+
"limit_px": 0.9,
19+
"order_type": {"limit": {"tif": "Ioc"}},
20+
"reduce_only": False,
21+
}
22+
order_result = exchange.bulk_orders([order], grouping={"p": 12345})
23+
print(order_result)
24+
25+
26+
if __name__ == "__main__":
27+
main()

hyperliquid/exchange.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,3 +1198,11 @@ def noop(self, nonce):
11981198
self.wallet, action, self.vault_address, nonce, self.expires_after, self.base_url == MAINNET_API_URL
11991199
)
12001200
return self._post_action(action, signature, nonce)
1201+
1202+
def gossip_priority_bid(self, slot_id, ip, max_gas):
1203+
nonce = get_timestamp_ms()
1204+
action = {"type": "gossipPriorityBid", "slotId": slot_id, "ip": ip, "maxGas": max_gas}
1205+
signature = sign_l1_action(
1206+
self.wallet, action, self.vault_address, nonce, self.expires_after, self.base_url == MAINNET_API_URL
1207+
)
1208+
return self._post_action(action, signature, nonce)

hyperliquid/info.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ def __init__(
3939
self.name_to_coin = {}
4040
self.asset_to_sz_decimals = {}
4141

42+
token_by_index = {token["index"]: token for token in spot_meta["tokens"]}
43+
4244
# spot assets start at 10000
4345
for spot_info in spot_meta["universe"]:
4446
asset = spot_info["index"] + 10000
4547
self.coin_to_asset[spot_info["name"]] = asset
4648
self.name_to_coin[spot_info["name"]] = spot_info["name"]
4749
base, quote = spot_info["tokens"]
48-
base_info = spot_meta["tokens"][base]
49-
quote_info = spot_meta["tokens"][quote]
50+
base_info = token_by_index[base]
51+
quote_info = token_by_index[quote]
5052
self.asset_to_sz_decimals[asset] = base_info["szDecimals"]
5153
name = f'{base_info["name"]}/{quote_info["name"]}'
5254
if name not in self.name_to_coin:

hyperliquid/utils/signing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
CancelRequest = TypedDict("CancelRequest", {"coin": str, "oid": int})
4343
CancelByCloidRequest = TypedDict("CancelByCloidRequest", {"coin": str, "cloid": Cloid})
4444

45-
Grouping = Union[Literal["na"], Literal["normalTpsl"], Literal["positionTpsl"]]
45+
PriorityGrouping = TypedDict("PriorityGrouping", {"p": int})
46+
Grouping = Union[Literal["na"], Literal["normalTpsl"], Literal["positionTpsl"], PriorityGrouping]
4647
Order = TypedDict(
4748
"Order", {"asset": int, "isBuy": bool, "limitPx": float, "sz": float, "reduceOnly": bool, "cloid": Optional[Cloid]}
4849
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
55

66
[tool.poetry]
77
name = "hyperliquid-python-sdk"
8-
version = "0.22.0"
8+
version = "0.23.0"
99
description = "SDK for Hyperliquid API trading with Python."
1010
readme = "README.md"
1111
authors = ["Hyperliquid <hello@hyperliquid.xyz>"]

0 commit comments

Comments
 (0)