Skip to content

Commit 0046fce

Browse files
committed
Update example utils balance check
1 parent fa80c7c commit 0046fce

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

examples/example_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ def setup(base_url=None, skip_ws=False):
2020
print("Running with agent address:", account.address)
2121
info = Info(base_url, skip_ws)
2222
user_state = info.user_state(address)
23+
spot_user_state = info.spot_user_state(address)
2324
margin_summary = user_state["marginSummary"]
24-
if float(margin_summary["accountValue"]) == 0:
25+
if float(margin_summary["accountValue"]) == 0 and len(spot_user_state["balances"]) == 0:
2526
print("Not running the example because the provided account has no equity.")
2627
url = info.base_url.split(".", 1)[1]
2728
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."

hyperliquid/info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def spot_meta(self) -> SpotMeta:
226226
{
227227
universe: [
228228
{
229-
tokens: [int, int]
229+
tokens: [int, int],
230230
name: str,
231231
index: int,
232232
isCanonical: bool
@@ -256,7 +256,7 @@ def spot_meta_and_asset_ctxs(self) -> SpotMetaAndAssetCtxs:
256256
{
257257
universe: [
258258
{
259-
tokens: [int, int]
259+
tokens: [int, int],
260260
name: str,
261261
index: int,
262262
isCanonical: bool

0 commit comments

Comments
 (0)