Skip to content

Commit 9c88ca0

Browse files
committed
fix: remove batch_clearinghouse_states endpoint and optimize test cassettes
1 parent 30d18f5 commit 9c88ca0

6 files changed

Lines changed: 55 additions & 111 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,6 @@ healthchecksdb
616616
MigrationBackup/
617617

618618
testing.py
619-
testing/
620619

621620
# End of https://www.gitignore.io/api/osx,python,pycharm,windows,visualstudio,visualstudiocode
622621
examples/config.json

hyperliquid/info.py

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,20 @@ def user_staking_rewards(self, address: str) -> Any:
594594
"""
595595
return self.post("/info", {"type": "delegatorRewards", "user": address})
596596

597+
def delegator_history(self, user: str) -> Any:
598+
"""Retrieve comprehensive staking history for a user.
599+
600+
POST /info
601+
602+
Args:
603+
user (str): Onchain address in 42-character hexadecimal format.
604+
605+
Returns:
606+
Comprehensive staking history including delegation and undelegation
607+
events with timestamps, transaction hashes, and detailed delta information.
608+
"""
609+
return self.post("/info", {"type": "delegatorHistory", "user": user})
610+
597611
def query_order_by_oid(self, user: str, oid: int) -> Any:
598612
return self.post("/info", {"type": "orderStatus", "user": user, "oid": oid})
599613

@@ -641,12 +655,10 @@ def user_non_funding_ledger_updates(self, user: str, startTime: int, endTime: Op
641655
Comprehensive ledger updates including deposits, withdrawals, transfers,
642656
liquidations, and other account activities excluding funding payments.
643657
"""
644-
if endTime is not None:
645-
return self.post(
646-
"/info",
647-
{"type": "userNonFundingLedgerUpdates", "user": user, "startTime": startTime, "endTime": endTime},
648-
)
649-
return self.post("/info", {"type": "userNonFundingLedgerUpdates", "user": user, "startTime": startTime})
658+
return self.post(
659+
"/info",
660+
{"type": "userNonFundingLedgerUpdates", "user": user, "startTime": startTime, "endTime": endTime},
661+
)
650662

651663
def portfolio(self, user: str) -> Any:
652664
"""Retrieve comprehensive portfolio performance data.
@@ -662,21 +674,6 @@ def portfolio(self, user: str) -> Any:
662674
"""
663675
return self.post("/info", {"type": "portfolio", "user": user})
664676

665-
def batch_clearinghouse_states(self, users: List[str], dex: str = "") -> Any:
666-
"""Retrieve perpetuals account summaries for multiple users.
667-
668-
POST /info
669-
670-
Args:
671-
users (List[str]): List of onchain addresses in 42-character hexadecimal format.
672-
dex (str): Perp dex name. Defaults to empty string (first perp dex).
673-
674-
Returns:
675-
Array where each item matches the clearinghouseState schema with fields like
676-
assetPositions, marginSummary, crossMarginSummary, time, and withdrawable.
677-
"""
678-
return self.post("/info", {"type": "batchClearinghouseStates", "users": users, "dex": dex})
679-
680677
def user_twap_slice_fills(self, user: str) -> Any:
681678
"""Retrieve a user's TWAP slice fills.
682679
@@ -733,20 +730,6 @@ def user_rate_limit(self, user: str) -> Any:
733730
"""
734731
return self.post("/info", {"type": "userRateLimit", "user": user})
735732

736-
def delegator_history(self, user: str) -> Any:
737-
"""Retrieve comprehensive staking history for a user.
738-
739-
POST /info
740-
741-
Args:
742-
user (str): Onchain address in 42-character hexadecimal format.
743-
744-
Returns:
745-
Comprehensive staking history including delegation and undelegation
746-
events with timestamps, transaction hashes, and detailed delta information.
747-
"""
748-
return self.post("/info", {"type": "delegatorHistory", "user": user})
749-
750733
def query_spot_deploy_auction_status(self, user: str) -> Any:
751734
return self.post("/info", {"type": "spotDeployState", "user": user})
752735

tests/cassettes/info_test/test_batch_clearinghouse_states.yaml

Lines changed: 0 additions & 53 deletions
This file was deleted.

tests/cassettes/info_test/test_historical_orders.yaml

Lines changed: 25 additions & 1 deletion
Large diffs are not rendered by default.

tests/cassettes/info_test/test_user_non_funding_ledger_updates_without_end_time.yaml

Lines changed: 12 additions & 1 deletion
Large diffs are not rendered by default.

tests/info_test.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pytest
22

33
from hyperliquid.info import Info
4-
from hyperliquid.utils.error import ServerError
54
from hyperliquid.utils.types import L2BookData, Meta, SpotMeta
65

76
TEST_META: Meta = {"universe": []}
@@ -188,25 +187,6 @@ def test_portfolio():
188187
), "Portfolio should contain performance metrics"
189188

190189

191-
@pytest.mark.vcr()
192-
def test_batch_clearinghouse_states():
193-
info = Info(skip_ws=True, meta=TEST_META, spot_meta=TEST_SPOT_META)
194-
users = ["0x31ca8395cf837de08b24da3f660e77761dfb974b", "0x2ba553d9f990a3b66b03b2dc0d030dfc1c061036"]
195-
# Note: This endpoint may not be available on all Hyperliquid nodes
196-
# It's only available on the official Hyperliquid public API
197-
try:
198-
response = info.batch_clearinghouse_states(users=users)
199-
assert isinstance(response, list), "The response should be a list"
200-
assert len(response) <= len(users), "Should return at most one state per user"
201-
for state in response:
202-
# Each state should have the same structure as clearinghouseState
203-
assert "assetPositions" in state, "Each state should have assetPositions"
204-
assert "marginSummary" in state, "Each state should have marginSummary"
205-
except (ConnectionError, TimeoutError, ValueError, ServerError) as e:
206-
# This is expected if the endpoint is not available
207-
print(f"batch_clearinghouse_states not available: {e}")
208-
209-
210190
@pytest.mark.vcr()
211191
def test_user_twap_slice_fills():
212192
info = Info(skip_ws=True, meta=TEST_META, spot_meta=TEST_SPOT_META)

0 commit comments

Comments
 (0)