Skip to content

Commit

Permalink
Merge pull request #255 from InjectiveLabs/feat/add_deriv_positions_e…
Browse files Browse the repository at this point in the history
…xample

feat/add_deriv_positions_example
  • Loading branch information
aarmoa authored Oct 6, 2023
2 parents 0b3b17b + 87b0af7 commit f4f56ca
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 f4f56ca

Please sign in to comment.