Skip to content

Commit

Permalink
(feat) Added example for liquidable positions request. Also removed s…
Browse files Browse the repository at this point in the history
…entry nodes from network config
  • Loading branch information
abel committed Oct 11, 2023
1 parent b18f478 commit fc0e683
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -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())
13 changes: 1 addition & 12 deletions pyinjective/core/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -259,22 +256,14 @@ 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"
grpc_exchange_endpoint = "k8s.global.mainnet.exchange.grpc.injective.network:443"
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,
Expand Down

0 comments on commit fc0e683

Please sign in to comment.