Skip to content

Commit b827942

Browse files
author
Louis Tao
committed
Version 0.2.0
1 parent 36dac26 commit b827942

File tree

9 files changed

+81
-142
lines changed

9 files changed

+81
-142
lines changed

examples/config.json.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"comments": "
33
Make a copy of this file and save to `config.json`
44
Fill in your secret key e.g. 0x0000000000000000000000000000000000000000000000000000000000000000
5-
If you are using an Agent/API Wallet you MUST also specify the public address of your account!
5+
If you are using an Agent/API Wallet you MUST also specify the public address of your account, not the
6+
address of the Agent/API Wallet.
67
Otherwise, feel free to leave it blank and it will be automatically derived from the secret key.
78
",
89
"secret_key": "",

examples/example_utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ def setup(base_url=None, skip_ws=False):
2424
if float(margin_summary["accountValue"]) == 0:
2525
print("Not running the example because the provided account has no equity.")
2626
url = info.base_url.split(".", 1)[1]
27-
print(f"If you think this is a mistake, make sure that {address} has a balance on {url}.")
28-
print("If address shown is your API wallet address, update the config to specify account_address")
29-
raise Exception("No accountValue")
27+
error_string = f"No accountValue:\nIf you think this is a mistake, make sure that {address} has a balance on {url}.\nIf address shown is your API wallet address, update the config to specify the address of your account, not the address of the API wallet."
28+
raise Exception(error_string)
3029
exchange = Exchange(account, base_url, account_address=address)
3130
return address, info, exchange

hyperliquid/exchange.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,25 @@ def update_isolated_margin(self, amount: float, coin: str) -> Any:
323323
timestamp,
324324
)
325325

326+
def set_referrer(self, code: str) -> Any:
327+
timestamp = get_timestamp_ms()
328+
set_referrer_action = {
329+
"type": "setReferrer",
330+
"code": code,
331+
}
332+
signature = sign_l1_action(
333+
self.wallet,
334+
set_referrer_action,
335+
None,
336+
timestamp,
337+
self.base_url == MAINNET_API_URL,
338+
)
339+
return self._post_action(
340+
set_referrer_action,
341+
signature,
342+
timestamp,
343+
)
344+
326345
def usd_transfer(self, amount: float, destination: str) -> Any:
327346
timestamp = get_timestamp_ms()
328347
payload = {

hyperliquid/info.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ def query_order_by_oid(self, user: str, oid: int) -> Any:
260260
def query_order_by_cloid(self, user: str, cloid: Cloid) -> Any:
261261
return self.post("/info", {"type": "orderStatus", "user": user, "oid": cloid.to_raw()})
262262

263+
def query_referral_state(self, user: str) -> Any:
264+
return self.post("/info", {"type": "referral", "user": user})
265+
263266
def subscribe(self, subscription: Subscription, callback: Callable[[Any], None]) -> int:
264267
if self.ws_manager is None:
265268
raise RuntimeError("Cannot call subscribe since skip_ws was used")

hyperliquid/utils/signing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ def order_type_to_wire(order_type: OrderType) -> OrderTypeWire:
7272
elif "trigger" in order_type:
7373
return {
7474
"trigger": {
75+
"isMarket": order_type["trigger"]["isMarket"],
7576
"triggerPx": float_to_wire(order_type["trigger"]["triggerPx"]),
7677
"tpsl": order_type["trigger"]["tpsl"],
77-
"isMarket": order_type["trigger"]["isMarket"],
7878
}
7979
}
8080
raise ValueError("Invalid order type", order_type)

0 commit comments

Comments
 (0)