From 5b4a48fbdd5321b3fd35d7bffd20f8560975a446 Mon Sep 17 00:00:00 2001 From: abel Date: Mon, 4 Dec 2023 15:57:13 -0300 Subject: [PATCH 1/4] (feat) Changed all Python examples to use the low leve API components funtions in AsyncClient --- source/includes/_account.md | 87 +-- source/includes/_accountsrpc.md | 166 +++--- source/includes/_auction.md | 15 +- source/includes/_auctionsrpc.md | 66 ++- source/includes/_authz.md | 62 ++- source/includes/_bank.md | 35 +- source/includes/_binaryoptions.md | 122 +++-- source/includes/_chainstream.md | 52 +- source/includes/_derivatives.md | 93 ++-- source/includes/_derivativesrpc.md | 833 +++++++++++++++++------------ source/includes/_explorerrpc.md | 271 ++++++---- source/includes/_insurance.md | 45 +- source/includes/_insurancerpc.md | 32 +- source/includes/_metarpc.md | 97 ++-- source/includes/_oracle.md | 31 +- source/includes/_oraclerpc.md | 86 ++- source/includes/_portfoliorpc.md | 65 ++- source/includes/_spot.md | 78 +-- source/includes/_spotrpc.md | 604 ++++++++++++--------- source/includes/_staking.md | 43 +- source/includes/_wasm.md | 28 +- 21 files changed, 1741 insertions(+), 1170 deletions(-) diff --git a/source/includes/_account.md b/source/includes/_account.md index 9ec2f07e..f4aa51cd 100644 --- a/source/includes/_account.md +++ b/source/includes/_account.md @@ -12,6 +12,8 @@ Includes all messages related to accounts and transfers. ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -32,7 +34,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) # prepare tx msg @@ -51,14 +53,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -72,7 +75,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -215,6 +218,8 @@ gas fee: 0.0000660495 INJ ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -235,7 +240,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) # prepare tx msg @@ -254,14 +259,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -275,7 +281,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -418,6 +424,8 @@ gas fee: 0.000064803 INJ ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -438,7 +446,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) dest_subaccount_id = address.get_subaccount_id(index=1) @@ -464,14 +472,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -485,7 +494,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -630,6 +639,8 @@ gas fee: 0.0000610515 INJ ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -650,7 +661,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) dest_subaccount_id = "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" @@ -676,14 +687,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -697,7 +709,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -842,6 +854,7 @@ gas fee: 0.0000611985 INJ import asyncio import requests +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE @@ -863,7 +876,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) # prepare msg asset = "injective-protocol" @@ -894,14 +907,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -915,7 +929,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -1134,21 +1148,22 @@ Transaction hash: 0xb538abc7c2f893a2fe24c7a8ea606ff48d980a754499f1bec89b862c2bcb ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: network = Network.testnet() client = AsyncClient(network) - tx_hash = "0D2427F669F9862C0392A3D7699D678B30FD9D38861782E3FA32C7816889032E" - tx_logs = await client.get_tx(tx_hash=tx_hash) + tx_hash = "D265527E3171C47D01D7EC9B839A95F8F794D4E683F26F5564025961C96EFDDA" + tx_logs = await client.fetch_tx(hash=tx_hash) print(tx_logs) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ```go @@ -1226,7 +1241,7 @@ func main() { |Parameter|Type|Description|Required| |----|----|----|----| -|tx_hash|String|The transaction hash|Yes| +|hash|String|The transaction hash|Yes| > Response Example: diff --git a/source/includes/_accountsrpc.md b/source/includes/_accountsrpc.md index f3604cd1..b12ee1e5 100644 --- a/source/includes/_accountsrpc.md +++ b/source/includes/_accountsrpc.md @@ -14,22 +14,22 @@ Get a list of subaccounts for a specific address. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: - # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) account_address = "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt" - subacc_list = await client.get_subaccount_list(account_address) + subacc_list = await client.fetch_subaccounts_list(account_address) print(subacc_list) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -128,11 +128,12 @@ Get the subaccount's transfer history. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient +from pyinjective.client.model.pagination import PaginationOption from pyinjective.core.network import Network + async def main() -> None: network = Network.testnet() client = AsyncClient(network) @@ -142,23 +143,16 @@ async def main() -> None: skip = 1 limit = 15 end_time = 1665118340224 - subacc_history = await client.get_subaccount_history( - subaccount_id=subaccount, - denom=denom, - transfer_types=transfer_types, - skip=skip, - limit=limit, - end_time=end_time + pagination = PaginationOption(skip=skip, limit=limit, end_time=end_time) + subacc_history = await client.fetch_subaccount_history( + subaccount_id=subaccount, denom=denom, transfer_types=transfer_types, pagination=pagination, ) print(subacc_history) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) - asyncio.get_event_loop().run_until_complete(main()) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -376,26 +370,23 @@ Get the balance of a subaccount for a specific denom. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: - # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) subaccount_id = "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" denom = "inj" - balance = await client.get_subaccount_balance( - subaccount_id=subaccount_id, - denom=denom - ) + balance = await client.fetch_subaccount_balance(subaccount_id=subaccount_id, denom=denom) print(balance) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -530,25 +521,23 @@ List the subaccount's balances for all denoms. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: network = Network.testnet() client = AsyncClient(network) subaccount = "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" denoms = ["inj", "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5"] - subacc_balances_list = await client.get_subaccount_balances_list( - subaccount_id=subaccount, - denoms=denoms - ) + subacc_balances_list = await client.fetch_subaccount_balances_list(subaccount_id=subaccount, denoms=denoms) print(subacc_balances_list) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -726,27 +715,26 @@ Get a summary of the subaccount's active/unfilled orders. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: network = Network.testnet() client = AsyncClient(network) subaccount = "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - # order_direction = "buy" - # market_id = "0xe112199d9ee44ceb2697ea0edd1cd422223c105f3ed2bdf85223d3ca59f5909a" - subacc_order_summary = await client.get_subaccount_order_summary( - subaccount_id=subaccount, - # order_direction=order_direction, - # market_id=market_id - ) + order_direction = "buy" + market_id = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + subacc_order_summary = await client.fetch_subaccount_order_summary( + subaccount_id=subaccount, order_direction=order_direction, market_id=market_id + ) print(subacc_order_summary) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -861,24 +849,48 @@ Stream the subaccount's balance for all denoms. ``` python import asyncio -import logging +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + +async def balance_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to balance updates ({exception})") + + +def stream_closed_processor(): + print("The balance updates stream has been closed") + + async def main() -> None: network = Network.testnet() client = AsyncClient(network) subaccount_id = "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" denoms = ["inj", "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5"] - subaccount = await client.stream_subaccount_balance(subaccount_id) - async for balance in subaccount: - print("Subaccount balance Update:\n") - print(balance) + task = asyncio.get_event_loop().create_task( + client.listen_subaccount_balance_updates( + subaccount_id=subaccount_id, + callback=balance_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + denoms=denoms, + ) + ) + + await asyncio.sleep(delay=60) + task.cancel() -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -958,10 +970,13 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; })(); ``` -|Parameter|Type|Description|Required| -|----|----|----|----| -|subaccount_id|String|Filter by subaccount ID|Yes| -|denoms|String Array|Filter balances by denoms. If not set, the balances of all the denoms for the subaccount are provided|No| +| Parameter | Type | Description | Required | +| ------------------ | ------------ | ----------------------------------------------------------------------------------------------------- | -------- | +| subaccount_id | String | Filter by subaccount ID | Yes | +| denoms | String Array | Filter balances by denoms. If not set, the balances of all the denoms for the subaccount are provided | No | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | ### Response Parameters @@ -1093,22 +1108,31 @@ Get orders with an order hash. This request will return market orders and limit ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: network = Network.testnet() client = AsyncClient(network) - spot_order_hashes = ["0xce0d9b701f77cd6ddfda5dd3a4fe7b2d53ba83e5d6c054fb2e9e886200b7b7bb", "0x2e2245b5431638d76c6e0cc6268970418a1b1b7df60a8e94b8cf37eae6105542"] - derivative_order_hashes = ["0x82113f3998999bdc3892feaab2c4e53ba06c5fe887a2d5f9763397240f24da50", "0xbb1f036001378cecb5fff1cc69303919985b5bf058c32f37d5aaf9b804c07a06"] - orders = await client.get_order_states(spot_order_hashes=spot_order_hashes, derivative_order_hashes=derivative_order_hashes) + spot_order_hashes = [ + "0xce0d9b701f77cd6ddfda5dd3a4fe7b2d53ba83e5d6c054fb2e9e886200b7b7bb", + "0x2e2245b5431638d76c6e0cc6268970418a1b1b7df60a8e94b8cf37eae6105542", + ] + derivative_order_hashes = [ + "0x82113f3998999bdc3892feaab2c4e53ba06c5fe887a2d5f9763397240f24da50", + "0xbb1f036001378cecb5fff1cc69303919985b5bf058c32f37d5aaf9b804c07a06", + ] + orders = await client.fetch_order_states( + spot_order_hashes=spot_order_hashes, derivative_order_hashes=derivative_order_hashes + ) print(orders) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -1337,21 +1361,22 @@ Get an overview of your portfolio. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: network = Network.testnet() client = AsyncClient(network) account_address = "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" - portfolio = await client.get_portfolio(account_address=account_address) + portfolio = await client.fetch_portfolio(account_address=account_address) print(portfolio) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -1492,24 +1517,23 @@ Get the rewards for Trade & Earn, the request will fetch all addresses for the l ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: network = Network.testnet() client = AsyncClient(network) - # account_address = "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" + account_address = "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" epoch = -1 - rewards = await client.get_rewards( - # account_address=account_address, - epoch=epoch) + rewards = await client.fetch_rewards(account_address=account_address, epoch=epoch) print(rewards) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go diff --git a/source/includes/_auction.md b/source/includes/_auction.md index 36b34011..017e0cac 100644 --- a/source/includes/_auction.md +++ b/source/includes/_auction.md @@ -13,6 +13,8 @@ Includes the message for placing bids in auctions. ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -33,7 +35,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) # prepare tx msg msg = composer.MsgBid(sender=address.to_acc_bech32(), round=16250, bid_amount=1) @@ -51,14 +53,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -72,7 +75,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) diff --git a/source/includes/_auctionsrpc.md b/source/includes/_auctionsrpc.md index 29833beb..82d6f0a6 100644 --- a/source/includes/_auctionsrpc.md +++ b/source/includes/_auctionsrpc.md @@ -15,21 +15,21 @@ Get the details of a specific auction. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) bid_round = 31 - auction = await client.get_auction(bid_round=bid_round) + auction = await client.fetch_auction(round=bid_round) print(auction) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) ``` @@ -83,9 +83,9 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; ``` -|Parameter|Type|Description|Required| -|----|----|----|----| -|bid_round|Integer|The auction round number. -1 for latest|Yes| +| Parameter | Type | Description | Required | +| --------- | ------- | --------------------------------------- | -------- | +| round | Integer | The auction round number. -1 for latest | Yes | ### Response Parameters @@ -224,21 +224,22 @@ Get the details of previous auctions. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - auctions = await client.get_auctions() + auctions = await client.fetch_auctions() print(auctions) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -433,22 +434,46 @@ Stream live updates for auction bids. ``` python import asyncio -import logging +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + +async def bid_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to bids updates ({exception})") + + +def stream_closed_processor(): + print("The bids updates stream has been closed") + + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - bids = await client.stream_bids() - async for bid in bids: - print(bid) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + task = asyncio.get_event_loop().create_task( + client.listen_bids_updates( + callback=bid_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + ) + ) + + await asyncio.sleep(delay=60) + task.cancel() + + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -524,6 +549,13 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; })(); ``` +| Parameter | Type | Description | Required | +| ------------------ | -------- | ---------------------------------------------------------------------------------------------------- | -------- | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | + + ### Response Parameters > Response Example: diff --git a/source/includes/_authz.md b/source/includes/_authz.md index 01a1c6da..fa0c9491 100644 --- a/source/includes/_authz.md +++ b/source/includes/_authz.md @@ -14,6 +14,8 @@ There are two types of authorization, Generic and Typed. Generic authorization w ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -34,7 +36,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) # subaccount_id = address.get_subaccount_id(index=0) # market_ids = ["0x0511ddc4e6586f3bfe1acb2dd905f8b8a82c97e1edaef654b12ca7e6031ca0fa"] @@ -71,14 +73,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -92,7 +95,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -265,6 +268,8 @@ gas fee: 0.0000589365 INJ import asyncio import uuid +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -285,7 +290,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) # prepare tx msg market_id = "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" @@ -320,20 +325,23 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return - sim_res_msg = composer.MsgResponses(sim_res, simulation=True) - data = sim_res_msg[0] - unpacked_msg_res = composer.UnpackMsgExecResponse(msg_type=msg0.__class__.__name__, data=data) + sim_res_msgs = sim_res["result"]["msgResponses"] + data = sim_res_msgs[0] + unpacked_msg_res = composer.unpack_msg_exec_response( + underlying_msg_type=msg0.__class__.__name__, msg_exec_response=data + ) print("simulation msg response") print(unpacked_msg_res) # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -347,7 +355,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -532,6 +540,8 @@ gas fee: 0.000066986 INJ ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -552,7 +562,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) # prepare tx msg msg = composer.MsgRevoke( @@ -574,14 +584,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -595,7 +606,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -733,23 +744,24 @@ Get the details of an authorization between a granter and a grantee. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: network = Network.testnet() client = AsyncClient(network) granter = "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" grantee = "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r" msg_type_url = "/injective.exchange.v1beta1.MsgCreateDerivativeLimitOrder" - authorizations = await client.get_grants(granter=granter, grantee=grantee, msg_type_url=msg_type_url) + authorizations = await client.fetch_grants(granter=granter, grantee=grantee, msg_type_url=msg_type_url) print(authorizations) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go diff --git a/source/includes/_bank.md b/source/includes/_bank.md index 6d955362..fc91d142 100644 --- a/source/includes/_bank.md +++ b/source/includes/_bank.md @@ -13,6 +13,8 @@ Bank module. ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -33,7 +35,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) # prepare tx msg msg = composer.MsgSend( @@ -56,14 +58,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -77,7 +80,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -397,22 +400,22 @@ Get the bank balance for all denoms. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: - # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) address = "inj1cml96vmptgw99syqrrz8az79xer2pcgp0a885r" - all_bank_balances = await client.get_bank_balances(address=address) + all_bank_balances = await client.fetch_bank_balances(address=address) print(all_bank_balances) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -607,23 +610,23 @@ Get the bank balance for a specific denom. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: - # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) address = "inj1cml96vmptgw99syqrrz8az79xer2pcgp0a885r" denom = "inj" - bank_balance = await client.get_bank_balance(address=address, denom=denom) + bank_balance = await client.fetch_bank_balance(address=address, denom=denom) print(bank_balance) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go diff --git a/source/includes/_binaryoptions.md b/source/includes/_binaryoptions.md index c238e845..1e18c032 100644 --- a/source/includes/_binaryoptions.md +++ b/source/includes/_binaryoptions.md @@ -13,11 +13,13 @@ Includes all messages related to binary options. import asyncio import uuid +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE -from pyinjective.utils.denom import Denom from pyinjective.core.network import Network from pyinjective.transaction import Transaction +from pyinjective.utils.denom import Denom from pyinjective.wallet import PrivateKey @@ -34,7 +36,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) # prepare trade info @@ -71,18 +73,19 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return - sim_res_msg = composer.MsgResponses(sim_res, simulation=True) + sim_res_msg = sim_res["result"]["msgResponses"] print("---Simulation Response---") print(sim_res_msg) # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -96,7 +99,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print("---Transaction Response---") print(res) print("gas wanted: {}".format(gas_limit)) @@ -156,6 +159,8 @@ gas fee: 0.0000606245 INJ import asyncio import uuid +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -176,7 +181,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) # prepare trade info @@ -208,18 +213,19 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return - sim_res_msg = composer.MsgResponses(sim_res, simulation=True) + sim_res_msg = sim_res["result"]["msgResponses"] print("---Simulation Response---") print(sim_res_msg) # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -233,7 +239,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print("---Transaction Response---") print(res) print("gas wanted: {}".format(gas_limit)) @@ -291,6 +297,8 @@ gas fee: 0.0000539515 INJ ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -311,7 +319,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) # prepare trade info @@ -335,18 +343,19 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return - sim_res_msg = composer.MsgResponses(sim_res, simulation=True) + sim_res_msg = sim_res["result"]["msgResponses"] print("---Simulation Response---") print(sim_res_msg) # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -360,7 +369,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print("---Transaction Response---") print(res) print("gas wanted: {}".format(gas_limit)) @@ -416,6 +425,8 @@ gas fee: 0.0000556515 INJ ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -436,7 +447,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) # prepare trade info market_id = "0xfafec40a7b93331c1fc89c23f66d11fbb48f38dfdd78f7f4fc4031fad90f6896" @@ -468,18 +479,19 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return - sim_res_msg = composer.MsgResponses(sim_res, simulation=True) + sim_res_msg = sim_res["result"]["msgResponses"] print("---Simulation Response---") print(sim_res_msg) # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -493,7 +505,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print("---Transaction Response---") print(res) print("gas wanted: {}".format(gas_limit)) @@ -546,6 +558,8 @@ gas fee: 0.0000556515 INJ ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -566,7 +580,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) # prepare tx msg msg = composer.MsgInstantBinaryOptionsMarketLaunch( @@ -600,18 +614,19 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return - sim_res_msg = composer.MsgResponses(sim_res, simulation=True) + sim_res_msg = sim_res["result"]["msgResponses"] print("---Simulation Response---") print(sim_res_msg) # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -625,7 +640,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print("---Transaction Response---") print(res) print("gas wanted: {}".format(gas_limit)) @@ -685,6 +700,8 @@ gas fee: 0.0000863755 INJ ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -705,7 +722,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) provider = "ufc" symbols = ["KHABIB-TKO-05/30/2023", "KHABIB-TKO-05/26/2023"] @@ -729,18 +746,19 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return - sim_res_msg = composer.MsgResponses(sim_res, simulation=True) + sim_res_msg = sim_res["result"]["msgResponses"] print("---Simulation Response---") print(sim_res_msg) # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -754,7 +772,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print("---Transaction Response---") print(res) print("gas wanted: {}".format(gas_limit)) @@ -811,6 +829,8 @@ Further note that if no marketIDs are provided in the SpotMarketIdsToCancelAll o import asyncio import uuid +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -831,7 +851,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) # prepare trade info @@ -941,18 +961,19 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return - sim_res_msg = composer.MsgResponses(sim_res, simulation=True) + sim_res_msg = sim_res["result"]["msgResponses"] print("---Simulation Response---") print(sim_res_msg) # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -966,7 +987,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print("---Transaction Response---") print(res) print("gas wanted: {}".format(gas_limit)) @@ -976,7 +997,6 @@ async def main() -> None: if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) - ``` ``` go diff --git a/source/includes/_chainstream.md b/source/includes/_chainstream.md index 1fa22a4c..9fae4dd2 100644 --- a/source/includes/_chainstream.md +++ b/source/includes/_chainstream.md @@ -13,14 +13,27 @@ In addition each filter supports a `*` wildcard to match all possible values. ``` python import asyncio +from typing import Any, Dict -from google.protobuf import json_format +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.composer import Composer from pyinjective.core.network import Network +async def chain_stream_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to chain stream updates ({exception})") + + +def stream_closed_processor(): + print("The chain stream updates stream has been closed") + + async def main() -> None: network = Network.testnet() @@ -52,24 +65,27 @@ async def main() -> None: subaccount_ids=[subaccount_id], market_ids=[inj_usdt_perp_market] ) oracle_price_filter = composer.chain_stream_oracle_price_filter(symbols=["INJ", "USDT"]) - stream = await client.chain_stream( - bank_balances_filter=bank_balances_filter, - subaccount_deposits_filter=subaccount_deposits_filter, - spot_trades_filter=spot_trades_filter, - derivative_trades_filter=derivative_trades_filter, - spot_orders_filter=spot_orders_filter, - derivative_orders_filter=derivative_orders_filter, - spot_orderbooks_filter=spot_orderbooks_filter, - derivative_orderbooks_filter=derivative_orderbooks_filter, - positions_filter=positions_filter, - oracle_price_filter=oracle_price_filter, - ) - async for event in stream: - print( - json_format.MessageToJson( - message=event, including_default_value_fields=True, preserving_proto_field_name=True - ) + + task = asyncio.get_event_loop().create_task( + client.listen_chain_stream_updates( + callback=chain_stream_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + bank_balances_filter=bank_balances_filter, + subaccount_deposits_filter=subaccount_deposits_filter, + spot_trades_filter=spot_trades_filter, + derivative_trades_filter=derivative_trades_filter, + spot_orders_filter=spot_orders_filter, + derivative_orders_filter=derivative_orders_filter, + spot_orderbooks_filter=spot_orderbooks_filter, + derivative_orderbooks_filter=derivative_orderbooks_filter, + positions_filter=positions_filter, + oracle_price_filter=oracle_price_filter, ) + ) + + await asyncio.sleep(delay=60) + task.cancel() if __name__ == "__main__": diff --git a/source/includes/_derivatives.md b/source/includes/_derivatives.md index cc8fffd0..4a72632e 100644 --- a/source/includes/_derivatives.md +++ b/source/includes/_derivatives.md @@ -13,6 +13,8 @@ Includes all messages related to derivative markets. import asyncio import uuid +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -33,7 +35,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) # prepare trade info @@ -66,18 +68,19 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return - sim_res_msg = composer.MsgResponses(sim_res, simulation=True) + sim_res_msg = sim_res["result"]["msgResponses"] print("---Simulation Response---") print(sim_res_msg) # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -91,7 +94,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print("---Transaction Response---") print(res) print("gas wanted: {}".format(gas_limit)) @@ -280,6 +283,8 @@ gas fee: 0.000069981 INJ import asyncio import uuid +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -300,7 +305,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) # prepare trade info @@ -334,18 +339,19 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return - sim_res_msg = composer.MsgResponses(sim_res, simulation=True) + sim_res_msg = sim_res["result"]["msgResponses"] print("---Simulation Response---") print(sim_res_msg) # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -359,7 +365,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print("---Transaction Response---") print(res) print("gas wanted: {}".format(gas_limit)) @@ -547,6 +553,8 @@ gas fee: 0.0000857195 INJ ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -567,7 +575,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) # prepare trade info @@ -592,14 +600,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -613,7 +622,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -772,6 +781,8 @@ Further note that if no marketIDs are provided in the SpotMarketIdsToCancelAll o import asyncio import uuid +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -792,7 +803,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) # prepare trade info @@ -902,18 +913,19 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return - sim_res_msg = composer.MsgResponses(sim_res, simulation=True) + sim_res_msg = sim_res["result"]["msgResponses"] print("---Simulation Response---") print(sim_res_msg) # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -927,7 +939,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print("---Transaction Response---") print(res) print("gas wanted: {}".format(gas_limit)) @@ -1203,6 +1215,8 @@ gas fee: 0.000329546 INJ ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -1223,7 +1237,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) # prepare trade info @@ -1251,14 +1265,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -1272,7 +1287,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -1442,7 +1457,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) subaccount_id_2 = address.get_subaccount_id(index=1) @@ -1538,7 +1553,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -1575,7 +1590,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -1665,7 +1680,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -1907,9 +1922,9 @@ There are two caveats to be mindful of when taking this approach: * If the client receives a sequence mismatch error (code 32), a refresh in sequence and subaccount nonce will likely resolve the error. ``` python - res = await self.client.send_tx_sync_mode(tx_raw_bytes) + res = await self.client.broadcast_tx_sync_mode(tx_raw_bytes) if res.code == 32: - await self.client.get_account(self.address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) ``` * To refresh the cached account sequence, updated account data can be fetched using the client. See example on right, using the Python client: * To refresh the cached subaccount nonce, the [`OrderHashManager`](https://github.com/InjectiveLabs/sdk-python/blob/master/pyinjective/orderhash.py#L47) can be reinitialized since the subaccount nonce is fetched from the chain during init. diff --git a/source/includes/_derivativesrpc.md b/source/includes/_derivativesrpc.md index 4d555b84..badd52ad 100644 --- a/source/includes/_derivativesrpc.md +++ b/source/includes/_derivativesrpc.md @@ -13,22 +13,23 @@ Get details of a single derivative market. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - market_id = "0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74" - market = await client.get_derivative_market(market_id=market_id) + market_id = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + market = await client.fetch_derivative_market(market_id=market_id) print(market) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -289,26 +290,24 @@ Get a list of one or more derivative markets. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - market_status = "active" + market_statuses = ["active"] quote_denom = "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - market = await client.get_derivative_markets( - market_status=market_status, - quote_denom=quote_denom - ) + market = await client.fetch_derivative_markets(market_statuses=market_statuses, quote_denom=quote_denom) print(market) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -363,10 +362,10 @@ const markets = await indexerGrpcDerivativesApi.fetchMarkets() console.log(markets) ``` -| Parameter | Type | Description | Required | -| ------------- | ------ | ------------------------------------------------------------------------------------------------------ | -------- | -| market_status | String | Filter by market status (Should be one of: ["active", "paused", "suspended", "demolished", "expired"]) | No | -| quote_denom | String | Filter by the Coin denomination of the quote currency | No | +| Parameter | Type | Description | Required | +| --------------- | ------------ | ------------------------------------------------------------------------------------------------------ | -------- | +| market_statuses | String Array | Filter by market status (Should be any of: ["active", "paused", "suspended", "demolished", "expired"]) | No | +| quote_denom | String | Filter by the Coin denomination of the quote currency | No | @@ -678,22 +677,46 @@ Stream live updates of derivative markets. ``` python import asyncio -import logging +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + +async def market_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to derivative markets updates ({exception})") + + +def stream_closed_processor(): + print("The derivative markets updates stream has been closed") + + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - markets = await client.stream_derivative_markets() - async for market in markets: - print(market) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + task = asyncio.get_event_loop().create_task( + client.listen_derivative_market_updates( + callback=market_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + ) + ) + + await asyncio.sleep(delay=60) + task.cancel() + + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -765,9 +788,12 @@ const streamFnArgs = { streamFn(streamFnArgs) ``` -| Parameter | Type | Description | Required | -| ---------- | ------------ | ------------------------------------------------------------------------------ | -------- | -| market_ids | String Array | List of market IDs for updates streaming, empty means 'ALL' derivative markets | No | +| Parameter | Type | Description | Required | +| ------------------ | ------------ | ---------------------------------------------------------------------------------------------------- | -------- | +| market_ids | String Array | List of market IDs for updates streaming, empty means 'ALL' derivative markets | No | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | ### Response Parameters > Streaming Response Example: @@ -983,32 +1009,34 @@ Lists historical orders posted from a subaccount ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient +from pyinjective.client.model.pagination import PaginationOption from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - market_id = "0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74" + market_ids = ["0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"] subaccount_id = "0x295639d56c987f0e24d21bb167872b3542a6e05a000000000000000000000000" is_conditional = "false" skip = 10 limit = 3 - orders = await client.get_historical_derivative_orders( - market_id=market_id, + pagination = PaginationOption(skip=skip, limit=limit) + orders = await client.fetch_derivative_orders_history( subaccount_id=subaccount_id, - skip=skip, - limit=limit, + market_ids=market_ids, is_conditional=is_conditional, + pagination=pagination, ) print(orders) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -1061,24 +1089,19 @@ func main() { ``` -| Parameter | Type | Description | Required | -| ------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------- | -------- | -| subaccount_id | String | Filter by subaccount ID | No | -| market_id | String | Filter by a single market ID | Yes | -| skip | Integer | Skip the first *n* items from the results. This can be used to fetch all results since the API caps at 100 | No | -| limit | Integer | Maximum number of items to be returned. 1 <= *n* <= 100 | No | -| order_types | String Array | The order types to be included (Should be one of: ["buy", "sell", "stop_buy", "stop_sell", "take_buy", "take_sell", "buy_po", "sell_po"]) | No | -| direction | String | Filter by order direction (Should be one of: ["buy", "sell"]) | No | -| start_time | Integer | Search for orders where createdAt >= startTime, time in milliseconds | No | -| end_time | Integer | Search for orders where createdAt <= startTime, time in milliseconds | No | -| is_conditional | String | Search for conditional/non-conditional orders(Should be one of: ["true", "false"]) | No | -| order_type | String | The order type (Should be one of: ["buy", "sell", "stop_buy", "stop_sell", "take_buy", "take_sell", "buy_po", "sell_po"]) | No | -| state | String | The order state (Should be one of: ["booked", "partial_filled", "filled", "canceled"]) | No | -| execution_types | String Array | The execution of the order (Should be one of: ["limit", "market"]) | No | -| market_ids | String Array | Filter by multiple market IDs | No | -| trade_id | String | Filter by the trade's trade id | No | -| active_markets_only | Bool | Return only orders for active markets | No | -| cid | String | Filter by the custom client order id of the trade's order | No | +| Parameter | Type | Description | Required | +| ------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -------- | +| subaccount_id | String | Filter by subaccount ID | No | +| market_ids | String Array | Filter by multiple market IDs | No | +| order_types | String Array | The order types to be included (Should be any of: ["buy", "sell", "stop_buy", "stop_sell", "take_buy", "take_sell", "buy_po", "sell_po"]) | No | +| direction | String | Filter by order direction (Should be one of: ["buy", "sell"]) | No | +| is_conditional | String | Search for conditional/non-conditional orders(Should be one of: ["true", "false"]) | No | +| state | String | The order state (Should be one of: ["booked", "partial_filled", "filled", "canceled"]) | No | +| execution_types | String Array | The execution of the order (Should be one of: ["limit", "market"]) | No | +| trade_id | String | Filter by the trade's trade id | No | +| active_markets_only | Bool | Return only orders for active markets | No | +| cid | String | Filter by the custom client order id of the trade's order | No | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters @@ -1300,27 +1323,48 @@ Stream order updates of a derivative market. ``` python import asyncio -import logging +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + +async def order_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to derivative orders history updates ({exception})") + + +def stream_closed_processor(): + print("The derivative orders history updates stream has been closed") + + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - market_id = "0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74" - order_side = "sell" - subaccount_id = "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" - orders = await client.stream_historical_derivative_orders( - market_id=market_id + market_id = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + + task = asyncio.get_event_loop().create_task( + client.listen_derivative_orders_history_updates( + callback=order_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + market_id=market_id, + ) ) - async for order in orders: - print(order) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + await asyncio.sleep(delay=60) + task.cancel() + + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -1408,14 +1452,17 @@ const orderHistory = await indexerGrpcDerivativesApi.fetchOrderHistory({ console.log(orderHistory) ``` -| Parameter | Type | Description | Required | -| --------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------- | -------- | -| market_id | String | Filter by market ID | Yes | -| subaccount_id | String | Filter by subaccount ID | No | -| direction | String | Filter by direction (Should be one of: ["buy", "sell"]) | No | -| state | String | Filter by state (Should be one of: ["booked", "partial_filled", "filled", "canceled"]) | No | -| order_types | String Array | Filter by order type (Should be one of: ["buy", "sell", "stop_buy", "stop_sell", "take_buy", "take_sell", "buy_po", "sell_po"]) | No | -| execution_types | String Array | Filter by execution type (Should be one of: ["limit", "market"]) | No | +| Parameter | Type | Description | Required | +| ------------------ | ------------ | ------------------------------------------------------------------------------------------------------------------------------- | -------- | +| subaccount_id | String | Filter by subaccount ID | No | +| market_id | String | Filter by market ID | No | +| order_types | String Array | Filter by order type (Should be one of: ["buy", "sell", "stop_buy", "stop_sell", "take_buy", "take_sell", "buy_po", "sell_po"]) | No | +| direction | String | Filter by direction (Should be one of: ["buy", "sell"]) | No | +| state | String | Filter by state (Should be one of: ["booked", "partial_filled", "filled", "canceled"]) | No | +| execution_types | String Array | Filter by execution type (Should be one of: ["limit", "market"]) | No | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | ### Response Parameters @@ -1543,26 +1590,30 @@ Get trades of a derivative market. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient +from pyinjective.client.model.pagination import PaginationOption from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - market_id = "0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74" - subaccount_id = "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" - trades = await client.get_derivative_trades( - market_id=market_id, - subaccount_id=subaccount_id + market_ids = ["0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"] + subaccount_ids = ["0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000"] + skip = 0 + limit = 4 + pagination = PaginationOption(skip=skip, limit=limit) + trades = await client.fetch_derivative_trades( + market_ids=market_ids, subaccount_ids=subaccount_ids, pagination=pagination ) print(trades) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -1632,22 +1683,17 @@ const trades = await indexerGrpcDerivativesApi.fetchTrades({ console.log(trades) ``` -| Parameter | Type | Description | Required | -| --------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------- | -------- | -| market_id | String | Filter by a single market ID | No | -| execution_side | String | Filter by the execution side of the trade (Should be one of: ["maker", "taker"]) | No | -| direction | String | Filter by the direction of the trade (Should be one of: ["buy", "sell"]) | No | -| subaccount_id | String | Filter by a single subaccount ID | No | -| skip | Integer | Skip the first *n* items from the results. This can be used to fetch all trades since the API caps at 100 | No | -| limit | Integer | Maximum number of items to be returned. 1 <= *n* <= 100 | No | -| start_time | Integer | startTime <= trade execution timestamp <= endTime | No | -| end_time | Integer | startTime <= trade execution timestamp <= endTime | No | -| market_ids | String Array | Filter by multiple market IDs | No | -| subaccount_ids | String Array | Filter by multiple subaccount IDs | No | -| execution_types | String Array | Filter by the *trade execution type (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | No | -| trade_id | String | Filter by the trade id of the trade | No | -| account_address | String | Filter by the account address | No | -| cid | String | Filter by the custom client order id of the trade's order | No | +| Parameter | Type | Description | Required | +| --------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------- | -------- | +| market_ids | String Array | Filter by multiple market IDs | No | +| subaccount_ids | String Array | Filter by multiple subaccount IDs | No | +| execution_side | String | Filter by the execution side of the trade (Should be one of: ["maker", "taker"]) | No | +| direction | String | Filter by the direction of the trade (Should be one of: ["buy", "sell"]) | No | +| execution_types | String Array | Filter by the *trade execution type (Should be any of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | No | +| trade_id | String | Filter by the trade id of the trade | No | +| account_address | String | Filter by the account address | No | +| cid | String | Filter by the custom client order id of the trade's order | No | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters > Response Example: @@ -1860,30 +1906,53 @@ Stream newly executed trades of a derivative market. The default request streams ``` python import asyncio -import logging +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + +async def market_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to derivative trades updates ({exception})") + + +def stream_closed_processor(): + print("The derivative trades updates stream has been closed") + + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) market_ids = [ - "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3", - "0xd5e4b12b19ecf176e4e14b42944731c27677819d2ed93be4104ad7025529c7ff" + "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "0x70bc8d7feab38b23d5fdfb12b9c3726e400c265edbcbf449b6c80c31d63d3a02", ] - subaccount_id = "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" - trades = await client.stream_derivative_trades( - market_id=market_ids[0], - subaccount_id=subaccount_id + subaccount_ids = ["0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000"] + + task = asyncio.get_event_loop().create_task( + client.listen_derivative_trades_updates( + callback=market_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + market_ids=market_ids, + subaccount_ids=subaccount_ids, + ) ) - async for trade in trades: - print(trade) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + await asyncio.sleep(delay=60) + task.cancel() + + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -1977,22 +2046,20 @@ import { ExchangeGrpcStreamClient } from "@injectivelabs/sdk-ts/dist/client/exch })(); ``` -| Parameter | Type | Description | Required | -| --------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------- | -------- | -| market_id | String | Filter by a single market ID | No | -| execution_side | String | Filter by the execution side of the trade (Should be one of: ["maker", "taker"]) | No | -| direction | String | Filter by the direction of the trade (Should be one of: ["buy", "sell"]) | No | -| subaccount_id | String | Filter by a single subaccount ID | No | -| skip | Integer | Skip will skip the first N items from the result | No | -| limit | Integer | Maximum number of items to be returned | No | -| start_time | Integer | Start timestamp (UNIX milliseconds) from when to filter trades | No | -| end_time | Integer | End timestamp (UNIX milliseconds) to filter trades | No | -| market_ids | String Array | Filter by multiple market IDs | No | -| subaccount_ids | String Array | Filter by multiple subaccount IDs | No | -| execution_types | String Array | Filter by the *trade execution type (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | No | -| trade_id | String | Filter by the trade's trade id | No | -| account_address | String | Filter by the account address | No | -| cid | String | Filter by the custom client order id of the trade's order | No | +| Parameter | Type | Description | Required | +| ------------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------- | -------- | +| market_ids | String Array | Filter by multiple market IDs | No | +| execution_side | String | Filter by the execution side of the trade (Should be one of: ["maker", "taker"]) | No | +| direction | String | Filter by the direction of the trade (Should be one of: ["buy", "sell"]) | No | +| subaccount_ids | String Array | Filter by multiple subaccount IDs | No | +| execution_types | String Array | Filter by the *trade execution type (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | No | +| trade_id | String | Filter by the trade's trade id | No | +| account_address | String | Filter by the account address | No | +| cid | String | Filter by the custom client order id of the trade's order | No | +| pagination | PaginationOption | Pagination configuration | No | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | ### Response Parameters > Streaming Response Example: @@ -2175,37 +2242,39 @@ Get the positions of a market. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient +from pyinjective.client.model.pagination import PaginationOption from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) market_ids = [ - "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3", - "0xe112199d9ee44ceb2697ea0edd1cd422223c105f3ed2bdf85223d3ca59f5909a" + "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "0xd97d0da6f6c11710ef06315971250e4e9aed4b7d4cd02059c9477ec8cf243782", ] subaccount_id = "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" direction = "short" subaccount_total_positions = False skip = 4 limit = 4 - positions = await client.get_derivative_positions( + pagination = PaginationOption(skip=skip, limit=limit) + positions = await client.fetch_derivative_positions( market_ids=market_ids, - # subaccount_id=subaccount_id, + subaccount_id=subaccount_id, direction=direction, subaccount_total_positions=subaccount_total_positions, - skip=skip, - limit=limit + pagination=pagination, ) print(positions) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -2282,17 +2351,13 @@ import { ExchangeGrpcClient } from "@injectivelabs/sdk-ts/dist/client/exchange/E })(); ``` -| Parameter | Type | Description | Required | -| -------------------------- | ------------ | ---------------------------------------------------------------------------------------------------------- | -------- | -| market_id | String | Filter by a single market ID | No | -| market_ids | String Array | Filter by multiple market IDs | No | -| subaccount_id | String | Filter by subaccount ID | No | -| direction | String | Filter by direction of position (Should be one of: ["long", "short"]) | | -| subaccount_total_positions | Boolean | Choose to return subaccount total positions (Should be one of: [True, False]) | | -| skip | Integer | Skip the first *n* items from the results. This can be used to fetch all results since the API caps at 100 | No | -| limit | Integer | Maximum number of items to be returned. 1 <= *n* <= 100 | No | -| start_time | Integer | startTime <= position timestamp <= endTime | No | -| end_time | Integer | startTime <= position timestamp <= endTime | No | +| Parameter | Type | Description | Required | +| -------------------------- | ---------------- | ----------------------------------------------------------------------------- | -------- | +| market_ids | String Array | Filter by multiple market IDs | No | +| subaccount_id | String | Filter by subaccount ID | No | +| direction | String | Filter by direction of position (Should be one of: ["long", "short"]) | No | +| subaccount_total_positions | Boolean | Choose to return subaccount total positions (Should be one of: [True, False]) | No | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters > Response Example: @@ -2453,27 +2518,50 @@ Stream position updates for a specific market. ``` python import asyncio -import logging +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + +async def positions_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to derivative positions updates ({exception})") + + +def stream_closed_processor(): + print("The derivative positions updates stream has been closed") + + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - market_id = "0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74" - subaccount_id = "0xea98e3aa091a6676194df40ac089e40ab4604bf9000000000000000000000000" - positions = await client.stream_derivative_positions( - market_id=market_id, - subaccount_id=subaccount_id + market_ids = ["0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"] + subaccount_ids = ["0xea98e3aa091a6676194df40ac089e40ab4604bf9000000000000000000000000"] + + task = asyncio.get_event_loop().create_task( + client.listen_derivative_positions_updates( + callback=positions_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + market_ids=market_ids, + subaccount_ids=subaccount_ids, + ) ) - async for position in positions: - print(position) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + await asyncio.sleep(delay=60) + task.cancel() + + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -2554,12 +2642,13 @@ import { ExchangeGrpcStreamClient } from "@injectivelabs/sdk-ts/dist/client/exch })(); ``` -| Parameter | Type | Description | Required | -| -------------- | ------------ | ------------------------------------------------------ | -------- | -| market_id | String | ID of the market to stream position data from | No | -| market_ids | String Array | IDs of the markets to stream position data from | No | -| subaccount_ids | String Array | Subaccount IDs of the traders to stream positions from | No | -| subaccount_id | String | Subaccount ID of the trader to stream positions from | No | +| Parameter | Type | Description | Required | +| ------------------ | ------------ | ---------------------------------------------------------------------------------------------------- | -------- | +| market_ids | String Array | IDs of the markets to stream position data from | No | +| subaccount_ids | String Array | Subaccount IDs of the traders to stream positions from | No | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | ### Response Parameters @@ -2699,22 +2788,23 @@ This API will be removed on April 5, 2023 on testnet and on April 22, 2023 on ma ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - market_id = "0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74" - market = await client.get_derivative_orderbook(market_id=market_id) + market_id = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + market = await client.fetch_derivative_orderbook_v2(market_id=market_id) print(market) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -3502,24 +3592,24 @@ Get an orderbook snapshot for one or more derivative markets. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) market_ids = [ - "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3", - "0xd5e4b12b19ecf176e4e14b42944731c27677819d2ed93be4104ad7025529c7ff" + "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "0xd5e4b12b19ecf176e4e14b42944731c27677819d2ed93be4104ad7025529c7ff", ] - orderbooks = await client.get_derivative_orderbooksV2(market_ids=market_ids) + orderbooks = await client.fetch_derivative_orderbooks_v2(market_ids=market_ids) print(orderbooks) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) ``` @@ -3659,23 +3749,46 @@ Stream orderbook snapshot updates for one or more derivative markets ``` python import asyncio -import logging +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network +async def orderbook_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to derivative orderbook snapshots ({exception})") + + +def stream_closed_processor(): + print("The derivative orderbook snapshots stream has been closed") + + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - market_ids = ["0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3"] - orderbooks = await client.stream_derivative_orderbook_snapshot(market_ids=market_ids) - async for orderbook in orderbooks: - print(orderbook) + market_ids = ["0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"] + + task = asyncio.get_event_loop().create_task( + client.listen_derivative_orderbook_snapshots( + market_ids=market_ids, + callback=orderbook_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + ) + ) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + await asyncio.sleep(delay=60) + task.cancel() + + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) ``` @@ -3708,9 +3821,12 @@ streamFn(streamFnArgs) ``` -| Parameter | Type | Description | Required | -| ---------- | ------------ | ------------------------------------------------------------------------ | -------- | -| market_ids | String Array | List of market IDs for orderbook streaming; empty means all spot markets | Yes | +| Parameter | Type | Description | Required | +| ------------------ | ------------ | ---------------------------------------------------------------------------------------------------- | -------- | +| market_ids | String Array | List of market IDs for orderbook streaming; empty means all spot markets | Yes | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | ### Response Parameters @@ -3829,13 +3945,23 @@ Stream incremental orderbook updates for one or more derivative markets. This st ``` python import asyncio -import logging -from decimal import * +from decimal import Decimal +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to derivative orderbook updates ({exception})") + + +def stream_closed_processor(): + print("The derivative orderbook updates stream has been closed") + + class PriceLevel: def __init__(self, price: Decimal, quantity: Decimal, timestamp: int): self.price = price @@ -3855,24 +3981,24 @@ class Orderbook: async def load_orderbook_snapshot(async_client: AsyncClient, orderbook: Orderbook): # load the snapshot - res = await async_client.get_derivative_orderbooksV2(market_ids=[orderbook.market_id]) - for snapshot in res.orderbooks: - if snapshot.market_id != orderbook.market_id: + res = await async_client.fetch_derivative_orderbooks_v2(market_ids=[orderbook.market_id]) + for snapshot in res["orderbooks"]: + if snapshot["marketId"] != orderbook.market_id: raise Exception("unexpected snapshot") - orderbook.sequence = int(snapshot.orderbook.sequence) + orderbook.sequence = int(snapshot["orderbook"]["sequence"]) - for buy in snapshot.orderbook.buys: - orderbook.levels["buys"][buy.price] = PriceLevel( - price=Decimal(buy.price), - quantity=Decimal(buy.quantity), - timestamp=buy.timestamp, + for buy in snapshot["orderbook"]["buys"]: + orderbook.levels["buys"][buy["price"]] = PriceLevel( + price=Decimal(buy["price"]), + quantity=Decimal(buy["quantity"]), + timestamp=int(buy["timestamp"]), ) - for sell in snapshot.orderbook.sells: - orderbook.levels["sells"][sell.price] = PriceLevel( - price=Decimal(sell.price), - quantity=Decimal(sell.quantity), - timestamp=sell.timestamp, + for sell in snapshot["orderbook"]["sells"]: + orderbook.levels["sells"][sell["price"]] = PriceLevel( + price=Decimal(sell["price"]), + quantity=Decimal(sell["quantity"]), + timestamp=int(sell["timestamp"]), ) break @@ -3882,78 +4008,96 @@ async def main() -> None: network = Network.testnet() async_client = AsyncClient(network) - market_id = "0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74" + market_id = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" orderbook = Orderbook(market_id=market_id) + updates_queue = asyncio.Queue() + tasks = [] + + async def queue_event(event: Dict[str, Any]): + await updates_queue.put(event) # start getting price levels updates - stream = await async_client.stream_derivative_orderbook_update(market_ids=[market_id]) - first_update = None - async for update in stream: - first_update = update.orderbook_level_updates - break + task = asyncio.get_event_loop().create_task( + async_client.listen_derivative_orderbook_updates( + market_ids=[market_id], + callback=queue_event, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + ) + ) + tasks.append(task) # load the snapshot once we are already receiving updates, so we don't miss any await load_orderbook_snapshot(async_client=async_client, orderbook=orderbook) - # start consuming updates again to process them - apply_orderbook_update(orderbook, first_update) - async for update in stream: - apply_orderbook_update(orderbook, update.orderbook_level_updates) + task = asyncio.get_event_loop().create_task( + apply_orderbook_update(orderbook=orderbook, updates_queue=updates_queue) + ) + tasks.append(task) + await asyncio.sleep(delay=60) + for task in tasks: + task.cancel() -def apply_orderbook_update(orderbook: Orderbook, updates): - # discard old updates - if updates.sequence <= orderbook.sequence: - return - print(" * * * * * * * * * * * * * * * * * * *") - - # ensure we have not missed any update - if updates.sequence > (orderbook.sequence + 1): - raise Exception("missing orderbook update events from stream, must restart: {} vs {}".format( - updates.sequence, (orderbook.sequence + 1))) - - print("updating orderbook with updates at sequence {}".format(updates.sequence)) - - # update orderbook - orderbook.sequence = updates.sequence - for direction, levels in {"buys": updates.buys, "sells": updates.sells}.items(): - for level in levels: - if level.is_active: - # upsert level - orderbook.levels[direction][level.price] = PriceLevel( - price=Decimal(level.price), - quantity=Decimal(level.quantity), - timestamp=level.timestamp) - else: - if level.price in orderbook.levels[direction]: - del orderbook.levels[direction][level.price] - - # sort the level numerically - buys = sorted(orderbook.levels["buys"].values(), key=lambda x: x.price, reverse=True) - sells = sorted(orderbook.levels["sells"].values(), key=lambda x: x.price, reverse=True) - - # lowest sell price should be higher than the highest buy price - if len(buys) > 0 and len(sells) > 0: - highest_buy = buys[0].price - lowest_sell = sells[-1].price - print("Max buy: {} - Min sell: {}".format(highest_buy, lowest_sell)) - if highest_buy >= lowest_sell: - raise Exception("crossed orderbook, must restart") - - # for the example, print the list of buys and sells orders. - print("sells") - for k in sells: - print(k) - print("=========") - print("buys") - for k in buys: - print(k) - print("====================================") +async def apply_orderbook_update(orderbook: Orderbook, updates_queue: asyncio.Queue): + while True: + updates = await updates_queue.get() + update = updates["orderbookLevelUpdates"] + # discard updates older than the snapshot + if int(update["sequence"]) <= orderbook.sequence: + return -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + print(" * * * * * * * * * * * * * * * * * * *") + + # ensure we have not missed any update + if int(update["sequence"]) > (orderbook.sequence + 1): + raise Exception( + "missing orderbook update events from stream, must restart: {} vs {}".format( + update["sequence"], (orderbook.sequence + 1) + ) + ) + + print("updating orderbook with updates at sequence {}".format(update["sequence"])) + + # update orderbook + orderbook.sequence = int(update["sequence"]) + for direction, levels in {"buys": update["buys"], "sells": update["sells"]}.items(): + for level in levels: + if level["isActive"]: + # upsert level + orderbook.levels[direction][level["price"]] = PriceLevel( + price=Decimal(level["price"]), quantity=Decimal(level["quantity"]), timestamp=level["timestamp"] + ) + else: + if level["price"] in orderbook.levels[direction]: + del orderbook.levels[direction][level["price"]] + + # sort the level numerically + buys = sorted(orderbook.levels["buys"].values(), key=lambda x: x.price, reverse=True) + sells = sorted(orderbook.levels["sells"].values(), key=lambda x: x.price, reverse=True) + + # lowest sell price should be higher than the highest buy price + if len(buys) > 0 and len(sells) > 0: + highest_buy = buys[0].price + lowest_sell = sells[-1].price + print("Max buy: {} - Min sell: {}".format(highest_buy, lowest_sell)) + if highest_buy >= lowest_sell: + raise Exception("crossed orderbook, must restart") + + # for the example, print the list of buys and sells orders. + print("sells") + for k in sells: + print(k) + print("=========") + print("buys") + for k in buys: + print(k) + print("====================================") + + +if __name__ == "__main__": asyncio.run(main()) ``` @@ -3988,9 +4132,12 @@ streamFn(streamFnArgs) ``` -| Parameter | Type | Description | Required | -| ---------- | ------------ | ------------------------------------------------------------------------------ | -------- | -| market_ids | String Array | List of market IDs for orderbook streaming; empty means all derivative markets | Yes | +| Parameter | Type | Description | Required | +| ------------------ | ------------ | ---------------------------------------------------------------------------------------------------- | -------- | +| market_ids | String Array | List of market IDs for orderbook streaming; empty means all derivative markets | Yes | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | ### Response Parameters @@ -4095,31 +4242,30 @@ Get the derivative orders of a specific subaccount. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient +from pyinjective.client.model.pagination import PaginationOption from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) subaccount_id = "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - market_id = "0xe112199d9ee44ceb2697ea0edd1cd422223c105f3ed2bdf85223d3ca59f5909a" + market_id = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" skip = 1 limit = 2 - orders = await client.get_derivative_subaccount_orders( - subaccount_id=subaccount_id, - market_id=market_id, - skip=skip, - limit=limit - ) + pagination = PaginationOption(skip=skip, limit=limit) + orders = await client.fetch_subaccount_orders_list( + subaccount_id=subaccount_id, market_id=market_id, pagination=pagination + ) print(orders) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -4189,12 +4335,11 @@ const subaccountOrders = await indexerGrpcDerivativesApi.fetchSubaccountOrdersLi console.log(subaccountOrders) ``` -| Parameter | Type | Description | Required | -| ------------- | ------- | ---------------------------------------------------------------------------------------------------------- | -------- | -| subaccount_id | String | Filter by subaccount ID | Yes | -| market_id | String | Filter by market ID | No | -| skip | Integer | Skip the first *n* items from the results. This can be used to fetch all results since the API caps at 100 | No | -| limit | Integer | Maximum number of items to be returned. 1 <= *n* <= 100 | No | +| Parameter | Type | Description | Required | +| ------------- | ---------------- | ------------------------ | -------- | +| subaccount_id | String | Filter by subaccount ID | Yes | +| market_id | String | Filter by market ID | No | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters @@ -4372,35 +4517,36 @@ Get the derivative trades for a specific subaccount. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient +from pyinjective.client.model.pagination import PaginationOption from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) subaccount_id = "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - market_id = "0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74" + market_id = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" execution_type = "market" direction = "sell" skip = 10 limit = 2 - trades = await client.get_derivative_subaccount_trades( + pagination = PaginationOption(skip=skip, limit=limit) + trades = await client.fetch_derivative_subaccount_trades_list( subaccount_id=subaccount_id, market_id=market_id, execution_type=execution_type, direction=direction, - skip=skip, - limit=limit + pagination=pagination, ) print(trades) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -4476,14 +4622,13 @@ const subaccountTrades = await indexerGrpcDerivativesApi.fetchSubaccountTradesLi console.log(subaccountTrades) ``` -| Parameter | Type | Description | Required | -| -------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------- | -------- | -| subaccount_id | String | Subaccount ID of trader to get trades from | Yes | -| market_id | String | Filter by Market ID | No | -| direction | String | Filter by the direction of the trades (Should be one of: ["buy", "sell"]) | No | -| execution_type | String | Filter by the *execution type of the trades (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | No | -| skip | Integer | Skip the first *n* items from the results. This can be used to fetch all results since the API caps at 100 | No | -| limit | Integer | Maximum number of items to be returned. 1 <= *n* <= 100 | No | +| Parameter | Type | Description | Required | +| -------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -------- | +| subaccount_id | String | Subaccount ID of trader to get trades from | Yes | +| market_id | String | Filter by Market ID | No | +| execution_type | String | Filter by the *execution type of the trades (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | No | +| direction | String | Filter by the direction of the trades (Should be one of: ["buy", "sell"]) | No | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters @@ -4668,32 +4813,31 @@ Get the funding payments for a subaccount. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient +from pyinjective.client.model.pagination import PaginationOption from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - market_id = "0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74" + market_ids = ["0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"] subaccount_id = "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" - skip=0 - limit=3 - end_time=1676426400125 - funding = await client.get_funding_payments( - market_id=market_id, - subaccount_id=subaccount_id, - skip=skip, - limit=limit, - end_time=end_time + skip = 0 + limit = 3 + end_time = 1676426400125 + pagination = PaginationOption(skip=skip, limit=limit, end_time=end_time) + funding_payments = await client.fetch_funding_payments( + market_ids=market_ids, subaccount_id=subaccount_id, pagination=pagination ) - print(funding) + print(funding_payments) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -4757,14 +4901,11 @@ const fundingPayments = await indexerGrpcDerivativesApi.fetchFundingPayments({ console.log(fundingPayments) ``` -| Parameter | Type | Description | Required | -| ------------- | ------------ | ---------------------------------------------------------------------------------------------------- | -------- | -| subaccount_id | String | Subaccount ID of the trader we want to get the positions from | Yes | -| market_id | String | Filter by a single market ID | No | -| market_ids | String Array | Filter by multiple market IDs | No | -| skip | Integer | Skip the last *n* funding payments. This can be used to fetch all payments since the API caps at 100 | No | -| limit | Integer | Maximum number of items to be returned. 1 <= *n* <= 100 | No | -| end_time | Integer | Upper bound (inclusive) of the funding payment timestamp | No | +| Parameter | Type | Description | Required | +| ------------- | ---------------- | ------------------------------------------------------------- | -------- | +| market_ids | String Array | Filter by multiple market IDs | No | +| subaccount_id | String | Subaccount ID of the trader we want to get the positions from | No | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters @@ -4876,30 +5017,28 @@ Get the historical funding rates for a specific market. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient +from pyinjective.client.model.pagination import PaginationOption from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - market_id = "0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74" - skip=0 - limit=3 - end_time=1675717201465 - funding_rates = await client.get_funding_rates( - market_id=market_id, - skip=skip, - limit=limit, - end_time=end_time - ) + market_id = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + skip = 0 + limit = 3 + end_time = 1675717201465 + pagination = PaginationOption(skip=skip, limit=limit, end_time=end_time) + funding_rates = await client.fetch_funding_rates(market_id=market_id, pagination=pagination) print(funding_rates) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -4961,12 +5100,10 @@ const fundingRates = await indexerGrpcDerivativesApi.fetchFundingRates({ console.log(fundingRates) ``` -| Parameter | Type | Description | Required | -| --------- | ------- | ------------------------------------------------------------------------------------------------------ | -------- | -| market_id | String | ID of the market to get funding rates for | Yes | -| skip | Integer | Skip the last *n* funding rates. This can be used to fetch all funding rates since the API caps at 100 | No | -| limit | Integer | Maximum number of funding rates to be returned. 1 <= *n* <= 100 | No | -| end_time | Integer | Upper bound (inclusive) of funding rate timestamp | No | +| Parameter | Type | Description | Required | +| ---------- | ---------------- | ----------------------------------------- | -------- | +| market_id | String | ID of the market to get funding rates for | Yes | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters @@ -5069,21 +5206,20 @@ Get details of a single binary options market. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: - # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) market_id = "0x175513943b8677368d138e57bcd6bef53170a0da192e7eaa8c2cd4509b54f8db" - market = await client.get_binary_options_market(market_id=market_id) + market = await client.fetch_binary_options_market(market_id=market_id) print(market) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) ``` @@ -5221,30 +5357,22 @@ Get a list of binary options markets. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: - # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) market_status = "active" - quote_denom = "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - limit = 2 - skip = 2 - market = await client.get_binary_options_markets( - market_status=market_status, - quote_denom=quote_denom, - limit=limit, - skip=skip - ) + quote_denom = "peggy0xdAC17F958D2ee523a2206206994597C13D831ec7" + market = await client.fetch_binary_options_markets(market_status=market_status, quote_denom=quote_denom) print(market) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) ``` @@ -5267,12 +5395,11 @@ console.log(binaryOptionsMarket) ``` -| Parameter | Type | Description | Required | -| ------------- | ------- | ----------------------------------------------------------------------------------------------------------------- | -------- | -| market_status | String | Filter by the status of the market (Should be one of: ["active", "paused", "suspended", "demolished", "expired"]) | No | -| quote_denom | String | Filter by the Coin denomination of the quote currency | No | -| skip | Integer | Skip the first *n* items from the results. This can be used to fetch all results since the API caps at 100 | No | -| limit | Integer | Maximum number of items to be returned. 1 <= *n* <= 100 | No | +| Parameter | Type | Description | Required | +| ------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------- | -------- | +| market_status | String | Filter by the status of the market (Should be one of: ["active", "paused", "suspended", "demolished", "expired"]) | No | +| quote_denom | String | Filter by the Coin denomination of the quote currency | No | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters diff --git a/source/includes/_explorerrpc.md b/source/includes/_explorerrpc.md index d554ec10..7786232c 100644 --- a/source/includes/_explorerrpc.md +++ b/source/includes/_explorerrpc.md @@ -14,29 +14,30 @@ Get the details for a specific transaction. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.composer import Composer from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) composer = Composer(network=network.string()) tx_hash = "0F3EBEC1882E1EEAC5B7BDD836E976250F1CD072B79485877CEACCB92ACDDF52" - transaction_response = await client.get_tx_by_hash(tx_hash=tx_hash) + transaction_response = await client.fetch_tx_by_tx_hash(tx_hash=tx_hash) print(transaction_response) - transaction_messages = composer.UnpackTransactionMessages(transaction=transaction_response.data) + transaction_messages = composer.unpack_transaction_messages(transaction_data=transaction_response["data"]) print(transaction_messages) first_message = transaction_messages[0] print(first_message) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -259,29 +260,35 @@ Get the details for a specific transaction. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient +from pyinjective.client.model.pagination import PaginationOption from pyinjective.composer import Composer from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) composer = Composer(network=network.string()) address = "inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex" - type = "cosmos.bank.v1beta1.MsgSend" + message_type = "cosmos.bank.v1beta1.MsgSend" limit = 2 - transactions_response = await client.get_account_txs(address=address, type=message_type, limit=limit) + pagination = PaginationOption(limit=limit) + transactions_response = await client.fetch_account_txs( + address=address, + message_type=message_type, + pagination=pagination, + ) print(transactions_response) - first_transaction_messages = composer.UnpackTransactionMessages(transaction=transactions_response.data[0]) + first_transaction_messages = composer.unpack_transaction_messages(transaction_data=transactions_response["data"][0]) print(first_transaction_messages) first_message = first_transaction_messages[0] print(first_message) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) ``` @@ -350,15 +357,17 @@ import { ExchangeGrpcClient } from "@injectivelabs/sdk-ts/dist/client/exchange/E })(); ``` -|Parameter|Type|Description|Required| -|----|----|----|----| -|address|String|The Injective Chain address|Yes| -|type|String|Filter by message type|No| -|module|String|Filter by module|No| -|before|Integer|Filter transactions before a given block height|No| -|after|Integer|Filter transactions after a given block height|No| -|limit|Integer|Limit the returned transactions|No| -|skip|Integer|Skip the first *n* transactions. This can be used to fetch all results since the API caps at 100.|No| +| Parameter | Type | Description | Required | +| ------------ | ---------------- | ----------------------------------------------- | -------- | +| address | String | The Injective Chain address | Yes | +| before | Integer | Filter transactions before a given block height | No | +| after | Integer | Filter transactions after a given block height | No | +| message_type | String | Filter by message type | No | +| module | String | Filter by module | No | +| from_number | Integer | Filter from transaction number | No | +| to_number | Integer | Filter to transaction number | No | +| status | String | Filter by transaction status | No | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters @@ -695,21 +704,23 @@ Get data for blocks. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient +from pyinjective.client.model.pagination import PaginationOption from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) limit = 2 - block = await client.get_blocks(limit=limit) - print(block) + pagination = PaginationOption(limit=limit) + blocks = await client.fetch_blocks(pagination=pagination) + print(blocks) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) ``` @@ -766,11 +777,11 @@ import { ExchangeGrpcClient } from "@injectivelabs/sdk-ts/dist/client/exchange/E })(); ``` -|Parameter|Type|Description|Required| -|----|----|----|----| -|before|Integer|Filter transactions before a given block height|No| -|after|Integer|Filter transactions after a given block height|No| -|limit|Integer|Limit the number of returned blocks|No| +| Parameter | Type | Description | Required | +| ---------- | ---------------- | ----------------------------------------------- | -------- | +| before | Integer | Filter transactions before a given block height | No | +| after | Integer | Filter transactions after a given block height | No | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters @@ -895,21 +906,21 @@ Get detailed data for a single block. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) block_height = "5825046" - block = await client.get_block(block_height=block_height) + block = await client.fetch_block(block_id=block_height) print(block) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) ``` @@ -966,9 +977,9 @@ import { ExchangeGrpcClient } from "@injectivelabs/sdk-ts/dist/client/exchange/E })(); ``` -|Parameter|Type|Description|Required| -|----|----|----|----| -|id|String|Block height|Yes| +| Parameter | Type | Description | Required | +| --------- | ------ | ------------ | -------- | +| block_id | String | Block height | Yes | ### Response Parameters @@ -1069,21 +1080,23 @@ Get the transactions. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient +from pyinjective.client.model.pagination import PaginationOption from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) limit = 2 - txs = await client.get_txs(limit=limit) + pagination = PaginationOption(limit=limit) + txs = await client.fetch_txs(pagination=pagination) print(txs) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) ``` @@ -1145,14 +1158,16 @@ import { ExchangeGrpcClient } from "@injectivelabs/sdk-ts/dist/client/exchange/E })(); ``` -|Parameter|Type|Description|Required| -|----|----|----|----| -|type|String|Filter by message type|No| -|module|String|Filter by module|No| -|before|Integer|Filter transactions before a given block height|No| -|after|Integer|Filter transactions after a given block height|No| -|limit|Integer|Limit the returned transactions|No| -|skip|Integer|Skip the first *n* transactions. This can be used to fetch all results since the API caps at 100.|No| +| Parameter | Type | Description | Required | +| ------------ | ---------------- | ----------------------------------------------- | -------- | +| before | Integer | Filter transactions before a given block height | No | +| after | Integer | Filter transactions after a given block height | No | +| message_type | String | Filter by message type | No | +| module | String | Filter by module | No | +| from_number | Integer | Filter from transaction number | No | +| to_number | Integer | Filter to transaction number | No | +| status | String | Filter by transaction status | No | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters @@ -1364,22 +1379,44 @@ Stream transactions. ``` python import asyncio -import logging +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + +async def tx_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to txs updates ({exception})") + + +def stream_closed_processor(): + print("The txs updates stream has been closed") + + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - stream_txs = await client.stream_txs( + + task = asyncio.get_event_loop().create_task( + client.listen_txs_updates( + callback=tx_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + ) ) - async for tx in stream_txs: - print(tx) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + await asyncio.sleep(delay=60) + task.cancel() + + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) ``` @@ -1451,6 +1488,13 @@ import { ExchangeGrpcStreamClient } from "@injectivelabs/sdk-ts/dist/client/exch })(); ``` +| Parameter | Type | Description | Required | +| ------------------ | -------- | ---------------------------------------------------------------------------------------------------- | -------- | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | + + ### Response Parameters > Response Example: @@ -1614,22 +1658,44 @@ Stream blocks. ``` python import asyncio -import logging +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + +async def block_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to blocks updates ({exception})") + + +def stream_closed_processor(): + print("The blocks updates stream has been closed") + + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - stream_blocks = await client.stream_blocks( + + task = asyncio.get_event_loop().create_task( + client.listen_blocks_updates( + callback=block_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + ) ) - async for block in stream_blocks: - print(block) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + await asyncio.sleep(delay=60) + task.cancel() + + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) ``` @@ -1702,6 +1768,12 @@ import { ExchangeGrpcStreamClient } from "@injectivelabs/sdk-ts/dist/client/exch })(); ``` +| Parameter | Type | Description | Required | +| ------------------ | -------- | ---------------------------------------------------------------------------------------------------- | -------- | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | + ### Response Parameters > Response Example: @@ -1799,21 +1871,21 @@ Get info on peggy deposits. By default, deposits for all senders and receivers w ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) receiver = "inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex" - peggy_deposits = await client.get_peggy_deposits(receiver=receiver) + peggy_deposits = await client.fetch_peggy_deposit_txs(receiver=receiver) print(peggy_deposits) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) ``` @@ -1879,12 +1951,11 @@ import { ExchangeGrpcClient } from "@injectivelabs/sdk-ts/dist/client/exchange/E })(); ``` -|Parameter|Type|Description|Required| -|----|----|----|----| -|sender|String|Filter by sender address|No| -|receiver|String|Filter by receiver address|No| -|limit|Integer|Limit the number of returned records|No| -|skip|Integer|Skip the first *n* records. This can be used to retrieve all records since the API caps at 100|No| +| Parameter | Type | Description | Required | +| ---------- | ---------------- | -------------------------- | -------- | +| sender | String | Filter by sender address | No | +| receiver | String | Filter by receiver address | No | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters @@ -2048,25 +2119,24 @@ Get info on peggy withdrawals. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient +from pyinjective.client.model.pagination import PaginationOption from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) sender = "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" limit = 2 - peggy_deposits = await client.get_peggy_withdrawals( - sender=sender, - limit=limit - ) + pagination = PaginationOption(limit=limit) + peggy_deposits = await client.fetch_peggy_withdrawal_txs(sender=sender, pagination=pagination) print(peggy_deposits) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) ``` @@ -2131,12 +2201,11 @@ import { ExchangeGrpcClient } from "@injectivelabs/sdk-ts/dist/client/exchange/E })(); ``` -|Parameter|Type|Description|Required| -|----|----|----|----| -|sender|String|Filter by sender address|No| -|receiver|String|Filter by receiver address|No| -|limit|Integer|Limit the number of returned records|No| -|skip|Integer|Skip the first *n* records. This can be used to retrieve all records since the API caps at 100|No| +| Parameter | Type | Description | Required | +| ---------- | ---------------- | -------------------------- | -------- | +| sender | String | Filter by sender address | No | +| receiver | String | Filter by receiver address | No | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters > Response Example: @@ -2297,11 +2366,12 @@ Get data on IBC transfers. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient +from pyinjective.client.model.pagination import PaginationOption from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() @@ -2314,20 +2384,20 @@ async def main() -> None: dest_port = "transfer" limit = 1 skip = 10 - ibc_transfers = await client.get_ibc_transfers( + pagination = PaginationOption(limit=limit, skip=skip) + ibc_transfers = await client.fetch_ibc_transfer_txs( sender=sender, receiver=receiver, src_channel=src_channel, src_port=src_port, - destination_channel=destination_channel, + dest_channel=destination_channel, dest_port=dest_port, - # limit=limit, - # skip=skip + pagination=pagination, ) print(ibc_transfers) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) ``` @@ -2392,16 +2462,15 @@ import { ExchangeGrpcClient } from "@injectivelabs/sdk-ts/dist/client/exchange/E })(); ``` -|Parameter|Type|Description|Required| -|----|----|----|----| -|sender|String|Filter transfers based on sender address|No| -|receiver|String|Filter transfers based on receiver address|No| -|src_channel|String|Filter transfers based on source channel|No| -|src_port|String|Filter transfers based on source port|No| -|dest_channel|String|Filter transfers based on destination channel|No| -|dest_port|String|Filter transfers based on destination port|No| -|limit|Integer|Limit the returned transfers|No| -|skip|Integer|Skip the last *n* transfers. This can be used to fetch all transfers since the API caps at 100|No| +| Parameter | Type | Description | Required | +| ------------ | ---------------- | --------------------------------------------- | -------- | +| sender | String | Filter transfers based on sender address | No | +| receiver | String | Filter transfers based on receiver address | No | +| src_channel | String | Filter transfers based on source channel | No | +| src_port | String | Filter transfers based on source port | No | +| dest_channel | String | Filter transfers based on destination channel | No | +| dest_port | String | Filter transfers based on destination port | No | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters diff --git a/source/includes/_insurance.md b/source/includes/_insurance.md index 1926d802..8fbb71d2 100644 --- a/source/includes/_insurance.md +++ b/source/includes/_insurance.md @@ -12,6 +12,8 @@ Includes the messages to create, underwrite and redeem in insurance funds. ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -33,7 +35,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) msg = composer.MsgCreateInsuranceFund( sender=address.to_acc_bech32(), @@ -59,14 +61,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -80,7 +83,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -123,6 +126,8 @@ gas fee: 0.000075824 INJ ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -144,7 +149,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) msg = composer.MsgUnderwrite( sender=address.to_acc_bech32(), @@ -166,14 +171,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -187,7 +193,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -226,6 +232,8 @@ gas fee: 0.000071021 INJ ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -247,7 +255,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) msg = composer.MsgRequestRedemption( sender=address.to_acc_bech32(), @@ -269,14 +277,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -290,7 +299,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) diff --git a/source/includes/_insurancerpc.md b/source/includes/_insurancerpc.md index f28ce125..a468b2f6 100644 --- a/source/includes/_insurancerpc.md +++ b/source/includes/_insurancerpc.md @@ -14,22 +14,23 @@ List all the insurance funds. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - insurance_funds = await client.get_insurance_funds() + insurance_funds = await client.fetch_insurance_funds() print(insurance_funds) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -250,11 +251,11 @@ Get a list of redemptions. If no parameters are provided, redemptions for all po ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() @@ -262,17 +263,14 @@ async def main() -> None: redeemer = "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" redemption_denom = "share4" status = "disbursed" - insurance_redemptions = await client.get_redemptions( - redeemer=redeemer, - redemption_denom=redemption_denom, - status=status - ) + insurance_redemptions = await client.fetch_redemptions(address=redeemer, denom=redemption_denom, status=status) print(insurance_redemptions) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -328,11 +326,11 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; })(); ``` -|Parameter|Type|Description|Required| -|----|----|----|----| -|redeemer|String|Filter by address of the redeemer|No| -|redemption_denom|String|Filter by denom of the insurance pool token|No| -|status|String|Filter by redemption status (Should be one of: ["disbursed", "pending"])|No| +| Parameter | Type | Description | Required | +| --------- | ------ | ------------------------------------------------------------------------ | -------- | +| address | String | Filter by address of the redeemer | No | +| denom | String | Filter by denom of the insurance pool token | No | +| status | String | Filter by redemption status (Should be one of: ["disbursed", "pending"]) | No | ### Response Parameters diff --git a/source/includes/_metarpc.md b/source/includes/_metarpc.md index 07c99800..fe1d6c3d 100644 --- a/source/includes/_metarpc.md +++ b/source/includes/_metarpc.md @@ -13,21 +13,22 @@ Get the server health. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - resp = await client.ping() - print('Health OK?', resp) + resp = await client.fetch_ping() + print("Health OK?", resp) + -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -106,21 +107,22 @@ Get the server version. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - resp = await client.version() - print('Version:', resp) + resp = await client.fetch_version() + print("Version:", resp) + -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -244,27 +246,27 @@ Get the server information. ``` python import asyncio -import logging import time from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - resp = await client.info() - print('[!] Info:') + resp = await client.fetch_info() + print("[!] Info:") print(resp) - latency = int(round(time.time() * 1000)) - resp.timestamp - print(f'Server Latency: {latency}ms') + latency = int(time.time() * 1000) - int(resp["timestamp"]) + print(f"Server Latency: {latency}ms") -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -391,46 +393,66 @@ Subscribe to a stream and gracefully disconnect and connect to another sentry no ``` python import asyncio +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to keepalive updates ({exception})") + + +def stream_closed_processor(): + print("The keepalive stream has been closed") + + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) + tasks = [] - task1 = asyncio.get_event_loop().create_task(get_markets(client)) - task2 = asyncio.get_event_loop().create_task(keepalive(client, [task1])) + async def keepalive_event_processor(event: Dict[str, Any]): + print("Server announce:", event) + for task in tasks: + task.cancel() + print("Cancelled all tasks") - try: - await asyncio.gather( - task1, - task2, + market_task = asyncio.get_event_loop().create_task(get_markets(client)) + tasks.append(market_task) + keepalive_task = asyncio.get_event_loop().create_task( + client.listen_keepalive( + callback=keepalive_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, ) + ) + + try: + await asyncio.gather(market_task, keepalive_task) except asyncio.CancelledError: print("main(): get_markets is cancelled now") async def get_markets(client): - stream = await client.stream_spot_markets() - async for market in stream: - print(market) + async def print_market_updates(event: Dict[str, Any]): + print(event) - -async def keepalive(client, tasks: list): - stream = await client.stream_keepalive() - async for announce in stream: - print("Server announce:", announce) - async for task in tasks: - task.cancel() - print("Cancelled all tasks") + await client.listen_spot_markets_updates( + callback=print_market_updates, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + ) if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + + ``` ``` go @@ -476,6 +498,13 @@ func main() { ``` +| Parameter | Type | Description | Required | +| ------------------ | -------- | ---------------------------------------------------------------------------------------------------- | -------- | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | + + ### Response Parameters > Response Example: diff --git a/source/includes/_oracle.md b/source/includes/_oracle.md index b9512af9..dee41254 100644 --- a/source/includes/_oracle.md +++ b/source/includes/_oracle.md @@ -12,6 +12,8 @@ Includes the message to relay a price feed. ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -32,16 +34,15 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) - provider = "ufc" - symbols = ["KHABIB-TKO-05/30/2023", "KHABIB-TKO-05/26/2023"] - prices = [0.5, 0.8] + price = 100 + price_to_send = [str(int(price * 10**18))] + base = ["BAYC"] + quote = ["WETH"] # prepare tx msg - msg = composer.MsgRelayProviderPrices( - sender=address.to_acc_bech32(), provider=provider, symbols=symbols, prices=prices - ) + msg = composer.MsgRelayPriceFeedPrice(sender=address.to_acc_bech32(), price=price_to_send, base=base, quote=quote) # build sim tx tx = ( @@ -56,18 +57,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return - sim_res_msg = composer.MsgResponses(sim_res, simulation=True) - print("---Simulation Response---") - print(sim_res_msg) - # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -81,8 +79,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) - print("---Transaction Response---") + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) diff --git a/source/includes/_oraclerpc.md b/source/includes/_oraclerpc.md index 71ed4467..7c65a509 100644 --- a/source/includes/_oraclerpc.md +++ b/source/includes/_oraclerpc.md @@ -14,22 +14,23 @@ Get a list of all oracles. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - oracle_list = await client.get_oracle_list() + oracle_list = await client.fetch_oracle_list() print(oracle_list) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -189,31 +190,32 @@ Get the oracle price of an asset. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - base_symbol = 'BTC' - quote_symbol = 'USDT' - oracle_type = 'bandibc' + base_symbol = "BTC" + quote_symbol = "USDT" + oracle_type = "bandibc" oracle_scale_factor = 6 - oracle_prices = await client.get_oracle_prices( + oracle_prices = await client.fetch_oracle_price( base_symbol=base_symbol, quote_symbol=quote_symbol, oracle_type=oracle_type, - oracle_scale_factor=oracle_scale_factor + oracle_scale_factor=oracle_scale_factor, ) print(oracle_prices) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -317,30 +319,53 @@ Stream new price changes for a specified oracle. If no oracles are provided, all ``` python import asyncio -import logging +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + +async def price_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to oracle prices updates ({exception})") + + +def stream_closed_processor(): + print("The oracle prices updates stream has been closed") + + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - base_symbol = 'BTC' - quote_symbol = 'USDT' - oracle_type = 'bandibc' - oracle_prices = await client.stream_oracle_prices( - base_symbol=base_symbol, - quote_symbol=quote_symbol, - oracle_type=oracle_type + base_symbol = "INJ" + quote_symbol = "USDT" + oracle_type = "bandibc" + + task = asyncio.get_event_loop().create_task( + client.listen_oracle_prices_updates( + callback=price_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + base_symbol=base_symbol, + quote_symbol=quote_symbol, + oracle_type=oracle_type, + ) ) - async for oracle in oracle_prices: - print(oracle) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + await asyncio.sleep(delay=60) + task.cancel() + + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -421,11 +446,14 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; })(); ``` -|Parameter|Type|Description|Required| -|----|----|----|----| -|base_symbol|String|Oracle base currency|Yes| -|quote_symbol|String|Oracle quote currency|Yes| -|oracle_type|String|The oracle provider|Yes| +| Parameter | Type | Description | Required | +| ------------------ | -------- | ---------------------------------------------------------------------------------------------------- | -------- | +| base_symbol | String | Oracle base currency | No | +| quote_symbol | String | Oracle quote currency | No | +| oracle_type | String | The oracle provider | No | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | ### Response Parameters diff --git a/source/includes/_portfoliorpc.md b/source/includes/_portfoliorpc.md index 2329fff6..1c61c931 100644 --- a/source/includes/_portfoliorpc.md +++ b/source/includes/_portfoliorpc.md @@ -15,24 +15,23 @@ Get details about an account's portfolio. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) account_address = "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt" - portfolio = await client.get_account_portfolio( - account_address=account_address - ) + portfolio = await client.fetch_account_portfolio(account_address=account_address) print(portfolio) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` @@ -83,9 +82,9 @@ const portfolio = await indexerGrpcAccountPortfolioApi.fetchAccountPortfolio(inj console.log(portfolio) ``` -|Parameter|Type|Description|Required| -|----|----|----|----| -|account_address|String|Address of the account to get portfolio for|Yes| +| Parameter | Type | Description | Required | +| --------------- | ------ | ------------------------------------------- | -------- | +| account_address | String | Address of the account to get portfolio for | Yes | ### Response Parameters > Response Example: @@ -245,24 +244,45 @@ Get continuous updates on account's portfolio. ``` python import asyncio -import logging +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network +async def account_portfolio_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to account portfolio updates ({exception})") + + +def stream_closed_processor(): + print("The account portfolio updates stream has been closed") + + async def main() -> None: network = Network.testnet() client = AsyncClient(network) account_address = "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt" - updates = await client.stream_account_portfolio(account_address=account_address) - async for update in updates: - print("Account portfolio Update:\n") - print(update) + task = asyncio.get_event_loop().create_task( + client.listen_account_portfolio_updates( + account_address=account_address, + callback=account_portfolio_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + ) + ) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + await asyncio.sleep(delay=60) + task.cancel() + + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) ``` @@ -336,11 +356,14 @@ const streamFnArgs = { streamFn(streamFnArgs) ``` -| Parameter | Type | Description | Required | -|-----------------|--------|----------------------------------------------------------------------------------------------|----------| -| account_address | String | The account's portfolio address | Yes | -| subaccount_id | String | Related subaccount ID | No | -| type | String | Type of portfolio document (should be one of ["bank", "total_balance", "available_balance"]) | No | +| Parameter | Type | Description | Required | +| ------------------ | -------- | ---------------------------------------------------------------------------------------------------- | -------- | +| account_address | String | The account's portfolio address | Yes | +| subaccount_id | String | Related subaccount ID | No | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | + ### Response Parameters > Response Example: diff --git a/source/includes/_spot.md b/source/includes/_spot.md index 525561b1..2a73b860 100644 --- a/source/includes/_spot.md +++ b/source/includes/_spot.md @@ -13,6 +13,8 @@ Includes all messages related to spot markets. import asyncio import uuid +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -33,7 +35,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) # prepare trade info @@ -65,18 +67,19 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return - sim_res_msg = composer.MsgResponses(sim_res, simulation=True) + sim_res_msg = sim_res["result"]["msgResponses"] print("---Simulation Response---") print(sim_res_msg) # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -90,7 +93,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print("---Transaction Response---") print(res) print("gas wanted: {}".format(gas_limit)) @@ -271,6 +274,8 @@ gas fee: 0.000065298 INJ import asyncio import uuid +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -291,7 +296,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) # prepare trade info @@ -325,18 +330,19 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return - sim_res_msg = composer.MsgResponses(sim_res, simulation=True) + sim_res_msg = sim_res["result"]["msgResponses"] print("---Simulation Response---") print(sim_res_msg) # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -350,7 +356,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print("---Transaction Response---") print(res) print("gas wanted: {}".format(gas_limit)) @@ -532,6 +538,8 @@ gas fee: 0.000064956 INJ ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -552,7 +560,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) # prepare trade info @@ -577,14 +585,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -598,7 +607,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -749,6 +758,8 @@ Further note that if no marketIDs are provided in the SpotMarketIdsToCancelAll o import asyncio import uuid +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -769,7 +780,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) # prepare trade info @@ -879,18 +890,19 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return - sim_res_msg = composer.MsgResponses(sim_res, simulation=True) + sim_res_msg = sim_res["result"]["msgResponses"] print("---Simulation Response---") print(sim_res_msg) # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -904,7 +916,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print("---Transaction Response---") print(res) print("gas wanted: {}".format(gas_limit)) @@ -1205,7 +1217,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) subaccount_id = address.get_subaccount_id(index=0) subaccount_id_2 = address.get_subaccount_id(index=1) @@ -1301,7 +1313,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -1338,7 +1350,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -1428,7 +1440,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -1672,9 +1684,9 @@ There are two caveats to be mindful of when taking this approach: * If the client receives a sequence mismatch error (code 32), a refresh in sequence and subaccount nonce will likely resolve the error. ``` python - res = await self.client.send_tx_sync_mode(tx_raw_bytes) + res = await self.client.broadcast_tx_sync_mode(tx_raw_bytes) if res.code == 32: - await self.client.get_account(self.address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) ``` * To refresh the cached account sequence, updated account data can be fetched using the client. See example on right, using the Python client: diff --git a/source/includes/_spotrpc.md b/source/includes/_spotrpc.md index 7889ebfe..24d7c414 100644 --- a/source/includes/_spotrpc.md +++ b/source/includes/_spotrpc.md @@ -14,21 +14,22 @@ Get details of a single spot market. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: network = Network.testnet() client = AsyncClient(network) market_id = "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - market = await client.get_spot_market(market_id=market_id) + market = await client.fetch_spot_market(market_id=market_id) print(market) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -214,28 +215,26 @@ Get a list of spot markets. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: network = Network.testnet() client = AsyncClient(network) market_status = "active" base_denom = "inj" quote_denom = "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - market = await client.get_spot_markets( - market_status=market_status, - base_denom=base_denom, - quote_denom=quote_denom + market = await client.fetch_spot_markets( + market_statuses=[market_status], base_denom=base_denom, quote_denom=quote_denom ) print(market) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -299,11 +298,11 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; ``` -| Parameter | Type | Description | Required | -| ------------- | ------ | ------------------------------------------------------------------------------------------------------------- | -------- | -| base_denom | String | Filter by the Coin denomination of the base currency | No | -| market_status | String | Filter by status of the market (Should be one of: ["active", "paused", "suspended", "demolished", "expired"]) | No | -| quote_denom | String | Filter by the Coin denomination of the quote currency | No | +| Parameter | Type | Description | Required | +| --------------- | ------------ | ------------------------------------------------------------------------------------------------------------- | -------- | +| market_statuses | String Array | Filter by status of the market (Should be any of: ["active", "paused", "suspended", "demolished", "expired"]) | No | +| base_denom | String | Filter by the Coin denomination of the base currency | No | +| quote_denom | String | Filter by the Coin denomination of the quote currency | No | ### Response Parameters @@ -498,22 +497,46 @@ Stream live updates of spot markets. ``` python import asyncio -import logging +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + +async def market_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to spot markets updates ({exception})") + + +def stream_closed_processor(): + print("The spot markets updates stream has been closed") + + async def main() -> None: # select network: local, testnet, mainnet - network = Network.testnet() + network = Network.mainnet() client = AsyncClient(network) - markets = await client.stream_spot_markets() - async for market in markets: - print(market) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + task = asyncio.get_event_loop().create_task( + client.listen_spot_markets_updates( + callback=market_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + ) + ) + + await asyncio.sleep(delay=60) + task.cancel() + + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -750,31 +773,33 @@ List history of orders (all states) for a spot market. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient +from pyinjective.client.model.pagination import PaginationOption from pyinjective.core.network import Network + async def main() -> None: network = Network.testnet() client = AsyncClient(network) - market_id = "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" + market_ids = ["0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"] subaccount_id = "0xbdaedec95d563fb05240d6e01821008454c24c36000000000000000000000000" skip = 10 limit = 3 order_types = ["buy_po"] - orders = await client.get_historical_spot_orders( - market_id=market_id, + pagination = PaginationOption(skip=skip, limit=limit) + orders = await client.fetch_spot_orders_history( subaccount_id=subaccount_id, - skip=skip, - limit=limit, - order_types=order_types + market_ids=market_ids, + order_types=order_types, + pagination=pagination, ) print(orders) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -827,22 +852,18 @@ func main() { ``` -| Parameter | Type | Description | Required | -| ------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------- | -------- | -| subaccount_id | String | Filter by subaccount ID | No | -| market_id | String | Filter by a single market ID | Yes | -| skip | Integer | Skip the first *n* items from the results. This can be used to fetch all results since the API caps at 100 | No | -| limit | Integer | Maximum number of items to be returned. 1 <= *n* <= 100 | No | -| order_types | String Array | The order types to be included (Should be one of: ["buy", "sell", "stop_buy", "stop_sell", "take_buy", "take_sell", "buy_po", "sell_po"]) | No | -| direction | String | Filter by order direction (Should be one of: ["buy", "sell"]) | No | -| start_time | Integer | Search for orders where createdAt >= startTime, time in milliseconds | No | -| end_time | Integer | Search for orders where createdAt <= startTime, time in milliseconds | No | -| state | String | The order state (Should be one of: ["booked", "partial_filled", "filled", "canceled"]) | No | -| execution_types | String Array | The execution of the order (Should be one of: ["limit", "market"]) | No | -| market_ids | String Array | Filter by multiple market IDs | No | -| trade_id | String | Filter by the trade's trade id | No | -| active_markets_only | Bool | Return only orders for active markets | No | -| cid | String | Filter by the custom client order id of the trade's order | No | +| Parameter | Type | Description | Required | +| ------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -------- | +| subaccount_id | String | Filter by subaccount ID | No | +| market_ids | String Array | Filter by multiple market IDs | No | +| order_types | String Array | The order types to be included (Should be one of: ["buy", "sell", "stop_buy", "stop_sell", "take_buy", "take_sell", "buy_po", "sell_po"]) | No | +| direction | String | Filter by order direction (Should be one of: ["buy", "sell"]) | No | +| state | String | The order state (Should be one of: ["booked", "partial_filled", "filled", "canceled"]) | No | +| execution_types | String Array | The execution of the order (Should be one of: ["limit", "market"]) | No | +| trade_id | String | Filter by the trade's trade id | No | +| active_markets_only | Bool | Return only orders for active markets | No | +| cid | String | Filter by the custom client order id of the trade's order | No | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters @@ -1111,27 +1132,49 @@ Stream order updates for spot markets. If no parameters are given, updates to al ``` python import asyncio -import logging +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + +async def order_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to spot orders history updates ({exception})") + + +def stream_closed_processor(): + print("The spot orders history updates stream has been closed") + + async def main() -> None: network = Network.testnet() client = AsyncClient(network) market_id = "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - order_side = "buy" - subaccount_id = "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" - orders = await client.stream_historical_spot_orders( - market_id=market_id, - order_side=order_side + order_direction = "buy" + + task = asyncio.get_event_loop().create_task( + client.listen_spot_orders_history_updates( + callback=order_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + market_id=market_id, + direction=order_direction, + ) ) - async for order in orders: - print(order) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + await asyncio.sleep(delay=60) + task.cancel() + + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -1222,14 +1265,17 @@ console.log(orderHistory) })(); ``` -| Parameter | Type | Description | Required | -| --------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------- | -------- | -| market_id | String | Filter by market ID | Yes | -| subaccount_id | String | Filter by subaccount ID | No | -| direction | String | Filter by direction (Should be one of: ["buy", "sell"]) | No | -| state | String | Filter by state (Should be one of: ["booked", "partial_filled", "filled", "canceled"]) | No | -| order_types | String Array | Filter by order type (Should be one of: ["buy", "sell", "stop_buy", "stop_sell", "take_buy", "take_sell", "buy_po", "sell_po"]) | No | -| execution_types | String Array | Filter by execution type (Should be one of: ["limit", "market"]) | No | +| Parameter | Type | Description | Required | +| ------------------ | ------------ | ------------------------------------------------------------------------------------------------------------------------------- | -------- | +| market_id | String | Filter by market ID | No | +| subaccount_id | String | Filter by subaccount ID | No | +| direction | String | Filter by direction (Should be one of: ["buy", "sell"]) | No | +| state | String | Filter by state (Should be one of: ["booked", "partial_filled", "filled", "canceled"]) | No | +| order_types | String Array | Filter by order type (Should be one of: ["buy", "sell", "stop_buy", "stop_sell", "take_buy", "take_sell", "buy_po", "sell_po"]) | No | +| execution_types | String Array | Filter by execution type (Should be one of: ["limit", "market"]) | No | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | ### Response Parameters @@ -1348,32 +1394,33 @@ Get trade history for a spot market. The default request returns all spot trades ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: network = Network.testnet() client = AsyncClient(network) market_ids = ["0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"] execution_side = "taker" direction = "buy" - subaccount_id = "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" + subaccount_ids = ["0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001"] execution_types = ["limitMatchNewOrder", "market"] - orders = await client.get_spot_trades( + orders = await client.fetch_spot_trades( market_ids=market_ids, + subaccount_ids=subaccount_ids, execution_side=execution_side, direction=direction, - subaccount_id=subaccount_id, - execution_types=execution_types + execution_types=execution_types, ) print(orders) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -1447,22 +1494,17 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; })(); ``` -| Parameter | Type | Description | Required | -| --------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------- | -------- | -| market_id | String | Filter by a single market ID | No | -| execution_side | String | Filter by the execution side of the trade (Should be one of: ["maker", "taker"]) | No | -| direction | String | Filter by the direction of the trade (Should be one of: ["buy", "sell"]) | No | -| subaccount_id | String | Filter by a single subaccount ID | No | -| skip | Integer | Skip the first *n* items from the results. This can be used to fetch all trades since the API caps at 100 | No | -| limit | Integer | Maximum number of items to be returned. 1 <= *n* <= 100 | No | -| start_time | Integer | startTime <= trade execution timestamp <= endTime | No | -| end_time | Integer | startTime <= trade execution timestamp <= endTime | No | -| market_ids | String Array | Filter by multiple market IDs | No | -| subaccount_ids | String Array | Filter by multiple subaccount IDs | No | -| execution_types | String Array | Filter by the *trade execution type (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | No | -| trade_id | String | Filter by the trade id of the trade | No | -| account_address | String | Filter by the account address | No | -| cid | String | Filter by the custom client order id of the trade's order | No | +| Parameter | Type | Description | Required | +| --------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------- | -------- | +| market_ids | String Array | Filter by multiple market IDs | No | +| subaccount_ids | String Array | Filter by multiple subaccount IDs | No | +| execution_side | String | Filter by the execution side of the trade (Should be one of: ["maker", "taker"]) | No | +| direction | String | Filter by the direction of the trade (Should be one of: ["buy", "sell"]) | No | +| execution_types | String Array | Filter by the *trade execution type (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | No | +| trade_id | String | Filter by the trade id of the trade | No | +| account_address | String | Filter by the account address | No | +| cid | String | Filter by the custom client order id of the trade's order | No | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters @@ -1656,36 +1698,58 @@ Stream newly executed trades of spot markets. The default request streams trades ``` python import asyncio -import logging +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + +async def trade_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to spot trades updates ({exception})") + + +def stream_closed_processor(): + print("The spot trades updates stream has been closed") + + async def main() -> None: network = Network.testnet() client = AsyncClient(network) market_ids = [ "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", - "0x7a57e705bb4e09c88aecfc295569481dbf2fe1d5efe364651fbe72385938e9b0" + "0x7a57e705bb4e09c88aecfc295569481dbf2fe1d5efe364651fbe72385938e9b0", ] execution_side = "maker" direction = "sell" subaccount_id = "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" execution_types = ["limitMatchRestingOrder"] - trades = await client.stream_spot_trades( - market_ids=market_ids, - execution_side=execution_side, - direction=direction, - subaccount_id=subaccount_id, - execution_types=execution_types + + task = asyncio.get_event_loop().create_task( + client.listen_spot_trades_updates( + callback=trade_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + market_ids=market_ids, + subaccount_ids=[subaccount_id], + execution_side=execution_side, + direction=direction, + execution_types=execution_types, + ) ) - async for trade in trades: - print(trade) + await asyncio.sleep(delay=60) + task.cancel() -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -1780,22 +1844,20 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; })(); ``` -| Parameter | Type | Description | Required | -| --------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------- | -------- | -| market_id | String | Filter by a single market ID | No | -| execution_side | String | Filter by the execution side of the trade (Should be one of: ["maker", "taker"]) | No | -| direction | String | Filter by the direction of the trade (Should be one of: ["buy", "sell"]) | No | -| subaccount_id | String | Filter by a single subaccount ID | No | -| skip | Integer | Skip will skip the first N items from the result | No | -| limit | Integer | Maximum number of items to be returned | No | -| start_time | Integer | Start timestamp (UNIX milliseconds) from when to filter trades | No | -| end_time | Integer | End timestamp (UNIX milliseconds) to filter trades | No | -| market_ids | String Array | Filter by multiple market IDs | No | -| subaccount_ids | String Array | Filter by multiple subaccount IDs | No | -| execution_types | String Array | Filter by the *trade execution type (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | No | -| trade_id | String | Filter by the trade's trade id | No | -| account_address | String | Filter by the account address | No | -| cid | String | Filter by the custom client order id of the trade's order | No | +| Parameter | Type | Description | Required | +| ------------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------- | -------- | +| market_ids | String Array | Filter by multiple market IDs | No | +| subaccount_ids | String Array | Filter by multiple subaccount IDs | No | +| execution_side | String | Filter by the execution side of the trade (Should be one of: ["maker", "taker"]) | No | +| direction | String | Filter by the direction of the trade (Should be one of: ["buy", "sell"]) | No | +| execution_types | String Array | Filter by the *trade execution type (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | No | +| trade_id | String | Filter by the trade's trade id | No | +| account_address | String | Filter by the account address | No | +| cid | String | Filter by the custom client order id of the trade's order | No | +| pagination | PaginationOption | Pagination configuration | No | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | ### Response Parameters > Streaming Response Example: @@ -2795,25 +2857,25 @@ Get an orderbook snapshot for one or more spot markets. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network + async def main() -> None: - # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) market_ids = [ "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", - "0x7a57e705bb4e09c88aecfc295569481dbf2fe1d5efe364651fbe72385938e9b0" + "0x7a57e705bb4e09c88aecfc295569481dbf2fe1d5efe364651fbe72385938e9b0", ] - orderbooks = await client.get_spot_orderbooksV2(market_ids=market_ids) + orderbooks = await client.fetch_spot_orderbooks_v2(market_ids=market_ids) print(orderbooks) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -3329,25 +3391,51 @@ Stream orderbook snapshot updates for one or more spot markets. ``` python import asyncio -import logging +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network +async def orderbook_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to spot orderbook snapshots ({exception})") + + +def stream_closed_processor(): + print("The spot orderbook snapshots stream has been closed") + + async def main() -> None: - # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - market_ids = ["0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"] - orderbooks = await client.stream_spot_orderbook_snapshot(market_ids=market_ids) - async for orderbook in orderbooks: - print(orderbook) + market_ids = [ + "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "0x7a57e705bb4e09c88aecfc295569481dbf2fe1d5efe364651fbe72385938e9b0", + ] -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + task = asyncio.get_event_loop().create_task( + client.listen_spot_orderbook_snapshots( + market_ids=market_ids, + callback=orderbook_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + ) + ) + + await asyncio.sleep(delay=60) + task.cancel() + + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -3386,9 +3474,12 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; })(); ``` -| Parameter | Type | Description | Required | -| ---------- | ------------ | ------------------------------------------------------------------------ | -------- | -| market_ids | String Array | List of market IDs for orderbook streaming; empty means all spot markets | Yes | +| Parameter | Type | Description | Required | +| ------------------ | ------------ | ---------------------------------------------------------------------------------------------------- | -------- | +| market_ids | String Array | List of market IDs for orderbook streaming; empty means all spot markets | Yes | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | ### Response Parameters @@ -3500,13 +3591,23 @@ Stream incremental orderbook updates for one or more spot markets. This stream s ``` python import asyncio -import logging -from decimal import * +from decimal import Decimal +from typing import Any, Dict + +from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to spot orderbook updates ({exception})") + + +def stream_closed_processor(): + print("The spot orderbook updates stream has been closed") + + class PriceLevel: def __init__(self, price: Decimal, quantity: Decimal, timestamp: int): self.price = price @@ -3526,24 +3627,24 @@ class Orderbook: async def load_orderbook_snapshot(async_client: AsyncClient, orderbook: Orderbook): # load the snapshot - res = await async_client.get_spot_orderbooksV2(market_ids=[orderbook.market_id]) - for snapshot in res.orderbooks: - if snapshot.market_id != orderbook.market_id: + res = await async_client.fetch_spot_orderbooks_v2(market_ids=[orderbook.market_id]) + for snapshot in res["orderbooks"]: + if snapshot["marketId"] != orderbook.market_id: raise Exception("unexpected snapshot") - orderbook.sequence = int(snapshot.orderbook.sequence) + orderbook.sequence = int(snapshot["orderbook"]["sequence"]) - for buy in snapshot.orderbook.buys: - orderbook.levels["buys"][buy.price] = PriceLevel( - price=Decimal(buy.price), - quantity=Decimal(buy.quantity), - timestamp=buy.timestamp, + for buy in snapshot["orderbook"]["buys"]: + orderbook.levels["buys"][buy["price"]] = PriceLevel( + price=Decimal(buy["price"]), + quantity=Decimal(buy["quantity"]), + timestamp=int(buy["timestamp"]), ) - for sell in snapshot.orderbook.sells: - orderbook.levels["sells"][sell.price] = PriceLevel( - price=Decimal(sell.price), - quantity=Decimal(sell.quantity), - timestamp=sell.timestamp, + for sell in snapshot["orderbook"]["sells"]: + orderbook.levels["sells"][sell["price"]] = PriceLevel( + price=Decimal(sell["price"]), + quantity=Decimal(sell["quantity"]), + timestamp=int(sell["timestamp"]), ) break @@ -3555,74 +3656,94 @@ async def main() -> None: market_id = "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" orderbook = Orderbook(market_id=market_id) + updates_queue = asyncio.Queue() + tasks = [] + + async def queue_event(event: Dict[str, Any]): + await updates_queue.put(event) + # start getting price levels updates - stream = await async_client.stream_spot_orderbook_update(market_ids=[market_id]) - first_update = None - async for update in stream: - first_update = update.orderbook_level_updates - break + task = asyncio.get_event_loop().create_task( + async_client.listen_spot_orderbook_updates( + market_ids=[market_id], + callback=queue_event, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + ) + ) + tasks.append(task) + # load the snapshot once we are already receiving updates, so we don't miss any await load_orderbook_snapshot(async_client=async_client, orderbook=orderbook) - # start consuming updates again to process them - apply_orderbook_update(orderbook, first_update) - async for update in stream: - apply_orderbook_update(orderbook, update.orderbook_level_updates) + task = asyncio.get_event_loop().create_task( + apply_orderbook_update(orderbook=orderbook, updates_queue=updates_queue) + ) + tasks.append(task) + await asyncio.sleep(delay=60) + for task in tasks: + task.cancel() -def apply_orderbook_update(orderbook: Orderbook, updates): - # discard updates older than the snapshot - if updates.sequence <= orderbook.sequence: - return - print(" * * * * * * * * * * * * * * * * * * *") - - # ensure we have not missed any update - if updates.sequence > (orderbook.sequence + 1): - raise Exception("missing orderbook update events from stream, must restart: {} vs {}".format( - updates.sequence, (orderbook.sequence + 1))) - - print("updating orderbook with updates at sequence {}".format(updates.sequence)) - - # update orderbook - orderbook.sequence = updates.sequence - for direction, levels in {"buys": updates.buys, "sells": updates.sells}.items(): - for level in levels: - if level.is_active: - # upsert level - orderbook.levels[direction][level.price] = PriceLevel( - price=Decimal(level.price), - quantity=Decimal(level.quantity), - timestamp=level.timestamp) - else: - if level.price in orderbook.levels[direction]: - del orderbook.levels[direction][level.price] - - # sort the level numerically - buys = sorted(orderbook.levels["buys"].values(), key=lambda x: x.price, reverse=True) - sells = sorted(orderbook.levels["sells"].values(), key=lambda x: x.price, reverse=True) - - # lowest sell price should be higher than the highest buy price - if len(buys) > 0 and len(sells) > 0: - highest_buy = buys[0].price - lowest_sell = sells[-1].price - print("Max buy: {} - Min sell: {}".format(highest_buy, lowest_sell)) - if highest_buy >= lowest_sell: - raise Exception("crossed orderbook, must restart") - - # for the example, print the list of buys and sells orders. - print("sells") - for k in sells: - print(k) - print("=========") - print("buys") - for k in buys: - print(k) - print("====================================") +async def apply_orderbook_update(orderbook: Orderbook, updates_queue: asyncio.Queue): + while True: + updates = await updates_queue.get() + update = updates["orderbookLevelUpdates"] + # discard updates older than the snapshot + if int(update["sequence"]) <= orderbook.sequence: + return -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + print(" * * * * * * * * * * * * * * * * * * *") + + # ensure we have not missed any update + if int(update["sequence"]) > (orderbook.sequence + 1): + raise Exception( + "missing orderbook update events from stream, must restart: {} vs {}".format( + update["sequence"], (orderbook.sequence + 1) + ) + ) + + print("updating orderbook with updates at sequence {}".format(update["sequence"])) + + # update orderbook + orderbook.sequence = int(update["sequence"]) + for direction, levels in {"buys": update["buys"], "sells": update["sells"]}.items(): + for level in levels: + if level["isActive"]: + # upsert level + orderbook.levels[direction][level["price"]] = PriceLevel( + price=Decimal(level["price"]), quantity=Decimal(level["quantity"]), timestamp=level["timestamp"] + ) + else: + if level["price"] in orderbook.levels[direction]: + del orderbook.levels[direction][level["price"]] + + # sort the level numerically + buys = sorted(orderbook.levels["buys"].values(), key=lambda x: x.price, reverse=True) + sells = sorted(orderbook.levels["sells"].values(), key=lambda x: x.price, reverse=True) + + # lowest sell price should be higher than the highest buy price + if len(buys) > 0 and len(sells) > 0: + highest_buy = buys[0].price + lowest_sell = sells[-1].price + print("Max buy: {} - Min sell: {}".format(highest_buy, lowest_sell)) + if highest_buy >= lowest_sell: + raise Exception("crossed orderbook, must restart") + + # for the example, print the list of buys and sells orders. + print("sells") + for k in sells: + print(k) + print("=========") + print("buys") + for k in buys: + print(k) + print("====================================") + + +if __name__ == "__main__": asyncio.run(main()) ``` @@ -3663,9 +3784,12 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; })(); ``` -| Parameter | Type | Description | Required | -| ---------- | ------------ | ------------------------------------------------------------------------ | -------- | -| market_ids | String Array | List of market IDs for orderbook streaming; empty means all spot markets | Yes | +| Parameter | Type | Description | Required | +| ------------------ | ------------ | ---------------------------------------------------------------------------------------------------- | -------- | +| market_ids | String Array | List of market IDs for orderbook streaming; empty means all spot markets | Yes | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | ### Response Parameters @@ -3766,11 +3890,12 @@ Get orders of a subaccount. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient +from pyinjective.client.model.pagination import PaginationOption from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() @@ -3779,17 +3904,16 @@ async def main() -> None: market_id = "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" skip = 10 limit = 10 - orders = await client.get_spot_subaccount_orders( - subaccount_id=subaccount_id, - market_id=market_id, - skip=skip, - limit=limit + pagination = PaginationOption(skip=skip, limit=limit) + orders = await client.fetch_spot_subaccount_orders_list( + subaccount_id=subaccount_id, market_id=market_id, pagination=pagination ) print(orders) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -3860,12 +3984,11 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; })(); ``` -| Parameter | Type | Description | Required | -| ------------- | ------- | --------------------------------------------------------------------------------------------------------- | -------- | -| subaccount_id | String | Filter by subaccount ID | Yes | -| market_id | String | Filter by market ID | No | -| skip | Integer | Skip the first *n* items from the results. This can be used to fetch all trades since the API caps at 100 | No | -| limit | Integer | Maximum number of items to be returned. 1 <= *n* <= 100 | No | +| Parameter | Type | Description | Required | +| ------------- | ---------------- | ------------------------ | -------- | +| subaccount_id | String | Filter by subaccount ID | Yes | +| market_id | String | Filter by market ID | No | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters @@ -4086,11 +4209,12 @@ Get trades of a subaccount. ``` python import asyncio -import logging from pyinjective.async_client import AsyncClient +from pyinjective.client.model.pagination import PaginationOption from pyinjective.core.network import Network + async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() @@ -4101,19 +4225,20 @@ async def main() -> None: direction = "buy" skip = 2 limit = 3 - trades = await client.get_spot_subaccount_trades( + pagination = PaginationOption(skip=skip, limit=limit) + trades = await client.fetch_spot_subaccount_trades_list( subaccount_id=subaccount_id, market_id=market_id, execution_type=execution_type, direction=direction, - skip=skip, - limit=limit + pagination=pagination, ) print(trades) -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -4193,14 +4318,13 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; })(); ``` -| Parameter | Type | Description | Required | -| -------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------- | -------- | -| subaccount_id | String | Filter by subaccount ID | Yes | -| market_id | String | Filter by market ID | No | -| direction | String | Filter by the direction of the trades (Should be one of: ["buy", "sell"]) | No | -| execution_type | String | Filter by the *execution type of the trades (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | No | -| skip | Integer | Skip the first *n* items from the results. This can be used to fetch all trades since the API caps at 100 | No | -| limit | Integer | Maximum number of items to be returned. 1 <= *n* <= 100 | No | +| Parameter | Type | Description | Required | +| -------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -------- | +| subaccount_id | String | Filter by subaccount ID | Yes | +| market_id | String | Filter by market ID | No | +| execution_type | String | Filter by the *execution type of the trades (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | No | +| direction | String | Filter by the direction of the trades (Should be one of: ["buy", "sell"]) | No | +| pagination | PaginationOption | Pagination configuration | No | ### Response Parameters > Response Example: diff --git a/source/includes/_staking.md b/source/includes/_staking.md index 639f7d8a..28a8224a 100644 --- a/source/includes/_staking.md +++ b/source/includes/_staking.md @@ -12,7 +12,10 @@ Includes the messages to claim and withdraw delegator rewards ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient +from pyinjective.composer import Composer as ProtoMsgComposer from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network from pyinjective.transaction import Transaction @@ -20,31 +23,35 @@ from pyinjective.wallet import PrivateKey async def main() -> None: + """For a validator to withdraw his rewards & commissions simultaneously""" # select network: local, testnet, mainnet network = Network.testnet() + composer = ProtoMsgComposer(network=network.string()) # initialize grpc client - client = AsyncClient(network) - composer = await client.composer() + client = AsyncClient(network, insecure=False) await client.sync_timeout_height() # load account + # private key is that from the validator's wallet priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) # prepare tx msg validator_address = "injvaloper1ultw9r29l8nxy5u6thcgusjn95vsy2caw722q5" - msg = composer.MsgWithdrawDelegatorReward( + msg0 = composer.MsgWithdrawDelegatorReward( delegator_address=address.to_acc_bech32(), validator_address=validator_address ) + msg1 = composer.MsgWithdrawValidatorCommission(validator_address=validator_address) + # build sim tx tx = ( Transaction() - .with_messages(msg) + .with_messages(msg0, msg1) .with_sequence(client.get_sequence()) .with_account_num(client.get_number()) .with_chain_id(network.chain_id) @@ -54,14 +61,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -75,7 +83,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -211,6 +219,8 @@ gas fee: 0.000097523 INJ ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -231,7 +241,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) # prepare tx msg validator_address = "injvaloper1ultw9r29l8nxy5u6thcgusjn95vsy2caw722q5" @@ -254,14 +264,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -275,7 +286,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) diff --git a/source/includes/_wasm.md b/source/includes/_wasm.md index 8c033641..ffbca488 100644 --- a/source/includes/_wasm.md +++ b/source/includes/_wasm.md @@ -14,6 +14,8 @@ CosmWasm smart contract interactions. ``` python import asyncio +from grpc import RpcError + from pyinjective.async_client import AsyncClient from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE from pyinjective.core.network import Network @@ -35,7 +37,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3") pub_key = priv_key.to_public_key() address = pub_key.to_address() - await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) # prepare tx msg # NOTE: COIN MUST BE SORTED IN ALPHABETICAL ORDER BY DENOMS @@ -67,14 +69,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0") fee = [ composer.Coin( @@ -88,7 +91,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) @@ -160,7 +163,7 @@ async def main() -> None: priv_key = PrivateKey.from_hex("5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e") pub_key = priv_key.to_public_key() address = pub_key.to_address() - account = await client.get_account(address.to_acc_bech32()) + await client.fetch_account(address.to_acc_bech32()) contract_message = '{"guardian_set_info":{}}' encoded_message = base64.b64encode(contract_message.encode(encoding="utf-8")).decode() @@ -191,14 +194,15 @@ async def main() -> None: sim_tx_raw_bytes = tx.get_tx_data(sim_sig, pub_key) # simulate tx - (sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes) - if not success: - print(sim_res) + try: + sim_res = await client.simulate(sim_tx_raw_bytes) + except RpcError as ex: + print(ex) return # build tx gas_price = GAS_PRICE - gas_limit = sim_res.gas_info.gas_used + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation + gas_limit = int(sim_res["gasInfo"]["gasUsed"]) + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation gas_fee = '{:.18f}'.format((gas_price * gas_limit) / pow(10, 18)).rstrip('0') fee = [composer.Coin( amount=gas_price * gas_limit, @@ -210,7 +214,7 @@ async def main() -> None: tx_raw_bytes = tx.get_tx_data(sig, pub_key) # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode - res = await client.send_tx_sync_mode(tx_raw_bytes) + res = await client.broadcast_tx_sync_mode(tx_raw_bytes) print(res) print("gas wanted: {}".format(gas_limit)) print("gas fee: {} INJ".format(gas_fee)) From 09b3756271dfb53de651106b465a3652d115275b Mon Sep 17 00:00:00 2001 From: abel Date: Fri, 8 Dec 2023 11:14:04 -0300 Subject: [PATCH 2/4] (fix) Updated Python SDK result examples --- source/includes/_account.md | 592 ++++++-- source/includes/_accountsrpc.md | 378 +++-- source/includes/_auctionsrpc.md | 185 ++- source/includes/_authz.md | 20 +- source/includes/_bank.md | 49 +- source/includes/_derivativesrpc.md | 2128 +++++++++++++++++++--------- source/includes/_explorerrpc.md | 773 ++++++---- source/includes/_insurancerpc.md | 127 +- source/includes/_metarpc.md | 59 +- source/includes/_oraclerpc.md | 89 +- source/includes/_portfoliorpc.md | 160 ++- source/includes/_spotrpc.md | 1715 +++++++++++++++------- 12 files changed, 4253 insertions(+), 2022 deletions(-) diff --git a/source/includes/_account.md b/source/includes/_account.md index f4aa51cd..8952d3b3 100644 --- a/source/includes/_account.md +++ b/source/includes/_account.md @@ -1247,142 +1247,462 @@ func main() { > Response Example: ``` python -tx { - body { - messages { - type_url: "/injective.exchange.v1beta1.MsgCreateBinaryOptionsLimitOrder" - value: "\n*inj1knhahceyp57j5x7xh69p7utegnnnfgxavmahjr\022\211\002\nB0xabc3d9ba7b826dd08af1bdc96cad66e8d5205aed0c534d80ac9b884406b98af8\022\241\001\nB0xb4efdbe3240d3d2a1bc6be8a1f717944e734a0dd000000000000000000000000\022*inj1knhahceyp57j5x7xh69p7utegnnnfgxavmahjr\032\030610000000000000000000000\"\025100000000000000000000\030\001\"\03261000000000000000000000000*\0010" - } - timeout_height: 3085449 - } - auth_info { - signer_infos { - public_key { - type_url: "/injective.crypto.v1beta1.ethsecp256k1.PubKey" - value: "\n!\002\200T< /\340\341IC\260n\372\373\314&\3751A\034HfMk\255[ai\334\3303t\375" - } - mode_info { - single { - mode: SIGN_MODE_DIRECT - } - } - sequence: 84001 - } - fee { - amount { - denom: "inj" - amount: "61392500000000" - } - gas_limit: 122785 - } - } - signatures: "\267k\031\273\205\031\307\037\344\244\311\275\256o\226V\331\315\304-\000\2146\243C\241\345\272\302\217\313\223#\t\370\357d\276o\355\3029\221\321\252\311\225%\325\300]\211>\361\001\323\336\200\372\252\234$\013\177" -} -tx_response { - height: 3085400 - txhash: "68B21A7CB5E27FFA62917E6B3D5B600FD0CE34D65EE26EAEB1633A4E2718F3EB" - data: "0A84010A3C2F696E6A6563746976652E65786368616E67652E763162657461312E4D736743726561746542696E6172794F7074696F6E734C696D69744F7264657212440A42307831353464626137633762316461623165396436646339303936306263666239653661343039386237313063343961623131333535616130636137356633626530" - raw_log: "[{\"events\":[{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"/injective.exchange.v1beta1.MsgCreateBinaryOptionsLimitOrder\"}]}]}]" - logs { - events { - type: "message" - attributes { - key: "action" - value: "/injective.exchange.v1beta1.MsgCreateBinaryOptionsLimitOrder" - } - } - } - gas_wanted: 122785 - gas_used: 119932 - tx { - type_url: "/cosmos.tx.v1beta1.Tx" - value: "\n\201\003\n\371\002\n\361\001\323\336\200\372\252\234$\013\177" - } - timestamp: "2022-09-17T12:17:08Z" - events { - type: "tx" - attributes { - key: "acc_seq" - value: "inj1knhahceyp57j5x7xh69p7utegnnnfgxavmahjr/84001" - index: true - } - } - events { - type: "tx" - attributes { - key: "signature" - value: "t2sZu4UZxx/kpMm9rm+WVtnNxC0AjDajQ6HlusKPy5MjCfjvZL5v7cI5kdGqyZUl1cBdiT7xAdPegPqqnCQLfw==" - index: true - } - } - events { - type: "coin_spent" - attributes { - key: "spender" - value: "inj1knhahceyp57j5x7xh69p7utegnnnfgxavmahjr" - index: true - } - attributes { - key: "amount" - value: "61392500000000inj" - index: true - } - } - events { - type: "coin_received" - attributes { - key: "receiver" - value: "inj17xpfvakm2amg962yls6f84z3kell8c5l6s5ye9" - index: true - } - attributes { - key: "amount" - value: "61392500000000inj" - index: true - } - } - events { - type: "transfer" - attributes { - key: "recipient" - value: "inj17xpfvakm2amg962yls6f84z3kell8c5l6s5ye9" - index: true - } - attributes { - key: "sender" - value: "inj1knhahceyp57j5x7xh69p7utegnnnfgxavmahjr" - index: true - } - attributes { - key: "amount" - value: "61392500000000inj" - index: true - } - } - events { - type: "message" - attributes { - key: "sender" - value: "inj1knhahceyp57j5x7xh69p7utegnnnfgxavmahjr" - index: true - } - } - events { - type: "tx" - attributes { - key: "fee" - value: "61392500000000inj" - index: true - } - } - events { - type: "message" - attributes { - key: "action" - value: "/injective.exchange.v1beta1.MsgCreateBinaryOptionsLimitOrder" - index: true - } - } +{ + "tx":{ + "body":{ + "messages":[ + "OrderedDict("[ + "(""@type", + "/cosmos.authz.v1beta1.MsgExec"")", + "(""grantee", + "inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7"")", + "(""msgs", + [ + "OrderedDict("[ + "(""@type", + "/injective.exchange.v1beta1.MsgCreateSpotMarketOrder"")", + "(""sender", + "inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7"")", + "(""order", + { + "marketId":"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "orderInfo":{ + "subaccountId":"0x6561b5033700b734c54df4084240395889d23492000000000000000000000000", + "feeRecipient":"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7", + "price":"10194000", + "quantity":"175000000000000000000000000000000000", + "cid":"" + }, + "orderType":"SELL", + "triggerPrice":"0" + }")" + ]")" + ]")" + ]")" + ], + "timeoutHeight":"17518637", + "memo":"", + "extensionOptions":[ + + ], + "nonCriticalExtensionOptions":[ + + ] + }, + "authInfo":{ + "signerInfos":[ + { + "publicKey":"OrderedDict("[ + "(""@type", + "/injective.crypto.v1beta1.ethsecp256k1.PubKey"")", + "(""key", + "AmHqvENFf9E5s9vQFLQbcbHv4OIKTEWXVO4f7PZS9YOz"")" + ]")", + "modeInfo":{ + "single":{ + "mode":"SIGN_MODE_DIRECT" + } + }, + "sequence":"211255" + } + ], + "fee":{ + "amount":[ + { + "denom":"inj", + "amount":"52378500000000" + } + ], + "gasLimit":"104757", + "payer":"", + "granter":"" + } + }, + "signatures":[ + "Hn4Ugl50quZLQv/btmpWGMDr4F4RX5eeaGMIbc5VzC06a0sH3yRLvcNPyAcODcVjMQ1jbIRM01SYkvu2By+xJw==" + ] + }, + "txResponse":{ + "height":"17518608", + "txhash":"D265527E3171C47D01D7EC9B839A95F8F794D4E683F26F5564025961C96EFDDA", + "data":"126F0A252F636F736D6F732E617574687A2E763162657461312E4D736745786563526573706F6E736512460A440A42307834316630316536623266646433623463303631663834323235666165653033333536646238643137656265373631356661393232663132363861666434316136", + "rawLog":"[{\"msg_index\":0,\"events\":[{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"/cosmos.authz.v1beta1.MsgExec\"},{\"key\":\"sender\",\"value\":\"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7\"},{\"key\":\"module\",\"value\":\"authz\"}]},{\"type\":\"coin_spent\",\"attributes\":[{\"key\":\"spender\",\"value\":\"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7\"},{\"key\":\"amount\",\"value\":\"175000000000000000inj\"},{\"key\":\"authz_msg_index\",\"value\":\"0\"}]},{\"type\":\"coin_received\",\"attributes\":[{\"key\":\"receiver\",\"value\":\"inj14vnmw2wee3xtrsqfvpcqg35jg9v7j2vdpzx0kk\"},{\"key\":\"amount\",\"value\":\"175000000000000000inj\"},{\"key\":\"authz_msg_index\",\"value\":\"0\"}]},{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"inj14vnmw2wee3xtrsqfvpcqg35jg9v7j2vdpzx0kk\"},{\"key\":\"sender\",\"value\":\"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7\"},{\"key\":\"amount\",\"value\":\"175000000000000000inj\"},{\"key\":\"authz_msg_index\",\"value\":\"0\"}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"sender\",\"value\":\"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7\"},{\"key\":\"authz_msg_index\",\"value\":\"0\"}]}]}]", + "logs":[ + { + "events":[ + { + "type":"message", + "attributes":[ + { + "key":"action", + "value":"/cosmos.authz.v1beta1.MsgExec" + }, + { + "key":"sender", + "value":"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7" + }, + { + "key":"module", + "value":"authz" + } + ] + }, + { + "type":"coin_spent", + "attributes":[ + { + "key":"spender", + "value":"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7" + }, + { + "key":"amount", + "value":"175000000000000000inj" + }, + { + "key":"authz_msg_index", + "value":"0" + } + ] + }, + { + "type":"coin_received", + "attributes":[ + { + "key":"receiver", + "value":"inj14vnmw2wee3xtrsqfvpcqg35jg9v7j2vdpzx0kk" + }, + { + "key":"amount", + "value":"175000000000000000inj" + }, + { + "key":"authz_msg_index", + "value":"0" + } + ] + }, + { + "type":"transfer", + "attributes":[ + { + "key":"recipient", + "value":"inj14vnmw2wee3xtrsqfvpcqg35jg9v7j2vdpzx0kk" + }, + { + "key":"sender", + "value":"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7" + }, + { + "key":"amount", + "value":"175000000000000000inj" + }, + { + "key":"authz_msg_index", + "value":"0" + } + ] + }, + { + "type":"message", + "attributes":[ + { + "key":"sender", + "value":"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7" + }, + { + "key":"authz_msg_index", + "value":"0" + } + ] + } + ], + "msgIndex":0, + "log":"" + } + ], + "gasWanted":"104757", + "gasUsed":"102564", + "tx":"OrderedDict("[ + "(""@type", + "/cosmos.tx.v1beta1.Tx"")", + "(""body", + { + "messages":[ + "OrderedDict("[ + "(""@type", + "/cosmos.authz.v1beta1.MsgExec"")", + "(""grantee", + "inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7"")", + "(""msgs", + [ + "OrderedDict("[ + "(""@type", + "/injective.exchange.v1beta1.MsgCreateSpotMarketOrder"")", + "(""sender", + "inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7"")", + "(""order", + { + "marketId":"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "orderInfo":{ + "subaccountId":"0x6561b5033700b734c54df4084240395889d23492000000000000000000000000", + "feeRecipient":"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7", + "price":"10194000", + "quantity":"175000000000000000000000000000000000", + "cid":"" + }, + "orderType":"SELL", + "triggerPrice":"0" + }")" + ]")" + ]")" + ]")" + ], + "timeoutHeight":"17518637", + "memo":"", + "extensionOptions":[ + + ], + "nonCriticalExtensionOptions":[ + + ] + }")", + "(""authInfo", + { + "signerInfos":[ + { + "publicKey":"OrderedDict("[ + "(""@type", + "/injective.crypto.v1beta1.ethsecp256k1.PubKey"")", + "(""key", + "AmHqvENFf9E5s9vQFLQbcbHv4OIKTEWXVO4f7PZS9YOz"")" + ]")", + "modeInfo":{ + "single":{ + "mode":"SIGN_MODE_DIRECT" + } + }, + "sequence":"211255" + } + ], + "fee":{ + "amount":[ + { + "denom":"inj", + "amount":"52378500000000" + } + ], + "gasLimit":"104757", + "payer":"", + "granter":"" + } + }")", + "(""signatures", + [ + "Hn4Ugl50quZLQv/btmpWGMDr4F4RX5eeaGMIbc5VzC06a0sH3yRLvcNPyAcODcVjMQ1jbIRM01SYkvu2By+xJw==" + ]")" + ]")", + "timestamp":"2023-10-23T18:48:19Z", + "events":[ + { + "type":"coin_spent", + "attributes":[ + { + "key":"spender", + "value":"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7", + "index":true + }, + { + "key":"amount", + "value":"52378500000000inj", + "index":true + } + ] + }, + { + "type":"coin_received", + "attributes":[ + { + "key":"receiver", + "value":"inj17xpfvakm2amg962yls6f84z3kell8c5l6s5ye9", + "index":true + }, + { + "key":"amount", + "value":"52378500000000inj", + "index":true + } + ] + }, + { + "type":"transfer", + "attributes":[ + { + "key":"recipient", + "value":"inj17xpfvakm2amg962yls6f84z3kell8c5l6s5ye9", + "index":true + }, + { + "key":"sender", + "value":"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7", + "index":true + }, + { + "key":"amount", + "value":"52378500000000inj", + "index":true + } + ] + }, + { + "type":"message", + "attributes":[ + { + "key":"sender", + "value":"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7", + "index":true + } + ] + }, + { + "type":"tx", + "attributes":[ + { + "key":"fee", + "value":"52378500000000inj", + "index":true + }, + { + "key":"fee_payer", + "value":"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7", + "index":true + } + ] + }, + { + "type":"tx", + "attributes":[ + { + "key":"acc_seq", + "value":"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7/211255", + "index":true + } + ] + }, + { + "type":"tx", + "attributes":[ + { + "key":"signature", + "value":"Hn4Ugl50quZLQv/btmpWGMDr4F4RX5eeaGMIbc5VzC06a0sH3yRLvcNPyAcODcVjMQ1jbIRM01SYkvu2By+xJw==", + "index":true + } + ] + }, + { + "type":"message", + "attributes":[ + { + "key":"action", + "value":"/cosmos.authz.v1beta1.MsgExec", + "index":true + }, + { + "key":"sender", + "value":"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7", + "index":true + }, + { + "key":"module", + "value":"authz", + "index":true + } + ] + }, + { + "type":"coin_spent", + "attributes":[ + { + "key":"spender", + "value":"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7", + "index":true + }, + { + "key":"amount", + "value":"175000000000000000inj", + "index":true + }, + { + "key":"authz_msg_index", + "value":"0", + "index":true + } + ] + }, + { + "type":"coin_received", + "attributes":[ + { + "key":"receiver", + "value":"inj14vnmw2wee3xtrsqfvpcqg35jg9v7j2vdpzx0kk", + "index":true + }, + { + "key":"amount", + "value":"175000000000000000inj", + "index":true + }, + { + "key":"authz_msg_index", + "value":"0", + "index":true + } + ] + }, + { + "type":"transfer", + "attributes":[ + { + "key":"recipient", + "value":"inj14vnmw2wee3xtrsqfvpcqg35jg9v7j2vdpzx0kk", + "index":true + }, + { + "key":"sender", + "value":"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7", + "index":true + }, + { + "key":"amount", + "value":"175000000000000000inj", + "index":true + }, + { + "key":"authz_msg_index", + "value":"0", + "index":true + } + ] + }, + { + "type":"message", + "attributes":[ + { + "key":"sender", + "value":"inj1v4sm2qehqzmnf32d7syyyspetzyaydyj4r4yv7", + "index":true + }, + { + "key":"authz_msg_index", + "value":"0", + "index":true + } + ] + } + ], + "codespace":"", + "code":0, + "info":"" + } } ``` diff --git a/source/includes/_accountsrpc.md b/source/includes/_accountsrpc.md index b12ee1e5..c4884a73 100644 --- a/source/includes/_accountsrpc.md +++ b/source/includes/_accountsrpc.md @@ -91,8 +91,13 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -subaccounts: "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" -subaccounts: "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000002" +{ + "subaccounts":[ + "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001", + "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000002", + "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000000" + ] +} ``` ``` go @@ -238,28 +243,42 @@ import { getNetworkEndpoints, Network } from '@injectivelabs/networks' > Response Example: ``` python -transfers { - transfer_type: "deposit" - src_account_address: "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" - dst_subaccount_id: "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - amount { - denom: "inj" - amount: "2000000000000000000" - } - executed_at: 1665117493543 -} -transfers { - transfer_type: "deposit" - src_account_address: "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" - dst_subaccount_id: "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - amount { - denom: "inj" - amount: "15000000000000000000" - } - executed_at: 1660313668990 -} -paging { - total: 3 +{ + "transfers":[ + { + "transferType":"deposit", + "srcAccountAddress":"inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku", + "dstSubaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "amount":{ + "denom":"inj", + "amount":"2000000000000000000" + }, + "executedAt":"1665117493543", + "srcSubaccountId":"", + "dstAccountAddress":"" + }, + { + "transferType":"deposit", + "srcAccountAddress":"inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku", + "dstSubaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "amount":{ + "denom":"inj", + "amount":"15000000000000000000" + }, + "executedAt":"1660313668990", + "srcSubaccountId":"", + "dstAccountAddress":"" + } + ], + "paging":{ + "total":"3", + "from":0, + "to":0, + "countBySubaccount":"0", + "next":[ + + ] + } } ``` @@ -453,14 +472,16 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -balance { - subaccount_id: "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - account_address: "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" - denom: "inj" - deposit { - total_balance: "1492235700000000000000" - available_balance: "1492235700000000000000" - } +{ + "balance":{ + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "accountAddress":"inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku", + "denom":"inj", + "deposit":{ + "totalBalance":"0", + "availableBalance":"0" + } + } } ``` @@ -603,23 +624,27 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -balances { - subaccount_id: "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - account_address: "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" - denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - deposit { - total_balance: "115310339308.284511627876066473" - available_balance: "115236639078.284511627876066473" - } -} -balances { - subaccount_id: "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - account_address: "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" - denom: "inj" - deposit { - total_balance: "1492235700000000000000" - available_balance: "1492235700000000000000" - } +{ + "balances":[ + { + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "accountAddress":"inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku", + "denom":"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "deposit":{ + "totalBalance":"131721505.337958346262317217", + "availableBalance":"0.337958346262317217" + } + }, + { + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "accountAddress":"inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku", + "denom":"inj", + "deposit":{ + "totalBalance":"0", + "availableBalance":"0" + } + } + ] } ``` @@ -814,8 +839,10 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -spot_orders_total: 1 -derivative_orders_total: 7 +{ + "derivativeOrdersTotal":"1", + "spotOrdersTotal":"0" +} ``` ``` go @@ -983,42 +1010,30 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Streaming Response Example: ``` python -Subaccount balance Update: - -balance { - subaccount_id: "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" - account_address: "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt" - denom: "inj" - deposit { - available_balance: "9980001000000000000" - } -} -timestamp: 1675902606000 - -Subaccount balance Update: - -balance { - subaccount_id: "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" - account_address: "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt" - denom: "inj" - deposit { - available_balance: "9990001000000000000" - } +{ + "balance": { + "subaccountId": "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "accountAddress": "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku", + "denom": "peggy0xdAC17F958D2ee523a2206206994597C13D831ec7", + "deposit": { + "totalBalance": "200493439765890.695319283887814576", + "availableBalance": "200493414240390.695319283887814031" + } + }, + "timestamp": 1654234765000 } -timestamp: 1675902946000 - -Subaccount balance Update: - -balance { - subaccount_id: "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" - account_address: "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt" - denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - deposit { - total_balance: "199999859.1576" - available_balance: "199989859.1576" - } +{ + "balance": { + "subaccountId": "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "accountAddress": "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku", + "denom": "peggy0xdAC17F958D2ee523a2206206994597C13D831ec7", + "deposit": { + "totalBalance": "200493847328858.695319283887814576", + "availableBalance": "200493821803358.695319283887814031" + } + }, + "timestamp": 1654234804000 } -timestamp: 1675902946000 ``` ``` go @@ -1209,41 +1224,35 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -spot_order_states { - order_hash: "0xa848395a768ee06af360e2e35bac6f598fdc52e8d0c34a588d32cd9108f3571f" - subaccount_id: "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - market_id: "0x0511ddc4e6586f3bfe1acb2dd905f8b8a82c97e1edaef654b12ca7e6031ca0fa" - order_type: "buy" - order_side: "buy" - state: "booked" - quantity_filled: "0" - quantity_remaining: "2000000" - created_at: 1652701438661 - updated_at: 1652701438661 -} -spot_order_states { - order_hash: "0x163861fba3d911631e18354a03e7357bc6358cd2042535e8ad11dc6c29f8c558" - subaccount_id: "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - market_id: "0x0511ddc4e6586f3bfe1acb2dd905f8b8a82c97e1edaef654b12ca7e6031ca0fa" - order_type: "buy" - order_side: "buy" - state: "booked" - quantity_filled: "0" - quantity_remaining: "2000000" - created_at: 1652693332688 - updated_at: 1652693332688 -} -derivative_order_states { - order_hash: "0x962af5e492a2ce4575616dbcf687a063ef9c4b33a047a9fb86794804923337c8" - subaccount_id: "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - market_id: "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce" - order_type: "sell" - order_side: "sell" - state: "booked" - quantity_filled: "1" - quantity_remaining: "0" - created_at: 1652786114544 - updated_at: 1652786114544 +{ + "spotOrderStates": [ + { + "orderHash": "0xb7b556d6eab10c4c185a660be44757a8a6715fb16db39708f2f76d9ce5ae8617", + "subaccountId": "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "marketId": "0x0511ddc4e6586f3bfe1acb2dd905f8b8a82c97e1edaef654b12ca7e6031ca0fa", + "orderType": "limit", + "orderSide": "buy", + "state": "booked", + "quantityFilled": "0", + "quantityRemaining": "1000000", + "createdAt": 1654080262300, + "updatedAt": 1654080262300 + } + ], + "derivativeOrderStates": [ + { + "orderHash": "0x4228f9a56a5bb50de4ceadc64df694c77e7752d58b71a7c557a27ec10e1a094e", + "subaccountId": "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "marketId": "0x1c79dac019f73e4060494ab1b4fcba734350656d6fc4d474f6a238c13c6f9ced", + "orderType": "limit", + "orderSide": "buy", + "state": "booked", + "quantityFilled": "0", + "quantityRemaining": "1", + "createdAt": 1654235059957, + "updatedAt": 1654235059957 + } + ] } ``` @@ -1438,17 +1447,87 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -portfolio { - portfolio_value: "121771.765274665073374624" - available_balance: "120622.8032988109636363" - locked_balance: "1476.0573145189379903" - unrealized_pnl: "-327.095338664828251976" - subaccounts { - subaccount_id: "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - available_balance: "120622.8032988109636363" - locked_balance: "1476.0573145189379903" - unrealized_pnl: "-327.095338664828251976" - } +{ + "portfolio":{ + "portfolioValue":"6229.040631548905238875", + "availableBalance":"92.4500010811984646", + "lockedBalance":"13218.3573583009093604", + "unrealizedPnl":"-7081.766727833202586125", + "subaccounts":[ + { + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000002", + "availableBalance":"0", + "lockedBalance":"0", + "unrealizedPnl":"0" + }, + { + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000006", + "availableBalance":"0", + "lockedBalance":"0", + "unrealizedPnl":"0" + }, + { + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000008", + "availableBalance":"0", + "lockedBalance":"0", + "unrealizedPnl":"0" + }, + { + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000009", + "availableBalance":"0", + "lockedBalance":"0", + "unrealizedPnl":"0" + }, + { + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f971347490200000061746f6d2d75736474", + "availableBalance":"0.00000066622556", + "lockedBalance":"0", + "unrealizedPnl":"0" + }, + { + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "availableBalance":"0.0000003382963046", + "lockedBalance":"13218.3573583009093604", + "unrealizedPnl":"-7081.766727833202586125" + }, + { + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f971347490200000000696e6a2d75736474", + "availableBalance":"0.0000000766766", + "lockedBalance":"0", + "unrealizedPnl":"0" + }, + { + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000001", + "availableBalance":"92.45", + "lockedBalance":"0", + "unrealizedPnl":"0" + }, + { + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000003", + "availableBalance":"0", + "lockedBalance":"0", + "unrealizedPnl":"0" + }, + { + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000007", + "availableBalance":"0", + "lockedBalance":"0", + "unrealizedPnl":"0" + }, + { + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000004", + "availableBalance":"0", + "lockedBalance":"0", + "unrealizedPnl":"0" + }, + { + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000005", + "availableBalance":"0", + "lockedBalance":"0", + "unrealizedPnl":"0" + } + ] + } } ``` @@ -1607,31 +1686,20 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -rewards { - account_address: "inj1qra8c03h70y36j85dpvtj05juxe9z7acuvz6vg" - rewards { - denom: "inj" - amount: "1954269574440758128" - } - distributed_at: 1672218001897 -} -rewards { - account_address: "inj1q4sww3amkmwhym54aaey5v8wemkh9v80jp8e3z" - rewards { - denom: "inj" - amount: "8497057876433151133" - } - distributed_at: 1672218001897 -} -rewards { - account_address: "inj1pqsujjk66dsf40v2lfrry46m2fym44thgn5qqh" - rewards { - denom: "inj" - amount: "41401176734199333" - } - distributed_at: 1672218001897 +{ + "rewards":[ + { + "accountAddress":"inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku", + "rewards":[ + { + "denom":"inj", + "amount":"11169382212463849" + } + ], + "distributedAt":"1672218001897" + } + ] } -... ``` ``` go diff --git a/source/includes/_auctionsrpc.md b/source/includes/_auctionsrpc.md index 82d6f0a6..f95ef827 100644 --- a/source/includes/_auctionsrpc.md +++ b/source/includes/_auctionsrpc.md @@ -92,36 +92,42 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -auction { - winner: "inj1uyk56r3xdcf60jwrmn7p9rgla9dc4gam56ajrq" - basket { - denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - amount: "2322098" - } - winning_bid_amount: "2000000000000000000" - round: 31 - end_timestamp: 1676013187000 - updated_at: 1675408390939 -} -bids { - bidder: "inj1pdxq82m20fzkjn2th2mm5jp7t5ex6j6klf9cs5" - amount: "1000000000000000000" - timestamp: 1675426622603 -} -bids { - bidder: "inj1tu9xwxms5dvz3782tjal0fy5rput78p3k5sfv6" - amount: "1010000000000000000" - timestamp: 1675427580363 -} -bids { - bidder: "inj1sdkt803zwq2tpej0k2a0z58hwyrnerzfsxj356" - amount: "1030000000000000000" - timestamp: 1675482275821 -} -bids { - bidder: "inj1uyk56r3xdcf60jwrmn7p9rgla9dc4gam56ajrq" - amount: "2000000000000000000" - timestamp: 1675595586380 +{ + "auction":{ + "winner":"inj1uyk56r3xdcf60jwrmn7p9rgla9dc4gam56ajrq", + "basket":[ + { + "denom":"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "amount":"2322098" + } + ], + "winningBidAmount":"2000000000000000000", + "round":"31", + "endTimestamp":"1676013187000", + "updatedAt":"1677075140258" + }, + "bids":[ + { + "bidder":"inj1pdxq82m20fzkjn2th2mm5jp7t5ex6j6klf9cs5", + "amount":"1000000000000000000", + "timestamp":"1675426622603" + }, + { + "bidder":"inj1tu9xwxms5dvz3782tjal0fy5rput78p3k5sfv6", + "amount":"1010000000000000000", + "timestamp":"1675427580363" + }, + { + "bidder":"inj1sdkt803zwq2tpej0k2a0z58hwyrnerzfsxj356", + "amount":"1030000000000000000", + "timestamp":"1675482275821" + }, + { + "bidder":"inj1uyk56r3xdcf60jwrmn7p9rgla9dc4gam56ajrq", + "amount":"2000000000000000000", + "timestamp":"1675595586380" + } + ] } ``` @@ -295,44 +301,66 @@ import { ExchangeGrpcClient } from "@injectivelabs/sdk-ts/dist/client/exchange/E > Response Example: ``` python -auctions { - basket { - denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - amount: "188940000" - } - round: 1 - end_timestamp: 1657869187000 - updated_at: 1658131202118 -} -auctions { - basket { - denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - amount: "219025410" - } - round: 2 - end_timestamp: 1658473987000 - updated_at: 1658134858904 -} - -... - -auctions { - basket { - denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - amount: "394877" - } - round: 32 - end_timestamp: 1676617987000 - updated_at: 1676013212591 -} -auctions { - basket { - denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - amount: "1563547" - } - round: 33 - end_timestamp: 1677222787000 - updated_at: 1676617990954 +{ + "auctions":[ + { + "basket":[ + { + "denom":"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "amount":"188940000" + } + ], + "round":"1", + "endTimestamp":"1657869187000", + "updatedAt":"1658131202118", + "winner":"", + "winningBidAmount":"" + }, + { + "basket":[ + { + "denom":"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "amount":"219025410" + } + ], + "round":"2", + "endTimestamp":"1658473987000", + "updatedAt":"1658134858904", + "winner":"", + "winningBidAmount":"" + }, + ... + { + "winner":"inj1rk9fguz9zjwtqm3t6e9fzp7n9dd7jfhaw9dcc4", + "basket":[ + { + "denom":"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "amount":"1066722260002" + } + ], + "winningBidAmount":"3007530000000000000000", + "round":"73", + "endTimestamp":"1701414787000", + "updatedAt":"1700809987278" + }, + { + "basket":[ + { + "denom":"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "amount":"1137356301548" + }, + { + "denom":"peggy0xf9152067989BDc8783fF586624124C05A529A5D1", + "amount":"128519416" + } + ], + "round":"74", + "endTimestamp":"1702019587000", + "updatedAt":"1701414788278", + "winner":"", + "winningBidAmount":"" + } + ] } ``` @@ -560,15 +588,18 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -bidder: "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r" -bid_amount: "2100000000000000000" -round: 33 -timestamp: 1676692477304 - -bidder: "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt" -bid_amount: "2200000000000000256" -round: 33 -timestamp: 1676692509733 +{ + "bidder": "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku", + "bidAmount": "1000000000000000000", + "round": 19532, + "timestamp": 1654233511715 +} +{ + "bidder": "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku", + "bidAmount": "3000000000000000000", + "round": 19532, + "timestamp": 1654233530633 +} ``` ``` go diff --git a/source/includes/_authz.md b/source/includes/_authz.md index fa0c9491..7f4ba02c 100644 --- a/source/includes/_authz.md +++ b/source/includes/_authz.md @@ -783,14 +783,18 @@ https://github.com/InjectiveLabs/injective-ts/wiki/04CoreModulesAuthz#msgrevoke > Response Example: ``` python -grants: { - authorization: { - type_url: "/cosmos.authz.v1beta1.GenericAuthorization", - value: "\n3/injective.exchange.v1beta1.MsgCreateSpotLimitOrder" - }, - expiration: { - seconds: 1673468820 - } +{ + "grants":[ + { + "authorization":"OrderedDict("[ + "(""@type", + "/cosmos.authz.v1beta1.GenericAuthorization"")", + "(""msg", + "/injective.exchange.v1beta1.MsgCreateSpotLimitOrder"")" + ]")", + "expiration":"2024-12-07T02:26:01Z" + } + ] } ``` diff --git a/source/includes/_bank.md b/source/includes/_bank.md index fc91d142..c5f64a44 100644 --- a/source/includes/_bank.md +++ b/source/includes/_bank.md @@ -516,12 +516,41 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -balances { - denom: "inj" - amount: "225858203095000000000" -} -pagination { - total: 1 +{ + "balances":[ + { + "denom":"factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/atom", + "amount":"10000000000" + }, + { + "denom":"factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/usdc", + "amount":"10000000000" + }, + { + "denom":"factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/weth", + "amount":"5000000000" + }, + { + "denom":"factory/inj1aetmaq5pswvfg6nhvgd4lt94qmg23ka3ljgxlm/SHURIKEN", + "amount":"115700000" + }, + { + "denom":"factory/inj1cml96vmptgw99syqrrz8az79xer2pcgp0a885r/test", + "amount":"1000000" + }, + { + "denom":"inj", + "amount":"760662316753211286487" + }, + { + "denom":"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "amount":"9996297948" + } + ], + "pagination":{ + "total":"7", + "nextKey":"" + } } ``` @@ -736,9 +765,11 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -balance { - denom: "inj" - amount: "225839507773500000000" +{ + "balance":{ + "denom":"inj", + "amount":"760662316753211286487" + } } ``` diff --git a/source/includes/_derivativesrpc.md b/source/includes/_derivativesrpc.md index badd52ad..9ab3642d 100644 --- a/source/includes/_derivativesrpc.md +++ b/source/includes/_derivativesrpc.md @@ -88,42 +88,44 @@ console.log(market) > Response Example: ``` python -market { - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - market_status: "active" - ticker: "BTC/USDT PERP" - oracle_base: "BTC" - oracle_quote: "USDT" - oracle_type: "bandibc" - oracle_scale_factor: 6 - initial_margin_ratio: "0.095" - maintenance_margin_ratio: "0.05" - quote_denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - quote_token_meta { - name: "Testnet Tether USDT" - address: "0x0000000000000000000000000000000000000000" - symbol: "USDT" - logo: "https://static.alchemyapi.io/images/assets/825.png" - decimals: 6 - updated_at: 1676338338818 - } - maker_fee_rate: "-0.0001" - taker_fee_rate: "0.001" - service_provider_fee: "0.4" - is_perpetual: true - min_price_tick_size: "100000" - min_quantity_tick_size: "0.0001" - perpetual_market_info { - hourly_funding_rate_cap: "0.000625" - hourly_interest_rate: "0.00000416666" - next_funding_timestamp: 1676340000 - funding_interval: 3600 - } - perpetual_market_funding { - cumulative_funding: "779109108.57624692966427974" - cumulative_price: "295.860245725710572515" - last_timestamp: 1676294229 - } +{ + "market":{ + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "marketStatus":"active", + "ticker":"INJ/USDT PERP", + "oracleBase":"0x2d9315a88f3019f8efa88dfe9c0f0843712da0bac814461e27733f6b83eb51b3", + "oracleQuote":"0x1fc18861232290221461220bd4e2acd1dcdfbc89c84092c93c18bdc7756c1588", + "oracleType":"pyth", + "oracleScaleFactor":6, + "initialMarginRatio":"0.05", + "maintenanceMarginRatio":"0.02", + "quoteDenom":"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "quoteTokenMeta":{ + "name":"Testnet Tether USDT", + "address":"0x0000000000000000000000000000000000000000", + "symbol":"USDT", + "logo":"https://static.alchemyapi.io/images/assets/825.png", + "decimals":6, + "updatedAt":"1698247516758" + }, + "makerFeeRate":"-0.0001", + "takerFeeRate":"0.001", + "serviceProviderFee":"0.4", + "isPerpetual":true, + "minPriceTickSize":"100", + "minQuantityTickSize":"0.0001", + "perpetualMarketInfo":{ + "hourlyFundingRateCap":"0.000625", + "hourlyInterestRate":"0.00000416666", + "nextFundingTimestamp":"1701990000", + "fundingInterval":"3600" + }, + "perpetualMarketFunding":{ + "cumulativeFunding":"-156010.283874921534910863", + "cumulativePrice":"566.477789213654772072", + "lastTimestamp":"1701906508" + } + } } ``` @@ -373,75 +375,75 @@ console.log(markets) > Response Example: ``` python -markets { - market_id: "0xe112199d9ee44ceb2697ea0edd1cd422223c105f3ed2bdf85223d3ca59f5909a" - market_status: "active" - ticker: "INJ/USDT PERP" - oracle_base: "INJ" - oracle_quote: "USDT" - oracle_type: "bandibc" - oracle_scale_factor: 6 - initial_margin_ratio: "0.095" - maintenance_margin_ratio: "0.05" - quote_denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - quote_token_meta { - name: "Testnet Tether USDT" - address: "0x0000000000000000000000000000000000000000" - symbol: "USDT" - logo: "https://static.alchemyapi.io/images/assets/825.png" - decimals: 6 - updated_at: 1676339989721 - } - maker_fee_rate: "-0.0001" - taker_fee_rate: "0.001" - service_provider_fee: "0.4" - is_perpetual: true - min_price_tick_size: "100000" - min_quantity_tick_size: "0.0001" - perpetual_market_info { - hourly_funding_rate_cap: "0.000625" - hourly_interest_rate: "0.00000416666" - next_funding_timestamp: 1676340000 - funding_interval: 3600 - } - perpetual_market_funding { - cumulative_funding: "30750.538513128695953648" - cumulative_price: "793.433131392911165592" - last_timestamp: 1674712474 - } -} - -... - -markets { - market_id: "0x3bb58218cd90efcce9ea9e317d137dcd4ce8485c6be346250dbf8cd60d9c9e2d" - market_status: "active" - ticker: "Frontrunner Futures 4: Expires 7.7.2023" - oracle_base: "FRNT" - oracle_quote: "USDT" - oracle_type: "pricefeed" - oracle_scale_factor: 6 - initial_margin_ratio: "0.999999999999999999" - maintenance_margin_ratio: "0.1" - quote_denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - quote_token_meta { - name: "Testnet Tether USDT" - address: "0x0000000000000000000000000000000000000000" - symbol: "USDT" - logo: "https://static.alchemyapi.io/images/assets/825.png" - decimals: 6 - updated_at: 1676339989721 - } - maker_fee_rate: "0.005" - taker_fee_rate: "0.012" - service_provider_fee: "0.4" - min_price_tick_size: "0.000000000000001" - min_quantity_tick_size: "0.0001" - expiry_futures_market_info { - expiration_timestamp: 1688747341 - settlement_price: "0" +[ + { + "marketId": "0x1c79dac019f73e4060494ab1b4fcba734350656d6fc4d474f6a238c13c6f9ced", + "marketStatus": "active", + "ticker": "BNB/USDT PERP", + "oracleBase": "BNB", + "oracleQuote": "USDT", + "oracleType": "bandibc", + "oracleScaleFactor": 6, + "initialMarginRatio": "0.095", + "maintenanceMarginRatio": "0.05", + "quoteDenom": "peggy0xdAC17F958D2ee523a2206206994597C13D831ec7", + "quoteTokenMeta": { + "name": "Tether", + "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7", + "symbol": "USDT", + "logo": "https://static.alchemyapi.io/images/assets/825.png", + "decimals": 6, + "updatedAt": 1650978923353 + }, + "makerFeeRate": "0.0005", + "takerFeeRate": "0.0012", + "serviceProviderFee": "0.4", + "isPerpetual": true, + "minPriceTickSize": "10000", + "minQuantityTickSize": "0.01", + "perpetualMarketInfo": { + "hourlyFundingRateCap": "0.000625", + "hourlyInterestRate": "0.00000416666", + "nextFundingTimestamp": 1654246800, + "fundingInterval": 3600 + }, + "perpetualMarketFunding": { + "cumulativeFunding": "56890491.178246679699729639", + "cumulativePrice": "7.082760891515203314", + "lastTimestamp": 1654245985 + } + }, + { + "marketId": "0x00030df39180df04a873cb4aadc50d4135640af5c858ab637dbd4d31b147478c", + "marketStatus": "active", + "ticker": "Frontrunner Futures: Expires 5.21.2023", + "oracleBase": "FRNT", + "oracleQuote": "USDT", + "oracleType": "pricefeed", + "oracleScaleFactor": 6, + "initialMarginRatio": "0.999999999999999999", + "maintenanceMarginRatio": "0.1", + "quoteDenom": "peggy0xdAC17F958D2ee523a2206206994597C13D831ec7", + "quoteTokenMeta": { + "name": "Tether", + "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7", + "symbol": "USDT", + "logo": "https://static.alchemyapi.io/images/assets/825.png", + "decimals": 6, + "updatedAt": 1653064108501 + }, + "makerFeeRate": "0.005", + "takerFeeRate": "0.012", + "serviceProviderFee": "0.4", + "isPerpetual": false, + "minPriceTickSize": "0.000000000000001", + "minQuantityTickSize": "0.0001", + "expiryFuturesMarketInfo": { + "expirationTimestamp": 1684600043, + "settlementPrice": "0" + } } -} +] ``` ```go @@ -799,45 +801,47 @@ streamFn(streamFnArgs) > Streaming Response Example: ``` python -market { - market_id: "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce" - market_status: "active" - ticker: "BTC/USDT PERP" - oracle_base: "BTC" - oracle_quote: "USDT" - oracle_type: "bandibc" - oracle_scale_factor: 6 - initial_margin_ratio: "0.095" - maintenance_margin_ratio: "0.05" - quote_denom: "peggy0xdAC17F958D2ee523a2206206994597C13D831ec7" - quote_token_meta { - name: "Tether" - address: "0xdAC17F958D2ee523a2206206994597C13D831ec7" - symbol: "USDT" - logo: "https://static.alchemyapi.io/images/assets/825.png" - decimals: 6 - updated_at: 1650978923435 - } - maker_fee_rate: "0.0005" - taker_fee_rate: "0.0012" - service_provider_fee: "0.4" - is_perpetual: true - min_price_tick_size: "100000" - min_quantity_tick_size: "0.0001" - perpetual_market_info { - hourly_funding_rate_cap: "0.000625" - hourly_interest_rate: "0.00000416666" - next_funding_timestamp: 1652796000 - funding_interval: 3600 - } - perpetual_market_funding { - cumulative_funding: "7234678245.415396885076050889" - cumulative_price: "6.214149999812187743" - last_timestamp: 1652775381 - } +{ + "market": { + "marketId": "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce", + "marketStatus": "active", + "ticker": "BTC/USDT PERP", + "oracleBase": "BTC", + "oracleQuote": "USDT", + "oracleType": "bandibc", + "oracleScaleFactor": 6, + "initialMarginRatio": "0.095", + "maintenanceMarginRatio": "0.05", + "quoteDenom": "peggy0xdAC17F958D2ee523a2206206994597C13D831ec7", + "quoteTokenMeta": { + "name": "Tether", + "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7", + "symbol": "USDT", + "logo": "https://static.alchemyapi.io/images/assets/825.png", + "decimals": 6, + "updatedAt": 1650978923435 + }, + "makerFeeRate": "0.0005", + "takerFeeRate": "0.0012", + "serviceProviderFee": "0.4", + "isPerpetual": true, + "minPriceTickSize": "100000", + "minQuantityTickSize": "0.0001", + "perpetualMarketInfo": { + "hourlyFundingRateCap": "0.000625", + "hourlyInterestRate": "0.00000416666", + "nextFundingTimestamp": 1654246800, + "fundingInterval": 3600 + }, + "perpetualMarketFunding": { + "cumulativeFunding": "8239865636.851083559033030036", + "cumulativePrice": "7.15770685160786651", + "lastTimestamp": 1654246073 + } + }, + "operationType": "update", + "timestamp": 1654246076000 } -operation_type: "update" -timestamp: 1652792406000 ``` ``` go @@ -1108,56 +1112,87 @@ func main() { > Response Example: ``` python -orders { - order_hash: "0x06a9b81441b4fd38bc9da9b928007286b340407481f41398daab291cde2bd6dc" - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - subaccount_id: "0x295639d56c987f0e24d21bb167872b3542a6e05a000000000000000000000000" - execution_type: "limit" - order_type: "sell" - price: "21805600000" - trigger_price: "0" - quantity: "0.001" - filled_quantity: "0.001" - state: "filled" - created_at: 1676269001530 - updated_at: 1676269001530 - direction: "sell" - margin: "21800000" -} -orders { - order_hash: "0x1b4ebdd127ecda4a0b392907e872ef960c9a2e76eb4e68a0ab5c1d631f540b85" - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - subaccount_id: "0x295639d56c987f0e24d21bb167872b3542a6e05a000000000000000000000000" - execution_type: "limit" - order_type: "sell" - price: "21805600000" - trigger_price: "0" - quantity: "0.001" - filled_quantity: "0.001" - state: "filled" - created_at: 1676268938604 - updated_at: 1676268938604 - direction: "sell" - margin: "21800000" -} -orders { - order_hash: "0x10c4cd0c744c08d38920d063ad5f811b97fd9f5d59224814ad9a02bdffb4c0bd" - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - subaccount_id: "0x295639d56c987f0e24d21bb167872b3542a6e05a000000000000000000000000" - execution_type: "limit" - order_type: "sell" - price: "21876100000" - trigger_price: "0" - quantity: "0.001" - filled_quantity: "0" - state: "canceled" - created_at: 1676268856766 - updated_at: 1676268924613 - direction: "sell" - margin: "21900000" -} -paging { - total: 32 +{ + "orders":[ + { + "orderHash":"0x3c98f1e38781ce8780f8f5ffe3a78cf3dbfa4d96f54d774a4847f46e9e89d6dc", + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "subaccountId":"0x5e249f0e8cb406f41de16e1bd6f6b55e7bc75add000000000000000000000005", + "executionType":"limit", + "orderType":"buy_po", + "price":"13097700", + "triggerPrice":"0", + "quantity":"110660.5284", + "filledQuantity":"0", + "state":"canceled", + "createdAt":"1701995288222", + "updatedAt":"1702002966962", + "direction":"buy", + "margin":"724699201412.34", + "txHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "isActive":false, + "isReduceOnly":false, + "isConditional":false, + "triggerAt":"0", + "placedOrderHash":"", + "cid":"" + }, + { + "orderHash":"0xc7c34746158b1e21bbdfa8edce0876fa00810f7b6f2236c302945c8e6b9eeb38", + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "subaccountId":"0x5e249f0e8cb406f41de16e1bd6f6b55e7bc75add000000000000000000000005", + "executionType":"limit", + "orderType":"buy_po", + "price":"13064100", + "triggerPrice":"0", + "quantity":"110945.1399", + "filledQuantity":"0", + "state":"canceled", + "createdAt":"1701995288222", + "updatedAt":"1702002966962", + "direction":"buy", + "margin":"724699201083.795", + "txHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "isActive":false, + "isReduceOnly":false, + "isConditional":false, + "triggerAt":"0", + "placedOrderHash":"", + "cid":"" + }, + { + "orderHash":"0x4478897d21c94df929c7d12c33d71973027ced1899ff253199b6e46124e680c1", + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "subaccountId":"0x5e249f0e8cb406f41de16e1bd6f6b55e7bc75add000000000000000000000005", + "executionType":"limit", + "orderType":"buy_po", + "price":"13030500", + "triggerPrice":"0", + "quantity":"111231.2193", + "filledQuantity":"0", + "state":"canceled", + "createdAt":"1701995288222", + "updatedAt":"1702002966962", + "direction":"buy", + "margin":"724699201544.325", + "txHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "isActive":false, + "isReduceOnly":false, + "isConditional":false, + "triggerAt":"0", + "placedOrderHash":"", + "cid":"" + } + ], + "paging":{ + "total":"1000", + "from":0, + "to":0, + "countBySubaccount":"0", + "next":[ + + ] + } } ``` @@ -1469,67 +1504,90 @@ console.log(orderHistory) > Streaming Response Example: ``` python -order { - order_hash: "0xfb526d72b85e9ffb4426c37bf332403fb6fb48709fb5d7ca3be7b8232cd10292" - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - is_active: true - subaccount_id: "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" - execution_type: "limit" - order_type: "sell_po" - price: "274310000" - trigger_price: "0" - quantity: "144" - filled_quantity: "0" - state: "booked" - created_at: 1665487076373 - updated_at: 1665487076373 - direction: "sell" - margin: "3950170000" +{ + "order":{ + "order_hash":"0x4aeb72ac2ae5811126a0c384e05ce68745316add0e705c39e73f68c76431515e", + "market_id":"0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74", + "is_active":true, + "subaccount_id":"0x7619f89a2172c6705aac7482f3adbf0601ea140e000000000000000000000000", + "execution_type":"limit", + "order_type":"sell_po", + "price":"27953000000", + "trigger_price":"0", + "quantity":"0.0344", + "filled_quantity":"0", + "state":"booked", + "created_at":1696617269292, + "updated_at":1696617269292, + "direction":"sell", + "margin":"320527734" + }, + "operation_type":"insert", + "timestamp":1696617272000 +} +{ + "order":{ + "order_hash":"0x24d82da3530ce5d2d392c9563d29b79c3a25e058dd6d79e0d8f651703256eb78", + "market_id":"0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74", + "subaccount_id":"0x6590d14d9e9c1d964f8c83bddc8a092f4a2d1284000000000000000000000000", + "execution_type":"limit", + "order_type":"buy_po", + "price":"27912000000", + "trigger_price":"0", + "quantity":"0.0344", + "filled_quantity":"0", + "state":"canceled", + "created_at":1696617207873, + "updated_at":1696617269292, + "direction":"buy", + "margin":"320057600" + }, + "operation_type":"update", + "timestamp":1696617272000 } -operation_type: "insert" -timestamp: 1665487078000 ``` ``` go { - "order": { - "order_hash": "0x4aeb72ac2ae5811126a0c384e05ce68745316add0e705c39e73f68c76431515e", - "market_id": "0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74", - "is_active": true, - "subaccount_id": "0x7619f89a2172c6705aac7482f3adbf0601ea140e000000000000000000000000", - "execution_type": "limit", - "order_type": "sell_po", - "price": "27953000000", - "trigger_price": "0", - "quantity": "0.0344", - "filled_quantity": "0", - "state": "booked", - "created_at": 1696617269292, - "updated_at": 1696617269292, - "direction": "sell", - "margin": "320527734" - }, - "operation_type": "insert", - "timestamp": 1696617272000 -}{ - "order": { - "order_hash": "0x24d82da3530ce5d2d392c9563d29b79c3a25e058dd6d79e0d8f651703256eb78", - "market_id": "0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74", - "subaccount_id": "0x6590d14d9e9c1d964f8c83bddc8a092f4a2d1284000000000000000000000000", - "execution_type": "limit", - "order_type": "buy_po", - "price": "27912000000", - "trigger_price": "0", - "quantity": "0.0344", - "filled_quantity": "0", - "state": "canceled", - "created_at": 1696617207873, - "updated_at": 1696617269292, - "direction": "buy", - "margin": "320057600" - }, - "operation_type": "update", - "timestamp": 1696617272000 + "order":{ + "order_hash":"0x4aeb72ac2ae5811126a0c384e05ce68745316add0e705c39e73f68c76431515e", + "market_id":"0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74", + "is_active":true, + "subaccount_id":"0x7619f89a2172c6705aac7482f3adbf0601ea140e000000000000000000000000", + "execution_type":"limit", + "order_type":"sell_po", + "price":"27953000000", + "trigger_price":"0", + "quantity":"0.0344", + "filled_quantity":"0", + "state":"booked", + "created_at":1696617269292, + "updated_at":1696617269292, + "direction":"sell", + "margin":"320527734" + }, + "operation_type":"insert", + "timestamp":1696617272000 +} +{ + "order":{ + "order_hash":"0x24d82da3530ce5d2d392c9563d29b79c3a25e058dd6d79e0d8f651703256eb78", + "market_id":"0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74", + "subaccount_id":"0x6590d14d9e9c1d964f8c83bddc8a092f4a2d1284000000000000000000000000", + "execution_type":"limit", + "order_type":"buy_po", + "price":"27912000000", + "trigger_price":"0", + "quantity":"0.0344", + "filled_quantity":"0", + "state":"canceled", + "created_at":1696617207873, + "updated_at":1696617269292, + "direction":"buy", + "margin":"320057600" + }, + "operation_type":"update", + "timestamp":1696617272000 } ``` @@ -1592,7 +1650,6 @@ Get trades of a derivative market. import asyncio from pyinjective.async_client import AsyncClient -from pyinjective.client.model.pagination import PaginationOption from pyinjective.core.network import Network @@ -1600,14 +1657,9 @@ async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - market_ids = ["0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"] - subaccount_ids = ["0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000"] - skip = 0 - limit = 4 - pagination = PaginationOption(skip=skip, limit=limit) - trades = await client.fetch_derivative_trades( - market_ids=market_ids, subaccount_ids=subaccount_ids, pagination=pagination - ) + market_id = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + subaccount_id = "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" + trades = await client.get_derivative_trades(market_id=market_id, subaccount_id=subaccount_id) print(trades) @@ -1886,9 +1938,10 @@ paging { | total | Integer | Total number of records available | -## StreamTrades +## TradesV2 -Stream newly executed trades of a derivative market. The default request streams trades from all derivative markets. +Get trades of a derivative market. +The difference between `Trades` and `TradesV2` is that the latter returns a `trade_id` compatible witht the one used for trade events in chain stream. **IP rate limit group:** `indexer` @@ -1900,54 +1953,30 @@ Stream newly executed trades of a derivative market. The default request streams 3. `"limitMatchRestingOrder"` for a resting limit order getting matched with another new limit order 4. `"limitMatchNewOrder"` for a new limit order getting matched immediately - ### Request Parameters > Request Example: ``` python import asyncio -from typing import Any, Dict - -from grpc import RpcError from pyinjective.async_client import AsyncClient +from pyinjective.client.model.pagination import PaginationOption from pyinjective.core.network import Network -async def market_event_processor(event: Dict[str, Any]): - print(event) - - -def stream_error_processor(exception: RpcError): - print(f"There was an error listening to derivative trades updates ({exception})") - - -def stream_closed_processor(): - print("The derivative trades updates stream has been closed") - - async def main() -> None: # select network: local, testnet, mainnet network = Network.testnet() client = AsyncClient(network) - market_ids = [ - "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", - "0x70bc8d7feab38b23d5fdfb12b9c3726e400c265edbcbf449b6c80c31d63d3a02", - ] + market_ids = ["0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"] subaccount_ids = ["0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000"] - - task = asyncio.get_event_loop().create_task( - client.listen_derivative_trades_updates( - callback=market_event_processor, - on_end_callback=stream_closed_processor, - on_status_callback=stream_error_processor, - market_ids=market_ids, - subaccount_ids=subaccount_ids, - ) + skip = 0 + limit = 4 + pagination = PaginationOption(skip=skip, limit=limit) + trades = await client.fetch_derivative_trades( + market_ids=market_ids, subaccount_ids=subaccount_ids, pagination=pagination ) - - await asyncio.sleep(delay=60) - task.cancel() + print(trades) if __name__ == "__main__": @@ -1959,40 +1988,450 @@ if __name__ == "__main__": package main import ( - "context" - "encoding/json" - "fmt" + "context" + "encoding/json" + "fmt" - "github.com/InjectiveLabs/sdk-go/client/common" - exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" - derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" + "github.com/InjectiveLabs/sdk-go/client/common" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" ) func main() { - // network := common.LoadNetwork("mainnet", "lb") - network := common.LoadNetwork("testnet", "k8s") - exchangeClient, err := exchangeclient.NewExchangeClient(network.ExchangeGrpcEndpoint, common.OptionTLSCert(network.ExchangeTlsCert)) - if err != nil { - panic(err) - } + network := common.LoadNetwork("testnet", "lb") + exchangeClient, err := exchangeclient.NewExchangeClient(network) + if err != nil { + fmt.Println(err) + } - ctx := context.Background() - marketId := "0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74" - subaccountId := "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" + ctx := context.Background() + marketId := "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce" + subaccountId := "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" - req := derivativeExchangePB.StreamTradesRequest{ - MarketId: marketId, - SubaccountId: subaccountId, - } - stream, err := exchangeClient.StreamDerivativeTrades(ctx, req) - if err != nil { - panic(err) - } + req := derivativeExchangePB.TradesV2Request{ + MarketId: marketId, + SubaccountId: subaccountId, + } - for { - select { - case <-ctx.Done(): - return + res, err := exchangeClient.GetDerivativeTradesV2(ctx, req) + if err != nil { + panic(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) +} +``` + +``` typescript + +``` + +| Parameter | Type | Description | Required | +| --------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------- | -------- | +| market_ids | String Array | Filter by multiple market IDs | No | +| subaccount_ids | String Array | Filter by multiple subaccount IDs | No | +| execution_side | String | Filter by the execution side of the trade (Should be one of: ["maker", "taker"]) | No | +| direction | String | Filter by the direction of the trade (Should be one of: ["buy", "sell"]) | No | +| execution_types | String Array | Filter by the *trade execution type (Should be any of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | No | +| trade_id | String | Filter by the trade id of the trade | No | +| account_address | String | Filter by the account address | No | +| cid | String | Filter by the custom client order id of the trade's order | No | +| pagination | PaginationOption | Pagination configuration | No | + +### Response Parameters +> Response Example: + +``` python +{ + "trades":[ + { + "orderHash":"0xc246b6a43d826667047f752a76e508511d0aa4f73aba1c3b95527037ccbcb50c", + "subaccountId":"0x101411266c6e2b610b4a0324d2bfb2ef0ca6e1dd000000000000000000000000", + "marketId":"0x56d0c0293c4415e2d48fc2c8503a56a0c7389247396a2ef9b0a48c01f0646705", + "tradeExecutionType":"limitMatchRestingOrder", + "positionDelta":{ + "tradeDirection":"buy", + "executionPrice":"10000000", + "executionQuantity":"1", + "executionMargin":"10000000" + }, + "payout":"0", + "fee":"-60000", + "executedAt":"1701978102242", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"22868_2", + "executionSide":"maker", + "cid":"49fb387d-aad3-4f03-85c5-e6c06c5ea685", + "isLiquidation":false + }, + { + "orderHash":"0x836e778ae11cee6cd31619ca7329121419471be7ea1bd2fafbae3a8d411a04c7", + "subaccountId":"0x101411266c6e2b610b4a0324d2bfb2ef0ca6e1dd000000000000000000000000", + "marketId":"0x7cc8b10d7deb61e744ef83bdec2bbcf4a056867e89b062c6a453020ca82bd4e4", + "tradeExecutionType":"limitMatchRestingOrder", + "positionDelta":{ + "tradeDirection":"buy", + "executionPrice":"10000000", + "executionQuantity":"1", + "executionMargin":"10000000" + }, + "payout":"0", + "fee":"-600", + "executedAt":"1701978102242", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"22868_4", + "executionSide":"maker", + "cid":"9a74f3ce-ea31-491e-9e64-e48541a8f7fd", + "isLiquidation":false + }, + { + "orderHash":"0x404577bc40896028733f7740d4efc6f6695fb9194f43dd545fb8923cbb01efd6", + "subaccountId":"0x3db1f84431dfe4df617f9eb2d04edf432beb9826000000000000000000000000", + "marketId":"0x56d0c0293c4415e2d48fc2c8503a56a0c7389247396a2ef9b0a48c01f0646705", + "tradeExecutionType":"limitMatchNewOrder", + "positionDelta":{ + "tradeDirection":"sell", + "executionPrice":"10000000", + "executionQuantity":"1", + "executionMargin":"10000000" + }, + "payout":"0", + "fee":"5000000", + "executedAt":"1701978102242", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"22868_3", + "executionSide":"taker", + "cid":"derivative_ATOM/USDT", + "isLiquidation":false + }, + { + "orderHash":"0x3fde93ceabc67a13372c237f5271784c0bbe97801ef12e883cfbde4c13e16300", + "subaccountId":"0x3db1f84431dfe4df617f9eb2d04edf432beb9826000000000000000000000000", + "marketId":"0x7cc8b10d7deb61e744ef83bdec2bbcf4a056867e89b062c6a453020ca82bd4e4", + "tradeExecutionType":"limitMatchNewOrder", + "positionDelta":{ + "tradeDirection":"sell", + "executionPrice":"10000000", + "executionQuantity":"1", + "executionMargin":"9000000" + }, + "payout":"0", + "fee":"10000", + "executedAt":"1701978102242", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"22868_5", + "executionSide":"taker", + "cid":"derivative_INJ/USDT", + "isLiquidation":false + }, + { + "orderHash":"0xc246b6a43d826667047f752a76e508511d0aa4f73aba1c3b95527037ccbcb50c", + "subaccountId":"0x101411266c6e2b610b4a0324d2bfb2ef0ca6e1dd000000000000000000000000", + "marketId":"0x56d0c0293c4415e2d48fc2c8503a56a0c7389247396a2ef9b0a48c01f0646705", + "tradeExecutionType":"limitMatchRestingOrder", + "positionDelta":{ + "tradeDirection":"buy", + "executionPrice":"10000000", + "executionQuantity":"1", + "executionMargin":"10000000" + }, + "payout":"0", + "fee":"-60000", + "executedAt":"1701961116630", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"1321_2", + "executionSide":"maker", + "cid":"49fb387d-aad3-4f03-85c5-e6c06c5ea685", + "isLiquidation":false + }, + { + "orderHash":"0x836e778ae11cee6cd31619ca7329121419471be7ea1bd2fafbae3a8d411a04c7", + "subaccountId":"0x101411266c6e2b610b4a0324d2bfb2ef0ca6e1dd000000000000000000000000", + "marketId":"0x7cc8b10d7deb61e744ef83bdec2bbcf4a056867e89b062c6a453020ca82bd4e4", + "tradeExecutionType":"limitMatchRestingOrder", + "positionDelta":{ + "tradeDirection":"buy", + "executionPrice":"10000000", + "executionQuantity":"1", + "executionMargin":"10000000" + }, + "payout":"0", + "fee":"-600", + "executedAt":"1701961116630", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"1321_4", + "executionSide":"maker", + "cid":"9a74f3ce-ea31-491e-9e64-e48541a8f7fd", + "isLiquidation":false + }, + { + "orderHash":"0xf6ae77b0a1e267b7f0b8618f3f226c39ba702a09fb3bdb650b0c28197d36d91d", + "subaccountId":"0x3db1f84431dfe4df617f9eb2d04edf432beb9826000000000000000000000000", + "marketId":"0x56d0c0293c4415e2d48fc2c8503a56a0c7389247396a2ef9b0a48c01f0646705", + "tradeExecutionType":"limitMatchNewOrder", + "positionDelta":{ + "tradeDirection":"sell", + "executionPrice":"10000000", + "executionQuantity":"1", + "executionMargin":"10000000" + }, + "payout":"0", + "fee":"5000000", + "executedAt":"1701961116630", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"1321_3", + "executionSide":"taker", + "cid":"49fb387d-aad3-4f03-85c5-e6c06c5ea685", + "isLiquidation":false + }, + { + "orderHash":"0x01ba4dd3b30bc946a31f5fe1aba9918e95d3dc8cf31a6c4b2d793068eae529e8", + "subaccountId":"0x3db1f84431dfe4df617f9eb2d04edf432beb9826000000000000000000000000", + "marketId":"0x7cc8b10d7deb61e744ef83bdec2bbcf4a056867e89b062c6a453020ca82bd4e4", + "tradeExecutionType":"limitMatchNewOrder", + "positionDelta":{ + "tradeDirection":"sell", + "executionPrice":"10000000", + "executionQuantity":"1", + "executionMargin":"9000000" + }, + "payout":"0", + "fee":"10000", + "executedAt":"1701961116630", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"1321_5", + "executionSide":"taker", + "cid":"9a74f3ce-ea31-491e-9e64-e48541a8f7fd", + "isLiquidation":false + } + ], + "paging":{ + "total":"8", + "from":1, + "to":8, + "countBySubaccount":"0", + "next":[ + + ] + } +} +``` + +``` go +{ + "trades": [ + { + "order_hash": "0x836e778ae11cee6cd31619ca7329121419471be7ea1bd2fafbae3a8d411a04c7", + "subaccount_id": "0x101411266c6e2b610b4a0324d2bfb2ef0ca6e1dd000000000000000000000000", + "market_id": "0x7cc8b10d7deb61e744ef83bdec2bbcf4a056867e89b062c6a453020ca82bd4e4", + "trade_execution_type": "limitMatchRestingOrder", + "position_delta": { + "trade_direction": "buy", + "execution_price": "10000000", + "execution_quantity": "1", + "execution_margin": "10000000" + }, + "payout": "0", + "fee": "-600", + "executed_at": 1701978102242, + "fee_recipient": "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "trade_id": "22868_4", + "execution_side": "maker", + "cid": "9a74f3ce-ea31-491e-9e64-e48541a8f7fd" + }, + { + "order_hash": "0x3fde93ceabc67a13372c237f5271784c0bbe97801ef12e883cfbde4c13e16300", + "subaccount_id": "0x3db1f84431dfe4df617f9eb2d04edf432beb9826000000000000000000000000", + "market_id": "0x7cc8b10d7deb61e744ef83bdec2bbcf4a056867e89b062c6a453020ca82bd4e4", + "trade_execution_type": "limitMatchNewOrder", + "position_delta": { + "trade_direction": "sell", + "execution_price": "10000000", + "execution_quantity": "1", + "execution_margin": "9000000" + }, + "payout": "0", + "fee": "10000", + "executed_at": 1701978102242, + "fee_recipient": "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "trade_id": "22868_5", + "execution_side": "taker", + "cid": "9a74f3ce-ea31-491e-9e64-e48541a8f7fd" + }, + { + "order_hash": "0x836e778ae11cee6cd31619ca7329121419471be7ea1bd2fafbae3a8d411a04c7", + "subaccount_id": "0x101411266c6e2b610b4a0324d2bfb2ef0ca6e1dd000000000000000000000000", + "market_id": "0x7cc8b10d7deb61e744ef83bdec2bbcf4a056867e89b062c6a453020ca82bd4e4", + "trade_execution_type": "limitMatchRestingOrder", + "position_delta": { + "trade_direction": "buy", + "execution_price": "10000000", + "execution_quantity": "1", + "execution_margin": "10000000" + }, + "payout": "0", + "fee": "-600", + "executed_at": 1701961116630, + "fee_recipient": "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "trade_id": "1321_4", + "execution_side": "maker", + "cid": "9a74f3ce-ea31-491e-9e64-e48541a8f7fd" + }, + { + "order_hash": "0x01ba4dd3b30bc946a31f5fe1aba9918e95d3dc8cf31a6c4b2d793068eae529e8", + "subaccount_id": "0x3db1f84431dfe4df617f9eb2d04edf432beb9826000000000000000000000000", + "market_id": "0x7cc8b10d7deb61e744ef83bdec2bbcf4a056867e89b062c6a453020ca82bd4e4", + "trade_execution_type": "limitMatchNewOrder", + "position_delta": { + "trade_direction": "sell", + "execution_price": "10000000", + "execution_quantity": "1", + "execution_margin": "9000000" + }, + "payout": "0", + "fee": "10000", + "executed_at": 1701961116630, + "fee_recipient": "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "trade_id": "1321_5", + "execution_side": "taker", + "cid": "9a74f3ce-ea31-491e-9e64-e48541a8f7fd" + } + ], + "paging": { + "total": 4, + "from": 1, + "to": 4 + } +} + +``` + +``` typescript + +``` + +| Parameter | Type | Description | +| --------- | --------------------- | ------------------------------------ | +| trades | DerivativeTrade Array | List of trades of derivative markets | +| paging | Paging | Pagination of results | + +**DerivativeTrade** + +| Parameter | Type | Description | +| -------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------ | +| order_hash | String | The order hash | +| subaccount_id | String | ID of subaccount that executed the trade | +| market_id | String | The market ID | +| trade_execution_type | String | *Execution type of the trade (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | +| is_liquidation | Boolean | True if the trade is a liquidation | +| position_delta | PositionDelta | Position delta from the trade | +| payout | String | The payout associated with the trade | +| fee | String | The fee associated with the trade | +| executed_at | Integer | Timestamp of trade execution (on chain) in UNIX millis | +| fee_recipient | String | The address that received 40% of the fees | +| trade_id | String | Unique identifier to differentiate between trades | +| execution_side | String | Execution side of trade (Should be one of: ["maker", "taker"]) | +| cid | String | Custom client order id | + +**PositionDelta** + +| Parameter | Type | Description | +| ------------------ | ------ | ----------------------------------------------------------- | +| execution_price | String | Execution price of the trade | +| execution_quantity | String | Execution quantity of the trade | +| trade_direction | String | The direction the trade (Should be one of: ["buy", "sell"]) | +| execution_margin | String | Execution margin of the trade | + +**Paging** + +| Parameter | Type | Description | +| --------- | ------- | --------------------------------- | +| total | Integer | Total number of records available | + + +## StreamTrades + +Stream newly executed trades of a derivative market. The default request streams trades from all derivative markets. + +**IP rate limit group:** `indexer` + + +**\*Trade execution types** + +1. `"market"` for market orders +2. `"limitFill"` for a resting limit order getting filled by a market order +3. `"limitMatchRestingOrder"` for a resting limit order getting matched with another new limit order +4. `"limitMatchNewOrder"` for a new limit order getting matched immediately + + +### Request Parameters +> Request Example: + +``` python +import asyncio + +from pyinjective.async_client import AsyncClient +from pyinjective.core.network import Network + + +async def main() -> None: + # select network: local, testnet, mainnet + network = Network.testnet() + client = AsyncClient(network) + market_ids = [ + "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "0xd5e4b12b19ecf176e4e14b42944731c27677819d2ed93be4104ad7025529c7ff", + ] + subaccount_id = "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" + trades = await client.stream_derivative_trades(market_id=market_ids[0], subaccount_id=subaccount_id) + async for trade in trades: + print(trade) + + +if __name__ == "__main__": + asyncio.get_event_loop().run_until_complete(main()) + +``` + +``` go +package main + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/InjectiveLabs/sdk-go/client/common" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" +) + +func main() { + // network := common.LoadNetwork("mainnet", "lb") + network := common.LoadNetwork("testnet", "k8s") + exchangeClient, err := exchangeclient.NewExchangeClient(network.ExchangeGrpcEndpoint, common.OptionTLSCert(network.ExchangeTlsCert)) + if err != nil { + panic(err) + } + + ctx := context.Background() + marketId := "0x141e3c92ed55107067ceb60ee412b86256cedef67b1227d6367b4cdf30c55a74" + subaccountId := "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" + + req := derivativeExchangePB.StreamTradesRequest{ + MarketId: marketId, + SubaccountId: subaccountId, + } + stream, err := exchangeClient.StreamDerivativeTrades(ctx, req) + if err != nil { + panic(err) + } + + for { + select { + case <-ctx.Done(): + return default: res, err := stream.Recv() if err != nil { @@ -2190,11 +2629,335 @@ timestamp: 1652793013000 "executedAt": 1654246489592, "feeRecipient": "inj1cml96vmptgw99syqrrz8az79xer2pcgp0a885r" }, - "operationType": "insert", - "timestamp": 1654246493000 + "operationType": "insert", + "timestamp": 1654246493000 +} +``` + +| Parameter | Type | Description | +| -------------- | --------------- | ------------------------------------------------------------------- | +| trade | DerivativeTrade | New derivative market trade | +| operation_type | String | Trade operation type (Should be one of: ["insert", "invalidate"]) | +| timestamp | Integer | Timestamp the new trade is written into the database in UNIX millis | + + +**DerivativeTrade** + +| Parameter | Type | Description | +| -------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------ | +| order_hash | String | The order hash | +| subaccount_id | String | ID of subaccount that executed the trade | +| market_id | String | The market ID | +| trade_execution_type | String | *Execution type of the trade (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | +| is_liquidation | Boolean | True if the trade is a liquidation | +| position_delta | PositionDelta | Position delta from the trade | +| payout | String | The payout associated with the trade | +| fee | String | The fee associated with the trade | +| executed_at | Integer | Timestamp of trade execution (on chain) in UNIX millis | +| fee_recipient | String | The address that received 40% of the fees | +| trade_id | String | Unique identifier to differentiate between trades | +| execution_side | String | Execution side of trade (Should be one of: ["maker", "taker"]) | +| cid | String | Custom client order id | + +**PositionDelta** + +| Parameter | Type | Description | +| ------------------ | ------ | ----------------------------------------------------------- | +| execution_price | String | Execution price of the trade | +| execution_quantity | String | Execution quantity of the trade | +| trade_direction | String | The direction the trade (Should be one of: ["buy", "sell"]) | +| execution_margin | String | Execution margin of the trade | + + +## StreamTradesV2 + +Stream newly executed trades of a derivative market. The default request streams trades from all derivative markets. +The difference between `StreamTrades` and `StreamTradesV2` is that the latter returns a `trade_id` compatible witht the one used for trade events in chain stream. + +**IP rate limit group:** `indexer` + + +**\*Trade execution types** + +1. `"market"` for market orders +2. `"limitFill"` for a resting limit order getting filled by a market order +3. `"limitMatchRestingOrder"` for a resting limit order getting matched with another new limit order +4. `"limitMatchNewOrder"` for a new limit order getting matched immediately + + +### Request Parameters +> Request Example: + +``` python +import asyncio +from typing import Any, Dict + +from grpc import RpcError + +from pyinjective.async_client import AsyncClient +from pyinjective.core.network import Network + + +async def market_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to derivative trades updates ({exception})") + + +def stream_closed_processor(): + print("The derivative trades updates stream has been closed") + + +async def main() -> None: + # select network: local, testnet, mainnet + network = Network.testnet() + client = AsyncClient(network) + market_ids = [ + "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "0x70bc8d7feab38b23d5fdfb12b9c3726e400c265edbcbf449b6c80c31d63d3a02", + ] + subaccount_ids = ["0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000"] + + task = asyncio.get_event_loop().create_task( + client.listen_derivative_trades_updates( + callback=market_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + market_ids=market_ids, + subaccount_ids=subaccount_ids, + ) + ) + + await asyncio.sleep(delay=60) + task.cancel() + + +if __name__ == "__main__": + asyncio.get_event_loop().run_until_complete(main()) + +``` + +``` go +package main + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/InjectiveLabs/sdk-go/client/common" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + exchangeClient, err := exchangeclient.NewExchangeClient(network) + if err != nil { + panic(err) + } + + ctx := context.Background() + marketId := "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce" + subaccountId := "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" + + req := derivativeExchangePB.StreamTradesV2Request{ + MarketId: marketId, + SubaccountId: subaccountId, + } + stream, err := exchangeClient.StreamDerivativeV2Trades(ctx, req) + if err != nil { + panic(err) + } + + for { + select { + case <-ctx.Done(): + return + default: + res, err := stream.Recv() + if err != nil { + panic(err) + return + } + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + } + } +} + +``` + + +``` typescript + +``` + +| Parameter | Type | Description | Required | +| ------------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------- | -------- | +| market_ids | String Array | Filter by multiple market IDs | No | +| execution_side | String | Filter by the execution side of the trade (Should be one of: ["maker", "taker"]) | No | +| direction | String | Filter by the direction of the trade (Should be one of: ["buy", "sell"]) | No | +| subaccount_ids | String Array | Filter by multiple subaccount IDs | No | +| execution_types | String Array | Filter by the *trade execution type (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | No | +| trade_id | String | Filter by the trade's trade id | No | +| account_address | String | Filter by the account address | No | +| cid | String | Filter by the custom client order id of the trade's order | No | +| pagination | PaginationOption | Pagination configuration | No | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | + +### Response Parameters +> Streaming Response Example: + +``` python +{ + "trade":{ + "orderHash":"0x01e6b3df831734c88c84522f9834b3656b3afde6891ac671742dd269be776510", + "subaccountId":"0x3db1f84431dfe4df617f9eb2d04edf432beb9826000000000000000000000000", + "marketId":"0x56d0c0293c4415e2d48fc2c8503a56a0c7389247396a2ef9b0a48c01f0646705", + "tradeExecutionType":"limitMatchNewOrder", + "positionDelta":{ + "tradeDirection":"sell", + "executionPrice":"10000000", + "executionQuantity":"1", + "executionMargin":"10000000" + }, + "payout":"0", + "fee":"5000000", + "executedAt":"1701979920875", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"25116_3", + "executionSide":"taker", + "cid":"derivative_ATOM/USDT", + "isLiquidation":false + }, + "operationType":"insert", + "timestamp":"1701979922000" +} +{ + "trade":{ + "orderHash":"0xc246b6a43d826667047f752a76e508511d0aa4f73aba1c3b95527037ccbcb50c", + "subaccountId":"0x101411266c6e2b610b4a0324d2bfb2ef0ca6e1dd000000000000000000000000", + "marketId":"0x56d0c0293c4415e2d48fc2c8503a56a0c7389247396a2ef9b0a48c01f0646705", + "tradeExecutionType":"limitMatchRestingOrder", + "positionDelta":{ + "tradeDirection":"buy", + "executionPrice":"10000000", + "executionQuantity":"1", + "executionMargin":"10000000" + }, + "payout":"0", + "fee":"-60000", + "executedAt":"1701979920875", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"25116_2", + "executionSide":"maker", + "cid":"49fb387d-aad3-4f03-85c5-e6c06c5ea685", + "isLiquidation":false + }, + "operationType":"insert", + "timestamp":"1701979922000" +} +{ + "trade":{ + "orderHash":"0xa0446c80b66dd6ab75b32e51e4e04929ae92df9fa7a64fe2d21ed9be536bb6d5", + "subaccountId":"0x3db1f84431dfe4df617f9eb2d04edf432beb9826000000000000000000000000", + "marketId":"0x7cc8b10d7deb61e744ef83bdec2bbcf4a056867e89b062c6a453020ca82bd4e4", + "tradeExecutionType":"limitMatchNewOrder", + "positionDelta":{ + "tradeDirection":"sell", + "executionPrice":"10000000", + "executionQuantity":"1", + "executionMargin":"9000000" + }, + "payout":"0", + "fee":"10000", + "executedAt":"1701979920875", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"25116_5", + "executionSide":"taker", + "cid":"derivative_INJ/USDT", + "isLiquidation":false + }, + "operationType":"insert", + "timestamp":"1701979922000" +} +{ + "trade":{ + "orderHash":"0x836e778ae11cee6cd31619ca7329121419471be7ea1bd2fafbae3a8d411a04c7", + "subaccountId":"0x101411266c6e2b610b4a0324d2bfb2ef0ca6e1dd000000000000000000000000", + "marketId":"0x7cc8b10d7deb61e744ef83bdec2bbcf4a056867e89b062c6a453020ca82bd4e4", + "tradeExecutionType":"limitMatchRestingOrder", + "positionDelta":{ + "tradeDirection":"buy", + "executionPrice":"10000000", + "executionQuantity":"1", + "executionMargin":"10000000" + }, + "payout":"0", + "fee":"-600", + "executedAt":"1701979920875", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"25116_4", + "executionSide":"maker", + "cid":"9a74f3ce-ea31-491e-9e64-e48541a8f7fd", + "isLiquidation":false + }, + "operationType":"insert", + "timestamp":"1701979922000" +} +``` + +``` go +{ + "trade": { + "order_hash": "0x0403d2e51d73aa1cb46004b16d76279afece9ad14e3784eb93aa6370de466f81", + "subaccount_id": "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000", + "market_id": "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce", + "trade_execution_type": "limitMatchRestingOrder", + "position_delta": { + "trade_direction": "sell", + "execution_price": "40249100000", + "execution_quantity": "0.06", + "execution_margin": "2388462000" + }, + "payout": "0", + "fee": "1207473", + "executed_at": 1653040243183, + "fee_recipient": "inj1cml96vmptgw99syqrrz8az79xer2pcgp0a885r" + }, + "operation_type": "insert", + "timestamp": 1653040246000 +}{ + "trade": { + "order_hash": "0x728d69975e4057d1801f1a7031d0ccf7242abacbf73320da55abab677efc2a7e", + "subaccount_id": "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000", + "market_id": "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce", + "trade_execution_type": "limitMatchRestingOrder", + "position_delta": { + "trade_direction": "sell", + "execution_price": "40249100000", + "execution_quantity": "0.02", + "execution_margin": "779300000" + }, + "payout": "0", + "fee": "402491", + "executed_at": 1653040243183, + "fee_recipient": "inj1cml96vmptgw99syqrrz8az79xer2pcgp0a885r" + }, + "operation_type": "insert", + "timestamp": 1653040246000 } ``` +``` typescript + +``` + | Parameter | Type | Description | | -------------- | --------------- | ------------------------------------------------------------------- | | trade | DerivativeTrade | New derivative market trade | @@ -2363,66 +3126,74 @@ import { ExchangeGrpcClient } from "@injectivelabs/sdk-ts/dist/client/exchange/E > Response Example: ``` python -positions { - ticker: "BTC/USDT PERP" - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - subaccount_id: "0xea98e3aa091a6676194df40ac089e40ab4604bf9000000000000000000000000" - direction: "short" - quantity: "0.01" - entry_price: "18000000000" - margin: "186042357.839476" - liquidation_price: "34861176937.092952" - mark_price: "16835930000" - aggregate_reduce_only_quantity: "0" - updated_at: 1676412001911 - created_at: -62135596800000 -} -positions { - ticker: "BTC/USDT PERP" - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - subaccount_id: "0xf0876e4b3afb41594c7fa7e79c37f638e9fc17bc000000000000000000000000" - direction: "short" - quantity: "0.3396" - entry_price: "18542170276.197423020607578062" - margin: "6166391787.817873" - liquidation_price: "34952360798.739463" - mark_price: "16835930000" - aggregate_reduce_only_quantity: "0" - updated_at: 1676412001911 - created_at: -62135596800000 -} -positions { - ticker: "INJ/USDT PERP" - market_id: "0xe112199d9ee44ceb2697ea0edd1cd422223c105f3ed2bdf85223d3ca59f5909a" - subaccount_id: "0x2da57011081e05273fe34560d7556ce79bc9ef2e000000000000000000000000" - direction: "short" - quantity: "2" - entry_price: "1000000" - margin: "2060353.334536" - liquidation_price: "1933501.587874" - mark_price: "1368087.992" - aggregate_reduce_only_quantity: "0" - updated_at: 1676412001911 - created_at: -62135596800000 -} -positions { - ticker: "INJ/USDT PERP" - market_id: "0xe112199d9ee44ceb2697ea0edd1cd422223c105f3ed2bdf85223d3ca59f5909a" - subaccount_id: "0x5bd0718082df50745334433ff9aff9c29d60733c000000000000000000000000" - direction: "short" - quantity: "5.8823" - entry_price: "1725484.929364364279278514" - margin: "3192502.681895" - liquidation_price: "2160205.018913" - mark_price: "1368087.992" - aggregate_reduce_only_quantity: "0" - updated_at: 1676412001911 - created_at: -62135596800000 -} -paging { - total: 13 - from: 5 - to: 8 +{ + "positions":[ + { + "ticker":"INJ/USDT PERP", + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "subaccountId":"0x00cd2929594559000670af009e2f5ef15fefa6cf000000000000000000000000", + "direction":"long", + "quantity":"0.000050211853307914", + "entryPrice":"12293600", + "margin":"316.500712", + "liquidationPrice":"6112544.170976", + "markPrice":"18461042.39", + "aggregateReduceOnlyQuantity":"0", + "updatedAt":"1702000801389", + "createdAt":"-62135596800000" + }, + { + "ticker":"INJ/USDT PERP", + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "subaccountId":"0x00cf63fab44e827a4fb12142d6e0d8e82099701a000000000000000000000000", + "direction":"long", + "quantity":"0.000058171926973086", + "entryPrice":"12293600", + "margin":"366.858203", + "liquidationPrice":"6109339.29325", + "markPrice":"18461042.39", + "aggregateReduceOnlyQuantity":"0", + "updatedAt":"1702000801389", + "createdAt":"-62135596800000" + }, + { + "ticker":"INJ/USDT PERP", + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "subaccountId":"0x010d36443f440708892e79dcbb6c1350c4c76662000000000000000000000000", + "direction":"long", + "quantity":"0.00008708028566368", + "entryPrice":"12293600", + "margin":"549.102034", + "liquidationPrice":"6110103.485758", + "markPrice":"18461042.39", + "aggregateReduceOnlyQuantity":"0", + "updatedAt":"1702000801389", + "createdAt":"-62135596800000" + }, + { + "ticker":"INJ/USDT PERP", + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "subaccountId":"0x021a86b9858f6e4150a724d444e94d10cb75c1b1000000000000000000000000", + "direction":"short", + "quantity":"0.077749303393590607", + "entryPrice":"15980281.340438795311756851", + "margin":"615528.738969", + "liquidationPrice":"23428549.626241", + "markPrice":"18461042.39", + "aggregateReduceOnlyQuantity":"0", + "updatedAt":"1702000801389", + "createdAt":"-62135596800000" + } + ], + "paging":{ + "total":"992", + "from":5, + "to":8, + "countBySubaccount":"0", + "next":[ + + ] + } } ``` @@ -2655,21 +3426,36 @@ import { ExchangeGrpcStreamClient } from "@injectivelabs/sdk-ts/dist/client/exch > Streaming Response Example: ``` python -positions { - ticker: "BTC/USDT PERP" - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - subaccount_id: "0xea98e3aa091a6676194df40ac089e40ab4604bf9000000000000000000000000" - direction: "short" - quantity: "0.01" - entry_price: "18000000000" - margin: "186042357.839476" - liquidation_price: "34861176937.092952" - mark_price: "16835930000" - aggregate_reduce_only_quantity: "0" - updated_at: 1676412001911 - created_at: -62135596800000 +{ + "position": { + "ticker": "BTC/USDT PERP", + "marketId": "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce", + "subaccountId": "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000", + "direction": "short", + "quantity": "1.6321", + "entryPrice": "40555935751.758890674529114982", + "margin": "65283896141.678537523412631302", + "liquidationPrice": "76719878206.648298", + "markPrice": "40128736026.4094317665", + "aggregateReduceOnlyQuantity": "0" + }, + "timestamp": 1654246646000 +} +{ + "position": { + "ticker": "BTC/USDT PERP", + "marketId": "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce", + "subaccountId": "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000", + "direction": "short", + "quantity": "1.6321", + "entryPrice": "40489113688.030524225816723708", + "margin": "65069810777.851918748331744252", + "liquidationPrice": "76531312698.56045", + "markPrice": "40128736026.4094317665", + "aggregateReduceOnlyQuantity": "0" + }, + "timestamp": 1654246687000 } -timestamp: 1652793296000 ``` ``` go @@ -3631,72 +4417,48 @@ if __name__ == "__main__": > Response Example: ``` python -orderbooks { - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - orderbook { - buys { - price: "5000000000" - quantity: "0.0097" - timestamp: 1676383776468 - } - buys { - price: "1000000000" - quantity: "0.001" - timestamp: 1661607737731 - } - sells { - price: "50000000000" - quantity: "0.1" - timestamp: 1676326399734 - } - sells { - price: "65111000000" - quantity: "0.0449" - timestamp: 1675291786816 - } - sells { - price: "70000000000" - quantity: "0.0001" - timestamp: 1671787246665 - } - sells { - price: "100000000000" - quantity: "0.0037" - timestamp: 1675291786816 - } - sells { - price: "101000000000" - quantity: "0.0007" - timestamp: 1675291761230 - } - sequence: 582 - } -} -orderbooks { - market_id: "0xd5e4b12b19ecf176e4e14b42944731c27677819d2ed93be4104ad7025529c7ff" - orderbook { - buys { - price: "930000000" - quantity: "0.01" - timestamp: 1676014824244 - } - buys { - price: "900000000" - quantity: "0.4999" - timestamp: 1670444208954 - } - buys { - price: "10000000" - quantity: "2" - timestamp: 1670437854869 - } - buys { - price: "1000000" - quantity: "1" - timestamp: 1667908624847 - } - sequence: 148 - } +{ + "orderbooks":[ + { + "marketId":"0xd5e4b12b19ecf176e4e14b42944731c27677819d2ed93be4104ad7025529c7ff", + "orderbook":{ + "sequence":"4099", + "timestamp":"1681978300931", + "buys":[ + + ], + "sells":[ + + ] + } + }, + { + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "orderbook":{ + "buys":[ + { + "price":"13400000", + "quantity":"683.3032", + "timestamp":"1702002966962" + }, + { + "price":"13366500", + "quantity":"108438.1403", + "timestamp":"1702002966962" + } + ], + "sells":[ + { + "price":"18390200", + "quantity":"78815.8042", + "timestamp":"1702002966962" + } + ], + "sequence":"1919116", + "timestamp":"1702003451726" + } + } + ] } ``` @@ -3833,52 +4595,32 @@ streamFn(streamFnArgs) > Streaming Response Example: ``` python -orderbook { - buys { - price: "10000000000" - quantity: "0.0002" - timestamp: 1676621246197 - } - buys { - price: "5000000000" - quantity: "0.0097" - timestamp: 1676383776468 - } - buys { - price: "1000000000" - quantity: "0.001" - timestamp: 1661607737731 - } - sells { - price: "50000000000" - quantity: "0.1" - timestamp: 1676326399734 - } - sells { - price: "65111000000" - quantity: "0.0449" - timestamp: 1675291786816 - } - sells { - price: "70000000000" - quantity: "0.0001" - timestamp: 1671787246665 - } - sells { - price: "100000000000" - quantity: "0.0037" - timestamp: 1675291786816 - } - sells { - price: "101000000000" - quantity: "0.0007" - timestamp: 1675291761230 - } - sequence: 584 +{ + "orderbook":{ + "buys":[ + { + "price":"13400000", + "quantity":"683.3032", + "timestamp":"1702002966962" + }, + ... + ], + "sells":[ + { + "price":"18390200", + "quantity":"78815.8042", + "timestamp":"1702002966962" + }, + ... + ], + "sequence":"1919121", + "timestamp":"1702003627697" + }, + "operationType":"update", + "timestamp":"1702003629000", + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" } -operation_type: "update" -timestamp: 1676621249000 -market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" + ``` ``` go @@ -4346,61 +5088,42 @@ console.log(subaccountOrders) > Response Example: ``` python -orders { - order_hash: "0x9f97ac0b9c13eca64d8e5a06e418fbd4d235fb3fbda05c3ad60d583802fd14fb" - order_side: "buy" - market_id: "0xe112199d9ee44ceb2697ea0edd1cd422223c105f3ed2bdf85223d3ca59f5909a" - subaccount_id: "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - margin: "2100000" - price: "1300000" - quantity: "1.6" - unfilled_quantity: "1.6" - trigger_price: "1400000" - fee_recipient: "inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8" - state: "booked" - created_at: 1673410494404 - updated_at: 1673410494404 - order_type: "stop_buy" - is_conditional: true - execution_type: "limit" -} -orders { - order_hash: "0x2f10b3100c622f4172cec285061c340f82c253c20a77ad574db07ff9b7b08832" - order_side: "buy" - market_id: "0xe112199d9ee44ceb2697ea0edd1cd422223c105f3ed2bdf85223d3ca59f5909a" - subaccount_id: "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - margin: "26000000" - price: "1300000" - quantity: "20" - unfilled_quantity: "20" - trigger_price: "1400000" - fee_recipient: "inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8" - state: "booked" - created_at: 1673410269039 - updated_at: 1673410269039 - order_type: "stop_buy" - is_conditional: true - execution_type: "limit" -} -paging { - total: 4 - from: 2 - to: 3 -} -orders { - order_hash: "0x457aadf92c40e5b2c4c7e6c3176872e72f36e11e7d4e718222b94a08a35ab071" - order_side: "buy" - market_id: "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce" - subaccount_id: "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - margin: "155000000" - price: "31000000000" - quantity: "0.01" - unfilled_quantity: "0.01" - trigger_price: "0" - fee_recipient: "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" - state: "booked" - created_at: 1652701438661 - updated_at: 1652701438661 +{ + "orders":[ + { + "orderHash":"0x0a3db65baf5d253b10e6f42e606a95503f72e920176b94e31ee802acde53ec84", + "orderSide":"buy", + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "margin":"10107500", + "price":"10107500", + "quantity":"1", + "unfilledQuantity":"1", + "triggerPrice":"0", + "feeRecipient":"inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8", + "state":"booked", + "createdAt":"1699794939298", + "updatedAt":"1699794939298", + "orderType":"buy", + "txHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "isReduceOnly":false, + "orderNumber":"0", + "isConditional":false, + "triggerAt":"0", + "placedOrderHash":"", + "executionType":"", + "cid":"" + } + ], + "paging":{ + "total":"2", + "from":2, + "to":2, + "countBySubaccount":"0", + "next":[ + + ] + } } ``` @@ -4635,41 +5358,49 @@ console.log(subaccountTrades) > Response Example: ``` python -trades { - order_hash: "0x902fc44dc5e7546bdc2a5c07174c3250da7af9661d1155c5b7e14326f6d9ae84" - subaccount_id: "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - trade_execution_type: "limitFill" - position_delta { - trade_direction: "sell" - execution_price: "43599000000" - execution_quantity: "0.0001" - execution_margin: "4300000" - } - payout: "0" - fee: "-261.594" - executed_at: 1667916924653 - fee_recipient: "inj1wrg096y69grgf8yg6tqxnh0tdwx4x47rsj8rs3" - trade_id: "4839711_902fc44dc5e7546bdc2a5c07174c3250da7af9661d1155c5b7e14326f6d9ae84" - execution_side: "maker" -} -trades { - order_hash: "0xb50a8911757ce7929c00ab816ad1d9e49da7374fa80a243e05b1b2a73c587ff6" - subaccount_id: "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - trade_execution_type: "limitFill" - position_delta { - trade_direction: "sell" - execution_price: "44983500000" - execution_quantity: "0.0001" - execution_margin: "4400000" - } - payout: "0" - fee: "-269.901" - executed_at: 1667916924653 - fee_recipient: "inj1wrg096y69grgf8yg6tqxnh0tdwx4x47rsj8rs3" - trade_id: "4839711_b50a8911757ce7929c00ab816ad1d9e49da7374fa80a243e05b1b2a73c587ff6" - execution_side: "maker" +{ + "trades":[ + { + "orderHash":"0x19da3923ce9141a9cfdb644d4ac72e0650e0e938c244ca9a55d100011fedc25e", + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "tradeExecutionType":"market", + "positionDelta":{ + "tradeDirection":"sell", + "executionPrice":"16945600", + "executionQuantity":"4", + "executionMargin":"67443600" + }, + "payout":"0", + "fee":"47447.68", + "executedAt":"1699795360671", + "feeRecipient":"inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8", + "tradeId":"18321280_201_0", + "executionSide":"taker", + "isLiquidation":false, + "cid":"" + }, + { + "orderHash":"0xe9c8a307d353d09f11f616c9b3ee7be890512ceca9da7d8e3a62411607afc9af", + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "tradeExecutionType":"limitFill", + "positionDelta":{ + "tradeDirection":"buy", + "executionPrice":"16945600", + "executionQuantity":"4", + "executionMargin":"67782400" + }, + "payout":"68143885.714285714285714287", + "fee":"-4066.944", + "executedAt":"1699795360671", + "feeRecipient":"inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8", + "tradeId":"18321280_202_0", + "executionSide":"maker", + "isLiquidation":false, + "cid":"" + } + ] } ``` @@ -4912,26 +5643,36 @@ console.log(fundingPayments) > Response Example: ``` python -payments { - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - subaccount_id: "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" - amount: "6.735816" - timestamp: 1676426400125 -} -payments { - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - subaccount_id: "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" - amount: "6.735816" - timestamp: 1676422802316 -} -payments { - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - subaccount_id: "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" - amount: "6.735816" - timestamp: 1676419200442 -} -paging { - total: 1000 +{ + "payments":[ + { + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "subaccountId":"0x00509ed903475672121d6a1fb2c646eef4da6c44000000000000000000000000", + "amount":"1.628605", + "timestamp":"1702000801389" + }, + { + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "subaccountId":"0x0000040f1111c5c3d2037940658ee770bb37e0a2000000000000000000000000", + "amount":"-0.005036", + "timestamp":"1702000801389" + }, + { + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "subaccountId":"0x0000007c60fab7a70c2ae0ebe437f3726b05e7eb000000000000000000000000", + "amount":"-0.006378", + "timestamp":"1702000801389" + } + ], + "paging":{ + "total":"1000", + "from":0, + "to":0, + "countBySubaccount":"0", + "next":[ + + ] + } } ``` @@ -5110,23 +5851,33 @@ console.log(fundingRates) > Response Example: ``` python -funding_rates { - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - rate: "0.000004" - timestamp: 1675717201465 -} -funding_rates { - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - rate: "0.000004" - timestamp: 1675713600164 -} -funding_rates { - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - rate: "0.000004" - timestamp: 1675710001202 -} -paging { - total: 5206 +{ + "fundingRates":[ + { + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "rate":"0.000004", + "timestamp":"1702000801389" + }, + { + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "rate":"0.000004", + "timestamp":"1701997200816" + }, + { + "marketId":"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6", + "rate":"0.000004", + "timestamp":"1701993600737" + } + ], + "paging":{ + "total":"5571", + "from":0, + "to":0, + "countBySubaccount":"0", + "next":[ + + ] + } } ``` @@ -5251,22 +6002,33 @@ console.log(binaryOptionsMarket) > Response Example: ``` python -market { - market_id: "0x175513943b8677368d138e57bcd6bef53170a0da192e7eaa8c2cd4509b54f8db" - market_status: "active" - ticker: "SSS-ZHABIB-TKO-05/30/2023" - oracle_symbol: "SSS-ZHABIB-TKO-05/30/2023" - oracle_provider: "Injective" - oracle_type: "provider" - oracle_scale_factor: 6 - expiration_timestamp: 1680730982 - settlement_timestamp: 1690730982 - quote_denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - maker_fee_rate: "0.0005" - taker_fee_rate: "0.001" - service_provider_fee: "0.4" - min_price_tick_size: "0.000000000000001" - min_quantity_tick_size: "0.01" +{ + "market": { + "marketId": "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "marketStatus": "active", + "ticker": "INJ/USDT BO", + "oracleSymbol": "inj", + "oracleProvider": "BANDIBC", + "oracleType": "provider", + "oracleScaleFactor": 6, + "expirationTimestamp": "2343242423", + "settlementTimestamp": "2342342323", + "quoteDenom": "USDT", + "quoteTokenMeta": { + "name": "Tether", + "address": '0xdAC17F958D2ee523a2206206994597C13D831ec7', + "symbol": "USDT", + "logo": "https://static.alchemyapi.io/images/assets/7278.png", + "decimals": 18; + "updatedAt": "1650978921846" + }, + "makerFeeRate": "0.001", + "takerFeeRate": "0.002", + "serviceProviderFee": "0.4", + "minPriceTickSize": "0.000000000000001", + "minQuantityTickSize": "1000000000000000", + "settlementPrice": "1" + } } ``` @@ -5406,42 +6168,40 @@ console.log(binaryOptionsMarket) > Response Example: ``` python -markets { - market_id: "0x5256e9d870dde51eaeb4078b8d01a155ec9ef508f9adca7751634f82c0d2f23d" - market_status: "active" - ticker: "BBB-KHABIB-TKO-05/30/2023" - oracle_symbol: "BBB-KHABIB-TKO-05/30/2023" - oracle_provider: "Injective" - oracle_type: "provider" - oracle_scale_factor: 6 - expiration_timestamp: 1680730982 - settlement_timestamp: 1690730982 - quote_denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - maker_fee_rate: "0.0005" - taker_fee_rate: "0.001" - service_provider_fee: "0.4" - min_price_tick_size: "0.01" - min_quantity_tick_size: "0.01" -} -markets { - market_id: "0xc48c9b65433ca868072eb01acdfe96b5931cbdf26b0dce92a42e817f52bd3f64" - market_status: "active" - ticker: "CCC-KHABIB-TKO-05/30/2023" - oracle_symbol: "CCC-KHABIB-TKO-05/30/2023" - oracle_provider: "Injective" - oracle_type: "provider" - oracle_scale_factor: 6 - expiration_timestamp: 1680730982 - settlement_timestamp: 1690730982 - quote_denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - maker_fee_rate: "0.0005" - taker_fee_rate: "0.001" - service_provider_fee: "0.4" - min_price_tick_size: "0.000000000000001" - min_quantity_tick_size: "0.01" -} -paging { - total: 12 +{ + "markets":[ + { + "marketId":"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "marketStatus":"active", + "ticker":"INJ/USDT BO", + "oracleSymbol":"inj", + "oracleProvider":"BANDIBC", + "oracleType":"provider", + "oracleScaleFactor":6, + "expirationTimestamp":"2343242423", + "settlementTimestamp":"2342342323", + "quoteDenom":"USDT", + "quoteTokenMeta":{ + "name":"Tether", + "address":"0xdAC17F958D2ee523a2206206994597C13D831ec7", + "symbol":"USDT", + "logo":"https://static.alchemyapi.io/images/assets/7278.png", + "decimals":18;"updatedAt":"1650978921846" + }, + "makerFeeRate":"0.001", + "takerFeeRate":"0.002", + "serviceProviderFee":"0.4", + "minPriceTickSize":"0.000000000000001", + "minQuantityTickSize":"1000000000000000", + "settlementPrice":"1" + } + ], + "paging":{ + "total":"5" + "from":"1" + "to":"3" + "countBySubaccount":"4" + } } ``` diff --git a/source/includes/_explorerrpc.md b/source/includes/_explorerrpc.md index 7786232c..ec8723ac 100644 --- a/source/includes/_explorerrpc.md +++ b/source/includes/_explorerrpc.md @@ -101,32 +101,95 @@ import { ExchangeGrpcClient } from "@injectivelabs/sdk-ts/dist/client/exchange/E > Response Example: ``` python -s: "ok" -data { - block_number: 5024371 - block_timestamp: "2022-11-14 13:16:18.946 +0000 UTC" - hash: "0x0f3ebec1882e1eeac5b7bdd836e976250f1cd072b79485877ceaccb92acddf52" - data: "\n\204\001\n Response Example: ``` python -paging { - total: 8979 - from: 8978 - to: 8979 -} -data { - block_number: 8342050 - block_timestamp: "2023-02-19 09:08:29.469 +0000 UTC" - hash: "0xf2b2140fe7162616c332fc8b2e630fd401f918788a512eab36ded6d8901dfcfd" - data: "\n\036\n\034/cosmos.bank.v1beta1.MsgSend\n\036\n\034/cosmos.bank.v1beta1.MsgSend\n\036\n\034/cosmos.bank.v1beta1.MsgSend\n\036\n\034/cosmos.bank.v1beta1.MsgSend\n\036\n\034/cosmos.bank.v1beta1.MsgSend\n\036\n\034/cosmos.bank.v1beta1.MsgSend\n\036\n\034/cosmos.bank.v1beta1.MsgSend\n\036\n\034/cosmos.bank.v1beta1.MsgSend" - gas_wanted: 400000 - gas_used: 272532 - gas_fee { - amount { - denom: "inj" - amount: "200000000000000" - } - gas_limit: 400000 - payer: "inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex" - } - tx_type: "injective-web3" - messages: "[{\"type\":\"/cosmos.bank.v1beta1.MsgSend\",\"value\":{\"amount\":[{\"amount\":\"10000000000000000000\",\"denom\":\"inj\"}],\"from_address\":\"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex\",\"to_address\":\"inj14jk6sp8s4turp5jmdn27yrr327emdh06wdrfzv\"}},{\"type\":\"/cosmos.bank.v1beta1.MsgSend\",\"value\":{\"amount\":[{\"amount\":\"10000000000\",\"denom\":\"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5\"}],\"from_address\":\"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex\",\"to_address\":\"inj14jk6sp8s4turp5jmdn27yrr327emdh06wdrfzv\"}},{\"type\":\"/cosmos.bank.v1beta1.MsgSend\",\"value\":{\"amount\":[{\"amount\":\"10000000000\",\"denom\":\"factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/usdc\"}],\"from_address\":\"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex\",\"to_address\":\"inj14jk6sp8s4turp5jmdn27yrr327emdh06wdrfzv\"}},{\"type\":\"/cosmos.bank.v1beta1.MsgSend\",\"value\":{\"amount\":[{\"amount\":\"10000000000000000000000\",\"denom\":\"peggy0x44C21afAaF20c270EBbF5914Cfc3b5022173FEB7\"}],\"from_address\":\"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex\",\"to_address\":\"inj14jk6sp8s4turp5jmdn27yrr327emdh06wdrfzv\"}},{\"type\":\"/cosmos.bank.v1beta1.MsgSend\",\"value\":{\"amount\":[{\"amount\":\"10000000000\",\"denom\":\"factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/aave\"}],\"from_address\":\"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex\",\"to_address\":\"inj14jk6sp8s4turp5jmdn27yrr327emdh06wdrfzv\"}},{\"type\":\"/cosmos.bank.v1beta1.MsgSend\",\"value\":{\"amount\":[{\"amount\":\"10000000000\",\"denom\":\"factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/crv\"}],\"from_address\":\"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex\",\"to_address\":\"inj14jk6sp8s4turp5jmdn27yrr327emdh06wdrfzv\"}},{\"type\":\"/cosmos.bank.v1beta1.MsgSend\",\"value\":{\"amount\":[{\"amount\":\"10000000000\",\"denom\":\"factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/cvx\"}],\"from_address\":\"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex\",\"to_address\":\"inj14jk6sp8s4turp5jmdn27yrr327emdh06wdrfzv\"}},{\"type\":\"/cosmos.bank.v1beta1.MsgSend\",\"value\":{\"amount\":[{\"amount\":\"10000000000\",\"denom\":\"factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/shib\"}],\"from_address\":\"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex\",\"to_address\":\"inj14jk6sp8s4turp5jmdn27yrr327emdh06wdrfzv\"}}]" - signatures { - pubkey: "injvalcons1phd706jqzd9wznkk5hgsfkrc8jqxv0kmu8f05r" - address: "inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex" - sequence: 8941 - signature: "n1RpdAlxuULogL7NxWsGMMXE2ONnIZny9G+Cv5OIc3YabHBPCjqHdNdmuzAYIcHEOqznU70GGlPTS3dfiXPqDhw=" - } - tx_number: 8979 - block_unix_timestamp: 1676797709469 +{ + "paging":{ + "total":"5000", + "from":221428, + "to":221429, + "countBySubaccount":"0", + "next":[ + + ] + }, + "data":[ + { + "blockNumber":"18138926", + "blockTimestamp":"2023-11-07 23:19:55.371 +0000 UTC", + "hash":"0x3790ade2bea6c8605851ec89fa968adf2a2037a5ecac11ca95e99260508a3b7e", + "data":"EiYKJC9jb3Ntb3MuYmFuay52MWJldGExLk1zZ1NlbmRSZXNwb25zZQ==", + "gasWanted":"400000", + "gasUsed":"93696", + "gasFee":{ + "amount":[ + { + "denom":"inj", + "amount":"200000000000000" + } + ], + "gasLimit":"400000", + "payer":"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex", + "granter":"" + }, + "txType":"injective-web3", + "messages":"W3sidHlwZSI6Ii9jb3Ntb3MuYmFuay52MWJldGExLk1zZ1NlbmQiLCJ2YWx1ZSI6eyJmcm9tX2FkZHJlc3MiOiJpbmoxcGhkNzA2anF6ZDl3em5razVoZ3Nma3JjOGpxeHYwa21sajBrZXgiLCJ0b19hZGRyZXNzIjoiaW5qMWQ2cXg4M25oeDNhM2d4N2U2NTR4NHN1OGh1cjVzODN1ODRoMnhjIiwiYW1vdW50IjpbeyJkZW5vbSI6ImZhY3RvcnkvaW5qMTd2eXRkd3FjenF6NzJqNjVzYXVrcGxya3RkNGd5Zm1lNWFnZjZjL3dldGgiLCJhbW91bnQiOiIxMDAwMDAwMDAwMDAwMDAwMDAifV19fV0=", + "signatures":[ + { + "pubkey":"02c33c539e2aea9f97137e8168f6e22f57b829876823fa04b878a2b7c2010465d9", + "address":"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex", + "sequence":"223460", + "signature":"gFXPJ5QENzq9SUHshE8g++aRLIlRCRVcOsYq+EOr3T4QgAAs5bVHf8NhugBjJP9B+AfQjQNNneHXPF9dEp4Uehs=" + } + ], + "txNumber":"221429", + "blockUnixTimestamp":"1699399195371", + "logs":"W3sibXNnX2luZGV4IjowLCJldmVudHMiOlt7InR5cGUiOiJtZXNzYWdlIiwiYXR0cmlidXRlcyI6W3sia2V5IjoiYWN0aW9uIiwidmFsdWUiOiIvY29zbW9zLmJhbmsudjFiZXRhMS5Nc2dTZW5kIn0seyJrZXkiOiJzZW5kZXIiLCJ2YWx1ZSI6ImluajFwaGQ3MDZqcXpkOXd6bmtrNWhnc2ZrcmM4anF4djBrbWxqMGtleCJ9LHsia2V5IjoibW9kdWxlIiwidmFsdWUiOiJiYW5rIn1dfSx7InR5cGUiOiJjb2luX3NwZW50IiwiYXR0cmlidXRlcyI6W3sia2V5Ijoic3BlbmRlciIsInZhbHVlIjoiaW5qMXBoZDcwNmpxemQ5d3pua2s1aGdzZmtyYzhqcXh2MGttbGowa2V4In0seyJrZXkiOiJhbW91bnQiLCJ2YWx1ZSI6IjEwMDAwMDAwMDAwMDAwMDAwMGZhY3RvcnkvaW5qMTd2eXRkd3FjenF6NzJqNjVzYXVrcGxya3RkNGd5Zm1lNWFnZjZjL3dldGgifV19LHsidHlwZSI6ImNvaW5fcmVjZWl2ZWQiLCJhdHRyaWJ1dGVzIjpbeyJrZXkiOiJyZWNlaXZlciIsInZhbHVlIjoiaW5qMWQ2cXg4M25oeDNhM2d4N2U2NTR4NHN1OGh1cjVzODN1ODRoMnhjIn0seyJrZXkiOiJhbW91bnQiLCJ2YWx1ZSI6IjEwMDAwMDAwMDAwMDAwMDAwMGZhY3RvcnkvaW5qMTd2eXRkd3FjenF6NzJqNjVzYXVrcGxya3RkNGd5Zm1lNWFnZjZjL3dldGgifV19LHsidHlwZSI6InRyYW5zZmVyIiwiYXR0cmlidXRlcyI6W3sia2V5IjoicmVjaXBpZW50IiwidmFsdWUiOiJpbmoxZDZxeDgzbmh4M2EzZ3g3ZTY1NHg0c3U4aHVyNXM4M3U4NGgyeGMifSx7ImtleSI6InNlbmRlciIsInZhbHVlIjoiaW5qMXBoZDcwNmpxemQ5d3pua2s1aGdzZmtyYzhqcXh2MGttbGowa2V4In0seyJrZXkiOiJhbW91bnQiLCJ2YWx1ZSI6IjEwMDAwMDAwMDAwMDAwMDAwMGZhY3RvcnkvaW5qMTd2eXRkd3FjenF6NzJqNjVzYXVrcGxya3RkNGd5Zm1lNWFnZjZjL3dldGgifV19LHsidHlwZSI6Im1lc3NhZ2UiLCJhdHRyaWJ1dGVzIjpbeyJrZXkiOiJzZW5kZXIiLCJ2YWx1ZSI6ImluajFwaGQ3MDZqcXpkOXd6bmtrNWhnc2ZrcmM4anF4djBrbWxqMGtleCJ9XX1dfV0=", + "id":"", + "code":0, + "info":"", + "codespace":"", + "events":[ + + ], + "memo":"", + "errorLog":"", + "claimIds":[ + + ] + }, + { + "blockNumber":"18138918", + "blockTimestamp":"2023-11-07 23:19:38.275 +0000 UTC", + "hash":"0xd1f313b090b8698223086c081f71d9590716b83390ae18bc7e6b84b9eb7c7500", + "data":"EiYKJC9jb3Ntb3MuYmFuay52MWJldGExLk1zZ1NlbmRSZXNwb25zZQ==", + "gasWanted":"400000", + "gasUsed":"93775", + "gasFee":{ + "amount":[ + { + "denom":"inj", + "amount":"200000000000000" + } + ], + "gasLimit":"400000", + "payer":"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex", + "granter":"" + }, + "txType":"injective-web3", + "messages":"W3sidHlwZSI6Ii9jb3Ntb3MuYmFuay52MWJldGExLk1zZ1NlbmQiLCJ2YWx1ZSI6eyJmcm9tX2FkZHJlc3MiOiJpbmoxcGhkNzA2anF6ZDl3em5razVoZ3Nma3JjOGpxeHYwa21sajBrZXgiLCJ0b19hZGRyZXNzIjoiaW5qMWQ2cXg4M25oeDNhM2d4N2U2NTR4NHN1OGh1cjVzODN1ODRoMnhjIiwiYW1vdW50IjpbeyJkZW5vbSI6ImZhY3RvcnkvaW5qMTd2eXRkd3FjenF6NzJqNjVzYXVrcGxya3RkNGd5Zm1lNWFnZjZjL2F0b20iLCJhbW91bnQiOiIxMDAwMDAwMDAwMDAwMDAwMDAwIn1dfX1d", + "signatures":[ + { + "pubkey":"02c33c539e2aea9f97137e8168f6e22f57b829876823fa04b878a2b7c2010465d9", + "address":"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex", + "sequence":"223459", + "signature":"3Xunour/wXJksgpgkAXC55UwSbUYYt1jpA2zgsMNbHpGucHhSJad13i+HtCXUQY5APABaKKgRC+KAD9UvlPV0Rs=" + } + ], + "txNumber":"221428", + "blockUnixTimestamp":"1699399178275", + "logs":"W3sibXNnX2luZGV4IjowLCJldmVudHMiOlt7InR5cGUiOiJtZXNzYWdlIiwiYXR0cmlidXRlcyI6W3sia2V5IjoiYWN0aW9uIiwidmFsdWUiOiIvY29zbW9zLmJhbmsudjFiZXRhMS5Nc2dTZW5kIn0seyJrZXkiOiJzZW5kZXIiLCJ2YWx1ZSI6ImluajFwaGQ3MDZqcXpkOXd6bmtrNWhnc2ZrcmM4anF4djBrbWxqMGtleCJ9LHsia2V5IjoibW9kdWxlIiwidmFsdWUiOiJiYW5rIn1dfSx7InR5cGUiOiJjb2luX3NwZW50IiwiYXR0cmlidXRlcyI6W3sia2V5Ijoic3BlbmRlciIsInZhbHVlIjoiaW5qMXBoZDcwNmpxemQ5d3pua2s1aGdzZmtyYzhqcXh2MGttbGowa2V4In0seyJrZXkiOiJhbW91bnQiLCJ2YWx1ZSI6IjEwMDAwMDAwMDAwMDAwMDAwMDBmYWN0b3J5L2luajE3dnl0ZHdxY3pxejcyajY1c2F1a3Bscmt0ZDRneWZtZTVhZ2Y2Yy9hdG9tIn1dfSx7InR5cGUiOiJjb2luX3JlY2VpdmVkIiwiYXR0cmlidXRlcyI6W3sia2V5IjoicmVjZWl2ZXIiLCJ2YWx1ZSI6ImluajFkNnF4ODNuaHgzYTNneDdlNjU0eDRzdThodXI1czgzdTg0aDJ4YyJ9LHsia2V5IjoiYW1vdW50IiwidmFsdWUiOiIxMDAwMDAwMDAwMDAwMDAwMDAwZmFjdG9yeS9pbmoxN3Z5dGR3cWN6cXo3Mmo2NXNhdWtwbHJrdGQ0Z3lmbWU1YWdmNmMvYXRvbSJ9XX0seyJ0eXBlIjoidHJhbnNmZXIiLCJhdHRyaWJ1dGVzIjpbeyJrZXkiOiJyZWNpcGllbnQiLCJ2YWx1ZSI6ImluajFkNnF4ODNuaHgzYTNneDdlNjU0eDRzdThodXI1czgzdTg0aDJ4YyJ9LHsia2V5Ijoic2VuZGVyIiwidmFsdWUiOiJpbmoxcGhkNzA2anF6ZDl3em5razVoZ3Nma3JjOGpxeHYwa21sajBrZXgifSx7ImtleSI6ImFtb3VudCIsInZhbHVlIjoiMTAwMDAwMDAwMDAwMDAwMDAwMGZhY3RvcnkvaW5qMTd2eXRkd3FjenF6NzJqNjVzYXVrcGxya3RkNGd5Zm1lNWFnZjZjL2F0b20ifV19LHsidHlwZSI6Im1lc3NhZ2UiLCJhdHRyaWJ1dGVzIjpbeyJrZXkiOiJzZW5kZXIiLCJ2YWx1ZSI6ImluajFwaGQ3MDZqcXpkOXd6bmtrNWhnc2ZrcmM4anF4djBrbWxqMGtleCJ9XX1dfV0=", + "id":"", + "code":0, + "info":"", + "codespace":"", + "events":[ + + ], + "memo":"", + "errorLog":"", + "claimIds":[ + + ] + } + ] } -data { - block_number: 8341799 - block_timestamp: "2023-02-19 08:58:47.271 +0000 UTC" - hash: "0xc2b2f05a66a851cb176503360ef24fd5927116dc2c33e43532865caa7d141627" - data: "\n\036\n\034/cosmos.bank.v1beta1.MsgSend\n\036\n\034/cosmos.bank.v1beta1.MsgSend\n\036\n\034/cosmos.bank.v1beta1.MsgSend\n\036\n\034/cosmos.bank.v1beta1.MsgSend\n\036\n\034/cosmos.bank.v1beta1.MsgSend\n\036\n\034/cosmos.bank.v1beta1.MsgSend\n\036\n\034/cosmos.bank.v1beta1.MsgSend\n\036\n\034/cosmos.bank.v1beta1.MsgSend" - gas_wanted: 400000 - gas_used: 272532 - gas_fee { - amount { - denom: "inj" - amount: "200000000000000" - } - gas_limit: 400000 - payer: "inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex" - } - tx_type: "injective-web3" - messages: "[{\"type\":\"/cosmos.bank.v1beta1.MsgSend\",\"value\":{\"amount\":[{\"amount\":\"10000000000000000000\",\"denom\":\"inj\"}],\"from_address\":\"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex\",\"to_address\":\"inj1dva86cg4eqjypujethrmjdltau8eqgnsuq5eyn\"}},{\"type\":\"/cosmos.bank.v1beta1.MsgSend\",\"value\":{\"amount\":[{\"amount\":\"10000000000\",\"denom\":\"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5\"}],\"from_address\":\"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex\",\"to_address\":\"inj1dva86cg4eqjypujethrmjdltau8eqgnsuq5eyn\"}},{\"type\":\"/cosmos.bank.v1beta1.MsgSend\",\"value\":{\"amount\":[{\"amount\":\"10000000000\",\"denom\":\"factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/usdc\"}],\"from_address\":\"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex\",\"to_address\":\"inj1dva86cg4eqjypujethrmjdltau8eqgnsuq5eyn\"}},{\"type\":\"/cosmos.bank.v1beta1.MsgSend\",\"value\":{\"amount\":[{\"amount\":\"10000000000000000000000\",\"denom\":\"peggy0x44C21afAaF20c270EBbF5914Cfc3b5022173FEB7\"}],\"from_address\":\"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex\",\"to_address\":\"inj1dva86cg4eqjypujethrmjdltau8eqgnsuq5eyn\"}},{\"type\":\"/cosmos.bank.v1beta1.MsgSend\",\"value\":{\"amount\":[{\"amount\":\"10000000000\",\"denom\":\"factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/aave\"}],\"from_address\":\"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex\",\"to_address\":\"inj1dva86cg4eqjypujethrmjdltau8eqgnsuq5eyn\"}},{\"type\":\"/cosmos.bank.v1beta1.MsgSend\",\"value\":{\"amount\":[{\"amount\":\"10000000000\",\"denom\":\"factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/crv\"}],\"from_address\":\"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex\",\"to_address\":\"inj1dva86cg4eqjypujethrmjdltau8eqgnsuq5eyn\"}},{\"type\":\"/cosmos.bank.v1beta1.MsgSend\",\"value\":{\"amount\":[{\"amount\":\"10000000000\",\"denom\":\"factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/cvx\"}],\"from_address\":\"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex\",\"to_address\":\"inj1dva86cg4eqjypujethrmjdltau8eqgnsuq5eyn\"}},{\"type\":\"/cosmos.bank.v1beta1.MsgSend\",\"value\":{\"amount\":[{\"amount\":\"10000000000\",\"denom\":\"factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/shib\"}],\"from_address\":\"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex\",\"to_address\":\"inj1dva86cg4eqjypujethrmjdltau8eqgnsuq5eyn\"}}]" - signatures { - pubkey: "injvalcons1phd706jqzd9wznkk5hgsfkrc8jqxv0kmu8f05r" - address: "inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex" - sequence: 8940 - signature: "djY9QipW+m3tJdV8Tb/LIL4XTvy4Ev9YFLVkQy980mtuyQURyHhRaiz3GQrAAHjG54FqB8IaftIoPFaoj01qNBs=" - } - tx_number: 8978 - block_unix_timestamp: 1676797127271 + +[ + { + "type":"/cosmos.bank.v1beta1.MsgSend", + "value":{ + "fromAddress":"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex", + "toAddress":"inj1d6qx83nhx3a3gx7e654x4su8hur5s83u84h2xc", + "amount":[ + { + "denom":"factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/weth", + "amount":"100000000000000000" + } + ] + } + } +] + +{ + "type":"/cosmos.bank.v1beta1.MsgSend", + "value":{ + "fromAddress":"inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex", + "toAddress":"inj1d6qx83nhx3a3gx7e654x4su8hur5s83u84h2xc", + "amount":[ + { + "denom":"factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/weth", + "amount":"100000000000000000" + } + ] + } } ``` @@ -788,26 +925,44 @@ import { ExchangeGrpcClient } from "@injectivelabs/sdk-ts/dist/client/exchange/E > Response Example: ``` python -paging { - total: 8342596 - from: 8342595 - to: 8342596 -} -data { - height: 8342596 - proposer: "injvalcons1xml3ew93xmjtuf5zwpcl9jzznphte30hvdre9a" - moniker: "InjectiveNode2" - block_hash: "0x03c2dfe96211d1184291eaef12d76888c17a6abe5404b04a3905f6094d23416b" - parent_hash: "0x810a9dfa2a4477023570b30ac3a06d50afffe74583e9a12730adfd1334a58167" - timestamp: "2023-02-19 09:29:36.396 +0000 UTC" -} -data { - height: 8342595 - proposer: "injvalcons1xwg7xkmpqp8q804c37sa4dzyfwgnh4a74ll9pz" - moniker: "InjectiveNode0" - block_hash: "0x2a2d48d6280e60c5f1ba68051b5dac78be36ee170c1c67edbc5ecda630c3d6ed" - parent_hash: "0xbd5f131de1dbbb6c020fde8acdef5052c16c87466b73aff5a66de0453bb6a077" - timestamp: "2023-02-19 09:29:34.077 +0000 UTC" +{ + "paging":{ + "total":"19388338", + "from":19388337, + "to":19388338, + "countBySubaccount":"0", + "next":[ + + ] + }, + "data":[ + { + "height":"19388338", + "proposer":"injvalcons1xml3ew93xmjtuf5zwpcl9jzznphte30hvdre9a", + "moniker":"InjectiveNode2", + "blockHash":"0x349ba348107a78e27a21aa86f7b6a7eab3cda33067872234eef5e6967fa0964c", + "parentHash":"0x3cdbdc7eee0767651785b5ac978af2fe2162caab8596da651c3c6403284902d7", + "timestamp":"2023-12-08 12:35:08.059 +0000 UTC", + "numPreCommits":"0", + "numTxs":"0", + "txs":[ + + ] + }, + { + "height":"19388337", + "proposer":"injvalcons1e0rj6fuy9yn5fwm9x4vw69xyuv7kzjm8rvw5r3", + "moniker":"InjectiveNode3", + "blockHash":"0x275aaa7206b6272b50a7d697d2ed432a2ab51aca3bcf3a0da3009521a29b1e07", + "parentHash":"0x44b8faece543cba46e1391e918b4f397e99461092c178149185275fff30d40bc", + "numTxs":"1", + "timestamp":"2023-12-08 12:35:06.749 +0000 UTC", + "numPreCommits":"0", + "txs":[ + + ] + } + ] } ``` @@ -986,29 +1141,54 @@ import { ExchangeGrpcClient } from "@injectivelabs/sdk-ts/dist/client/exchange/E > Response Example: ``` python -s: "ok" -data { - height: 5825046 - proposer: "injvalcons1xml3ew93xmjtuf5zwpcl9jzznphte30hvdre9a" - moniker: "InjectiveNode2" - block_hash: "0x5982527aa7bc62d663256d505ab396e699954e46ada71a11de2a75f6e514d073" - parent_hash: "0x439caaef7ed0c6d9c2bdd7ffcd8c7303a4eb6a7c33d7db189f85f9b3a496fbc6" - num_txs: 2 - txs { - block_number: 5825046 - block_timestamp: "2022-12-11 22:06:49.182 +0000 UTC" - hash: "0xe46713fbedc907278b6bd22165946d8673169c1a0360383e5e31abf219290c6a" - messages: "null" - tx_number: 1294976 - } - txs { - block_number: 5825046 - block_timestamp: "2022-12-11 22:06:49.182 +0000 UTC" - hash: "0xbe8c8ca9a41196adf59b88fe9efd78e7532e04169152e779be3dc14ba7c360d9" - messages: "null" - tx_number: 1294975 - } - timestamp: "2022-12-11 22:06:49.182 +0000 UTC" +{ + "s":"ok", + "data":{ + "height":"5825046", + "proposer":"injvalcons1xml3ew93xmjtuf5zwpcl9jzznphte30hvdre9a", + "moniker":"InjectiveNode2", + "blockHash":"0x5982527aa7bc62d663256d505ab396e699954e46ada71a11de2a75f6e514d073", + "parentHash":"0x439caaef7ed0c6d9c2bdd7ffcd8c7303a4eb6a7c33d7db189f85f9b3a496fbc6", + "numTxs":"2", + "txs":[ + { + "blockNumber":"5825046", + "blockTimestamp":"2022-12-11 22:06:49.182 +0000 UTC", + "hash":"0xbe8c8ca9a41196adf59b88fe9efd78e7532e04169152e779be3dc14ba7c360d9", + "messages":"bnVsbA==", + "txNumber":"994979", + "txMsgTypes":"WyIvaW5qZWN0aXZlLmV4Y2hhbmdlLnYxYmV0YTEuTXNnQ3JlYXRlQmluYXJ5T3B0aW9uc0xpbWl0T3JkZXIiXQ==", + "id":"", + "codespace":"", + "errorLog":"", + "code":0, + "logs":"", + "claimIds":[ + + ] + }, + { + "blockNumber":"5825046", + "blockTimestamp":"2022-12-11 22:06:49.182 +0000 UTC", + "hash":"0xe46713fbedc907278b6bd22165946d8673169c1a0360383e5e31abf219290c6a", + "messages":"bnVsbA==", + "txNumber":"994978", + "txMsgTypes":"WyIvaWJjLmNvcmUuY2xpZW50LnYxLk1zZ1VwZGF0ZUNsaWVudCIsIi9pYmMuY29yZS5jaGFubmVsLnYxLk1zZ1JlY3ZQYWNrZXQiXQ==", + "id":"", + "codespace":"", + "errorLog":"", + "code":0, + "logs":"", + "claimIds":[ + + ] + } + ], + "timestamp":"2022-12-11 22:06:49.182 +0000 UTC", + "numPreCommits":"0", + "totalTxs":"0" + }, + "errmsg":"" } ``` @@ -1174,24 +1354,51 @@ import { ExchangeGrpcClient } from "@injectivelabs/sdk-ts/dist/client/exchange/E > Response Example: ``` python -paging { - total: 1946523 - from: 1946522 - to: 1946523 -} -data { - block_number: 8343107 - block_timestamp: "2023-02-19 09:49:22.369 +0000 UTC" - hash: "0xa55865da99b4113c5ee6ed4dae89433db381c0d84040c684784e7241538e8872" - messages: "[{\"type\":\"/injective.exchange.v1beta1.MsgCreateBinaryOptionsMarketOrder\",\"value\":{\"order\":{\"margin\":\"20400.000000000000000000\",\"market_id\":\"0x2deca454199c275d3e8363f12f563edcc5fefe6bf0b73499eefc229f69053208\",\"order_info\":{\"fee_recipient\":\"inj1ftfn3shsk38l62eca65kxmdqs4gk70klkkrmrq\",\"price\":\"20000.000000000000000000\",\"quantity\":\"1.000000000000000000\",\"subaccount_id\":\"0x4ad338c2f0b44ffd2b38eea9636da085516f3edf000000000000000000000000\"},\"order_type\":\"BUY\",\"trigger_price\":\"0.000000000000000000\"},\"sender\":\"inj1ftfn3shsk38l62eca65kxmdqs4gk70klkkrmrq\"}}]" - tx_number: 1946523 +{ + "paging":{ + "total":"17748338", + "from":17748337, + "to":17748338, + "countBySubaccount":"0", + "next":[ + + ] + }, + "data":[ + { + "blockNumber":"19388410", + "blockTimestamp":"2023-12-08 12:37:42.632 +0000 UTC", + "hash":"0xe9e2bd81acb24a6d04ab3eb50e5188858a63b8ec05b694c8731b2be8dc34b2d0", + "messages":"W3sidHlwZSI6Ii9jb3Ntd2FzbS53YXNtLnYxLk1zZ0V4ZWN1dGVDb250cmFjdCIsInZhbHVlIjp7InNlbmRlciI6ImluajFmdXc4OTMyNmQ0NzlrbjR2aGd6dnRhYWY3bTJoeDltZ25nZnFhMyIsImNvbnRyYWN0IjoiaW5qMTNnOWhwbnRjdHpnaGU5Mjkzc2xlMjhxNGU0ZTVtMGdzM2hwcDBoIiwibXNnIjp7InBvc3RfZGF0YSI6eyJkYXRhIjoiQ3RFREN2MEJDZ0lJQ3hETjhTd1lscHpNcXdZaUlPMFUvUTdFSFF1VEVUSHoxcmhtK0g3MUdJdkhsTXRwRUhOVlZQTDZHbUpHS2lCdDlWcmszekdtdGI0UVY2Z3hiVmlvOUJlT3VzenRmWUhtSUlOYzRxbTFyeklnQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQTZJQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQVFpQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUZJVW44bHVMWERzaHVYd2FBcm8wcjllYUNocCtRSmFJQThyemk3UXFtRng1eW8rR2tOKzk3RjIvRUZZNEVRVGVGQjdYSTFKWTg0TFlndHZjSFJwWHpFM016Z3RNUkpDQ2tBVWNraTd4K2dBMUlyNlpINnNWTWRDSWVndU9Cdm5ONVFoZVpYbU9FTWhyZG54eHl6bXpLbks0cEVuRUFFSEgvMTVnZE1HQXRIZ3BiV0N3VGtYSG5vT0dvb0JDa01LRkovSmJpMXc3SWJsOEdnSzZOSy9YbWdvYWZrQ0VpSUtJTlprU09wWUtNbldoNytFamlQWDJ5eG52d1VIRVlrdXROSjV4bU5qTmRyVEdJQ0FtcWJxcitNQkVrTUtGSi9KYmkxdzdJYmw4R2dLNk5LL1htZ29hZmtDRWlJS0lOWmtTT3BZS01uV2g3K0VqaVBYMnl4bnZ3VUhFWWt1dE5KNXhtTmpOZHJUR0lDQW1xYnFyK01CRWdBPSJ9fSwiZnVuZHMiOltdfX1d", + "txNumber":"17748338", + "txMsgTypes":"WyIvY29zbXdhc20ud2FzbS52MS5Nc2dFeGVjdXRlQ29udHJhY3QiXQ==", + "logs":"W3sibXNnX2luZGV4IjowLCJldmVudHMiOlt7InR5cGUiOiJtZXNzYWdlIiwiYXR0cmlidXRlcyI6W3sia2V5IjoiYWN0aW9uIiwidmFsdWUiOiIvY29zbXdhc20ud2FzbS52MS5Nc2dFeGVjdXRlQ29udHJhY3QifSx7ImtleSI6InNlbmRlciIsInZhbHVlIjoiaW5qMWZ1dzg5MzI2ZDQ3OWtuNHZoZ3p2dGFhZjdtMmh4OW1nbmdmcWEzIn0seyJrZXkiOiJtb2R1bGUiLCJ2YWx1ZSI6Indhc20ifV19LHsidHlwZSI6ImV4ZWN1dGUiLCJhdHRyaWJ1dGVzIjpbeyJrZXkiOiJfY29udHJhY3RfYWRkcmVzcyIsInZhbHVlIjoiaW5qMTNnOWhwbnRjdHpnaGU5Mjkzc2xlMjhxNGU0ZTVtMGdzM2hwcDBoIn1dfSx7InR5cGUiOiJ3YXNtIiwiYXR0cmlidXRlcyI6W3sia2V5IjoiX2NvbnRyYWN0X2FkZHJlc3MiLCJ2YWx1ZSI6ImluajEzZzlocG50Y3R6Z2hlOTI5M3NsZTI4cTRlNGU1bTBnczNocHAwaCJ9LHsia2V5IjoibWV0aG9kIiwidmFsdWUiOiJwb3N0ZGF0YSJ9XX1dfV0=", + "id":"", + "codespace":"", + "errorLog":"", + "code":0, + "claimIds":[ + + ] + }, + { + "blockNumber":"19388408", + "blockTimestamp":"2023-12-08 12:37:38.713 +0000 UTC", + "hash":"0xd9197814915db8cfcc38743d1680764530da238304899723f5b37b49500304d3", + "messages":"W3sidHlwZSI6Ii9jb3Ntd2FzbS53YXNtLnYxLk1zZ0V4ZWN1dGVDb250cmFjdCIsInZhbHVlIjp7InNlbmRlciI6ImluajFkZWVqYzY2dmhjcWVuNXFqdTJlZGxjOHdqczN4OTJzaHYza2F0cyIsImNvbnRyYWN0IjoiaW5qMThybGZscDM3MzVoMjVqbWp4OTdkMjJjNzJzeGsyNjBhbWRqeGx1IiwibXNnIjp7InVwZGF0ZV9wcmljZV9mZWVkcyI6eyJkYXRhIjpbIlVFNUJWUUVBQUFBQW9BRUFBQUFBQVFDK3FzR3JqcjdzeXVmS3l3VDN6dllvcXRyVzc3cXZlSFFIbDl3V3hhU3RMRVJaS1liS2Q2UE45clNReW5OU1ZkbGVIdkRJaWh2d2lrYnhCY2o2bkxSb0FXVnpEaEVBQUFBQUFCcmhBZnJ0ckZoUjR5dWJJN1g1UVJxTUs2eEtyajdVM1h1QkhkR25McVNxY1FBQUFBQUNhNVRJQVVGVlYxWUFBQUFBQUFiYjlqUUFBQ2NRNmRhVWViTjRsM25SWmtyZlZVayt6Z0poQ3VrT0FGVUEvbVVQQTJmVXArK1lGYVdUNmhYVFpaUHdaRHFxOEJTYnNFdm1lcmhSM3MwQUFBQUJ0TXJCaHdBQUFBQUFNdFZtLy8vLytBQUFBQUJsY3c0UkFBQUFBR1Z6RGc4QUFBQUJzU2Q5cUFBQUFBQUFPNEpiQ21Gbzh0UGlWbTl5WkFkVUxNUUROZzRVNmV1ZXhHMklqdVlia1VTdlo2ZWhIbStQTlpXNXIxSTZFeHFURGFZNWJTREtpSWYyZHZBRWN6NXAwcEdTTEJzQm0yRHhZZVFKTkRXaTZ5U3VFTXp1MGViL0M4SHR6NjJwbkZDd00vUEFzcVFXM3UxRC9GUDAwcDBMRldKL1FSQjRMQ1pnK09Bb09DM2FTODFBUElqajU0TkpEdm9aMC9vTU5ucTlhdE5qV2dQWUhvaERDNUpZaWtzM3ZCM1MrMzNwK0daM1VVcC8yK3pKTjVCUVBTQTJQbFpCZXpuMEFseG8yM1IvcjQ3bCt4czJ2YnNXajFxa0FGVUFIOEdJWVNNaWtDSVVZU0lMMU9LczBkemZ2SW5JUUpMSlBCaTl4M1ZzRllnQUFBQUFCZllLTndBQUFBQUFBRlloLy8vLytBQUFBQUJsY3c0UkFBQUFBR1Z6RGc4QUFBQUFCZllYY3dBQUFBQUFBR05wQ24wRnd6c1lTem54aEtYc2JhQWhDd2phYTVhTHU4bVhKL2xtQWlJV050d2lnc1BWd09KN0hKb0VZWkpXb0ZxTTVoRVZvdmtDWWF5NG5jMFFqK2N3WkJHWmdGbmlYTGdEVjU3dEZHeE0rWWFMTkE5YWpTV2lLb0sxemVxUjN2TGpLMkIxSVgweHYwQVVTL0FVWURIYmREcDFYRzJyM1dveExzZlV4QVgrMnJ0UEVYN0syWEZkNFlHSUpvc21laXIxSThBZ3owUlp6c2JMZlo1ZHdwWWs1bStrRUVFN0l3SHllYXI0UTlub2orLzI0OVVBZmpuMEFseG8yM1IvcjQ3bCt4czJ2YnNXajFxa0FGVUErY0FYSzZFTitrMFpDSTJVOWI5aDA3Vk5XOWRJT2pJcW1DNFRjKzZPb3hzQUFBUDVhSU9ib1FBQUFBQmF1WVlwLy8vLytBQUFBQUJsY3c0UkFBQUFBR1Z6RGc4QUFBUDBZWjdLWUFBQUFBQlBSM1dlQ2dOdE94cWZPdFZOTXNwdm1NT0NZclB4MnBOSkpxVVJvdVYzalZKejdjNXY3QktTeVNxVWJtOVVUUkFOcHkrc05abnE1NVprUUVuaExTU20wckZIeXNZV0s4Rm13NVN4TFJjQUlUNXRQTnpaam5wWGR1aDJPK20vVmcwdG5RL1kxTXJ4N29sRC9GUDAwcDBMRldKL1FSQjRMQ1pnK09Bb09DM2FTODFBUElqajU0TkpEdm9aMC9vTU5ucTlhdE5qV2dQWUhvaERDNUpZaWtzM3ZCM1MrMzNwK0daM1VVcC8yK3pKTjVCUVBTQTJQbFpCZXpuMEFseG8yM1IvcjQ3bCt4czJ2YnNXajFxa0FGVUFOL1FOS0pnVm5vOHVVcms4dDQ5SHpEZ3BveDVTV3JsMXhKekZ4ZGtYWTNnQUFBQUFCdm5jR0FBQUFBQUFBT0lvLy8vLytBQUFBQUJsY3c0UkFBQUFBR1Z6RGc4QUFBQUFCdkZFWlFBQUFBQUFBUGxKQ21GaEpCK0ZMMlJka3Q0RzVNd1VZNTE4anlMQ0xEMUZTaGNUSnV0V1hSUjEwaEJFVit1N0RkNThUV1FncnlPQXpsMnQyaE1IM1dpbXFNNkZGOVkwbytGblh1K3dCcnE5ZXhWelpIRU1UcTJvM3doZjJ5bVY0aVZhbDhnNzI5MjdONGlRQkl4QnRJVDhuVkRxUERuQ3RJcVVlUEY1alpydTBPM2RZeVpxUjQwT2RGK3VtVkplUnNnZ0FEV0FlaXIxSThBZ3owUlp6c2JMZlo1ZHdwWWs1bStrRUVFN0l3SHllYXI0UTlub2orLzI0OVVBZmpuMEFseG8yM1IvcjQ3bCt4czJ2YnNXajFxa0FGVUFNS0dSV1BXbFRBcmZqN2RXQmljMFB5S2h2SVVyaWRWcjRhek54ZHY1YlE0QUFBQUFBQjcwMkFBQUFBQUFBQUJ6Ly8vLy9RQUFBQUJsY3c0UkFBQUFBR1Z6RGc4QUFBQUFBQjczV0FBQUFBQUFBQUI5Q3ZNTTI2VVlPVlBBRVBnZmMwOU0zYkthcklVdEhqVDhidU5HQms4MTQrQ1VQOGZMTjR3Vkd5dkJETzQzNC9GbnF3MENqNUhTZisrbmdhSTFLUlUvMVZaSnN5MFE2TER0eFpuRnpMK1NqVXlyd3RmV3J1V1ZkQnJBVDFFMDFYdmtnL094QlpKQnRJVDhuVkRxUERuQ3RJcVVlUEY1alpydTBPM2RZeVpxUjQwT2RGK3VtVkplUnNnZ0FEV0FlaXIxSThBZ3owUlp6c2JMZlo1ZHdwWWs1bStrRUVFN0l3SHllYXI0UTlub2orLzI0OVVBZmpuMEFseG8yM1IvcjQ3bCt4czJ2YnNXajFxa0FGVUF3YkVuYWZaak41alVXdC9XSy94d0VVZzVJeTRwU2JBZnM5UDVKOUpnWVZRQUFBQUFBQUdsT3dBQUFBQUFBQUFLLy8vLyt3QUFBQUJsY3c0UkFBQUFBR1Z6RGc4QUFBQUFBQUdsTVFBQUFBQUFBQUFLQ2lnRHd3eUo5TDRjaFNBSzZnRVZsckxkaUVQdmJhQ1owd09WUGpHNEpSeEpwMHBBY1BnbFo3YnVFQXdDd2tvN1JDVUxHRElPQ0k5aWg4ZlA4eTNzcnI0ekp6UkYycmI0MXZlM3pYeU9iRXJNVEZ1UGkvRmhtR3M5Mlh5NEV4eXZleVRrY056Mnc3OHFRMTIrckN6R0F3ejdwTjNNbnJyUVRQR0tGUnVjUU5FekF1WjBOaXVaUjd4dk8xdC9hdE5qV2dQWUhvaERDNUpZaWtzM3ZCM1MrMzNwK0daM1VVcC8yK3pKTjVCUVBTQTJQbFpCZXpuMEFseG8yM1IvcjQ3bCt4czJ2YnNXajFxa0FGVUFNaHVrMWdqNmRicDIxdGM5cW5GYXZMM3JuYm9DSlg4Rm9iV1JlTFNmV1pzQUFBQUFBQ1JIWndBQUFBQUFBQUp4Ly8vLyt3QUFBQUJsY3c0UkFBQUFBR1Z6RGc4QUFBQUFBQ1JTZndBQUFBQUFBQUgwQ3VXM0tTaW95T0dIQ0FCK3Nsc2ZKWldESWVtN0pmNlVueElLd3hRMWkrNzUwQ1lPTFFpbEJ5SnRHR3VqVGllbzlubXo4dVJsSkx1b3hEVm11eFUvMVZaSnN5MFE2TER0eFpuRnpMK1NqVXlyd3RmV3J1V1ZkQnJBVDFFMDFYdmtnL094QlpKQnRJVDhuVkRxUERuQ3RJcVVlUEY1alpydTBPM2RZeVpxUjQwT2RGK3VtVkplUnNnZ0FEV0FlaXIxSThBZ3owUlp6c2JMZlo1ZHdwWWs1bStrRUVFN0l3SHllYXI0UTlub2orLzI0OVVBZmpuMEFseG8yM1IvcjQ3bCt4czJ2YnNXajFxa0FGVUFJS2s0OVV0bzhmTHZHT29ES1BiZEIwZjQ2aEZJYlNLd0llZzZrQXZvbDNZQUFBQUFBQUl6blFBQUFBQUFBQUFJLy8vLy9RQUFBQUJsY3c0UkFBQUFBR1Z6RGc4QUFBQUFBQUl6L1FBQUFBQUFBQUFJQ2hwOEhiS1JRdnRrWUJKdzMxR1lPdjJPTUFURXU4bVhKL2xtQWlJV050d2lnc1BWd09KN0hKb0VZWkpXb0ZxTTVoRVZvdmtDWWF5NG5jMFFqK2N3WkJHWmdGbmlYTGdEVjU3dEZHeE0rWWFMTkE5YWpTV2lLb0sxemVxUjN2TGpLMkIxSVgweHYwQVVTL0FVWURIYmREcDFYRzJyM1dveExzZlV4QVgrMnJ0UEVYN0syWEZkNFlHSUpvc21laXIxSThBZ3owUlp6c2JMZlo1ZHdwWWs1bStrRUVFN0l3SHllYXI0UTlub2orLzI0OVVBZmpuMEFseG8yM1IvcjQ3bCt4czJ2YnNXajFxa0FGVUF2TDNDZFZ2WFNpQmwrZE1vUEN1S3k5aVk1SE85dVFwblpMUGIxR2ZGYnMwQUFBQUFBQUhyUUFBQUFBQUFBQUFLLy8vLyt3QUFBQUJsY3c0UkFBQUFBR1Z6RGc4QUFBQUFBQUhyVFFBQUFBQUFBQUFKQ3BySEprTUViNFk1R1EwQ0R5bktnZkxyODBYNzRXOGM3dG1FWGE3RG43WHk0SjlSeVZiYngyWElBQWRBSzRnTVlCTWNLVTNmZ0VUdEE5L0U1S1kvTWRLVERFNVhvS25ULzdaYkxZUGdxd3F1aEQ4WFNRVEVxZU1JYm9hUWRkblVMTVkzd2hiMnc3OHFRMTIrckN6R0F3ejdwTjNNbnJyUVRQR0tGUnVjUU5FekF1WjBOaXVaUjd4dk8xdC9hdE5qV2dQWUhvaERDNUpZaWtzM3ZCM1MrMzNwK0daM1VVcC8yK3pKTjVCUVBTQTJQbFpCZXpuMEFseG8yM1IvcjQ3bCt4czJ2YnNXajFxa0FGVUF5b0M2YmNNdUNOQnZHcWlHQVI3dEhYZkhlK25yZGh6QkRYSzMwS0w5VjZZQUFBQTNFZDZLc2dBQUFBQUZlOGp5Ly8vLytBQUFBQUJsY3c0UkFBQUFBR1Z6RGc4QUFBQTNBN29GWUFBQUFBQUZjbnJyQ2p3UmZsTzI3N1JXaTkxaXBEMEhIbWFzL3M0WWVEME5YNlo3Qnk3cDVhV1UzOC84ZEFsNVZFTUVsM2djeC96Mjl2ditDL2tjd05zSnlYTVFHY1Z5Z1JvOUdRcXp0cFl6MmxpRVBzcFhOR0F3dkhhekRvVkJIWHhMQ2dBT1VrWTVwUGYvc3QxQURuekVwd0hvYTlVQ29DZGhGbE5TN0d3NVhmR0tGUnVjUU5FekF1WjBOaXVaUjd4dk8xdC9hdE5qV2dQWUhvaERDNUpZaWtzM3ZCM1MrMzNwK0daM1VVcC8yK3pKTjVCUVBTQTJQbFpCZXpuMEFseG8yM1IvcjQ3bCt4czJ2YnNXajFxa0FGVUFZU0p0T2I3cUdkTTA4WHd2Njg0bjRTWkcyRVoxa2s2N0Fybk5ycWFISitNQUFBQUFQUkNMYXdBQUFBQUFDT3I4Ly8vLytBQUFBQUJsY3c0UkFBQUFBR1Z6RGc4QUFBQUFQR01hYmdBQUFBQUFDY0xZQ3I0dEhHVk9sNkh0dnpwVFlTMGNjaTdLTk5FYmxWRXlJU1lMTVpSemxhOEI2VnhOQ3FKbHZYUExZM0p3ckw4RG1NS2czNXJMVk14TWF4TE5EdkZOOHBTK2VzRjZrKy96SVc3WkxKY2l1MzE0N1NpcmpSbm42MHhhRlJYVkZWVVJycWlML1U0ZXlDTXIrWTdvRndFQ3RzS0F6OTdWNzQ4QlB6QnVtd3Fkc2d1Rnl1Q3ZJWldGTzNaVWlEMXp1dE1XYjBpYW9zK2o5SmVLeDhZRTZvQnVFRWlrRUVFN0l3SHllYXI0UTlub2orLzI0OVVBZmpuMEFseG8yM1IvcjQ3bCt4czJ2YnNXajFxa0FGVUFMWk1WcUk4d0dmanZxSTMrbkE4SVEzRXRvTHJJRkVZZUozTS9hNFByVWJNQUFBQUFkT2pNaXdBQUFBQUFKUDRCLy8vLytBQUFBQUJsY3c0UkFBQUFBR1Z6RGc4QUFBQUFjNlN1L0FBQUFBQUFJdXIzQ2hsMVJhT3BEV2k2S1VCbkozS1kwUUJ5WE5hdVlsNXV5YWpsQ0IwNlVxS29YM2h4VUFhbmdmWi83Wk1vWDlvdStEc2x5MW9hWkV3Z1ZqcVAvS3ZVeUh2QzhEcElDVU16aTNxakRab0c0ZjNoclJrQ1NjZmtiWGFybXNpOGZOVi9RUHJYN3U0eHYwQVVTL0FVWURIYmREcDFYRzJyM1dveExzZlV4QVgrMnJ0UEVYN0syWEZkNFlHSUpvc21laXIxSThBZ3owUlp6c2JMZlo1ZHdwWWs1bStrRUVFN0l3SHllYXI0UTlub2orLzI0OVVBZmpuMEFseG8yM1IvcjQ3bCt4czJ2YnNXajFxa0FGVUE3WUx2djYzZ0VJUC9xUFpHWk1ocTg1S0N5ZkNFaDNCbXJuSzJOZWQzR1BBQUFBQUFBQUE4V2dBQUFBQUFBQUJDLy8vLzlnQUFBQUJsY3c0UEFBQUFBR1Z6RGc0QUFBQUFBQUE4RkFBQUFBQUFBQUE2Q2lNOHhBaUtQUzByN2xOQnFGUVdvQUIySHN5cDArTm9vcmxKT3hJZzlMYmJOZEdMNHZUUzNZaTF6TUczOGVjSk1NM05zL1Q3OEkvS1JDajBUc3c1dWlZNlpncDROSmROMnJjSXBxekNsNVZNVkNnYUxBVHVienR3blNReDI5UDdBWU80T2RCbVhtSkF5TWg5YytwT01vWnY0dFo3ZEt3dnB5M2FTODFBUElqajU0TkpEdm9aMC9vTU5ucTlhdE5qV2dQWUhvaERDNUpZaWtzM3ZCM1MrMzNwK0daM1VVcC8yK3pKTjVCUVBTQTJQbFpCZXpuMEFseG8yM1IvcjQ3bCt4czJ2YnNXajFxa0FGVUFRZk5pV1hIS0x0SW1QbmhYUCtYT0krRTlKVmp0UHk1SHF3K0UrNTU2NXlJQUFBQUFCZlhnL3dBQUFBQUFBSFV0Ly8vLytBQUFBQUJsY3c0UkFBQUFBR1Z6RGc4QUFBQUFCZlhsakFBQUFBQUFBR3NYQ2tYVS94MUtZdEczb2VvUzVuQUlOV0tyUlBDc1R0NmVodjcxNXBSS25VZzJTTWNqbEVWdU91aklJUm5nZFpXSjlGVi9FV2hBMjdmaGZrT1pEeTZqQzUxTzlYT3cwTTByc0VlYUtWNzQ0NWFGM3doZjJ5bVY0aVZhbDhnNzI5MjdONGlRQkl4QnRJVDhuVkRxUERuQ3RJcVVlUEY1alpydTBPM2RZeVpxUjQwT2RGK3VtVkplUnNnZ0FEV0FlaXIxSThBZ3owUlp6c2JMZlo1ZHdwWWs1bStrRUVFN0l3SHllYXI0UTlub2orLzI0OVVBZmpuMEFseG8yM1IvcjQ3bCt4czJ2YnNXajFxayJdfX0sImZ1bmRzIjpbeyJkZW5vbSI6ImluaiIsImFtb3VudCI6IjE0In1dfX1d", + "txNumber":"17748337", + "txMsgTypes":"WyIvY29zbXdhc20ud2FzbS52MS5Nc2dFeGVjdXRlQ29udHJhY3QiXQ==", + "logs":"W3sibXNnX2luZGV4IjowLCJldmVudHMiOlt7InR5cGUiOiJtZXNzYWdlIiwiYXR0cmlidXRlcyI6W3sia2V5IjoiYWN0aW9uIiwidmFsdWUiOiIvY29zbXdhc20ud2FzbS52MS5Nc2dFeGVjdXRlQ29udHJhY3QifSx7ImtleSI6InNlbmRlciIsInZhbHVlIjoiaW5qMWRlZWpjNjZ2aGNxZW41cWp1MmVkbGM4d2pzM3g5MnNodjNrYXRzIn0seyJrZXkiOiJtb2R1bGUiLCJ2YWx1ZSI6Indhc20ifV19LHsidHlwZSI6ImNvaW5fc3BlbnQiLCJhdHRyaWJ1dGVzIjpbeyJrZXkiOiJzcGVuZGVyIiwidmFsdWUiOiJpbmoxZGVlamM2NnZoY3FlbjVxanUyZWRsYzh3anMzeDkyc2h2M2thdHMifSx7ImtleSI6ImFtb3VudCIsInZhbHVlIjoiMTRpbmoifV19LHsidHlwZSI6ImNvaW5fcmVjZWl2ZWQiLCJhdHRyaWJ1dGVzIjpbeyJrZXkiOiJyZWNlaXZlciIsInZhbHVlIjoiaW5qMThybGZscDM3MzVoMjVqbWp4OTdkMjJjNzJzeGsyNjBhbWRqeGx1In0seyJrZXkiOiJhbW91bnQiLCJ2YWx1ZSI6IjE0aW5qIn1dfSx7InR5cGUiOiJ0cmFuc2ZlciIsImF0dHJpYnV0ZXMiOlt7ImtleSI6InJlY2lwaWVudCIsInZhbHVlIjoiaW5qMThybGZscDM3MzVoMjVqbWp4OTdkMjJjNzJzeGsyNjBhbWRqeGx1In0seyJrZXkiOiJzZW5kZXIiLCJ2YWx1ZSI6ImluajFkZWVqYzY2dmhjcWVuNXFqdTJlZGxjOHdqczN4OTJzaHYza2F0cyJ9LHsia2V5IjoiYW1vdW50IiwidmFsdWUiOiIxNGluaiJ9XX0seyJ0eXBlIjoiZXhlY3V0ZSIsImF0dHJpYnV0ZXMiOlt7ImtleSI6Il9jb250cmFjdF9hZGRyZXNzIiwidmFsdWUiOiJpbmoxOHJsZmxwMzczNWgyNWptang5N2QyMmM3MnN4azI2MGFtZGp4bHUifV19LHsidHlwZSI6Indhc20iLCJhdHRyaWJ1dGVzIjpbeyJrZXkiOiJfY29udHJhY3RfYWRkcmVzcyIsInZhbHVlIjoiaW5qMThybGZscDM3MzVoMjVqbWp4OTdkMjJjNzJzeGsyNjBhbWRqeGx1In0seyJrZXkiOiJhY3Rpb24iLCJ2YWx1ZSI6InVwZGF0ZV9wcmljZV9mZWVkcyJ9LHsia2V5IjoibnVtX2F0dGVzdGF0aW9ucyIsInZhbHVlIjoiMTQifSx7ImtleSI6Im51bV91cGRhdGVkIiwidmFsdWUiOiIxNCJ9XX0seyJ0eXBlIjoiaW5qZWN0aXZlLm9yYWNsZS52MWJldGExLkV2ZW50U2V0UHl0aFByaWNlcyIsImF0dHJpYnV0ZXMiOlt7ImtleSI6InByaWNlcyIsInZhbHVlIjoiW3tcInByaWNlX2lkXCI6XCIweGZlNjUwZjAzNjdkNGE3ZWY5ODE1YTU5M2VhMTVkMzY1OTNmMDY0M2FhYWYwMTQ5YmIwNGJlNjdhYjg1MWRlY2RcIixcImVtYV9wcmljZVwiOlwiNzIuNjcxMjI2MDAwMDAwMDAwMDAwXCIsXCJlbWFfY29uZlwiOlwiMC4wMzg5OTk5NTAwMDAwMDAwMDBcIixcImNvbmZcIjpcIjAuMDMzMzE0MzAwMDAwMDAwMDAwXCIsXCJwdWJsaXNoX3RpbWVcIjpcIjE3MDIwMzkwNTdcIixcInByaWNlX3N0YXRlXCI6e1wicHJpY2VcIjpcIjczLjI4MTUzOTkxMDAwMDAwMDAwMFwiLFwiY3VtdWxhdGl2ZV9wcmljZVwiOlwiNTk1NjAyMjQ3LjEzNjEzNTY0MDAwMDAwMDAwMFwiLFwidGltZXN0YW1wXCI6XCIxNzAyMDM5MDU4XCJ9fSx7XCJwcmljZV9pZFwiOlwiMHgxZmMxODg2MTIzMjI5MDIyMTQ2MTIyMGJkNGUyYWNkMWRjZGZiYzg5Yzg0MDkyYzkzYzE4YmRjNzc1NmMxNTg4XCIsXCJlbWFfcHJpY2VcIjpcIjEuMDAwMTM5MzkwMDAwMDAwMDAwXCIsXCJlbWFfY29uZlwiOlwiMC4wMDAyNTQ0OTAwMDAwMDAwMDBcIixcImNvbmZcIjpcIjAuMDAwMjIwNDkwMDAwMDAwMDAwXCIsXCJwdWJsaXNoX3RpbWVcIjpcIjE3MDIwMzkwNTdcIixcInByaWNlX3N0YXRlXCI6e1wicHJpY2VcIjpcIjEuMDAwMTA1NTEwMDAwMDAwMDAwXCIsXCJjdW11bGF0aXZlX3ByaWNlXCI6XCIyMzIyNzc5Ni40NzU2MjQ3MzAwMDAwMDAwMDBcIixcInRpbWVzdGFtcFwiOlwiMTcwMjAzOTA1OFwifX0se1wicHJpY2VfaWRcIjpcIjB4ZjljMDE3MmJhMTBkZmE0ZDE5MDg4ZDk0ZjViZjYxZDNiNTRkNWJkNzQ4M2EzMjJhOTgyZTEzNzNlZThlYTMxYlwiLFwiZW1hX3ByaWNlXCI6XCI0MzQ4MS40NDcwMDAwMDAwMDAwMDAwMDBcIixcImVtYV9jb25mXCI6XCIxMy4zMDA4MzIzMDAwMDAwMDAwMDBcIixcImNvbmZcIjpcIjE1LjIyMTA3OTQ1MDAwMDAwMDAwMFwiLFwicHVibGlzaF90aW1lXCI6XCIxNzAyMDM5MDU3XCIsXCJwcmljZV9zdGF0ZVwiOntcInByaWNlXCI6XCI0MzY5Ny4zNTE5NTU1MzAwMDAwMDAwMDBcIixcImN1bXVsYXRpdmVfcHJpY2VcIjpcIjY4MzMwNjY2NjY4NC45NjIwNDczMjAwMDAwMDAwMDBcIixcInRpbWVzdGFtcFwiOlwiMTcwMjAzOTA1OFwifX0se1wicHJpY2VfaWRcIjpcIjB4MzdmNDBkMjg5ODE1OWU4ZjJlNTJiOTNjYjc4ZjQ3Y2MzODI5YTMxZTUyNWFiOTc1YzQ5Y2M1YzVkOTE3NjM3OFwiLFwiZW1hX3ByaWNlXCI6XCIxLjE2NDc0OTgxMDAwMDAwMDAwMFwiLFwiZW1hX2NvbmZcIjpcIjAuMDAwNjM4MTcwMDAwMDAwMDAwXCIsXCJjb25mXCI6XCIwLjAwMDU3ODk2MDAwMDAwMDAwMFwiLFwicHVibGlzaF90aW1lXCI6XCIxNzAyMDM5MDU3XCIsXCJwcmljZV9zdGF0ZVwiOntcInByaWNlXCI6XCIxLjE3MDM4MTA0MDAwMDAwMDAwMFwiLFwiY3VtdWxhdGl2ZV9wcmljZVwiOlwiMjQxNzYzMTkuNDE3NDMwMDgwMDAwMDAwMDAwXCIsXCJ0aW1lc3RhbXBcIjpcIjE3MDIwMzkwNThcIn19LHtcInByaWNlX2lkXCI6XCIweDMwYTE5MTU4ZjVhNTRjMGFkZjhmYjc1NjA2MjczNDNmMjJhMWJjODUyYjg5ZDU2YmUxYWNjZGM1ZGJmOTZkMGVcIixcImVtYV9wcmljZVwiOlwiMjAyOS40MDAwMDAwMDAwMDAwMDAwMDBcIixcImVtYV9jb25mXCI6XCIwLjEyNTAwMDAwMDAwMDAwMDAwMFwiLFwiY29uZlwiOlwiMC4xMTUwMDAwMDAwMDAwMDAwMDBcIixcInB1Ymxpc2hfdGltZVwiOlwiMTcwMjAzOTA1N1wiLFwicHJpY2Vfc3RhdGVcIjp7XCJwcmljZVwiOlwiMjAyOC43NjAwMDAwMDAwMDAwMDAwMDBcIixcImN1bXVsYXRpdmVfcHJpY2VcIjpcIjQzNzQ1MDU5NjM4LjQyMDAwMDAwMDAwMDAwMDAwMFwiLFwidGltZXN0YW1wXCI6XCIxNzAyMDM5MDU4XCJ9fSx7XCJwcmljZV9pZFwiOlwiMHhjMWIxMjc2OWY2NjMzNzk4ZDQ1YWRmZDYyYmZjNzAxMTQ4MzkyMzJlMjk0OWIwMWZiM2QzZjkyN2QyNjA2MTU0XCIsXCJlbWFfcHJpY2VcIjpcIjEuMDc4MjUwMDAwMDAwMDAwMDAwXCIsXCJlbWFfY29uZlwiOlwiMC4wMDAxMDAwMDAwMDAwMDAwMDBcIixcImNvbmZcIjpcIjAuMDAwMTAwMDAwMDAwMDAwMDAwXCIsXCJwdWJsaXNoX3RpbWVcIjpcIjE3MDIwMzkwNTdcIixcInByaWNlX3N0YXRlXCI6e1wicHJpY2VcIjpcIjEuMDc4MzUwMDAwMDAwMDAwMDAwXCIsXCJjdW11bGF0aXZlX3ByaWNlXCI6XCIyNDIzNzczMS4wNzEwMTAwMDAwMDAwMDAwMDBcIixcInRpbWVzdGFtcFwiOlwiMTcwMjAzOTA1OFwifX0se1wicHJpY2VfaWRcIjpcIjB4MzIxYmE0ZDYwOGZhNzViYTc2ZDZkNzNkYWE3MTVhYmNiZGViOWRiYTAyMjU3ZjA1YTFiNTkxNzhiNDlmNTk5YlwiLFwiZW1hX3ByaWNlXCI6XCIyMy44MDQxNTAwMDAwMDAwMDAwMDBcIixcImVtYV9jb25mXCI6XCIwLjAwNTAwMDAwMDAwMDAwMDAwMFwiLFwiY29uZlwiOlwiMC4wMDYyNTAwMDAwMDAwMDAwMDBcIixcInB1Ymxpc2hfdGltZVwiOlwiMTcwMjAzOTA1N1wiLFwicHJpY2Vfc3RhdGVcIjp7XCJwcmljZVwiOlwiMjMuNzc1NzUwMDAwMDAwMDAwMDAwXCIsXCJjdW11bGF0aXZlX3ByaWNlXCI6XCI1MjkwNjUwMTUuNTE0ODEwMDAwMDAwMDAwMDAwXCIsXCJ0aW1lc3RhbXBcIjpcIjE3MDIwMzkwNThcIn19LHtcInByaWNlX2lkXCI6XCIweDIwYTkzOGY1NGI2OGYxZjJlZjE4ZWEwMzI4ZjZkZDA3NDdmOGVhMTE0ODZkMjJiMDIxZTgzYTkwMGJlODk3NzZcIixcImVtYV9wcmljZVwiOlwiMTQ0LjM4MTAwMDAwMDAwMDAwMDAwMFwiLFwiZW1hX2NvbmZcIjpcIjAuMDA4MDAwMDAwMDAwMDAwMDAwXCIsXCJjb25mXCI6XCIwLjAwODAwMDAwMDAwMDAwMDAwMFwiLFwicHVibGlzaF90aW1lXCI6XCIxNzAyMDM5MDU3XCIsXCJwcmljZV9zdGF0ZVwiOntcInByaWNlXCI6XCIxNDQuMjg1MDAwMDAwMDAwMDAwMDAwXCIsXCJjdW11bGF0aXZlX3ByaWNlXCI6XCIzMTQ4MTY5NTYzLjY5MjAwMDAwMDAwMDAwMDAwMFwiLFwidGltZXN0YW1wXCI6XCIxNzAyMDM5MDU4XCJ9fSx7XCJwcmljZV9pZFwiOlwiMHhiY2JkYzI3NTViZDc0YTIwNjVmOWQzMjgzYzJiOGFjYmQ4OThlNDczYmRiOTBhNjc2NGIzZGJkNDY3YzU2ZWNkXCIsXCJlbWFfcHJpY2VcIjpcIjEuMjU3NzMwMDAwMDAwMDAwMDAwXCIsXCJlbWFfY29uZlwiOlwiMC4wMDAwOTAwMDAwMDAwMDAwMDBcIixcImNvbmZcIjpcIjAuMDAwMTAwMDAwMDAwMDAwMDAwXCIsXCJwdWJsaXNoX3RpbWVcIjpcIjE3MDIwMzkwNTdcIixcInByaWNlX3N0YXRlXCI6e1wicHJpY2VcIjpcIjEuMjU3NjAwMDAwMDAwMDAwMDAwXCIsXCJjdW11bGF0aXZlX3ByaWNlXCI6XCIyNzk5MTIyNS43NTQ3MDAwMDAwMDAwMDAwMDBcIixcInRpbWVzdGFtcFwiOlwiMTcwMjAzOTA1OFwifX0se1wicHJpY2VfaWRcIjpcIjB4Y2E4MGJhNmRjMzJlMDhkMDZmMWFhODg2MDExZWVkMWQ3N2M3N2JlOWViNzYxY2MxMGQ3MmI3ZDBhMmZkNTdhNlwiLFwiZW1hX3ByaWNlXCI6XCIyMzYyLjg1NzI0MDAwMDAwMDAwMDAwMFwiLFwiZW1hX2NvbmZcIjpcIjAuOTEzODg2NTEwMDAwMDAwMDAwXCIsXCJjb25mXCI6XCIwLjkxOTk4NDUwMDAwMDAwMDAwMFwiLFwicHVibGlzaF90aW1lXCI6XCIxNzAyMDM5MDU3XCIsXCJwcmljZV9zdGF0ZVwiOntcInByaWNlXCI6XCIyMzY1LjIyOTk4NDUwMDAwMDAwMDAwMFwiLFwiY3VtdWxhdGl2ZV9wcmljZVwiOlwiNDE3OTY4MDExMjEuNzk4MDYyMjEwMDAwMDAwMDAwXCIsXCJ0aW1lc3RhbXBcIjpcIjE3MDIwMzkwNThcIn19LHtcInByaWNlX2lkXCI6XCIweDYxMjI2ZDM5YmVlYTE5ZDMzNGYxN2MyZmViY2UyN2UxMjY0NmQ4NDY3NTkyNGViYjAyYjljZGFlYTY4NzI3ZTNcIixcImVtYV9wcmljZVwiOlwiMTAuMTMxMjc3OTAwMDAwMDAwMDAwXCIsXCJlbWFfY29uZlwiOlwiMC4wMDYzOTcwNDAwMDAwMDAwMDBcIixcImNvbmZcIjpcIjAuMDA1ODQ0NDQwMDAwMDAwMDAwXCIsXCJwdWJsaXNoX3RpbWVcIjpcIjE3MDIwMzkwNTdcIixcInByaWNlX3N0YXRlXCI6e1wicHJpY2VcIjpcIjEwLjI0NDk0NDQzMDAwMDAwMDAwMFwiLFwiY3VtdWxhdGl2ZV9wcmljZVwiOlwiMjEzODk1OTI4Ljc1Nzk5NTcyMDAwMDAwMDAwMFwiLFwidGltZXN0YW1wXCI6XCIxNzAyMDM5MDU4XCJ9fSx7XCJwcmljZV9pZFwiOlwiMHgyZDkzMTVhODhmMzAxOWY4ZWZhODhkZmU5YzBmMDg0MzcxMmRhMGJhYzgxNDQ2MWUyNzczM2Y2YjgzZWI1MWIzXCIsXCJlbWFfcHJpY2VcIjpcIjE5LjQwMTcyNTQwMDAwMDAwMDAwMFwiLFwiZW1hX2NvbmZcIjpcIjAuMDIyODgzNzUwMDAwMDAwMDAwXCIsXCJjb25mXCI6XCIwLjAyNDI0MzIxMDAwMDAwMDAwMFwiLFwicHVibGlzaF90aW1lXCI6XCIxNzAyMDM5MDU3XCIsXCJwcmljZV9zdGF0ZVwiOntcInByaWNlXCI6XCIxOS42MTQxMzc3MTAwMDAwMDAwMDBcIixcImN1bXVsYXRpdmVfcHJpY2VcIjpcIjE5Njk2NjI1Ni4xNTc4MjA0ODAwMDAwMDAwMDBcIixcInRpbWVzdGFtcFwiOlwiMTcwMjAzOTA1OFwifX0se1wicHJpY2VfaWRcIjpcIjB4ZWQ4MmVmYmZhZGUwMTA4M2ZmYThmNjQ2NjRjODZhZjM5MjgyYzlmMDg0ODc3MDY2YWU3MmI2MzVlNzc3MThmMFwiLFwiZW1hX3ByaWNlXCI6XCIwLjAwMDAwMTUzODAwMDAwMDAwMFwiLFwiZW1hX2NvbmZcIjpcIjAuMDAwMDAwMDA1ODAwMDAwMDAwXCIsXCJjb25mXCI6XCIwLjAwMDAwMDAwNjYwMDAwMDAwMFwiLFwicHVibGlzaF90aW1lXCI6XCIxNzAyMDM5MDU1XCIsXCJwcmljZV9zdGF0ZVwiOntcInByaWNlXCI6XCIwLjAwMDAwMTU0NTAwMDAwMDAwMFwiLFwiY3VtdWxhdGl2ZV9wcmljZVwiOlwiMjAuOTYzNzUwNDQyMjAwMDAwMDAwXCIsXCJ0aW1lc3RhbXBcIjpcIjE3MDIwMzkwNThcIn19LHtcInByaWNlX2lkXCI6XCIweDQxZjM2MjU5NzFjYTJlZDIyNjNlNzg1NzNmZTVjZTIzZTEzZDI1NThlZDNmMmU0N2FiMGY4NGZiOWU3YWU3MjJcIixcImVtYV9wcmljZVwiOlwiMS4wMDAwMTE2NDAwMDAwMDAwMDBcIixcImVtYV9jb25mXCI6XCIwLjAwMDI3NDE1MDAwMDAwMDAwMFwiLFwiY29uZlwiOlwiMC4wMDAyOTk5NzAwMDAwMDAwMDBcIixcInB1Ymxpc2hfdGltZVwiOlwiMTcwMjAzOTA1N1wiLFwicHJpY2Vfc3RhdGVcIjp7XCJwcmljZVwiOlwiMC45OTk5OTk5OTAwMDAwMDAwMDBcIixcImN1bXVsYXRpdmVfcHJpY2VcIjpcIjIzMjIyMDc2Ljg1MzYxNTM4MDAwMDAwMDAwMFwiLFwidGltZXN0YW1wXCI6XCIxNzAyMDM5MDU4XCJ9fV0ifV19XX1d", + "id":"", + "codespace":"", + "errorLog":"", + "code":0, + "claimIds":[ + + ] + } + ] } -data { - block_number: 8343044 - block_timestamp: "2023-02-19 09:46:56.317 +0000 UTC" - hash: "0xe4a8bdad7346811a903668d0f73adb3789717f87d3bce494596302c05a4a35b6" - messages: "[{\"type\":\"/injective.exchange.v1beta1.MsgExternalTransfer\",\"value\":{\"amount\":{\"amount\":\"2200000000\",\"denom\":\"peggy0xf9152067989BDc8783fF586624124C05A529A5D1\"},\"destination_subaccount_id\":\"0x7801adeda27f597d615ec67c8e3de33206efcae3000000000000000000000000\",\"sender\":\"inj1ftfn3shsk38l62eca65kxmdqs4gk70klkkrmrq\",\"source_subaccount_id\":\"0x4ad338c2f0b44ffd2b38eea9636da085516f3edf000000000000000000000000\"}}]" - tx_number: 1946522 } ``` @@ -1499,11 +1706,20 @@ import { ExchangeGrpcStreamClient } from "@injectivelabs/sdk-ts/dist/client/exch > Response Example: ``` python -block_number: 26726157 -block_timestamp: "2023-02-19 10:20:31.019 +0000 UTC" -hash: "0xeaa82cb1e98cb8939c8a2ff78fa48d00d7a70b748b117883dc023aa4eacedba3" -messages: "[{\"type\":\"/injective.exchange.v1beta1.MsgBatchCancelSpotOrders\",\"value\":{\"data\":[{\"market_id\":\"0xd5f5895102b67300a2f8f2c2e4b8d7c4c820d612bc93c039ba8cb5b93ccedf22\",\"order_hash\":\"0x030d0ee550e5a0f71f632ccc09cb82c83bbe48da9e1eedb7ddcc790e91bd589d\",\"order_mask\":0,\"subaccount_id\":\"0x32b16783ea9a08602dc792f24c3d78bba6e333d3000000000000000000000000\"},{\"market_id\":\"0xd5f5895102b67300a2f8f2c2e4b8d7c4c820d612bc93c039ba8cb5b93ccedf22\",\"order_hash\":\"0x66ac4f81aa93584a998f68a5542469405c7eeb86514de3d15c6e2a4fbe946bef\",\"order_mask\":0,\"subaccount_id\":\"0x32b16783ea9a08602dc792f24c3d78bba6e333d3000000000000000000000000\"}],\"sender\":\"inj1x2ck0ql2ngyxqtw8jteyc0tchwnwxv7npaungt\"}}]" -tx_number: 165598679 +{ + "blockNumber":"19388455", + "blockTimestamp":"2023-12-08 12:39:19.596 +0000 UTC", + "hash":"0xf4f17301c06df63160b60a071985fc0e0093a53e4027a2086fc51b0a46b6b43c", + "messages":"[{\"type\":\"/cosmos.authz.v1beta1.MsgExec\",\"value\":{\"grantee\":\"inj12shqy72r0apr4d9ft9x6z59t5yfjj4jv9n79l6\",\"msgs\":[{\"@type\":\"/injective.exchange.v1beta1.MsgBatchUpdateOrders\",\"sender\":\"inj15uad884tqeq9r76x3fvktmjge2r6kek55c2zpa\",\"subaccount_id\":\"\",\"spot_market_ids_to_cancel_all\":[],\"derivative_market_ids_to_cancel_all\":[],\"spot_orders_to_cancel\":[],\"derivative_orders_to_cancel\":[],\"spot_orders_to_create\":[],\"derivative_orders_to_create\":[{\"market_id\":\"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6\",\"order_info\":{\"subaccount_id\":\"0xa73ad39eab064051fb468a5965ee48ca87ab66d4000000000000000000000004\",\"fee_recipient\":\"inj15uad884tqeq9r76x3fvktmjge2r6kek55c2zpa\",\"price\":\"18495900.000000000000000000\",\"quantity\":\"60.000000000000000000\",\"cid\":\"HBOTSIJUT60bfedf775353d7bf700310e7cd\"},\"order_type\":\"SELL\",\"margin\":\"0.000000000000000000\",\"trigger_price\":\"0.000000000000000000\"}],\"binary_options_orders_to_cancel\":[],\"binary_options_market_ids_to_cancel_all\":[],\"binary_options_orders_to_create\":[]}]}}]", + "txNumber":"17748407", + "id":"", + "codespace":"", + "errorLog":"", + "code":0, + "claimIds":[ + + ] +} ``` ``` go @@ -1779,29 +1995,45 @@ import { ExchangeGrpcStreamClient } from "@injectivelabs/sdk-ts/dist/client/exch > Response Example: ``` python -height: 26775925 -proposer: "injvalcons1kmxsj4ak8kmnazkqu5wdphjn4aq2c37hkz63u6" -moniker: "Frens (\360\237\244\235,\360\237\244\235)" -block_hash: "0xfabc0a2e783463f5beb9118f8f3ce0803b9a1df4d5f4e64914a4f3dd90c20c75" -parent_hash: "0xe42820ae62bf5b3c3197597c0b87a02a044d36d98371efc11abc4bfc9a44137e" -num_txs: 14 -timestamp: "2023-02-20 01:14:22.936 +0000 UTC" - -height: 26775926 -proposer: "injvalcons1893nm5rlsl3pdcx26q0qhcskughcn2el3w335z" -moniker: "Binance Staking" -block_hash: "0x24c2edfb974143296a90523c85e58f2e14e7f380f3853c2354b65b91b4e5f386" -parent_hash: "0xd9efcbefbbd39be97363fa55ab93f43c598efe9c97542424e2e6ab8e6545e74d" -num_txs: 10 -timestamp: "2023-02-20 01:14:24.422 +0000 UTC" - -height: 26775927 -proposer: "injvalcons175ctmkculqfkwzn0du09w3r56ny38p04w8fen0" -moniker: "Everstake" -block_hash: "0x05090b92cf5d35c9d8531988670e9ea09e7be8a9218cfa9fc670c6438e4566e8" -parent_hash: "0x8771dd3a0747033b69dd94dcb356d309c6096519ae525d5d309985a49a843171" -num_txs: 11 -timestamp: "2023-02-20 01:14:25.422 +0000 UTC" +{ + "height":"19388498", + "proposer":"injvalcons1xml3ew93xmjtuf5zwpcl9jzznphte30hvdre9a", + "moniker":"InjectiveNode2", + "blockHash":"0xf12fd7ce5a00a4bab5028f6b6e94e014d31074b8f4a45d03731ab640533c71b7", + "parentHash":"0x601b7b2c202e8142535b1a76ec095a05e91c2507cbb462d59c0fd251fd769255", + "numTxs":"2", + "timestamp":"2023-12-08 12:40:51.641 +0000 UTC", + "numPreCommits":"0", + "txs":[ + + ] +} +{ + "height":"19388499", + "proposer":"injvalcons1xwg7xkmpqp8q804c37sa4dzyfwgnh4a74ll9pz", + "moniker":"InjectiveNode0", + "blockHash":"0x36bc946dba7fd81ea9b8dac4a70ca20ff4bc8e59b6ed2005e397d6ab0d3655d7", + "parentHash":"0xf37f966ec5d8275c74f25fbb3c39e7f58b30ca36dff5592cde44dd251b943fd8", + "numTxs":"3", + "timestamp":"2023-12-08 12:40:53.945 +0000 UTC", + "numPreCommits":"0", + "txs":[ + + ] +} +{ + "height":"19388500", + "proposer":"injvalcons18x63wcw5hjxlf535lgn4qy20yer7mm0qedu0la", + "moniker":"InjectiveNode1", + "blockHash":"0x1da9e10a726da84a5f7b53e25a598165a5ac44b573b7a3a7a1044242f9de2c83", + "parentHash":"0xad1f884d19fac8c6abc8b1e896e34a84583c49dc3ff66070c477a5af71bf54a2", + "numTxs":"2", + "timestamp":"2023-12-08 12:40:56.463 +0000 UTC", + "numPreCommits":"0", + "txs":[ + + ] +} ``` ``` go @@ -1962,33 +2194,41 @@ import { ExchangeGrpcClient } from "@injectivelabs/sdk-ts/dist/client/exchange/E > Response Example: ``` python -field { - sender: "0x0DdBE7EA40134Ae14eD6A5d104d8783c80663edB" - receiver: "inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex" - event_nonce: 12 - event_height: 7171276 - amount: "99999999990000000000000000" - denom: "0x85AbEac4F09762e28a49D7dA91260A46766F4F79" - orchestrator_address: "inj1c8rpu79mr70hqsgzutdd6rhvzhej9vntm6fqku" - state: "Completed" - claim_type: 1 - tx_hashes: "0xc2a026da61473eb252041187088f47240d855662357fbd3ce8fc67e57ffc5e8d" - created_at: "2022-07-05 02:13:22.284 +0000 UTC" - updated_at: "2022-07-05 02:14:06.033 +0000 UTC" -} -field { - sender: "0x0DdBE7EA40134Ae14eD6A5d104d8783c80663edB" - receiver: "inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex" - event_nonce: 4 - event_height: 7167025 - amount: "20000000000000" - denom: "0x85AbEac4F09762e28a49D7dA91260A46766F4F79" - orchestrator_address: "inj1c8rpu79mr70hqsgzutdd6rhvzhej9vntm6fqku" - state: "Completed" - claim_type: 1 - tx_hashes: "0xcc9536b19cc1c5afdc6469a66055f2ed05b0e2084fd41ecf35eb5d668bebd066" - created_at: "2022-07-04 22:41:28.751 +0000 UTC" - updated_at: "2022-07-04 22:45:17.775 +0000 UTC" +{ + "field":[ + { + "sender":"0x197E6c3f19951eA0bA90Ddf465bcC79790cDD12d", + "receiver":"inj1r9lxc0cej502pw5smh6xt0x8j7gvm5fdrj6xhk", + "eventNonce":"624", + "eventHeight":"10122722", + "amount":"500000000000000000", + "denom":"0xAD1794307245443B3Cb55d88e79EEE4d8a548C03", + "orchestratorAddress":"inj1c8rpu79mr70hqsgzutdd6rhvzhej9vntm6fqku", + "state":"Completed", + "claimType":1, + "txHashes":[ + "0x028a43ad2089cad45a8855143508f7381787d7f17cc19e3cda1bc2300c1d043f" + ], + "createdAt":"2023-11-28 16:55:54.841 +0000 UTC", + "updatedAt":"2023-11-28 16:56:07.944 +0000 UTC" + }, + { + "sender":"0x197E6c3f19951eA0bA90Ddf465bcC79790cDD12d", + "receiver":"inj1r9lxc0cej502pw5smh6xt0x8j7gvm5fdrj6xhk", + "eventNonce":"622", + "eventHeight":"10094898", + "amount":"550000000000000000", + "denom":"0xAD1794307245443B3Cb55d88e79EEE4d8a548C03", + "orchestratorAddress":"inj1c8rpu79mr70hqsgzutdd6rhvzhej9vntm6fqku", + "state":"Completed", + "claimType":1, + "txHashes":[ + "0xa528a522ce00b0f44add4a634ec92417c483fc045aa6b3f1cfceb685cdcf13a7" + ], + "createdAt":"2023-11-23 18:09:52.228 +0000 UTC", + "updatedAt":"2023-11-23 18:10:31.294 +0000 UTC" + } + ] } ``` @@ -2211,37 +2451,75 @@ import { ExchangeGrpcClient } from "@injectivelabs/sdk-ts/dist/client/exchange/E > Response Example: ``` python -field { - sender: "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" - receiver: "0xAF79152AC5dF276D9A8e1E2E22822f9713474902" - amount: "21827160493827160494" - denom: "inj" - bridge_fee: "6172839506172839506" - outgoing_tx_id: 24 - batch_timeout: 8325101 - batch_nonce: 27 - orchestrator_address: "inj15cmejnxc4t5x0056jlwygcdv3nykwu7yk0p9hz" - event_nonce: 50 - event_height: 8322300 - state: "Completed" - claim_type: 2 - tx_hashes: "0x7cb912b0c3d546ad861afb3e8136e7204efa08703e556e9ce38426675dad7321" - tx_hashes: "0xd237ce1c2934ecb9777b4e0737c1b0d4eae84f3eb01d2d544d5873e5fd01f255" - tx_hashes: "0xd83ed042386a6aeffffff5463cec01677a8850bbad2c09d8bd7fb98adb32668b" - created_at: "2023-01-16 16:53:37.779 +0000 UTC" - updated_at: "2023-01-16 17:08:46.272 +0000 UTC" -} -field { - sender: "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" - receiver: "0xAF79152AC5dF276D9A8e1E2E22822f9713474902" - amount: "490000000" - denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - bridge_fee: "10000000" - outgoing_tx_id: 23 - state: "InjectiveConfirming" - tx_hashes: "0x806672175a2ba47fe709e29cc6c791b2fbe40a000e64b9e68d7e6f68da20556e" - created_at: "2023-01-16 16:51:27.399 +0000 UTC" - updated_at: "2023-01-16 16:51:27.399 +0000 UTC" +{ + "field":[ + { + "sender":"inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku", + "receiver":"0xAF79152AC5dF276D9A8e1E2E22822f9713474902", + "amount":"1424956871765382404", + "denom":"inj", + "bridgeFee":"575043128234617596", + "outgoingTxId":"1136", + "batchTimeout":"10125614", + "batchNonce":"1600", + "orchestratorAddress":"inj1c8rpu79mr70hqsgzutdd6rhvzhej9vntm6fqku", + "state":"Cancelled", + "txHashes":[ + "0x0d9a7e280898b4452a4cd283c0447ea36d9f09f223d9812f64bbd694851dec8c", + "0x9a456aa20d613c2cd646cbfff0b77c49e746757c24352e967578cd6e86ad62e1", + "0x6ad03f12df86ead8efe52b1aecc35a4527c548283a901c71d6ca731a5bcf0a71", + "0x8cb343b8ec48de5b30c9825156e29ab649570f15a8d1b4a4c850d736d99a670e", + "0x9830d597d9ef2e60fa0c161cb0f39528e3d589c52bf365bf6971369025ce55ee", + "0xa955975323aac3a3ad52adc45379a6ce19ec4d91f661265521a55139b2a6ad8d", + "0x15dfa29c3f0e888b808b488c02f4596bbd6d30d566ddcf12fb80f658e6e2bc50", + "0x016df0af7326ea14160f8f6d233578c9dfdecc9568b5b464deb80584ea00d652", + "0xcf07704ba6ddf1ee4cdda30c594098ec7d4826fffc4a32891f76d1f632de5f61", + "0xc6198363885fda70ec365020a99df9ba9b0a6dc880d7b83e956e7441c1cd8824", + "0x25081d4593dc0f31c7e7465d2fbdb4f68289cd64b47968f532038085f9013ace", + "0x684b59d4cd779d1333b9f2cfa5db1a28ed5ba6a9be3b96fa63aa0cf6577ade0e" + ], + "createdAt":"2023-11-09 07:37:31.258 +0000 UTC", + "updatedAt":"2023-11-28 16:59:17.646 +0000 UTC", + "eventNonce":"0", + "eventHeight":"0", + "claimType":0 + }, + { + "sender":"inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku", + "receiver":"0xAF79152AC5dF276D9A8e1E2E22822f9713474902", + "amount":"19254843517138599106", + "denom":"inj", + "bridgeFee":"745156482861400894", + "outgoingTxId":"912", + "batchTimeout":"10125613", + "batchNonce":"1598", + "orchestratorAddress":"inj1qu62yv9xutqgeqms7gzvdnay5j5lph2j2e4q5h", + "state":"Cancelled", + "txHashes":[ + "0x1fc11c1db466716ad08237ec13128dead7a5edc2324a2d10eede9c45fd1789bc", + "0x747b809a56f1e2f9065378df6f46a9e2d725f04ccf505608756aa41a73551235", + "0x06db2f347054b394a70326314c04c2421757960a5b23724ec40cd84cc27ce44c", + "0x3c36a54a326ad9eb37ccfb2b8d8db72f3d2b5bdbc8d3693bf202ce98b315bdd8", + "0x7a2df716dae67e1fe9acbb336beda22882e92dc60836d19396305f9f03d34530", + "0xe31b3b5cabdae870a4c93d15cadfa6ac173e7d60ee2f021f4a047d4523bf7481", + "0x9d8d67e82d9f54477ca31e339643fc18b655fb24a9ebaa122400f49c5737df5e", + "0xa9039fee3b119f27fb0e733d8cfe2f9e96af51802a6a4088af3a5cabb1fb6de8", + "0x77d86350929b7cf6f4fe0094365bb71e9dc36a3e089a6af961cf05a153b54ade", + "0x3846355740bcfa46d7ac9092e9065df0a7f232f2736ac05a09fff69ee32314f2", + "0x86771d5fef383f8e256196d50ab62843aba63f3d23d3190f99cb882bcdaa45c9", + "0x27c712e45ec0458c9a39cf031d3d5de2d1ba1ef8833528062508a1ef0a02e64b", + "0x534fe5777662f31d098f6a5da2a73efc553a8fa81010da319162b7673062a90c", + "0xaafcd570b535ecc063573a94e9dd58dfcfcb0f30853945aa79e64fccc5907688", + "0x58258c46c3a674051e8c74c75ebe234942f85dacbeaba57c95ead9fa41b6d3a8", + "0xa434119dd2e647db048cfad61f3b97feef6008c38e68d7c574a6153b41dd49fe" + ], + "createdAt":"2023-10-27 16:18:16.23 +0000 UTC", + "updatedAt":"2023-11-28 16:59:04.777 +0000 UTC", + "eventNonce":"0", + "eventHeight":"0", + "claimType":0 + } + ] } ``` @@ -2477,23 +2755,30 @@ import { ExchangeGrpcClient } from "@injectivelabs/sdk-ts/dist/client/exchange/E > Response Example: ``` python -field { - sender: "inj1cll5cv3ezgal30gagkhnq2um6zf6qrmhw4r6c8" - receiver: "cosmos1usr9g5a4s2qrwl63sdjtrs2qd4a7huh622pg82" - source_port: "transfer" - source_channel: "channel-2" - destination_port: "transfer" - destination_channel: "channel-30" - amount: "10000000" - denom: "inj" - timeout_height: "0-2318098" - timeout_timestamp: 1657468864213943000 - packet_sequence: 1 - data_hex: "7b22616d6f756e74223a223130303030303030222c2264656e6f6d223a22696e6a222c227265636569766572223a22636f736d6f7331757372396735613473327172776c363373646a74727332716434613768756836323270673832222c2273656e646572223a22696e6a31636c6c35637633657a67616c33306761676b686e7132756d367a663671726d68773472366338227d" - state: "Submitted" - tx_hashes: "0xccd0e88bc664aa4cf6e1c425a73bbca246fc8c3c409dff819c0ec925f5237ff6" - created_at: "2022-07-10 15:51:05.022 +0000 UTC" - updated_at: "2022-07-10 15:51:05.022 +0000 UTC" +{ + "field":[ + { + "sender":"inj14nendtsz0c40n7xtzwkjmdc8dkuz835jdydxhn", + "receiver":"nois1mvuupgre7pjx3k5tm5729frkn9nvju6pgsxawc47pgamctypdzlsm7hg90", + "sourcePort":"transfer", + "sourceChannel":"channel-74", + "destinationPort":"transfer", + "destinationChannel":"channel-33", + "amount":"1000000", + "denom":"transfer/channel-74/unois", + "timeoutHeight":"0-0", + "timeoutTimestamp":"1702124625185146392", + "packetSequence":"20509", + "dataHex":"N2IyMjYxNmQ2Zjc1NmU3NDIyM2EyMjMxMzAzMDMwMzAzMDMwMjIyYzIyNjQ2NTZlNmY2ZDIyM2EyMjc0NzI2MTZlNzM2NjY1NzIyZjYzNjg2MTZlNmU2NTZjMmQzNzM0MmY3NTZlNmY2OTczMjIyYzIyNzI2NTYzNjU2OTc2NjU3MjIyM2EyMjZlNmY2OTczMzE2ZDc2NzU3NTcwNjc3MjY1Mzc3MDZhNzgzMzZiMzU3NDZkMzUzNzMyMzk2NjcyNmI2ZTM5NmU3NjZhNzUzNjcwNjc3Mzc4NjE3NzYzMzQzNzcwNjc2MTZkNjM3NDc5NzA2NDdhNmM3MzZkMzc2ODY3MzkzMDIyMmMyMjczNjU2ZTY0NjU3MjIyM2EyMjY5NmU2YTMxMzQ2ZTY1NmU2NDc0NzM3YTMwNjMzNDMwNmUzNzc4NzQ3YTc3NmI2YTZkNjQ2MzM4NjQ2Yjc1N2EzODMzMzU2YTY0Nzk2NDc4Njg2ZTIyN2Q=", + "state":"Completed", + "txHashes":[ + "0x3bf678143df5202cb9646e3d449978d385aff8d7b7e8cd5b1e1442163816d609", + "0x5abaf2ac5afd669c5cf5b8e22eceb211f6a334510dc58a5766d66848eede9407" + ], + "createdAt":"2023-12-08 12:23:45.185 +0000 UTC", + "updatedAt":"2023-12-08 12:23:58.769 +0000 UTC" + } + ] } ``` diff --git a/source/includes/_insurancerpc.md b/source/includes/_insurancerpc.md index a468b2f6..25dc436a 100644 --- a/source/includes/_insurancerpc.md +++ b/source/includes/_insurancerpc.md @@ -88,54 +88,35 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -funds { - market_ticker: "BTC/USDT PERP" - market_id: "0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3" - deposit_denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - pool_token_denom: "share1" - redemption_notice_period_duration: 1209600 - balance: "100000000000" - total_share: "1000000000000000000" - oracle_base: "BTC" - oracle_quote: "USDT" - oracle_type: "bandibc" -} -funds { - market_ticker: "ETH/USDT PERP" - market_id: "0xd5e4b12b19ecf176e4e14b42944731c27677819d2ed93be4104ad7025529c7ff" - deposit_denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - pool_token_denom: "share2" - redemption_notice_period_duration: 1209600 - balance: "101101000000" - total_share: "1011010000000000000" - oracle_base: "ETH" - oracle_quote: "USDT" - oracle_type: "bandibc" -} -funds { - market_ticker: "INJ/USDT PERP" - market_id: "0xe112199d9ee44ceb2697ea0edd1cd422223c105f3ed2bdf85223d3ca59f5909a" - deposit_denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - pool_token_denom: "share3" - redemption_notice_period_duration: 1209600 - balance: "101010000000" - total_share: "1010100000000000000" - oracle_base: "INJ" - oracle_quote: "USDT" - oracle_type: "bandibc" -} -funds { - market_ticker: "Frontrunner Futures 4: Expires 7.7.2023" - market_id: "0x3bb58218cd90efcce9ea9e317d137dcd4ce8485c6be346250dbf8cd60d9c9e2d" - deposit_denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - pool_token_denom: "share4" - redemption_notice_period_duration: 1209600 - balance: "1015000000" - total_share: "101500000000000000000" - oracle_base: "FRNT" - oracle_quote: "USDT" - oracle_type: "pricefeed" - expiry: 1688747341 +{ + "funds":[ + { + "marketTicker":"BTC/USDT PERP", + "marketId":"0x90e662193fa29a3a7e6c07be4407c94833e762d9ee82136a2cc712d6b87d7de3", + "depositDenom":"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "poolTokenDenom":"share1", + "redemptionNoticePeriodDuration":"1209600", + "balance":"3825059708", + "totalShare":"1000000000000000000", + "oracleBase":"BTC", + "oracleQuote":"USDT", + "oracleType":"bandibc", + "expiry":"0" + }, + { + "marketTicker":"ETH/USDT PERP", + "marketId":"0xd5e4b12b19ecf176e4e14b42944731c27677819d2ed93be4104ad7025529c7ff", + "depositDenom":"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "poolTokenDenom":"share2", + "redemptionNoticePeriodDuration":"1209600", + "balance":"723501080000", + "totalShare":"7235010800000000000", + "oracleBase":"ETH", + "oracleQuote":"USDT", + "oracleType":"bandibc", + "expiry":"0" + } + ] } ``` @@ -337,29 +318,33 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -redemption_schedules { - redemption_id: 1 - status: "disbursed" - redeemer: "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" - claimable_redemption_time: 1674798129093000 - redemption_amount: "500000000000000000" - redemption_denom: "share4" - requested_at: 1673588529093000 - disbursed_amount: "5000000" - disbursed_denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - disbursed_at: 1674798130965000 -} -redemption_schedules { - redemption_id: 2 - status: "disbursed" - redeemer: "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" - claimable_redemption_time: 1674798342397000 - redemption_amount: "2000000000000000000" - redemption_denom: "share4" - requested_at: 1673588742397000 - disbursed_amount: "20000000" - disbursed_denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - disbursed_at: 1674798343097000 +{ + "redemptionSchedules":[ + { + "redemptionId":"1", + "status":"disbursed", + "redeemer":"inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku", + "claimableRedemptionTime":"1674798129093000", + "redemptionAmount":"500000000000000000", + "redemptionDenom":"share4", + "requestedAt":"1673588529093000", + "disbursedAmount":"5000000", + "disbursedDenom":"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "disbursedAt":"1674798130965000" + }, + { + "redemptionId":"2", + "status":"disbursed", + "redeemer":"inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku", + "claimableRedemptionTime":"1674798342397000", + "redemptionAmount":"2000000000000000000", + "redemptionDenom":"share4", + "requestedAt":"1673588742397000", + "disbursedAmount":"20000000", + "disbursedDenom":"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "disbursedAt":"1674798343097000" + } + ] } ``` diff --git a/source/includes/_metarpc.md b/source/includes/_metarpc.md index fe1d6c3d..edcd27e0 100644 --- a/source/includes/_metarpc.md +++ b/source/includes/_metarpc.md @@ -178,22 +178,14 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -Version: version: "dev" -build { - key: "BuildDate" - value: "20230210-0651" -} -build { - key: "GitCommit" - value: "6b0c142" -} -build { - key: "GoArch" - value: "amd64" -} -build { - key: "GoVersion" - value: "go1.19.2" +{ + "version":"v1.12.46-rc1", + "build":{ + "BuildDate":"20231110-0736", + "GitCommit":"2b326fe", + "GoVersion":"go1.20.5", + "GoArch":"amd64" + } } ``` @@ -326,29 +318,18 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -timestamp: 1676695214189 -server_time: 1676695214692 -version: "dev" -build { - key: "BuildDate" - value: "20230210-0651" -} -build { - key: "GitCommit" - value: "6b0c142" -} -build { - key: "GoArch" - value: "amd64" -} -build { - key: "GoVersion" - value: "go1.19.2" +{ + "timestamp":"1702040535291", + "serverTime":"1702040536394", + "version":"v1.12.46-guilds-rc5", + "build":{ + "BuildDate":"20231113-1523", + "GitCommit":"78a9ea2", + "GoVersion":"go1.20.5", + "GoArch":"amd64" + }, + "region":"" } - -Server Latency: 427ms - -Server Latency: 375ms ``` ``` typescript @@ -451,8 +432,6 @@ async def get_markets(client): if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) - - ``` ``` go diff --git a/source/includes/_oraclerpc.md b/source/includes/_oraclerpc.md index 7c65a509..c84fcd46 100644 --- a/source/includes/_oraclerpc.md +++ b/source/includes/_oraclerpc.md @@ -85,32 +85,58 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -oracles { - symbol: "BTC" - oracle_type: "bandibc" - price: "16835.93" -} -oracles { - symbol: "ETH" - oracle_type: "bandibc" - price: "1251.335" -} -oracles { - symbol: "INJ" - oracle_type: "bandibc" - price: "1.368087992" -} -oracles { - symbol: "USDT" - oracle_type: "bandibc" - price: "0.999785552" -} -oracles { - symbol: "FRNT/USDT" - base_symbol: "FRNT" - quote_symbol: "USDT" - oracle_type: "pricefeed" - price: "0.5" +{ + "oracles":[ + { + "symbol":"BTC", + "oracleType":"bandibc", + "price":"16835.93", + "baseSymbol":"", + "quoteSymbol":"" + }, + { + "symbol":"ETH", + "oracleType":"bandibc", + "price":"1251.335", + "baseSymbol":"", + "quoteSymbol":"" + }, + { + "symbol":"INJ", + "oracleType":"bandibc", + "price":"1.368087992", + "baseSymbol":"", + "quoteSymbol":"" + }, + { + "symbol":"USDT", + "oracleType":"bandibc", + "price":"0.999785552", + "baseSymbol":"", + "quoteSymbol":"" + }, + { + "symbol":"FRNT/USDT", + "baseSymbol":"FRNT", + "quoteSymbol":"USDT", + "oracleType":"pricefeed", + "price":"0.5" + }, + { + "symbol":"0xb327d9cf0ecd793a175fa70ac8d2dc109d4462758e556962c4a87b02ec4f3f15", + "baseSymbol":"0xb327d9cf0ecd793a175fa70ac8d2dc109d4462758e556962c4a87b02ec4f3f15", + "quoteSymbol":"0xb327d9cf0ecd793a175fa70ac8d2dc109d4462758e556962c4a87b02ec4f3f15", + "oracleType":"pyth", + "price":"7.33638432" + }, + { + "symbol":"0xecf553770d9b10965f8fb64771e93f5690a182edc32be4a3236e0caaa6e0581a", + "baseSymbol":"0xecf553770d9b10965f8fb64771e93f5690a182edc32be4a3236e0caaa6e0581a", + "quoteSymbol":"0xecf553770d9b10965f8fb64771e93f5690a182edc32be4a3236e0caaa6e0581a", + "oracleType":"pyth", + "price":"225.28704062" + } + ] } ``` @@ -288,7 +314,7 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -price: "16835930000" +{ "price": '1.368087992' } ``` ``` go @@ -460,11 +486,10 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Streaming Response Example: ``` python -price: "16835.93" -timestamp: 1676539631606 - -price: "16840.12" -timestamp: 1676539635432 +{ + "price":"1.3683814386627584", + "timestamp":"1702043286264" +} ``` ``` go diff --git a/source/includes/_portfoliorpc.md b/source/includes/_portfoliorpc.md index 1c61c931..e7561cd4 100644 --- a/source/includes/_portfoliorpc.md +++ b/source/includes/_portfoliorpc.md @@ -90,56 +90,93 @@ console.log(portfolio) > Response Example: ``` python -portfolio { - account_address: "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt" - bank_balances { - denom: "inj" - amount: "9990005504242500000000" - } - bank_balances { - denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - amount: "9689943508" - } - subaccounts { - subaccount_id: "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000002" - denom: "inj" - deposit { - total_balance: "1000000000000" - available_balance: "1000000000000" - } - } - subaccounts { - subaccount_id: "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000000" - denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - deposit { - total_balance: "0.4444" - available_balance: "0.4444" - } - } - subaccounts { - subaccount_id: "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000000" - denom: "inj" - deposit { - total_balance: "0" - available_balance: "0" - } - } - subaccounts { - subaccount_id: "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" - denom: "inj" - deposit { - total_balance: "11050001000000000000" - available_balance: "10990001000000000000" - } - } - subaccounts { - subaccount_id: "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" - denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - deposit { - total_balance: "302618110.6156" - available_balance: "298208110.6156" - } - } +{ + "portfolio":{ + "accountAddress":"inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt", + "bankBalances":[ + { + "denom":"inj", + "amount":"9689395972014420000000" + }, + { + "denom":"peggy0x44C21afAaF20c270EBbF5914Cfc3b5022173FEB7", + "amount":"100000000000000000000" + }, + { + "denom":"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "amount":"8689670208" + } + ], + "subaccounts":[ + { + "subaccountId":"0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000000", + "denom":"peggy0x44C21afAaF20c270EBbF5914Cfc3b5022173FEB7", + "deposit":{ + "totalBalance":"0", + "availableBalance":"0" + } + }, + { + "subaccountId":"0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000000", + "denom":"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "deposit":{ + "totalBalance":"0.170858923182467801", + "availableBalance":"0.170858923182467801" + } + }, + { + "subaccountId":"0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000000", + "denom":"inj", + "deposit":{ + "totalBalance":"0.458458", + "availableBalance":"0.458458" + } + }, + { + "subaccountId":"0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000002", + "denom":"inj", + "deposit":{ + "totalBalance":"1000000000000", + "availableBalance":"1000000000000" + } + }, + { + "subaccountId":"0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001", + "denom":"inj", + "deposit":{ + "totalBalance":"11010001000000000000", + "availableBalance":"11010001000000000000" + } + }, + { + "subaccountId":"0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001", + "denom":"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "deposit":{ + "totalBalance":"298666021.6838251182660625", + "availableBalance":"298666021.6838251182660625" + } + } + ], + "positionsWithUpnl":[ + { + "position":{ + "ticker":"TIA/USDT-01NOV2023", + "marketId":"0xf97a740538e10845e0c3db9ea94c6eaf8a570aeebe3e3511e2e387501a40e4bb", + "subaccountId":"0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000000", + "direction":"short", + "quantity":"139.6", + "entryPrice":"22522222.222222222222222222", + "margin":"985863999.424172444444444445", + "liquidationPrice":"29004201.230732", + "markPrice":"23.706683000000000000", + "aggregateReduceOnlyQuantity":"0", + "updatedAt":"1696481899", + "createdAt":"0" + }, + "unrealizedPnl":"-165.350724577777780880" + } + ] + } } ``` @@ -369,15 +406,20 @@ streamFn(streamFnArgs) > Response Example: ``` python -type: "bank" -denom: "inj" -amount: "9990005452404000000000" - -Account portfolio Update: - -type: "bank" -denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" -amount: "9689943532" +{ + "type": "total_balances", + "denom": "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "amount": "302686408.8456", + "subaccountId": "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001", + "timestamp": "342423423" +} +{ + "type": "total_balances", + "denom": "inj", + "amount": "11040001000000000000", + "subaccount_id": "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001", + "timestamp": "342432343" +} ``` ``` go diff --git a/source/includes/_spotrpc.md b/source/includes/_spotrpc.md index 24d7c414..ccb70650 100644 --- a/source/includes/_spotrpc.md +++ b/source/includes/_spotrpc.md @@ -90,33 +90,35 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -market { - market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - market_status: "active" - ticker: "INJ/USDT" - base_denom: "inj" - base_token_meta { - name: "Injective Protocol" - address: "0xe28b3B32B6c345A34Ff64674606124Dd5Aceca30" - symbol: "INJ" - logo: "https://static.alchemyapi.io/images/assets/7226.png" - decimals: 18 - updated_at: 1658129632873 - } - quote_denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - quote_token_meta { - name: "Testnet Tether USDT" - address: "0x0000000000000000000000000000000000000000" - symbol: "USDT" - logo: "https://static.alchemyapi.io/images/assets/825.png" - decimals: 6 - updated_at: 1675929393340 - } - maker_fee_rate: "-0.0001" - taker_fee_rate: "0.001" - service_provider_fee: "0.4" - min_price_tick_size: "0.000000000000001" - min_quantity_tick_size: "1000000000000000" +{ + "market":{ + "marketId":"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "marketStatus":"active", + "ticker":"INJ/USDT", + "baseDenom":"inj", + "baseTokenMeta":{ + "name":"Injective Protocol", + "address":"0xe28b3B32B6c345A34Ff64674606124Dd5Aceca30", + "symbol":"INJ", + "logo":"https://static.alchemyapi.io/images/assets/7226.png", + "decimals":18, + "updatedAt":"1683119359318" + }, + "quoteDenom":"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "quoteTokenMeta":{ + "name":"Testnet Tether USDT", + "address":"0x0000000000000000000000000000000000000000", + "symbol":"USDT", + "logo":"https://static.alchemyapi.io/images/assets/825.png", + "decimals":6, + "updatedAt":"1683119359320" + }, + "makerFeeRate":"-0.0001", + "takerFeeRate":"0.001", + "serviceProviderFee":"0.4", + "minPriceTickSize":"0.000000000000001", + "minQuantityTickSize":"1000000000000000" + } } ``` @@ -309,33 +311,37 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -markets { - market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - market_status: "active" - ticker: "INJ/USDT" - base_denom: "inj" - base_token_meta { - name: "Injective Protocol" - address: "0xe28b3B32B6c345A34Ff64674606124Dd5Aceca30" - symbol: "INJ" - logo: "https://static.alchemyapi.io/images/assets/7226.png" - decimals: 18 - updated_at: 1658129632873 - } - quote_denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" - quote_token_meta { - name: "Testnet Tether USDT" - address: "0x0000000000000000000000000000000000000000" - symbol: "USDT" - logo: "https://static.alchemyapi.io/images/assets/825.png" - decimals: 6 - updated_at: 1675929959325 - } - maker_fee_rate: "-0.0001" - taker_fee_rate: "0.001" - service_provider_fee: "0.4" - min_price_tick_size: "0.000000000000001" - min_quantity_tick_size: "1000000000000000" +{ + "markets":[ + { + "marketId":"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "marketStatus":"active", + "ticker":"INJ/USDT", + "baseDenom":"inj", + "baseTokenMeta":{ + "name":"Injective Protocol", + "address":"0xe28b3B32B6c345A34Ff64674606124Dd5Aceca30", + "symbol":"INJ", + "logo":"https://static.alchemyapi.io/images/assets/7226.png", + "decimals":18, + "updatedAt":"1683119359318" + }, + "quoteDenom":"peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", + "quoteTokenMeta":{ + "name":"Testnet Tether USDT", + "address":"0x0000000000000000000000000000000000000000", + "symbol":"USDT", + "logo":"https://static.alchemyapi.io/images/assets/825.png", + "decimals":6, + "updatedAt":"1683119359320" + }, + "makerFeeRate":"-0.0001", + "takerFeeRate":"0.001", + "serviceProviderFee":"0.4", + "minPriceTickSize":"0.000000000000001", + "minQuantityTickSize":"1000000000000000" + } + ] } ``` @@ -623,36 +629,38 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Streaming Response Example: ``` python -market: { - market_id: "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", - market_status: "active", - ticker: "INJ/USDT", - base_denom: "inj", - base_token_meta: { - name: "Injective Protocol", - address: "0xe28b3B32B6c345A34Ff64674606124Dd5Aceca30", - symbol: "INJ", - logo: "https://static.alchemyapi.io/images/assets/7226.png", - decimals: 18, - updated_at: 1632535055751 - }, - quote_denom: "peggy0x69efCB62D98f4a6ff5a0b0CFaa4AAbB122e85e08", - quote_token_meta: { - name: "Tether", - address: "0x69efCB62D98f4a6ff5a0b0CFaa4AAbB122e85e08", - symbol: "USDT", - logo: "https://static.alchemyapi.io/images/assets/825.png", - decimals: 6, - updated_at: 1632535055759 - }, - maker_fee_rate: "0.001", - taker_fee_rate: "0.002", - service_provider_fee: "0.4", - min_price_tick_size: "0.000000000000001", - min_quantity_tick_size: "1000000000000000" -}, - operation_type: "update", - timestamp: 1632535055790 +{ + "market":{ + "marketId":"0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", + "marketStatus":"active", + "ticker":"INJ/USDT", + "baseDenom":"inj", + "baseTokenMeta":{ + "name":"Injective Protocol", + "address":"0xe28b3B32B6c345A34Ff64674606124Dd5Aceca30", + "symbol":"INJ", + "logo":"https://static.alchemyapi.io/images/assets/7226.png", + "decimals":18, + "updatedAt":1632535055751 + }, + "quoteDenom":"peggy0x69efCB62D98f4a6ff5a0b0CFaa4AAbB122e85e08", + "quoteTokenMeta":{ + "name":"Tether", + "address":"0x69efCB62D98f4a6ff5a0b0CFaa4AAbB122e85e08", + "symbol":"USDT", + "logo":"https://static.alchemyapi.io/images/assets/825.png", + "decimals":6, + "updatedAt":1632535055759 + }, + "makerFeeRate":"0.001", + "takerFeeRate":"0.002", + "serviceProviderRate":"0.4", + "minPriceTickSize":"0.000000000000001", + "minQuantityTickSize":"1000000000000000" + }, + "operationType":"update", + "timestamp":1632535055790 +} ``` ``` go @@ -719,10 +727,9 @@ market: { "serviceProviderRate": "0.4", "minPriceTickSize": "0.000000000000001", "minQuantityTickSize": "1000000000000000" - }, - "operationType": "update", - "timestamp": 1632535055790 - } + }, + "operationType": "update", + "timestamp": 1632535055790 } ``` @@ -870,55 +877,73 @@ func main() { > Response Example: ``` python -orders { - order_hash: "0x5421e66dee390cbc734c2aaa3e9cf4b6917a3c9cf496c2e1ba3661e9cebcce56" - market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - subaccount_id: "0xbdaedec95d563fb05240d6e01821008454c24c36000000000000000000000000" - execution_type: "limit" - order_type: "buy_po" - price: "0.000000000000001" - trigger_price: "0" - quantity: "1000000000000000" - filled_quantity: "0" - state: "canceled" - created_at: 1669998526840 - updated_at: 1670919394668 - direction: "buy" -} -orders { - order_hash: "0xf4d33d0eb3ee93a79df7e1c330b729dc56ab18b423be8d82c972f9dd2498fb3c" - market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - subaccount_id: "0xbdaedec95d563fb05240d6e01821008454c24c36000000000000000000000000" - execution_type: "limit" - order_type: "buy_po" - price: "0.000000000000001" - trigger_price: "0" - quantity: "1000000000000000" - filled_quantity: "0" - state: "canceled" - created_at: 1669998526840 - updated_at: 1670919410587 - direction: "buy" -} -orders { - order_hash: "0x3fedb6c07b56155e4e7752dd3f24dfbf58a6cfc1370b9cd2973e79e31d29b17a" - market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - subaccount_id: "0xbdaedec95d563fb05240d6e01821008454c24c36000000000000000000000000" - execution_type: "limit" - order_type: "buy_po" - price: "0.000000000000001" - trigger_price: "0" - quantity: "1000000000000000" - filled_quantity: "0" - state: "canceled" - created_at: 1669998524140 - updated_at: 1670919410587 - direction: "buy" -} -paging { - total: 1000 +{ + "orders":[ + { + "orderHash":"0x4e6629ce45597a3dc3941c5382cc7bc542d52fbcc6b03c4fd604c94a9bec0cc1", + "marketId":"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "subaccountId":"0xbdaedec95d563fb05240d6e01821008454c24c36000000000000000000000000", + "executionType":"limit", + "orderType":"buy_po", + "price":"0.000000000000001", + "triggerPrice":"0", + "quantity":"1000000000000000", + "filledQuantity":"1000000000000000", + "state":"filled", + "createdAt":"1668264339149", + "updatedAt":"1682667017745", + "direction":"buy", + "txHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "isActive":false, + "cid":"" + }, + { + "orderHash":"0x347de654c8484fe36473c3569382ff27d25e95c660fd055163b7193607867a8b", + "marketId":"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "subaccountId":"0xbdaedec95d563fb05240d6e01821008454c24c36000000000000000000000000", + "executionType":"limit", + "orderType":"buy_po", + "price":"0.000000000000001", + "triggerPrice":"0", + "quantity":"1000000000000000", + "filledQuantity":"1000000000000000", + "state":"filled", + "createdAt":"1668264339149", + "updatedAt":"1682667017745", + "direction":"buy", + "txHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "isActive":false, + "cid":"" + }, + { + "orderHash":"0x2141d52714f5c9328170cc674de8ecf876463b1999bea4124d1de595152b718f", + "marketId":"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "subaccountId":"0xbdaedec95d563fb05240d6e01821008454c24c36000000000000000000000000", + "executionType":"limit", + "orderType":"buy_po", + "price":"0.000000000000001", + "triggerPrice":"0", + "quantity":"1000000000000000", + "filledQuantity":"1000000000000000", + "state":"filled", + "createdAt":"1668264339149", + "updatedAt":"1682667017745", + "direction":"buy", + "txHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "isActive":false, + "cid":"" + } + ], + "paging":{ + "total":"1000", + "from":0, + "to":0, + "countBySubaccount":"0", + "next":[ + + ] + } } - ``` ``` go @@ -1282,24 +1307,28 @@ console.log(orderHistory) > Streaming Response Example: ``` python -order { - order_hash: "0xe34ada890ab627fb904d8dd50411a4ca64d1f6cb56c7305a2833772b36ae5660" - market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - is_active: true - subaccount_id: "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" - execution_type: "limit" - order_type: "buy_po" - price: "0.000000000001849" - trigger_price: "0" - quantity: "10817000000000000000" - filled_quantity: "0" - state: "booked" - created_at: 1665486460484 - updated_at: 1665486460484 - direction: "buy" +{ + "order":{ + "orderHash":"0xff6a1ce6339911bb6f0765e17e70144ae62834e65e551e910018203d62bc6d12", + "marketId":"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "subaccountId":"0x5e249f0e8cb406f41de16e1bd6f6b55e7bc75add000000000000000000000004", + "executionType":"limit", + "orderType":"buy_po", + "price":"0.000000000019028", + "triggerPrice":"0", + "quantity":"67129093000000000000000", + "filledQuantity":"0", + "state":"canceled", + "createdAt":"1702044186286", + "updatedAt":"1702044188683", + "direction":"buy", + "txHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "isActive":false, + "cid":"" + }, + "operationType":"update", + "timestamp":"1702044191000" } -operation_type: "insert" -timestamp: 1665486462000 ``` ``` go @@ -1405,13 +1434,13 @@ async def main() -> None: market_ids = ["0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"] execution_side = "taker" direction = "buy" - subaccount_ids = ["0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001"] + subaccount_id = "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" execution_types = ["limitMatchNewOrder", "market"] - orders = await client.fetch_spot_trades( + orders = await client.get_spot_trades( market_ids=market_ids, - subaccount_ids=subaccount_ids, execution_side=execution_side, direction=direction, + subaccount_id=subaccount_id, execution_types=execution_types, ) print(orders) @@ -1679,9 +1708,10 @@ paging { | total | Integer | Total number of records available | -## StreamTrades +## TradesV2 -Stream newly executed trades of spot markets. The default request streams trades from all spot markets. +Get trade history for a spot market. The default request returns all spot trades from all markets. +The difference between `Trades` and `TradesV2` is that the latter returns a `trade_id` compatible witht the one used for trade events in chain stream. **IP rate limit group:** `indexer` @@ -1693,63 +1723,39 @@ Stream newly executed trades of spot markets. The default request streams trades 3. `"limitMatchRestingOrder"` for a resting limit order getting matched with another new limit order 4. `"limitMatchNewOrder"` for a new limit order getting matched immediately + ### Request Parameters > Request Example: ``` python import asyncio -from typing import Any, Dict - -from grpc import RpcError from pyinjective.async_client import AsyncClient from pyinjective.core.network import Network -async def trade_event_processor(event: Dict[str, Any]): - print(event) - - -def stream_error_processor(exception: RpcError): - print(f"There was an error listening to spot trades updates ({exception})") - - -def stream_closed_processor(): - print("The spot trades updates stream has been closed") - - async def main() -> None: network = Network.testnet() client = AsyncClient(network) - market_ids = [ - "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", - "0x7a57e705bb4e09c88aecfc295569481dbf2fe1d5efe364651fbe72385938e9b0", - ] - execution_side = "maker" - direction = "sell" - subaccount_id = "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" - execution_types = ["limitMatchRestingOrder"] - - task = asyncio.get_event_loop().create_task( - client.listen_spot_trades_updates( - callback=trade_event_processor, - on_end_callback=stream_closed_processor, - on_status_callback=stream_error_processor, - market_ids=market_ids, - subaccount_ids=[subaccount_id], - execution_side=execution_side, - direction=direction, - execution_types=execution_types, - ) + market_ids = ["0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"] + execution_side = "taker" + direction = "buy" + subaccount_ids = ["0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001"] + execution_types = ["limitMatchNewOrder", "market"] + orders = await client.fetch_spot_trades( + market_ids=market_ids, + subaccount_ids=subaccount_ids, + execution_side=execution_side, + direction=direction, + execution_types=execution_types, ) - - await asyncio.sleep(delay=60) - task.cancel() + print(orders) if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main()) + ``` ``` go @@ -1770,78 +1776,800 @@ func main() { network := common.LoadNetwork("testnet", "k8s") exchangeClient, err := exchangeclient.NewExchangeClient(network.ExchangeGrpcEndpoint, common.OptionTLSCert(network.ExchangeTlsCert)) if err != nil { - fmt.Println(err) + panic(err) } ctx := context.Background() marketId := "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0" subaccountId := "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - req := spotExchangePB.StreamTradesRequest{ + req := spotExchangePB.TradesRequest{ MarketId: marketId, SubaccountId: subaccountId, } - stream, err := exchangeClient.StreamSpotTrades(ctx, req) + + res, err := exchangeClient.GetSpotTrades(ctx, req) if err != nil { - fmt.Println(err) + panic(err) } - for { - select { - case <-ctx.Done(): - return - default: - res, err := stream.Recv() - if err != nil { - fmt.Println(err) - return + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) +} +``` + +``` typescript +import { + TradeDirection, + PaginationOption, + TradeExecutionType, + IndexerGrpcSpotApi, +} from "@injectivelabs/sdk-ts"; +import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; + +(async () => { + const endpoints = getNetworkEndpoints(Network.TestnetK8s); + const indexerGrpcSpotApi = new IndexerGrpcSpotApi(endpoints.indexer); + + const marketId = "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce"; + const executionTypes = [TradeExecutionType.Market]; + const direction = TradeDirection.Buy; + const subaccountId = "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000"; + const paginationOption = {} as PaginationOption; + + const trades = await indexerGrpcSpotApi.fetchTrades({ + marketId, + executionTypes, + direction, + subaccountId, + pagination: paginationOption, + }); + + console.log(trades); +})(); +``` + +| Parameter | Type | Description | Required | +| --------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------- | -------- | +| market_ids | String Array | Filter by multiple market IDs | No | +| subaccount_ids | String Array | Filter by multiple subaccount IDs | No | +| execution_side | String | Filter by the execution side of the trade (Should be one of: ["maker", "taker"]) | No | +| direction | String | Filter by the direction of the trade (Should be one of: ["buy", "sell"]) | No | +| execution_types | String Array | Filter by the *trade execution type (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | No | +| trade_id | String | Filter by the trade id of the trade | No | +| account_address | String | Filter by the account address | No | +| cid | String | Filter by the custom client order id of the trade's order | No | +| pagination | PaginationOption | Pagination configuration | No | + + +### Response Parameters +> Response Example: + +``` python +{ + "trades":[ + { + "orderHash":"0x952bb14a7a377697d724c60d6077ef3dfe894c98f854970fab187247be832b6f", + "subaccountId":"0x101411266c6e2b610b4a0324d2bfb2ef0ca6e1dd000000000000000000000000", + "marketId":"0x01edfab47f124748dc89998eb33144af734484ba07099014594321729a0ca16b", + "tradeExecutionType":"limitMatchRestingOrder", + "tradeDirection":"buy", + "price":{ + "price":"0.00000000001", + "quantity":"1000000000000000000", + "timestamp":"1701961116630" + }, + "fee":"-600", + "executedAt":"1701961116630", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"1321_0", + "executionSide":"maker", + "cid":"96866b8b-02dd-4288-97d3-e5254e4888b3" + }, + { + "orderHash":"0x85a824c31f59cf68235b48666c4821334813f2b80db937f02d192f1e3fc74368", + "subaccountId":"0x3db1f84431dfe4df617f9eb2d04edf432beb9826000000000000000000000000", + "marketId":"0x01edfab47f124748dc89998eb33144af734484ba07099014594321729a0ca16b", + "tradeExecutionType":"limitMatchNewOrder", + "tradeDirection":"sell", + "price":{ + "price":"0.00000000001", + "quantity":"1000000000000000000", + "timestamp":"1701961116630" + }, + "fee":"10000", + "executedAt":"1701961116630", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"1321_1", + "executionSide":"taker", + "cid":"spot_AAVE/USDT" + }, + { + "orderHash":"0xffabb2d12a745d79eb12c7ef0eb59c729aaa4387a141f858153c8b8f58168b2e", + "subaccountId":"0x101411266c6e2b610b4a0324d2bfb2ef0ca6e1dd000000000000000000000000", + "marketId":"0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", + "tradeExecutionType":"limitMatchRestingOrder", + "tradeDirection":"buy", + "price":{ + "price":"0.00000000001", + "quantity":"2000000000000000000", + "timestamp":"1701960607140" + }, + "fee":"-2400", + "executedAt":"1701960607140", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"646_0", + "executionSide":"maker", + "cid":"ec581735-f801-4bf3-9101-282b301bf5cd" + }, + { + "orderHash":"0xa19e24eef9877ec4980b8d259c1d21fa1dafcd50691e6f853e84af74fb23c05c", + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "marketId":"0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", + "tradeExecutionType":"limitMatchNewOrder", + "tradeDirection":"sell", + "price":{ + "price":"0.00000000001", + "quantity":"2000000000000000000", + "timestamp":"1701960607140" + }, + "fee":"40000", + "executedAt":"1701960607140", + "feeRecipient":"inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8", + "tradeId":"646_1", + "executionSide":"taker", + "cid":"" + }, + { + "orderHash":"0xffabb2d12a745d79eb12c7ef0eb59c729aaa4387a141f858153c8b8f58168b2e", + "subaccountId":"0x101411266c6e2b610b4a0324d2bfb2ef0ca6e1dd000000000000000000000000", + "marketId":"0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", + "tradeExecutionType":"limitMatchRestingOrder", + "tradeDirection":"buy", + "price":{ + "price":"0.00000000001", + "quantity":"8000000000000000000", + "timestamp":"1701960594997" + }, + "fee":"-9600", + "executedAt":"1701960594997", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"630_0", + "executionSide":"maker", + "cid":"ec581735-f801-4bf3-9101-282b301bf5cd" + }, + { + "orderHash":"0x87b786072190a2f38e9057987be7bdcb4e2274a6c16fdb9670e5c2ded765140f", + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "marketId":"0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", + "tradeExecutionType":"limitMatchNewOrder", + "tradeDirection":"sell", + "price":{ + "price":"0.00000000001", + "quantity":"8000000000000000000", + "timestamp":"1701960594997" + }, + "fee":"160000", + "executedAt":"1701960594997", + "feeRecipient":"inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8", + "tradeId":"630_1", + "executionSide":"taker", + "cid":"" } - str, _ := json.MarshalIndent(res, "", " ") - fmt.Print(string(str)) - } + ], + "paging":{ + "total":"6", + "from":1, + "to":6, + "countBySubaccount":"0", + "next":[ + + ] + } +} + +``` + +``` go +{ + "trades": [ + { + "order_hash": "0xffabb2d12a745d79eb12c7ef0eb59c729aaa4387a141f858153c8b8f58168b2e", + "subaccount_id": "0x101411266c6e2b610b4a0324d2bfb2ef0ca6e1dd000000000000000000000000", + "market_id": "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", + "trade_execution_type": "limitMatchRestingOrder", + "trade_direction": "buy", + "price": { + "price": "0.00000000001", + "quantity": "2000000000000000000", + "timestamp": 1701960607140 + }, + "fee": "-2400", + "executed_at": 1701960607140, + "fee_recipient": "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "trade_id": "646_0", + "execution_side": "maker", + "cid": "ec581735-f801-4bf3-9101-282b301bf5cd" + }, + { + "order_hash": "0xa19e24eef9877ec4980b8d259c1d21fa1dafcd50691e6f853e84af74fb23c05c", + "subaccount_id": "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "market_id": "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", + "trade_execution_type": "limitMatchNewOrder", + "trade_direction": "sell", + "price": { + "price": "0.00000000001", + "quantity": "2000000000000000000", + "timestamp": 1701960607140 + }, + "fee": "40000", + "executed_at": 1701960607140, + "fee_recipient": "inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8", + "trade_id": "646_1", + "execution_side": "taker" + }, + { + "order_hash": "0xffabb2d12a745d79eb12c7ef0eb59c729aaa4387a141f858153c8b8f58168b2e", + "subaccount_id": "0x101411266c6e2b610b4a0324d2bfb2ef0ca6e1dd000000000000000000000000", + "market_id": "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", + "trade_execution_type": "limitMatchRestingOrder", + "trade_direction": "buy", + "price": { + "price": "0.00000000001", + "quantity": "8000000000000000000", + "timestamp": 1701960594997 + }, + "fee": "-9600", + "executed_at": 1701960594997, + "fee_recipient": "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "trade_id": "630_0", + "execution_side": "maker", + "cid": "ec581735-f801-4bf3-9101-282b301bf5cd" + }, + { + "order_hash": "0x87b786072190a2f38e9057987be7bdcb4e2274a6c16fdb9670e5c2ded765140f", + "subaccount_id": "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "market_id": "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", + "trade_execution_type": "limitMatchNewOrder", + "trade_direction": "sell", + "price": { + "price": "0.00000000001", + "quantity": "8000000000000000000", + "timestamp": 1701960594997 + }, + "fee": "160000", + "executed_at": 1701960594997, + "fee_recipient": "inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8", + "trade_id": "630_1", + "execution_side": "taker" } + ], + "paging": { + "total": 4, + "from": 1, + "to": 4 + } +} + +``` + +``` typescript +[ + { + "orderHash": "0xf7b0741b6e6ca6121f7747f662348674efc12e544746caf2d6cd045d6782dcb9", + "subaccountId": "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000", + "marketId": "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", + "tradeExecutionType": "limitMatchRestingOrder", + "tradeDirection": "buy", + "price": { + "price": "0.000000000001880078", + "quantity": "32000000000000000000", + "timestamp": 1653642433329 + }, + "fee": "60162.496", + "executedAt": 1653642433329, + "feeRecipient": "inj1cml96vmptgw99syqrrz8az79xer2pcgp0a885r" + }, + { + "orderHash": "0x6f0be3232ffd084c0377302177c9fcf5caafea412c6c8d2daa352c91bd3c1c3c", + "subaccountId": "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000", + "marketId": "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", + "tradeExecutionType": "limitMatchRestingOrder", + "tradeDirection": "buy", + "price": { + "price": "0.0000000000018405", + "quantity": "26000000000000000000", + "timestamp": 1653631819163 + }, + "fee": "47853", + "executedAt": 1653631819163, + "feeRecipient": "inj1cml96vmptgw99syqrrz8az79xer2pcgp0a885r" + } +] +``` + +| Parameter | Type | Description | +| --------- | --------------- | ---------------------------------- | +| trades | SpotTrade Array | Trades of a particular spot market | +| paging | Paging | Pagination of results | + +**SpotTrade** + +| Parameter | Type | Description | +| -------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------- | +| order_hash | String | The order hash | +| subaccount_id | String | The subaccountId that executed the trade | +| market_id | String | The ID of the market that this trade is in | +| trade_execution_type | String | Execution type of the trade (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | +| trade_direction | String | Direction of the trade(Should be one of: ["buy", "sell"]) | +| price | PriceLevel | Price level at which trade has been executed | +| fee | String | The fee associated with the trade (quote asset denom) | +| executed_at | Integer | Timestamp of trade execution (on chain) in UNIX millis | +| fee_recipient | String | The address that received 40% of the fees | +| trade_id | String | Unique identifier to differentiate between trades | +| execution_side | String | Execution side of trade (Should be one of: ["maker", "taker"]) | +| cid | String | Identifier for the order specified by the user (up to 36 characters, like a UUID) | + + +**PriceLevel** + +| Parameter | Type | Description | +| --------- | ------- | ------------------------------------------------- | +| price | String | Price number of the price level | +| quantity | String | Quantity of the price level | +| timestamp | Integer | Price level last updated timestamp in UNIX millis | + +**Paging** + +| Parameter | Type | Description | +| --------- | ------- | --------------------------------- | +| total | Integer | Total number of records available | + + +## StreamTrades + +Stream newly executed trades of spot markets. The default request streams trades from all spot markets. + +**IP rate limit group:** `indexer` + + +**\*Trade execution types** + +1. `"market"` for market orders +2. `"limitFill"` for a resting limit order getting filled by a market order +3. `"limitMatchRestingOrder"` for a resting limit order getting matched with another new limit order +4. `"limitMatchNewOrder"` for a new limit order getting matched immediately + +### Request Parameters +> Request Example: + +``` python +import asyncio + +from pyinjective.async_client import AsyncClient +from pyinjective.core.network import Network + + +async def main() -> None: + network = Network.testnet() + client = AsyncClient(network) + market_ids = [ + "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "0x7a57e705bb4e09c88aecfc295569481dbf2fe1d5efe364651fbe72385938e9b0", + ] + execution_side = "maker" + direction = "sell" + subaccount_id = "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" + execution_types = ["limitMatchRestingOrder"] + trades = await client.stream_spot_trades( + market_ids=market_ids, + execution_side=execution_side, + direction=direction, + subaccount_id=subaccount_id, + execution_types=execution_types, + ) + async for trade in trades: + print(trade) + + +if __name__ == "__main__": + asyncio.get_event_loop().run_until_complete(main()) + +``` + +``` go +package main + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/InjectiveLabs/sdk-go/client/common" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" +) + +func main() { + // network := common.LoadNetwork("mainnet", "lb") + network := common.LoadNetwork("testnet", "k8s") + exchangeClient, err := exchangeclient.NewExchangeClient(network.ExchangeGrpcEndpoint, common.OptionTLSCert(network.ExchangeTlsCert)) + if err != nil { + fmt.Println(err) + } + + ctx := context.Background() + marketId := "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0" + subaccountId := "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" + + req := spotExchangePB.StreamTradesRequest{ + MarketId: marketId, + SubaccountId: subaccountId, + } + stream, err := exchangeClient.StreamSpotTrades(ctx, req) + if err != nil { + fmt.Println(err) + } + + for { + select { + case <-ctx.Done(): + return + default: + res, err := stream.Recv() + if err != nil { + fmt.Println(err) + return + } + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + } + } +} +``` + +``` typescript +import { + TradeDirection, + PaginationOption, + IndexerGrpcSpotStream, + SpotTradesStreamCallback, +} from "@injectivelabs/sdk-ts"; +import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; + +(async () => { + const endpoints = getNetworkEndpoints(Network.TestnetK8s); + const indexerGrpcSpotStream = new IndexerGrpcSpotStream(endpoints.indexer); + + const marketIds = [ + "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + ]; + const subaccountId = + "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001"; + const direction = TradeDirection.Buy; + const pagination = {} as PaginationOption; + + const streamFn = indexerGrpcSpotStream.streamSpotTrades.bind( + indexerGrpcSpotStream + ); + + const callback: SpotTradesStreamCallback = (trades) => { + console.log(trades); + }; + + const streamFnArgs = { + marketIds, + subaccountId, + direction, + pagination, + callback, + }; + + streamFn(streamFnArgs); +})(); +``` + +| Parameter | Type | Description | Required | +| ------------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------- | -------- | +| market_ids | String Array | Filter by multiple market IDs | No | +| subaccount_ids | String Array | Filter by multiple subaccount IDs | No | +| execution_side | String | Filter by the execution side of the trade (Should be one of: ["maker", "taker"]) | No | +| direction | String | Filter by the direction of the trade (Should be one of: ["buy", "sell"]) | No | +| execution_types | String Array | Filter by the *trade execution type (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | No | +| trade_id | String | Filter by the trade's trade id | No | +| account_address | String | Filter by the account address | No | +| cid | String | Filter by the custom client order id of the trade's order | No | +| pagination | PaginationOption | Pagination configuration | No | +| callback | Function | Function receiving one parameter (a stream event JSON dictionary) to process each new event | Yes | +| on_end_callback | Function | Function with the logic to execute when the stream connection is interrupted | No | +| on_status_callback | Function | Function receiving one parameter (the exception) with the logic to execute when an exception happens | No | + +### Response Parameters +> Streaming Response Example: + +``` python +trade { + order_hash: "0x03b7ac1869cbdead911b2953cd6a0eae119312783b5fbee9db65ad2a53c5ce6d" + subaccount_id: "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" + market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" + trade_execution_type: "limitMatchRestingOrder" + trade_direction: "sell" + price { + price: "0.000000000007523" + quantity: "10000000000000000" + timestamp: 1676015144404 + } + fee: "-7.523" + executed_at: 1676015144404 + fee_recipient: "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt" + trade_id: "8007760_1_0" + execution_side: "maker" +} +operation_type: "insert" +timestamp: 1676015190000 + +trade { + order_hash: "0x03b7ac1869cbdead911b2953cd6a0eae119312783b5fbee9db65ad2a53c5ce6d" + subaccount_id: "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" + market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" + trade_execution_type: "limitMatchRestingOrder" + trade_direction: "sell" + price { + price: "0.000000000007523" + quantity: "10000000000000000" + timestamp: 1676015256701 + } + fee: "-7.523" + executed_at: 1676015256701 + fee_recipient: "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt" + trade_id: "8007808_1_0" + execution_side: "maker" +} +operation_type: "insert" +timestamp: 1676015260000 +``` + +``` go +{ + "trade": { + "order_hash": "0x88e34872af0147f57c8c5a093c3a6a8a97358615bccf975b4a06dfb5162daeaf", + "subaccount_id": "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "market_id": "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", + "trade_execution_type": "market", + "trade_direction": "sell", + "price": { + "price": "0.000000000001654", + "quantity": "1000000000000000000", + "timestamp": 1653042087046 + }, + "fee": "3308", + "executed_at": 1653042087046, + "fee_recipient": "inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8" + }, + "operation_type": "insert", + "timestamp": 1653042089000 +}{ + "trade": { + "order_hash": "0xb5d651a01faa90ec53b0fa34f00f3ecdfe169f9fc35be8114ee113eea9257c30", + "subaccount_id": "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "market_id": "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", + "trade_execution_type": "market", + "trade_direction": "sell", + "price": { + "price": "0.000000000001654", + "quantity": "2000000000000000000", + "timestamp": 1653042093023 + }, + "fee": "6616", + "executed_at": 1653042093023, + "fee_recipient": "inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8" + }, + "operation_type": "insert", + "timestamp": 1653042098000 +} +``` + +``` typescript +{ + "trade": { + "orderHash": "0xedf6203fce7e3391052ddd8244385b267ddbe81aebd90724cde09c0c1b4af73b", + "subaccountId": "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "marketId": "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", + "tradeExecutionType": "market", + "tradeDirection": "sell", + "price": { + "price": "0.000000000003", + "quantity": "1000000000000000000", + "timestamp": 1654080019844 + }, + "fee": "6000", + "executedAt": 1654080019844, + "feeRecipient": "inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8" + }, + "operationType": "insert", + "timestamp": 1654080026000 +} +{ + "trade": { + "orderHash": "0xac596cc795ba91dc8f10b6d251e211679f908be04f8becca566210fab20bfd2f", + "subaccountId": "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "marketId": "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", + "tradeExecutionType": "market", + "tradeDirection": "sell", + "price": { + "price": "0.000000000003", + "quantity": "49000000000000000000", + "timestamp": 1654080025588 + }, + "fee": "294000", + "executedAt": 1654080025588, + "feeRecipient": "inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8" + }, + "operationType": "insert", + "timestamp": 1654080028000 +} +``` + +| Parameter | Type | Description | +| -------------- | --------- | ------------------------------------------------------------------- | +| trade | SpotTrade | New spot market trade | +| operation_type | String | Trade operation type (Should be one of: ["insert", "invalidate"]) | +| timestamp | Integer | Timestamp the new trade is written into the database in UNIX millis | + +**SpotTrade** + +| Parameter | Type | Description | +| -------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------- | +| order_hash | String | The order hash | +| subaccount_id | String | The subaccountId that executed the trade | +| market_id | String | The ID of the market that this trade is in | +| trade_execution_type | String | Execution type of the trade (Should be one of: ["market", "limitFill", "limitMatchRestingOrder", "limitMatchNewOrder"]) | +| trade_direction | String | Direction of the trade(Should be one of: ["buy", "sell"]) | +| price | PriceLevel | Price level at which trade has been executed | +| fee | String | The fee associated with the trade (quote asset denom) | +| executed_at | Integer | Timestamp of trade execution (on chain) in UNIX millis | +| fee_recipient | String | The address that received 40% of the fees | +| trade_id | String | Unique identifier to differentiate between trades | +| execution_side | String | Execution side of trade (Should be one of: ["maker", "taker"]) | +| cid | String | Identifier for the order specified by the user (up to 36 characters, like a UUID) | + + +**PriceLevel** + +| Parameter | Type | Description | +| --------- | ------- | ------------------------------------------------- | +| price | String | Price number of the price level | +| quantity | String | Quantity of the price level | +| timestamp | Integer | Price level last updated timestamp in UNIX millis | + + +## StreamTradesV2 + +Stream newly executed trades of spot markets. The default request streams trades from all spot markets. +The difference between `StreamTrades` and `StreamTradesV2` is that the latter returns a `trade_id` compatible witht the one used for trade events in chain stream. + +**IP rate limit group:** `indexer` + + +**\*Trade execution types** + +1. `"market"` for market orders +2. `"limitFill"` for a resting limit order getting filled by a market order +3. `"limitMatchRestingOrder"` for a resting limit order getting matched with another new limit order +4. `"limitMatchNewOrder"` for a new limit order getting matched immediately + +### Request Parameters +> Request Example: + +``` python +import asyncio +from typing import Any, Dict + +from grpc import RpcError + +from pyinjective.async_client import AsyncClient +from pyinjective.core.network import Network + + +async def trade_event_processor(event: Dict[str, Any]): + print(event) + + +def stream_error_processor(exception: RpcError): + print(f"There was an error listening to spot trades updates ({exception})") + + +def stream_closed_processor(): + print("The spot trades updates stream has been closed") + + +async def main() -> None: + network = Network.testnet() + client = AsyncClient(network) + market_ids = [ + "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "0x7a57e705bb4e09c88aecfc295569481dbf2fe1d5efe364651fbe72385938e9b0", + ] + execution_side = "maker" + direction = "sell" + subaccount_id = "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" + execution_types = ["limitMatchRestingOrder"] + + task = asyncio.get_event_loop().create_task( + client.listen_spot_trades_updates( + callback=trade_event_processor, + on_end_callback=stream_closed_processor, + on_status_callback=stream_error_processor, + market_ids=market_ids, + subaccount_ids=[subaccount_id], + execution_side=execution_side, + direction=direction, + execution_types=execution_types, + ) + ) + + await asyncio.sleep(delay=60) + task.cancel() + + +if __name__ == "__main__": + asyncio.get_event_loop().run_until_complete(main()) + +``` + +``` go +package main + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/InjectiveLabs/sdk-go/client/common" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + exchangeClient, err := exchangeclient.NewExchangeClient(network) + if err != nil { + fmt.Println(err) + } + + ctx := context.Background() + marketId := "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0" + subaccountId := "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" + + req := spotExchangePB.StreamTradesV2Request{ + MarketId: marketId, + SubaccountId: subaccountId, + } + stream, err := exchangeClient.StreamSpotTradesV2(ctx, req) + if err != nil { + fmt.Println(err) + } + + for { + select { + case <-ctx.Done(): + return + default: + res, err := stream.Recv() + if err != nil { + fmt.Println(err) + return + } + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + } + } } + ``` ``` typescript -import { - TradeDirection, - PaginationOption, - IndexerGrpcSpotStream, - SpotTradesStreamCallback, -} from "@injectivelabs/sdk-ts"; -import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; - -(async () => { - const endpoints = getNetworkEndpoints(Network.TestnetK8s); - const indexerGrpcSpotStream = new IndexerGrpcSpotStream(endpoints.indexer); - - const marketIds = [ - "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", - ]; - const subaccountId = - "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001"; - const direction = TradeDirection.Buy; - const pagination = {} as PaginationOption; - - const streamFn = indexerGrpcSpotStream.streamSpotTrades.bind( - indexerGrpcSpotStream - ); - - const callback: SpotTradesStreamCallback = (trades) => { - console.log(trades); - }; - - const streamFnArgs = { - marketIds, - subaccountId, - direction, - pagination, - callback, - }; - streamFn(streamFnArgs); -})(); ``` | Parameter | Type | Description | Required | @@ -1863,45 +2591,50 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Streaming Response Example: ``` python -trade { - order_hash: "0x03b7ac1869cbdead911b2953cd6a0eae119312783b5fbee9db65ad2a53c5ce6d" - subaccount_id: "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" - market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - trade_execution_type: "limitMatchRestingOrder" - trade_direction: "sell" - price { - price: "0.000000000007523" - quantity: "10000000000000000" - timestamp: 1676015144404 - } - fee: "-7.523" - executed_at: 1676015144404 - fee_recipient: "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt" - trade_id: "8007760_1_0" - execution_side: "maker" +{ + "trade":{ + "orderHash":"0xa7f4a7d85136d97108d271caadd93bf697ff965790e0e1558617b953cced4adc", + "subaccountId":"0x3db1f84431dfe4df617f9eb2d04edf432beb9826000000000000000000000000", + "marketId":"0x01edfab47f124748dc89998eb33144af734484ba07099014594321729a0ca16b", + "tradeExecutionType":"limitMatchNewOrder", + "tradeDirection":"sell", + "price":{ + "price":"0.00000000001", + "quantity":"1000000000000000000", + "timestamp":"1701978102242" + }, + "fee":"10000", + "executedAt":"1701978102242", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"22868_1", + "executionSide":"taker", + "cid":"96866b8b-02dd-4288-97d3-e5254e4999d4" + }, + "operationType":"insert", + "timestamp":"1701978103000" } -operation_type: "insert" -timestamp: 1676015190000 - -trade { - order_hash: "0x03b7ac1869cbdead911b2953cd6a0eae119312783b5fbee9db65ad2a53c5ce6d" - subaccount_id: "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" - market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - trade_execution_type: "limitMatchRestingOrder" - trade_direction: "sell" - price { - price: "0.000000000007523" - quantity: "10000000000000000" - timestamp: 1676015256701 - } - fee: "-7.523" - executed_at: 1676015256701 - fee_recipient: "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt" - trade_id: "8007808_1_0" - execution_side: "maker" +{ + "trade":{ + "orderHash":"0x952bb14a7a377697d724c60d6077ef3dfe894c98f854970fab187247be832b6f", + "subaccountId":"0x101411266c6e2b610b4a0324d2bfb2ef0ca6e1dd000000000000000000000000", + "marketId":"0x01edfab47f124748dc89998eb33144af734484ba07099014594321729a0ca16b", + "tradeExecutionType":"limitMatchRestingOrder", + "tradeDirection":"buy", + "price":{ + "price":"0.00000000001", + "quantity":"1000000000000000000", + "timestamp":"1701978102242" + }, + "fee":"-600", + "executedAt":"1701978102242", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "tradeId":"22868_0", + "executionSide":"maker", + "cid":"96866b8b-02dd-4288-97d3-e5254e4888b3" + }, + "operationType":"insert", + "timestamp":"1701978103000" } -operation_type: "insert" -timestamp: 1676015260000 ``` ``` go @@ -1945,44 +2678,6 @@ timestamp: 1676015260000 ``` ``` typescript -{ - "trade": { - "orderHash": "0xedf6203fce7e3391052ddd8244385b267ddbe81aebd90724cde09c0c1b4af73b", - "subaccountId": "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", - "marketId": "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", - "tradeExecutionType": "market", - "tradeDirection": "sell", - "price": { - "price": "0.000000000003", - "quantity": "1000000000000000000", - "timestamp": 1654080019844 - }, - "fee": "6000", - "executedAt": 1654080019844, - "feeRecipient": "inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8" - }, - "operationType": "insert", - "timestamp": 1654080026000 -} -{ - "trade": { - "orderHash": "0xac596cc795ba91dc8f10b6d251e211679f908be04f8becca566210fab20bfd2f", - "subaccountId": "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", - "marketId": "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", - "tradeExecutionType": "market", - "tradeDirection": "sell", - "price": { - "price": "0.000000000003", - "quantity": "49000000000000000000", - "timestamp": 1654080025588 - }, - "fee": "294000", - "executedAt": 1654080025588, - "feeRecipient": "inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8" - }, - "operationType": "insert", - "timestamp": 1654080028000 -} ``` | Parameter | Type | Description | @@ -2908,53 +3603,62 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -orderbooks { - market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - orderbook { - buys { - price: "0.000000000006057" - quantity: "38000000000000000000" - timestamp: 1652395483345 - } - buys { - price: "0.000000000005643" - quantity: "8000000000000000000" - timestamp: 1652340918434 - } - sells { - price: "0.000000000008102" - quantity: "50000000000000000000" - timestamp: 1652773614923 - } - sells { - price: "0.000000000008108" - quantity: "48000000000000000000" - timestamp: 1652774630240 - sequence: 512 -orderbooks { - market_id: "0x7a57e705bb4e09c88aecfc295569481dbf2fe1d5efe364651fbe72385938e9b0" - orderbook { - buys { - price: "0.000000000001654" - quantity: "27000000000000000000" - timestamp: 1652395260912 - } - buys { - price: "0.000000000001608" - quantity: "38000000000000000000" - timestamp: 1652351094680 - sells { - price: "0.00000000002792" - quantity: "30000000000000000" - timestamp: 1652263504751 - } - sells { - price: "0.0000000003" - quantity: "220000000000000000000" - timestamp: 1652264026293 - } - sequence: 711 - } +{ + "orderbooks":[ + { + "marketId":"0x7a57e705bb4e09c88aecfc295569481dbf2fe1d5efe364651fbe72385938e9b0", + "orderbook":{ + "sells":[ + { + "price":"0.000000000005", + "quantity":"27767884000000000000000", + "timestamp":"1694702425539" + }, + { + "price":"0.0000000000045", + "quantity":"3519999000000000000000000", + "timestamp":"1694424758707" + } + ], + "timestamp":"-62135596800000", + "buys":[ + + ], + "sequence":"0" + } + }, + { + "marketId":"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "orderbook":{ + "buys":[ + { + "price":"0.000000000073489", + "quantity":"129000000000000000", + "timestamp":"1702042963690" + }, + { + "price":"0.000000000064261", + "quantity":"1292000000000000000", + "timestamp":"1702039612697" + } + ], + "sells":[ + { + "price":"0.000000000085", + "quantity":"6693248000000000000000", + "timestamp":"1702044317059" + }, + { + "price":"0.000000000085768", + "quantity":"581000000000000000", + "timestamp":"1701944786578" + } + ], + "sequence":"6916386", + "timestamp":"1702044336800" + } + } + ] } ``` @@ -3486,47 +4190,39 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Streaming Response Example: ``` python -orderbook { - buys { - price: "0.000000000007" - quantity: "1000000000000000000" - timestamp: 1675904400063 - } - buys { - price: "0.000000000001" - quantity: "10000000000000000" - timestamp: 1675882430039 - } - buys { - price: "0.000000000000001" - quantity: "17983000000000000000" - timestamp: 1675880932648 - } - sells { - price: "0.000000000007523" - quantity: "20000000000000000" - timestamp: 1676610722671 - } - sells { - price: "0.000000000007525" - quantity: "10000000000000000" - timestamp: 1676015247335 - } - sells { - price: "0.000000000007526" - quantity: "50000000000000000" - timestamp: 1676089482358 - } - sells { - price: "0.000000000008" - quantity: "10000000000000000" - timestamp: 1675904636889 - } - sequence: 713 +{ + "orderbook":{ + "buys":[ + { + "price":"0.000000000073489", + "quantity":"129000000000000000", + "timestamp":"1702042963690" + }, + { + "price":"0.000000000064261", + "quantity":"1292000000000000000", + "timestamp":"1702039612697" + } + ], + "sells":[ + { + "price":"0.000000000085", + "quantity":"6681507000000000000000", + "timestamp":"1702044411262" + }, + { + "price":"0.000000000085768", + "quantity":"581000000000000000", + "timestamp":"1701944786578" + } + ], + "sequence":"6916434", + "timestamp":"1702044439698" + }, + "operationType":"update", + "timestamp":"1702044441000", + "marketId":"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" } -operation_type: "update" -timestamp: 1676610727000 -market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" ``` ``` go @@ -3995,52 +4691,50 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -orders { - order_hash: "0x982d82c58a3e96680915636c9a5fe6b25af8581ceec19087f611a96e1d73b79e" - order_side: "sell" - market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - subaccount_id: "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" - price: "0.000000000008" - quantity: "10000000000000000" - unfilled_quantity: "10000000000000000" - trigger_price: "0" - fee_recipient: "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt" - state: "booked" - created_at: 1675904636889 - updated_at: 1675904636889 -} -orders { - order_hash: "0x2c497f2a6e62fc4a3db39f6483d2dac797b9345d1033738ee316136611c7951c" - order_side: "buy" - market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - subaccount_id: "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" - price: "0.000000000007" - quantity: "1000000000000000000" - unfilled_quantity: "1000000000000000000" - trigger_price: "0" - fee_recipient: "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt" - state: "booked" - created_at: 1675904400063 - updated_at: 1675904400063 -} -orders { - order_hash: "0xd567b9d5b3dde5d37980f8aa7110be94163d016978ca5614a373d0ad5326a96b" - order_side: "buy" - market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - subaccount_id: "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001" - price: "0.000000000001" - quantity: "10000000000000000" - unfilled_quantity: "10000000000000000" - trigger_price: "0" - fee_recipient: "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt" - state: "booked" - created_at: 1675882430039 - updated_at: 1675882430039 -} -paging { - total: 13 - from: 11 - to: 13 +{ + "orders":[ + { + "orderHash":"0x3414f6f1a37a864166b19930680eb62a99798b5e406c2d14ed1ee66ab9958503", + "orderSide":"buy", + "marketId":"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "subaccountId":"0xbdaedec95d563fb05240d6e01821008454c24c36000000000000000000000000", + "price":"0.000000000003", + "quantity":"55000000000000000000", + "unfilledQuantity":"55000000000000000000", + "triggerPrice":"0", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "state":"booked", + "createdAt":"1701808096494", + "updatedAt":"1701808096494", + "txHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "cid":"670c52ec-f68f-456c-8aeb-e271071a43ac" + }, + { + "orderHash":"0xb7b6d54d1e01e1eb0005e34e08a96b715b557eeee7c5f3a439636f98ddd66b91", + "orderSide":"buy", + "marketId":"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "subaccountId":"0xbdaedec95d563fb05240d6e01821008454c24c36000000000000000000000000", + "price":"0.000000000003", + "quantity":"55000000000000000000", + "unfilledQuantity":"55000000000000000000", + "triggerPrice":"0", + "feeRecipient":"inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", + "state":"booked", + "createdAt":"1701808058512", + "updatedAt":"1701808058512", + "txHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "cid":"bba97476-e7f4-4313-874b-7ef115daccb4" + } + ], + "paging":{ + "total":"53", + "from":1, + "to":2, + "countBySubaccount":"0", + "next":[ + + ] + } } ``` @@ -4330,56 +5024,63 @@ import { getNetworkEndpoints, Network } from "@injectivelabs/networks"; > Response Example: ``` python -trades { - order_hash: "0x5ff08b7fe885b62aaaadb0c8b8877d9031d39fd67a1b94bc19da34e3be48238f" - subaccount_id: "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - trade_execution_type: "market" - trade_direction: "buy" - price { - price: "0.000000000055" - quantity: "182000000000000000" - timestamp: 1673343614891 - } - fee: "10010" - executed_at: 1673343614891 - fee_recipient: "inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8" - trade_id: "6858954_5ff08b7fe885b62aaaadb0c8b8877d9031d39fd67a1b94bc19da34e3be48238f" - execution_side: "taker" -} -trades { - order_hash: "0x38d614f920c8ab577eb7ab8ed1f1c452e4aeba9b69885ec1e8b308052957174d" - subaccount_id: "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - trade_execution_type: "market" - trade_direction: "buy" - price { - price: "0.000000000055" - quantity: "1544000000000000000" - timestamp: 1673343521906 - } - fee: "84920" - executed_at: 1673343521906 - fee_recipient: "inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8" - trade_id: "6858914_38d614f920c8ab577eb7ab8ed1f1c452e4aeba9b69885ec1e8b308052957174d" - execution_side: "taker" -} -trades { - order_hash: "0xfe1a82268e2147ba359092a751fd4e3ee375d1887bf1fa00de5ece88764bd7f5" - subaccount_id: "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - market_id: "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - trade_execution_type: "market" - trade_direction: "buy" - price { - price: "0.000000000055" - quantity: "1816000000000000000" - timestamp: 1673343487116 - } - fee: "99880" - executed_at: 1673343487116 - fee_recipient: "inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8" - trade_id: "6858899_fe1a82268e2147ba359092a751fd4e3ee375d1887bf1fa00de5ece88764bd7f5" - execution_side: "taker" +{ + "trades":[ + { + "orderHash":"0x6dfd01151a5b3cfb3a61777335f0d8d324a479b9006fd9642f52b402aec53d4f", + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "marketId":"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "tradeExecutionType":"market", + "tradeDirection":"buy", + "price":{ + "price":"0.000000000015589", + "quantity":"1000000000000000", + "timestamp":"1700675201676" + }, + "fee":"10.9123", + "executedAt":"1700675201676", + "feeRecipient":"inj1zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3t5qxqh", + "tradeId":"18740619_240_0", + "executionSide":"taker", + "cid":"" + }, + { + "orderHash":"0x6a6cd0afb038322b67a88cd827e2800483e3571c5e82663df37a33770fa0a8d1", + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "marketId":"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "tradeExecutionType":"market", + "tradeDirection":"buy", + "price":{ + "price":"0.000000000015742", + "quantity":"1000000000000000", + "timestamp":"1700232025894" + }, + "fee":"11.0194", + "executedAt":"1700232025894", + "feeRecipient":"inj1zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3t5qxqh", + "tradeId":"18529043_240_0", + "executionSide":"taker", + "cid":"" + }, + { + "orderHash":"0xa3049ebaa97ac3755c09bd53ea30e86b98aef40bf037cb9d91dedfc1fd4b7735", + "subaccountId":"0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000", + "marketId":"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", + "tradeExecutionType":"limitMatchNewOrder", + "tradeDirection":"buy", + "price":{ + "price":"0.000000000015874", + "quantity":"21000000000000000000", + "timestamp":"1700221121919" + }, + "fee":"233347.8", + "executedAt":"1700221121919", + "feeRecipient":"inj1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8dkncm8", + "tradeId":"18523837_243_0", + "executionSide":"taker", + "cid":"" + } + ] } ``` From fbcd3e2c45bca2afa91cad3e174b1b2677c50169 Mon Sep 17 00:00:00 2001 From: abel Date: Sun, 31 Dec 2023 00:29:13 -0300 Subject: [PATCH 3/4] (fix) Solve issue in build workflow with middleman dependencies for different Ruby versions --- .github/workflows/build.yml | 40 +++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d84f52dc..aa5b02ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,8 +11,9 @@ jobs: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - ruby-version: [2.6, 2.7, 3.0] + ruby-version: [2.7, 3.2] # Removed version 3.3 for now because it started to fail due to dependencies issue steps: - uses: actions/checkout@v2 @@ -20,23 +21,24 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} - - - uses: actions/cache@v2 - with: - path: vendor/bundle - key: gems-${{ runner.os }}-${{ matrix.ruby-version }}-${{ hashFiles('**/Gemfile.lock') }} - restore-keys: | - gems-${{ runner.os }}-${{ matrix.ruby-version }}- - gems-${{ runner.os }}- - - # necessary to get ruby 2.3 to work nicely with bundler vendor/bundle cache - # can remove once ruby 2.3 is no longer supported - # - run: gem update --system - - - run: bundle config set deployment 'true' - - name: bundle install - run: | - bundle config path vendor/bundle - bundle install --jobs 4 --retry 3 + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + + # Commenting out the use of cache@v2 because we start using the `bundler-cache` option from setup-ruby@v1 + # - uses: actions/cache@v2 + # with: + # path: vendor/bundle + # key: gems-${{ runner.os }}-${{ matrix.ruby-version }}-${{ hashFiles('**/Gemfile.lock') }} + # restore-keys: | + # gems-${{ runner.os }}-${{ matrix.ruby-version }}- + # gems-${{ runner.os }}- + + # Commenting out the configuration of `deployment` option because setup-ruby@v1 used this option by default if a Gemfile.lock is present + # - run: bundle config set deployment 'true' + + # Commenting out the bundle install step because it is executed by setup-ruby@v1 + # - name: bundle install + # run: | + # bundle config path vendor/bundle + # bundle install --jobs 4 --retry 3 - run: bundle exec middleman build From a6516ab8bb3ddacfff8ba6cdd100c116e4242169 Mon Sep 17 00:00:00 2001 From: abel Date: Sun, 31 Dec 2023 00:38:19 -0300 Subject: [PATCH 4/4] (fix) Replicated changes in build workflow into the deploy workflows --- .github/workflows/deploy.yml | 17 ++--------------- .github/workflows/dev_deploy.yml | 17 ++--------------- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a8c5f455..c837dd41 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -8,7 +8,7 @@ jobs: deploy: runs-on: ubuntu-latest env: - ruby-version: 2.6 + ruby-version: 2.7 steps: - uses: actions/checkout@v2 @@ -16,20 +16,7 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: ${{ env.ruby-version }} - - - uses: actions/cache@v2 - with: - path: vendor/bundle - key: gems-${{ runner.os }}-${{ env.ruby-version }}-${{ hashFiles('**/Gemfile.lock') }} - restore-keys: | - gems-${{ runner.os }}-${{ env.ruby-version }}- - gems-${{ runner.os }}- - - - run: bundle config set deployment 'true' - - name: bundle install - run: | - bundle config path vendor/bundle - bundle install --jobs 4 --retry 3 + bundler-cache: true # runs 'bundle install' and caches installed gems automatically - run: bundle exec middleman build diff --git a/.github/workflows/dev_deploy.yml b/.github/workflows/dev_deploy.yml index 5b64bfde..08fa0296 100644 --- a/.github/workflows/dev_deploy.yml +++ b/.github/workflows/dev_deploy.yml @@ -8,7 +8,7 @@ jobs: deploy: runs-on: ubuntu-latest env: - ruby-version: 2.6 + ruby-version: 2.7 steps: - uses: actions/checkout@v2 @@ -16,20 +16,7 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: ${{ env.ruby-version }} - - - uses: actions/cache@v2 - with: - path: vendor/bundle - key: gems-${{ runner.os }}-${{ env.ruby-version }}-${{ hashFiles('**/Gemfile.lock') }} - restore-keys: | - gems-${{ runner.os }}-${{ env.ruby-version }}- - gems-${{ runner.os }}- - - - run: bundle config set deployment 'true' - - name: bundle install - run: | - bundle config path vendor/bundle - bundle install --jobs 4 --retry 3 + bundler-cache: true # runs 'bundle install' and caches installed gems automatically - run: bundle exec middleman build