From 87b0af7a511be773ac0c441c2885196aecd36dcf Mon Sep 17 00:00:00 2001 From: abel Date: Fri, 6 Oct 2023 12:53:14 -0300 Subject: [PATCH] (feat) Added example for liquidable positions request. Also removed sentry nodes from network config --- .../23_LiquidablePositions.py | 30 +++++++++++++++++++ pyinjective/core/network.py | 13 +------- 2 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 examples/exchange_client/derivative_exchange_rpc/23_LiquidablePositions.py diff --git a/examples/exchange_client/derivative_exchange_rpc/23_LiquidablePositions.py b/examples/exchange_client/derivative_exchange_rpc/23_LiquidablePositions.py new file mode 100644 index 00000000..e87f67b1 --- /dev/null +++ b/examples/exchange_client/derivative_exchange_rpc/23_LiquidablePositions.py @@ -0,0 +1,30 @@ +import asyncio + +from google.protobuf import json_format + +from pyinjective.async_client import AsyncClient +from pyinjective.core.network import Network + + +async def main() -> None: + network = Network.testnet() + client = AsyncClient(network) + market_id = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + skip = 10 + limit = 3 + positions = await client.get_derivative_liquidable_positions( + market_id=market_id, + skip=skip, + limit=limit, + ) + print( + json_format.MessageToJson( + message=positions, + including_default_value_fields=True, + preserving_proto_field_name=True, + ) + ) + + +if __name__ == "__main__": + asyncio.get_event_loop().run_until_complete(main()) diff --git a/pyinjective/core/network.py b/pyinjective/core/network.py index 39c4af65..9131329a 100644 --- a/pyinjective/core/network.py +++ b/pyinjective/core/network.py @@ -244,9 +244,6 @@ def mainnet(cls, node="lb"): nodes = [ "lb", # us, asia, prod "lb_k8s", - "sentry0", # ca, prod - "sentry1", # ca, prod - "sentry3", # us, prod ] if node not in nodes: raise ValueError("Must be one of {}".format(nodes)) @@ -259,7 +256,7 @@ def mainnet(cls, node="lb"): grpc_explorer_endpoint = "sentry.explorer.grpc.injective.network:443" cookie_assistant = BareMetalLoadBalancedCookieAssistant() use_secure_connection = True - elif node == "lb_k8s": + else: lcd_endpoint = "https://k8s.global.mainnet.lcd.injective.network:443" tm_websocket_endpoint = "wss://k8s.global.mainnet.tm.injective.network:443/websocket" grpc_endpoint = "k8s.global.mainnet.chain.grpc.injective.network:443" @@ -267,14 +264,6 @@ def mainnet(cls, node="lb"): grpc_explorer_endpoint = "k8s.global.mainnet.explorer.grpc.injective.network:443" cookie_assistant = KubernetesLoadBalancedCookieAssistant() use_secure_connection = True - else: - lcd_endpoint = f"http://{node}.injective.network:10337" - tm_websocket_endpoint = f"ws://{node}.injective.network:26657/websocket" - grpc_endpoint = f"{node}.injective.network:9900" - grpc_exchange_endpoint = f"{node}.injective.network:9910" - grpc_explorer_endpoint = f"{node}.injective.network:9911" - cookie_assistant = DisabledCookieAssistant() - use_secure_connection = False return cls( lcd_endpoint=lcd_endpoint,