From e43385081af9930297488c2a52dbe27053427a2a Mon Sep 17 00:00:00 2001 From: doge2 Date: Tue, 7 Jan 2025 19:50:31 -0500 Subject: [PATCH] sprint33 34 --- orderly_evm_connector/rest/__init__.py | 1 + orderly_evm_connector/rest/_account.py | 2 +- orderly_evm_connector/rest/_liquidation.py | 2 + orderly_evm_connector/rest/_rewards.py | 21 +++++++++- .../websocket/websocket_api/__init__.py | 40 +++++++++++++++++++ .../websocket/websocket_api/_stream.py | 20 ++++++++++ tests/rest/test_accounts.py | 1 - 7 files changed, 83 insertions(+), 4 deletions(-) diff --git a/orderly_evm_connector/rest/__init__.py b/orderly_evm_connector/rest/__init__.py index 93aafc5..a1b7c96 100644 --- a/orderly_evm_connector/rest/__init__.py +++ b/orderly_evm_connector/rest/__init__.py @@ -197,6 +197,7 @@ def __init__( from orderly_evm_connector.rest._rewards import get_valor_pool_info from orderly_evm_connector.rest._rewards import get_valor_redeem_info from orderly_evm_connector.rest._rewards import get_wallet_trading_rewards_history + from orderly_evm_connector.rest._rewards import get_market_making_rewards_leaderboard class RestAsync(AsyncAPI): diff --git a/orderly_evm_connector/rest/_account.py b/orderly_evm_connector/rest/_account.py index f05cc60..4c1e91f 100644 --- a/orderly_evm_connector/rest/_account.py +++ b/orderly_evm_connector/rest/_account.py @@ -26,7 +26,7 @@ def get_account_details(self, account_id: str): https://orderly.network/docs/build-on-evm/evm-api/restful-api/public/get-account-details """ - check_required_parameters([[account_id, "address"]]) + check_required_parameters([[account_id, "account_id"]]) payload = {"account_id": account_id} return self._request("GET", "/v1/public/account", payload=payload) diff --git a/orderly_evm_connector/rest/_liquidation.py b/orderly_evm_connector/rest/_liquidation.py index 305d12c..907e228 100644 --- a/orderly_evm_connector/rest/_liquidation.py +++ b/orderly_evm_connector/rest/_liquidation.py @@ -102,6 +102,8 @@ def get_liquidated_positions_of_account(self, **kwargs): end_t(timestamp) page(number) size(number) + sort_by(string) + liquidation_id(number) https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-liquidated-positions-of-account """ payload = {**kwargs} diff --git a/orderly_evm_connector/rest/_rewards.py b/orderly_evm_connector/rest/_rewards.py index 91676b9..649ac54 100644 --- a/orderly_evm_connector/rest/_rewards.py +++ b/orderly_evm_connector/rest/_rewards.py @@ -105,7 +105,7 @@ def get_current_epoch_estimate_broker(self): -def get_parameters_of_each_mm_epoch(self): +def get_parameters_of_each_mm_epoch(self, epoch: str, market: str): """ Get Parameters of Each MM Epoch of All MM Epochs @@ -116,7 +116,24 @@ def get_parameters_of_each_mm_epoch(self): https://docs.orderly.network/build-on-evm/evm-api/restful-api/public/get-parameters-of-each-mm-epoch-for-all-mm-epochs """ - return self._request("GET", "/v1/public/market_making_rewards/epoch_info") + check_required_parameters([[epoch, "epoch"], [market, "market"]]) + payload = {"epoch": epoch, "market": market} + return self._request("GET", "/v1/public/market_making_rewards/leaderboard", payload=payload) + + + +def get_market_making_rewards_leaderboard(self): + """ + Get Market Making Rewards Leaderboard + + Limit: 10 requests per 1 second + + GET /v1/public/market_making_rewards/market_making_rewards/leaderboard + + https://docs.orderly.network/build-on-evm/evm-api/restful-api/public/get-market-making-rewards-leaderboard + """ + + return self._request("GET", "/v1/market_making_rewards/market_making_rewards/leaderboard") def get_wallet_group_mm_rewards_history(self, address: str, symbol: str = None): diff --git a/orderly_evm_connector/websocket/websocket_api/__init__.py b/orderly_evm_connector/websocket/websocket_api/__init__.py index d08be3a..455131d 100644 --- a/orderly_evm_connector/websocket/websocket_api/__init__.py +++ b/orderly_evm_connector/websocket/websocket_api/__init__.py @@ -59,6 +59,11 @@ def __init__( get_liquidation_push, ) + from orderly_evm_connector.websocket.websocket_api._stream import get_price_changes + from orderly_evm_connector.websocket.websocket_api._stream import get_history_charts_1m + from orderly_evm_connector.websocket.websocket_api._stream import get_maintenance_status + from orderly_evm_connector.websocket.websocket_api._stream import get_announcements + class WebsocketPublicAPIClientAsync(OrderlyWebsocketClient): def __init__( self, @@ -180,6 +185,41 @@ async def get_liquidation_push(self, *args, **kwargs): await asyncio.sleep(0) + async def get_price_changes(self, *args, **kwargs): + from orderly_evm_connector.websocket.websocket_api._stream import ( + get_price_changes, + ) + get_price_changes(self, *args, **kwargs) + await asyncio.sleep(0) + + + async def get_history_charts_1m(self, *args, **kwargs): + from orderly_evm_connector.websocket.websocket_api._stream import ( + get_history_charts_1m, + ) + get_history_charts_1m(self, *args, **kwargs) + await asyncio.sleep(0) + + + async def get_maintenance_status(self, *args, **kwargs): + from orderly_evm_connector.websocket.websocket_api._stream import ( + get_maintenance_status, + ) + get_maintenance_status(self, *args, **kwargs) + await asyncio.sleep(0) + + + async def get_announcements(self, *args, **kwargs): + from orderly_evm_connector.websocket.websocket_api._stream import ( + get_announcements, + ) + get_announcements(self, *args, **kwargs) + await asyncio.sleep(0) + + + + + class WebsocketPrivateAPIClient(OrderlyWebsocketClient): def __init__( self, diff --git a/orderly_evm_connector/websocket/websocket_api/_stream.py b/orderly_evm_connector/websocket/websocket_api/_stream.py index 50c0f47..00e76ea 100644 --- a/orderly_evm_connector/websocket/websocket_api/_stream.py +++ b/orderly_evm_connector/websocket/websocket_api/_stream.py @@ -176,3 +176,23 @@ def get_liquidation_push(self): """ _message = {"id": self.wss_id, "event": "subscribe", "topic": "liquidation"} self.send_message_to_server(_message) + + +def get_price_changes(self): + _message = {"id": self.wss_id, "event": "subscribe", "topic": "price_changes"} + self.send_message_to_server(_message) + + +def get_history_charts_1m(self): + _message = {"id": self.wss_id, "event": "subscribe", "topic": "history_charts_1m"} + self.send_message_to_server(_message) + + +def get_maintenance_status(self): + _message = {"id": self.wss_id, "event": "subscribe", "topic": "maintenance_status"} + self.send_message_to_server(_message) + + +def get_announcements(self): + _message = {"id": self.wss_id, "event": "subscribe", "topic": "announcement"} + self.send_message_to_server(_message) diff --git a/tests/rest/test_accounts.py b/tests/rest/test_accounts.py index f4d6cb1..5838891 100644 --- a/tests/rest/test_accounts.py +++ b/tests/rest/test_accounts.py @@ -49,7 +49,6 @@ 200 ) def test_get_account(): - client = Client( orderly_key=orderly_key, orderly_secret=orderly_secret,