diff --git a/examples/chain_client/7_ChainStream.py b/examples/chain_client/7_ChainStream.py index b38933d7..b4aaf612 100644 --- a/examples/chain_client/7_ChainStream.py +++ b/examples/chain_client/7_ChainStream.py @@ -8,7 +8,8 @@ async def chain_stream_event_processor(event: Dict[str, Any]): - print(event) + for funding_update in event["marketFundingUpdates"]: + print(funding_update) def stream_error_processor(exception: RpcError): @@ -20,41 +21,16 @@ def stream_closed_processor(): async def main() -> None: - network = Network.testnet() + network = Network.mainnet() client = AsyncClient(network) composer = await client.composer() - subaccount_id = "0xbdaedec95d563fb05240d6e01821008454c24c36000000000000000000000000" + btc_usdc_perp_market = "0x0ee7ca44147bab6ec81ac293b5fe7915488e612af59964b2d663d6008d861dee" + inj_usdc_perp_market = "0x790aee464fbbd02cf4476444554c71d1225f7edfe15e6dc7f874c455fd883d31" - inj_usdt_market = "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" - inj_usdt_perp_market = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" - - bank_balances_filter = composer.chain_stream_bank_balances_filter( - accounts=["inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"] - ) - subaccount_deposits_filter = composer.chain_stream_subaccount_deposits_filter(subaccount_ids=[subaccount_id]) - spot_trades_filter = composer.chain_stream_trades_filter(subaccount_ids=["*"], market_ids=[inj_usdt_market]) - derivative_trades_filter = composer.chain_stream_trades_filter( - subaccount_ids=["*"], market_ids=[inj_usdt_perp_market] - ) - spot_orders_filter = composer.chain_stream_orders_filter( - subaccount_ids=[subaccount_id], market_ids=[inj_usdt_market] - ) - derivative_orders_filter = composer.chain_stream_orders_filter( - subaccount_ids=[subaccount_id], market_ids=[inj_usdt_perp_market] - ) - spot_orderbooks_filter = composer.chain_stream_orderbooks_filter(market_ids=[inj_usdt_market]) - derivative_orderbooks_filter = composer.chain_stream_orderbooks_filter(market_ids=[inj_usdt_perp_market]) - positions_filter = composer.chain_stream_positions_filter( - subaccount_ids=[subaccount_id], market_ids=[inj_usdt_perp_market] - ) - oracle_price_filter = composer.chain_stream_oracle_price_filter(symbols=["INJ", "USDT"]) - order_failures_filter = composer.chain_stream_order_failures_filter( - accounts=["inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"] - ) - conditional_order_trigger_failures_filter = composer.chain_stream_conditional_order_trigger_failures_filter( - subaccount_ids=[subaccount_id], market_ids=[inj_usdt_perp_market] + market_funding_filter = composer.chain_stream_market_funding_filter( + market_ids=[btc_usdc_perp_market, inj_usdc_perp_market] ) task = asyncio.get_event_loop().create_task( @@ -62,18 +38,7 @@ async def main() -> None: 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, - order_failures_filter=order_failures_filter, - conditional_order_trigger_failures_filter=conditional_order_trigger_failures_filter, + market_funding_filter=market_funding_filter, ) ) @@ -82,4 +47,4 @@ async def main() -> None: if __name__ == "__main__": - asyncio.get_event_loop().run_until_complete(main()) + asyncio.run(main()) diff --git a/pyinjective/async_client_v2.py b/pyinjective/async_client_v2.py index 34a4142b..0475955e 100644 --- a/pyinjective/async_client_v2.py +++ b/pyinjective/async_client_v2.py @@ -963,6 +963,7 @@ async def listen_chain_stream_updates( conditional_order_trigger_failures_filter: Optional[ chain_stream_v2_query.ConditionalOrderTriggerFailuresFilter ] = None, + market_funding_filter: Optional[chain_stream_v2_query.MarketFundingFilter] = None, ): return await self.chain_stream_api.stream_v2( callback=callback, @@ -980,6 +981,7 @@ async def listen_chain_stream_updates( oracle_price_filter=oracle_price_filter, order_failures_filter=order_failures_filter, conditional_order_trigger_failures_filter=conditional_order_trigger_failures_filter, + market_funding_filter=market_funding_filter, ) # region IBC Transfer module @@ -1457,9 +1459,11 @@ async def _initialize_tokens_and_markets(self): Decimal(market_info["minQuantityTickSize"]) ), min_notional=Token.convert_value_from_extended_decimal_format(Decimal(market_info["minNotional"])), - settlement_price=None - if market_info["settlementPrice"] == "" - else Token.convert_value_from_extended_decimal_format(Decimal(market_info["settlementPrice"])), + settlement_price=( + None + if market_info["settlementPrice"] == "" + else Token.convert_value_from_extended_decimal_format(Decimal(market_info["settlementPrice"])) + ), ) binary_option_markets[market.id] = market diff --git a/pyinjective/client/chain/grpc_stream/chain_grpc_chain_stream.py b/pyinjective/client/chain/grpc_stream/chain_grpc_chain_stream.py index 8f871309..502cf873 100644 --- a/pyinjective/client/chain/grpc_stream/chain_grpc_chain_stream.py +++ b/pyinjective/client/chain/grpc_stream/chain_grpc_chain_stream.py @@ -79,6 +79,7 @@ async def stream_v2( conditional_order_trigger_failures_filter: Optional[ chain_stream_v2_pb.ConditionalOrderTriggerFailuresFilter ] = None, + market_funding_filter: Optional[chain_stream_v2_pb.MarketFundingFilter] = None, ): request = chain_stream_v2_pb.StreamRequest( bank_balances_filter=bank_balances_filter, @@ -93,6 +94,7 @@ async def stream_v2( oracle_price_filter=oracle_price_filter, order_failures_filter=order_failures_filter, conditional_order_trigger_failures_filter=conditional_order_trigger_failures_filter, + market_funding_filter=market_funding_filter, ) await self._assistant.listen_stream( diff --git a/pyinjective/composer_v2.py b/pyinjective/composer_v2.py index 1d64e7e8..8e8af7b7 100644 --- a/pyinjective/composer_v2.py +++ b/pyinjective/composer_v2.py @@ -1670,6 +1670,13 @@ def chain_stream_conditional_order_trigger_failures_filter( subaccount_ids=subaccount_ids, market_ids=market_ids ) + def chain_stream_market_funding_filter( + self, + market_ids: Optional[List[str]] = None, + ) -> chain_stream_v2_query.MarketFundingFilter: + market_ids = market_ids or ["*"] + return chain_stream_v2_query.MarketFundingFilter(market_ids=market_ids) + # endregion # ------------------------------------------------ diff --git a/pyinjective/proto/injective/stream/v2/query_pb2.py b/pyinjective/proto/injective/stream/v2/query_pb2.py index 0344aa22..d1866aa6 100644 --- a/pyinjective/proto/injective/stream/v2/query_pb2.py +++ b/pyinjective/proto/injective/stream/v2/query_pb2.py @@ -16,10 +16,11 @@ from pyinjective.proto.gogoproto import gogo_pb2 as gogoproto_dot_gogo__pb2 from pyinjective.proto.injective.exchange.v2 import events_pb2 as injective_dot_exchange_dot_v2_dot_events__pb2 from pyinjective.proto.injective.exchange.v2 import exchange_pb2 as injective_dot_exchange_dot_v2_dot_exchange__pb2 +from pyinjective.proto.injective.exchange.v2 import market_pb2 as injective_dot_exchange_dot_v2_dot_market__pb2 from pyinjective.proto.injective.exchange.v2 import order_pb2 as injective_dot_exchange_dot_v2_dot_order__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1finjective/stream/v2/query.proto\x12\x13injective.stream.v2\x1a\x1e\x63osmos/base/v1beta1/coin.proto\x1a\x14gogoproto/gogo.proto\x1a\"injective/exchange/v2/events.proto\x1a$injective/exchange/v2/exchange.proto\x1a!injective/exchange/v2/order.proto\"\xdd\t\n\rStreamRequest\x12_\n\x14\x62\x61nk_balances_filter\x18\x01 \x01(\x0b\x32\'.injective.stream.v2.BankBalancesFilterB\x04\xc8\xde\x1f\x01R\x12\x62\x61nkBalancesFilter\x12q\n\x1asubaccount_deposits_filter\x18\x02 \x01(\x0b\x32-.injective.stream.v2.SubaccountDepositsFilterB\x04\xc8\xde\x1f\x01R\x18subaccountDepositsFilter\x12U\n\x12spot_trades_filter\x18\x03 \x01(\x0b\x32!.injective.stream.v2.TradesFilterB\x04\xc8\xde\x1f\x01R\x10spotTradesFilter\x12\x61\n\x18\x64\x65rivative_trades_filter\x18\x04 \x01(\x0b\x32!.injective.stream.v2.TradesFilterB\x04\xc8\xde\x1f\x01R\x16\x64\x65rivativeTradesFilter\x12U\n\x12spot_orders_filter\x18\x05 \x01(\x0b\x32!.injective.stream.v2.OrdersFilterB\x04\xc8\xde\x1f\x01R\x10spotOrdersFilter\x12\x61\n\x18\x64\x65rivative_orders_filter\x18\x06 \x01(\x0b\x32!.injective.stream.v2.OrdersFilterB\x04\xc8\xde\x1f\x01R\x16\x64\x65rivativeOrdersFilter\x12`\n\x16spot_orderbooks_filter\x18\x07 \x01(\x0b\x32$.injective.stream.v2.OrderbookFilterB\x04\xc8\xde\x1f\x01R\x14spotOrderbooksFilter\x12l\n\x1c\x64\x65rivative_orderbooks_filter\x18\x08 \x01(\x0b\x32$.injective.stream.v2.OrderbookFilterB\x04\xc8\xde\x1f\x01R\x1a\x64\x65rivativeOrderbooksFilter\x12U\n\x10positions_filter\x18\t \x01(\x0b\x32$.injective.stream.v2.PositionsFilterB\x04\xc8\xde\x1f\x01R\x0fpositionsFilter\x12\\\n\x13oracle_price_filter\x18\n \x01(\x0b\x32&.injective.stream.v2.OraclePriceFilterB\x04\xc8\xde\x1f\x01R\x11oraclePriceFilter\x12\x62\n\x15order_failures_filter\x18\x0b \x01(\x0b\x32(.injective.stream.v2.OrderFailuresFilterB\x04\xc8\xde\x1f\x01R\x13orderFailuresFilter\x12\x9a\x01\n)conditional_order_trigger_failures_filter\x18\x0c \x01(\x0b\x32:.injective.stream.v2.ConditionalOrderTriggerFailuresFilterB\x04\xc8\xde\x1f\x01R%conditionalOrderTriggerFailuresFilter\"\xe5\x08\n\x0eStreamResponse\x12!\n\x0c\x62lock_height\x18\x01 \x01(\x04R\x0b\x62lockHeight\x12\x1d\n\nblock_time\x18\x02 \x01(\x03R\tblockTime\x12\x45\n\rbank_balances\x18\x03 \x03(\x0b\x32 .injective.stream.v2.BankBalanceR\x0c\x62\x61nkBalances\x12X\n\x13subaccount_deposits\x18\x04 \x03(\x0b\x32\'.injective.stream.v2.SubaccountDepositsR\x12subaccountDeposits\x12?\n\x0bspot_trades\x18\x05 \x03(\x0b\x32\x1e.injective.stream.v2.SpotTradeR\nspotTrades\x12Q\n\x11\x64\x65rivative_trades\x18\x06 \x03(\x0b\x32$.injective.stream.v2.DerivativeTradeR\x10\x64\x65rivativeTrades\x12\x45\n\x0bspot_orders\x18\x07 \x03(\x0b\x32$.injective.stream.v2.SpotOrderUpdateR\nspotOrders\x12W\n\x11\x64\x65rivative_orders\x18\x08 \x03(\x0b\x32*.injective.stream.v2.DerivativeOrderUpdateR\x10\x64\x65rivativeOrders\x12Z\n\x16spot_orderbook_updates\x18\t \x03(\x0b\x32$.injective.stream.v2.OrderbookUpdateR\x14spotOrderbookUpdates\x12\x66\n\x1c\x64\x65rivative_orderbook_updates\x18\n \x03(\x0b\x32$.injective.stream.v2.OrderbookUpdateR\x1a\x64\x65rivativeOrderbookUpdates\x12;\n\tpositions\x18\x0b \x03(\x0b\x32\x1d.injective.stream.v2.PositionR\tpositions\x12\x45\n\roracle_prices\x18\x0c \x03(\x0b\x32 .injective.stream.v2.OraclePriceR\x0coraclePrices\x12\x1b\n\tgas_price\x18\r \x01(\tR\x08gasPrice\x12N\n\x0eorder_failures\x18\x0e \x03(\x0b\x32\'.injective.stream.v2.OrderFailureUpdateR\rorderFailures\x12\x86\x01\n\"conditional_order_trigger_failures\x18\x0f \x03(\x0b\x32\x39.injective.stream.v2.ConditionalOrderTriggerFailureUpdateR\x1f\x63onditionalOrderTriggerFailures\"a\n\x0fOrderbookUpdate\x12\x10\n\x03seq\x18\x01 \x01(\x04R\x03seq\x12<\n\torderbook\x18\x02 \x01(\x0b\x32\x1e.injective.stream.v2.OrderbookR\torderbook\"\xa4\x01\n\tOrderbook\x12\x1b\n\tmarket_id\x18\x01 \x01(\tR\x08marketId\x12;\n\nbuy_levels\x18\x02 \x03(\x0b\x32\x1c.injective.exchange.v2.LevelR\tbuyLevels\x12=\n\x0bsell_levels\x18\x03 \x03(\x0b\x32\x1c.injective.exchange.v2.LevelR\nsellLevels\"\x90\x01\n\x0b\x42\x61nkBalance\x12\x18\n\x07\x61\x63\x63ount\x18\x01 \x01(\tR\x07\x61\x63\x63ount\x12g\n\x08\x62\x61lances\x18\x02 \x03(\x0b\x32\x19.cosmos.base.v1beta1.CoinB0\xc8\xde\x1f\x00\xaa\xdf\x1f(github.com/cosmos/cosmos-sdk/types.CoinsR\x08\x62\x61lances\"\x83\x01\n\x12SubaccountDeposits\x12#\n\rsubaccount_id\x18\x01 \x01(\tR\x0csubaccountId\x12H\n\x08\x64\x65posits\x18\x02 \x03(\x0b\x32&.injective.stream.v2.SubaccountDepositB\x04\xc8\xde\x1f\x00R\x08\x64\x65posits\"i\n\x11SubaccountDeposit\x12\x14\n\x05\x64\x65nom\x18\x01 \x01(\tR\x05\x64\x65nom\x12>\n\x07\x64\x65posit\x18\x02 \x01(\x0b\x32\x1e.injective.exchange.v2.DepositB\x04\xc8\xde\x1f\x00R\x07\x64\x65posit\"\xb8\x01\n\x0fSpotOrderUpdate\x12>\n\x06status\x18\x01 \x01(\x0e\x32&.injective.stream.v2.OrderUpdateStatusR\x06status\x12\x1d\n\norder_hash\x18\x02 \x01(\tR\torderHash\x12\x10\n\x03\x63id\x18\x03 \x01(\tR\x03\x63id\x12\x34\n\x05order\x18\x04 \x01(\x0b\x32\x1e.injective.stream.v2.SpotOrderR\x05order\"k\n\tSpotOrder\x12\x1b\n\tmarket_id\x18\x01 \x01(\tR\x08marketId\x12\x41\n\x05order\x18\x02 \x01(\x0b\x32%.injective.exchange.v2.SpotLimitOrderB\x04\xc8\xde\x1f\x00R\x05order\"\xc4\x01\n\x15\x44\x65rivativeOrderUpdate\x12>\n\x06status\x18\x01 \x01(\x0e\x32&.injective.stream.v2.OrderUpdateStatusR\x06status\x12\x1d\n\norder_hash\x18\x02 \x01(\tR\torderHash\x12\x10\n\x03\x63id\x18\x03 \x01(\tR\x03\x63id\x12:\n\x05order\x18\x04 \x01(\x0b\x32$.injective.stream.v2.DerivativeOrderR\x05order\"\x94\x01\n\x0f\x44\x65rivativeOrder\x12\x1b\n\tmarket_id\x18\x01 \x01(\tR\x08marketId\x12G\n\x05order\x18\x02 \x01(\x0b\x32+.injective.exchange.v2.DerivativeLimitOrderB\x04\xc8\xde\x1f\x00R\x05order\x12\x1b\n\tis_market\x18\x03 \x01(\x08R\x08isMarket\"\x87\x03\n\x08Position\x12\x1b\n\tmarket_id\x18\x01 \x01(\tR\x08marketId\x12#\n\rsubaccount_id\x18\x02 \x01(\tR\x0csubaccountId\x12\x16\n\x06isLong\x18\x03 \x01(\x08R\x06isLong\x12?\n\x08quantity\x18\x04 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x08quantity\x12\x44\n\x0b\x65ntry_price\x18\x05 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\nentryPrice\x12;\n\x06margin\x18\x06 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x06margin\x12]\n\x18\x63umulative_funding_entry\x18\x07 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x16\x63umulativeFundingEntry\"t\n\x0bOraclePrice\x12\x16\n\x06symbol\x18\x01 \x01(\tR\x06symbol\x12\x39\n\x05price\x18\x02 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x05price\x12\x12\n\x04type\x18\x03 \x01(\tR\x04type\"\x84\x04\n\tSpotTrade\x12\x1b\n\tmarket_id\x18\x01 \x01(\tR\x08marketId\x12\x15\n\x06is_buy\x18\x02 \x01(\x08R\x05isBuy\x12$\n\rexecutionType\x18\x03 \x01(\tR\rexecutionType\x12?\n\x08quantity\x18\x04 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x08quantity\x12\x39\n\x05price\x18\x05 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x05price\x12#\n\rsubaccount_id\x18\x06 \x01(\tR\x0csubaccountId\x12\x35\n\x03\x66\x65\x65\x18\x07 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x03\x66\x65\x65\x12\x1d\n\norder_hash\x18\x08 \x01(\tR\torderHash\x12\x38\n\x15\x66\x65\x65_recipient_address\x18\t \x01(\tB\x04\xc8\xde\x1f\x01R\x13\x66\x65\x65RecipientAddress\x12\x10\n\x03\x63id\x18\n \x01(\tR\x03\x63id\x12\x19\n\x08trade_id\x18\x0b \x01(\tR\x07tradeId\x12?\n\x08notional\x18\x0c \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x08notional\"\xfe\x03\n\x0f\x44\x65rivativeTrade\x12\x1b\n\tmarket_id\x18\x01 \x01(\tR\x08marketId\x12\x15\n\x06is_buy\x18\x02 \x01(\x08R\x05isBuy\x12$\n\rexecutionType\x18\x03 \x01(\tR\rexecutionType\x12#\n\rsubaccount_id\x18\x04 \x01(\tR\x0csubaccountId\x12K\n\x0eposition_delta\x18\x05 \x01(\x0b\x32$.injective.exchange.v2.PositionDeltaR\rpositionDelta\x12;\n\x06payout\x18\x06 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x06payout\x12\x35\n\x03\x66\x65\x65\x18\x07 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x03\x66\x65\x65\x12\x1d\n\norder_hash\x18\x08 \x01(\tR\torderHash\x12\x38\n\x15\x66\x65\x65_recipient_address\x18\t \x01(\tB\x04\xc8\xde\x1f\x01R\x13\x66\x65\x65RecipientAddress\x12\x10\n\x03\x63id\x18\n \x01(\tR\x03\x63id\x12\x19\n\x08trade_id\x18\x0b \x01(\tR\x07tradeId\x12%\n\x0eis_liquidation\x18\x0c \x01(\x08R\risLiquidation\"~\n\x12OrderFailureUpdate\x12\x18\n\x07\x61\x63\x63ount\x18\x01 \x01(\tR\x07\x61\x63\x63ount\x12\x1d\n\norder_hash\x18\x02 \x01(\tR\torderHash\x12\x10\n\x03\x63id\x18\x03 \x01(\tR\x03\x63id\x12\x1d\n\nerror_code\x18\x04 \x01(\rR\terrorCode\"\x8a\x02\n$ConditionalOrderTriggerFailureUpdate\x12\x1b\n\tmarket_id\x18\x01 \x01(\tR\x08marketId\x12#\n\rsubaccount_id\x18\x02 \x01(\tR\x0csubaccountId\x12\x42\n\nmark_price\x18\x03 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\tmarkPrice\x12\x1d\n\norder_hash\x18\x04 \x01(\tR\torderHash\x12\x10\n\x03\x63id\x18\x05 \x01(\tR\x03\x63id\x12+\n\x11\x65rror_description\x18\x06 \x01(\tR\x10\x65rrorDescription\"T\n\x0cTradesFilter\x12%\n\x0esubaccount_ids\x18\x01 \x03(\tR\rsubaccountIds\x12\x1d\n\nmarket_ids\x18\x02 \x03(\tR\tmarketIds\"W\n\x0fPositionsFilter\x12%\n\x0esubaccount_ids\x18\x01 \x03(\tR\rsubaccountIds\x12\x1d\n\nmarket_ids\x18\x02 \x03(\tR\tmarketIds\"T\n\x0cOrdersFilter\x12%\n\x0esubaccount_ids\x18\x01 \x03(\tR\rsubaccountIds\x12\x1d\n\nmarket_ids\x18\x02 \x03(\tR\tmarketIds\"0\n\x0fOrderbookFilter\x12\x1d\n\nmarket_ids\x18\x01 \x03(\tR\tmarketIds\"0\n\x12\x42\x61nkBalancesFilter\x12\x1a\n\x08\x61\x63\x63ounts\x18\x01 \x03(\tR\x08\x61\x63\x63ounts\"A\n\x18SubaccountDepositsFilter\x12%\n\x0esubaccount_ids\x18\x01 \x03(\tR\rsubaccountIds\"+\n\x11OraclePriceFilter\x12\x16\n\x06symbol\x18\x01 \x03(\tR\x06symbol\"1\n\x13OrderFailuresFilter\x12\x1a\n\x08\x61\x63\x63ounts\x18\x01 \x03(\tR\x08\x61\x63\x63ounts\"m\n%ConditionalOrderTriggerFailuresFilter\x12%\n\x0esubaccount_ids\x18\x01 \x03(\tR\rsubaccountIds\x12\x1d\n\nmarket_ids\x18\x02 \x03(\tR\tmarketIds*L\n\x11OrderUpdateStatus\x12\x0f\n\x0bUnspecified\x10\x00\x12\n\n\x06\x42ooked\x10\x01\x12\x0b\n\x07Matched\x10\x02\x12\r\n\tCancelled\x10\x03\x32_\n\x06Stream\x12U\n\x08StreamV2\x12\".injective.stream.v2.StreamRequest\x1a#.injective.stream.v2.StreamResponse0\x01\x42\xdc\x01\n\x17\x63om.injective.stream.v2B\nQueryProtoP\x01ZGgithub.com/InjectiveLabs/injective-core/injective-chain/stream/types/v2\xa2\x02\x03ISX\xaa\x02\x13Injective.Stream.V2\xca\x02\x13Injective\\Stream\\V2\xe2\x02\x1fInjective\\Stream\\V2\\GPBMetadata\xea\x02\x15Injective::Stream::V2b\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1finjective/stream/v2/query.proto\x12\x13injective.stream.v2\x1a\x1e\x63osmos/base/v1beta1/coin.proto\x1a\x14gogoproto/gogo.proto\x1a\"injective/exchange/v2/events.proto\x1a$injective/exchange/v2/exchange.proto\x1a\"injective/exchange/v2/market.proto\x1a!injective/exchange/v2/order.proto\"\xc1\n\n\rStreamRequest\x12_\n\x14\x62\x61nk_balances_filter\x18\x01 \x01(\x0b\x32\'.injective.stream.v2.BankBalancesFilterB\x04\xc8\xde\x1f\x01R\x12\x62\x61nkBalancesFilter\x12q\n\x1asubaccount_deposits_filter\x18\x02 \x01(\x0b\x32-.injective.stream.v2.SubaccountDepositsFilterB\x04\xc8\xde\x1f\x01R\x18subaccountDepositsFilter\x12U\n\x12spot_trades_filter\x18\x03 \x01(\x0b\x32!.injective.stream.v2.TradesFilterB\x04\xc8\xde\x1f\x01R\x10spotTradesFilter\x12\x61\n\x18\x64\x65rivative_trades_filter\x18\x04 \x01(\x0b\x32!.injective.stream.v2.TradesFilterB\x04\xc8\xde\x1f\x01R\x16\x64\x65rivativeTradesFilter\x12U\n\x12spot_orders_filter\x18\x05 \x01(\x0b\x32!.injective.stream.v2.OrdersFilterB\x04\xc8\xde\x1f\x01R\x10spotOrdersFilter\x12\x61\n\x18\x64\x65rivative_orders_filter\x18\x06 \x01(\x0b\x32!.injective.stream.v2.OrdersFilterB\x04\xc8\xde\x1f\x01R\x16\x64\x65rivativeOrdersFilter\x12`\n\x16spot_orderbooks_filter\x18\x07 \x01(\x0b\x32$.injective.stream.v2.OrderbookFilterB\x04\xc8\xde\x1f\x01R\x14spotOrderbooksFilter\x12l\n\x1c\x64\x65rivative_orderbooks_filter\x18\x08 \x01(\x0b\x32$.injective.stream.v2.OrderbookFilterB\x04\xc8\xde\x1f\x01R\x1a\x64\x65rivativeOrderbooksFilter\x12U\n\x10positions_filter\x18\t \x01(\x0b\x32$.injective.stream.v2.PositionsFilterB\x04\xc8\xde\x1f\x01R\x0fpositionsFilter\x12\\\n\x13oracle_price_filter\x18\n \x01(\x0b\x32&.injective.stream.v2.OraclePriceFilterB\x04\xc8\xde\x1f\x01R\x11oraclePriceFilter\x12\x62\n\x15order_failures_filter\x18\x0b \x01(\x0b\x32(.injective.stream.v2.OrderFailuresFilterB\x04\xc8\xde\x1f\x01R\x13orderFailuresFilter\x12\x9a\x01\n)conditional_order_trigger_failures_filter\x18\x0c \x01(\x0b\x32:.injective.stream.v2.ConditionalOrderTriggerFailuresFilterB\x04\xc8\xde\x1f\x01R%conditionalOrderTriggerFailuresFilter\x12\x62\n\x15market_funding_filter\x18\r \x01(\x0b\x32(.injective.stream.v2.MarketFundingFilterB\x04\xc8\xde\x1f\x01R\x13marketFundingFilter\"\xc5\t\n\x0eStreamResponse\x12!\n\x0c\x62lock_height\x18\x01 \x01(\x04R\x0b\x62lockHeight\x12\x1d\n\nblock_time\x18\x02 \x01(\x03R\tblockTime\x12\x45\n\rbank_balances\x18\x03 \x03(\x0b\x32 .injective.stream.v2.BankBalanceR\x0c\x62\x61nkBalances\x12X\n\x13subaccount_deposits\x18\x04 \x03(\x0b\x32\'.injective.stream.v2.SubaccountDepositsR\x12subaccountDeposits\x12?\n\x0bspot_trades\x18\x05 \x03(\x0b\x32\x1e.injective.stream.v2.SpotTradeR\nspotTrades\x12Q\n\x11\x64\x65rivative_trades\x18\x06 \x03(\x0b\x32$.injective.stream.v2.DerivativeTradeR\x10\x64\x65rivativeTrades\x12\x45\n\x0bspot_orders\x18\x07 \x03(\x0b\x32$.injective.stream.v2.SpotOrderUpdateR\nspotOrders\x12W\n\x11\x64\x65rivative_orders\x18\x08 \x03(\x0b\x32*.injective.stream.v2.DerivativeOrderUpdateR\x10\x64\x65rivativeOrders\x12Z\n\x16spot_orderbook_updates\x18\t \x03(\x0b\x32$.injective.stream.v2.OrderbookUpdateR\x14spotOrderbookUpdates\x12\x66\n\x1c\x64\x65rivative_orderbook_updates\x18\n \x03(\x0b\x32$.injective.stream.v2.OrderbookUpdateR\x1a\x64\x65rivativeOrderbookUpdates\x12;\n\tpositions\x18\x0b \x03(\x0b\x32\x1d.injective.stream.v2.PositionR\tpositions\x12\x45\n\roracle_prices\x18\x0c \x03(\x0b\x32 .injective.stream.v2.OraclePriceR\x0coraclePrices\x12\x1b\n\tgas_price\x18\r \x01(\tR\x08gasPrice\x12N\n\x0eorder_failures\x18\x0e \x03(\x0b\x32\'.injective.stream.v2.OrderFailureUpdateR\rorderFailures\x12\x86\x01\n\"conditional_order_trigger_failures\x18\x0f \x03(\x0b\x32\x39.injective.stream.v2.ConditionalOrderTriggerFailureUpdateR\x1f\x63onditionalOrderTriggerFailures\x12^\n\x16market_funding_updates\x18\x10 \x03(\x0b\x32(.injective.stream.v2.MarketFundingUpdateR\x14marketFundingUpdates\"a\n\x0fOrderbookUpdate\x12\x10\n\x03seq\x18\x01 \x01(\x04R\x03seq\x12<\n\torderbook\x18\x02 \x01(\x0b\x32\x1e.injective.stream.v2.OrderbookR\torderbook\"\xa4\x01\n\tOrderbook\x12\x1b\n\tmarket_id\x18\x01 \x01(\tR\x08marketId\x12;\n\nbuy_levels\x18\x02 \x03(\x0b\x32\x1c.injective.exchange.v2.LevelR\tbuyLevels\x12=\n\x0bsell_levels\x18\x03 \x03(\x0b\x32\x1c.injective.exchange.v2.LevelR\nsellLevels\"\x90\x01\n\x0b\x42\x61nkBalance\x12\x18\n\x07\x61\x63\x63ount\x18\x01 \x01(\tR\x07\x61\x63\x63ount\x12g\n\x08\x62\x61lances\x18\x02 \x03(\x0b\x32\x19.cosmos.base.v1beta1.CoinB0\xc8\xde\x1f\x00\xaa\xdf\x1f(github.com/cosmos/cosmos-sdk/types.CoinsR\x08\x62\x61lances\"\x83\x01\n\x12SubaccountDeposits\x12#\n\rsubaccount_id\x18\x01 \x01(\tR\x0csubaccountId\x12H\n\x08\x64\x65posits\x18\x02 \x03(\x0b\x32&.injective.stream.v2.SubaccountDepositB\x04\xc8\xde\x1f\x00R\x08\x64\x65posits\"i\n\x11SubaccountDeposit\x12\x14\n\x05\x64\x65nom\x18\x01 \x01(\tR\x05\x64\x65nom\x12>\n\x07\x64\x65posit\x18\x02 \x01(\x0b\x32\x1e.injective.exchange.v2.DepositB\x04\xc8\xde\x1f\x00R\x07\x64\x65posit\"\xb8\x01\n\x0fSpotOrderUpdate\x12>\n\x06status\x18\x01 \x01(\x0e\x32&.injective.stream.v2.OrderUpdateStatusR\x06status\x12\x1d\n\norder_hash\x18\x02 \x01(\tR\torderHash\x12\x10\n\x03\x63id\x18\x03 \x01(\tR\x03\x63id\x12\x34\n\x05order\x18\x04 \x01(\x0b\x32\x1e.injective.stream.v2.SpotOrderR\x05order\"k\n\tSpotOrder\x12\x1b\n\tmarket_id\x18\x01 \x01(\tR\x08marketId\x12\x41\n\x05order\x18\x02 \x01(\x0b\x32%.injective.exchange.v2.SpotLimitOrderB\x04\xc8\xde\x1f\x00R\x05order\"\xc4\x01\n\x15\x44\x65rivativeOrderUpdate\x12>\n\x06status\x18\x01 \x01(\x0e\x32&.injective.stream.v2.OrderUpdateStatusR\x06status\x12\x1d\n\norder_hash\x18\x02 \x01(\tR\torderHash\x12\x10\n\x03\x63id\x18\x03 \x01(\tR\x03\x63id\x12:\n\x05order\x18\x04 \x01(\x0b\x32$.injective.stream.v2.DerivativeOrderR\x05order\"\x94\x01\n\x0f\x44\x65rivativeOrder\x12\x1b\n\tmarket_id\x18\x01 \x01(\tR\x08marketId\x12G\n\x05order\x18\x02 \x01(\x0b\x32+.injective.exchange.v2.DerivativeLimitOrderB\x04\xc8\xde\x1f\x00R\x05order\x12\x1b\n\tis_market\x18\x03 \x01(\x08R\x08isMarket\"\x87\x03\n\x08Position\x12\x1b\n\tmarket_id\x18\x01 \x01(\tR\x08marketId\x12#\n\rsubaccount_id\x18\x02 \x01(\tR\x0csubaccountId\x12\x16\n\x06isLong\x18\x03 \x01(\x08R\x06isLong\x12?\n\x08quantity\x18\x04 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x08quantity\x12\x44\n\x0b\x65ntry_price\x18\x05 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\nentryPrice\x12;\n\x06margin\x18\x06 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x06margin\x12]\n\x18\x63umulative_funding_entry\x18\x07 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x16\x63umulativeFundingEntry\"t\n\x0bOraclePrice\x12\x16\n\x06symbol\x18\x01 \x01(\tR\x06symbol\x12\x39\n\x05price\x18\x02 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x05price\x12\x12\n\x04type\x18\x03 \x01(\tR\x04type\"\x84\x04\n\tSpotTrade\x12\x1b\n\tmarket_id\x18\x01 \x01(\tR\x08marketId\x12\x15\n\x06is_buy\x18\x02 \x01(\x08R\x05isBuy\x12$\n\rexecutionType\x18\x03 \x01(\tR\rexecutionType\x12?\n\x08quantity\x18\x04 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x08quantity\x12\x39\n\x05price\x18\x05 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x05price\x12#\n\rsubaccount_id\x18\x06 \x01(\tR\x0csubaccountId\x12\x35\n\x03\x66\x65\x65\x18\x07 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x03\x66\x65\x65\x12\x1d\n\norder_hash\x18\x08 \x01(\tR\torderHash\x12\x38\n\x15\x66\x65\x65_recipient_address\x18\t \x01(\tB\x04\xc8\xde\x1f\x01R\x13\x66\x65\x65RecipientAddress\x12\x10\n\x03\x63id\x18\n \x01(\tR\x03\x63id\x12\x19\n\x08trade_id\x18\x0b \x01(\tR\x07tradeId\x12?\n\x08notional\x18\x0c \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x08notional\"\xfe\x03\n\x0f\x44\x65rivativeTrade\x12\x1b\n\tmarket_id\x18\x01 \x01(\tR\x08marketId\x12\x15\n\x06is_buy\x18\x02 \x01(\x08R\x05isBuy\x12$\n\rexecutionType\x18\x03 \x01(\tR\rexecutionType\x12#\n\rsubaccount_id\x18\x04 \x01(\tR\x0csubaccountId\x12K\n\x0eposition_delta\x18\x05 \x01(\x0b\x32$.injective.exchange.v2.PositionDeltaR\rpositionDelta\x12;\n\x06payout\x18\x06 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x06payout\x12\x35\n\x03\x66\x65\x65\x18\x07 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x03\x66\x65\x65\x12\x1d\n\norder_hash\x18\x08 \x01(\tR\torderHash\x12\x38\n\x15\x66\x65\x65_recipient_address\x18\t \x01(\tB\x04\xc8\xde\x1f\x01R\x13\x66\x65\x65RecipientAddress\x12\x10\n\x03\x63id\x18\n \x01(\tR\x03\x63id\x12\x19\n\x08trade_id\x18\x0b \x01(\tR\x07tradeId\x12%\n\x0eis_liquidation\x18\x0c \x01(\x08R\risLiquidation\"~\n\x12OrderFailureUpdate\x12\x18\n\x07\x61\x63\x63ount\x18\x01 \x01(\tR\x07\x61\x63\x63ount\x12\x1d\n\norder_hash\x18\x02 \x01(\tR\torderHash\x12\x10\n\x03\x63id\x18\x03 \x01(\tR\x03\x63id\x12\x1d\n\nerror_code\x18\x04 \x01(\rR\terrorCode\"\x8a\x02\n$ConditionalOrderTriggerFailureUpdate\x12\x1b\n\tmarket_id\x18\x01 \x01(\tR\x08marketId\x12#\n\rsubaccount_id\x18\x02 \x01(\tR\x0csubaccountId\x12\x42\n\nmark_price\x18\x03 \x01(\tB#\xc8\xde\x1f\x00\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\tmarkPrice\x12\x1d\n\norder_hash\x18\x04 \x01(\tR\torderHash\x12\x10\n\x03\x63id\x18\x05 \x01(\tR\x03\x63id\x12+\n\x11\x65rror_description\x18\x06 \x01(\tR\x10\x65rrorDescription\"\xb9\x02\n\x13MarketFundingUpdate\x12\x1b\n\tmarket_id\x18\x01 \x01(\tR\x08marketId\x12M\n\x07\x66unding\x18\x02 \x01(\x0b\x32-.injective.exchange.v2.PerpetualMarketFundingB\x04\xc8\xde\x1f\x00R\x07\x66unding\x12*\n\x11is_hourly_funding\x18\x03 \x01(\x08R\x0fisHourlyFunding\x12\x46\n\x0c\x66unding_rate\x18\x04 \x01(\tB#\xc8\xde\x1f\x01\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\x0b\x66undingRate\x12\x42\n\nmark_price\x18\x05 \x01(\tB#\xc8\xde\x1f\x01\xda\xde\x1f\x1b\x63osmossdk.io/math.LegacyDecR\tmarkPrice\"T\n\x0cTradesFilter\x12%\n\x0esubaccount_ids\x18\x01 \x03(\tR\rsubaccountIds\x12\x1d\n\nmarket_ids\x18\x02 \x03(\tR\tmarketIds\"W\n\x0fPositionsFilter\x12%\n\x0esubaccount_ids\x18\x01 \x03(\tR\rsubaccountIds\x12\x1d\n\nmarket_ids\x18\x02 \x03(\tR\tmarketIds\"T\n\x0cOrdersFilter\x12%\n\x0esubaccount_ids\x18\x01 \x03(\tR\rsubaccountIds\x12\x1d\n\nmarket_ids\x18\x02 \x03(\tR\tmarketIds\"0\n\x0fOrderbookFilter\x12\x1d\n\nmarket_ids\x18\x01 \x03(\tR\tmarketIds\"0\n\x12\x42\x61nkBalancesFilter\x12\x1a\n\x08\x61\x63\x63ounts\x18\x01 \x03(\tR\x08\x61\x63\x63ounts\"A\n\x18SubaccountDepositsFilter\x12%\n\x0esubaccount_ids\x18\x01 \x03(\tR\rsubaccountIds\"+\n\x11OraclePriceFilter\x12\x16\n\x06symbol\x18\x01 \x03(\tR\x06symbol\"1\n\x13OrderFailuresFilter\x12\x1a\n\x08\x61\x63\x63ounts\x18\x01 \x03(\tR\x08\x61\x63\x63ounts\"m\n%ConditionalOrderTriggerFailuresFilter\x12%\n\x0esubaccount_ids\x18\x01 \x03(\tR\rsubaccountIds\x12\x1d\n\nmarket_ids\x18\x02 \x03(\tR\tmarketIds\"4\n\x13MarketFundingFilter\x12\x1d\n\nmarket_ids\x18\x01 \x03(\tR\tmarketIds*L\n\x11OrderUpdateStatus\x12\x0f\n\x0bUnspecified\x10\x00\x12\n\n\x06\x42ooked\x10\x01\x12\x0b\n\x07Matched\x10\x02\x12\r\n\tCancelled\x10\x03\x32_\n\x06Stream\x12U\n\x08StreamV2\x12\".injective.stream.v2.StreamRequest\x1a#.injective.stream.v2.StreamResponse0\x01\x42\xdc\x01\n\x17\x63om.injective.stream.v2B\nQueryProtoP\x01ZGgithub.com/InjectiveLabs/injective-core/injective-chain/stream/types/v2\xa2\x02\x03ISX\xaa\x02\x13Injective.Stream.V2\xca\x02\x13Injective\\Stream\\V2\xe2\x02\x1fInjective\\Stream\\V2\\GPBMetadata\xea\x02\x15Injective::Stream::V2b\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) @@ -51,6 +52,8 @@ _globals['_STREAMREQUEST'].fields_by_name['order_failures_filter']._serialized_options = b'\310\336\037\001' _globals['_STREAMREQUEST'].fields_by_name['conditional_order_trigger_failures_filter']._loaded_options = None _globals['_STREAMREQUEST'].fields_by_name['conditional_order_trigger_failures_filter']._serialized_options = b'\310\336\037\001' + _globals['_STREAMREQUEST'].fields_by_name['market_funding_filter']._loaded_options = None + _globals['_STREAMREQUEST'].fields_by_name['market_funding_filter']._serialized_options = b'\310\336\037\001' _globals['_BANKBALANCE'].fields_by_name['balances']._loaded_options = None _globals['_BANKBALANCE'].fields_by_name['balances']._serialized_options = b'\310\336\037\000\252\337\037(github.com/cosmos/cosmos-sdk/types.Coins' _globals['_SUBACCOUNTDEPOSITS'].fields_by_name['deposits']._loaded_options = None @@ -89,60 +92,70 @@ _globals['_DERIVATIVETRADE'].fields_by_name['fee_recipient_address']._serialized_options = b'\310\336\037\001' _globals['_CONDITIONALORDERTRIGGERFAILUREUPDATE'].fields_by_name['mark_price']._loaded_options = None _globals['_CONDITIONALORDERTRIGGERFAILUREUPDATE'].fields_by_name['mark_price']._serialized_options = b'\310\336\037\000\332\336\037\033cosmossdk.io/math.LegacyDec' - _globals['_ORDERUPDATESTATUS']._serialized_start=6471 - _globals['_ORDERUPDATESTATUS']._serialized_end=6547 - _globals['_STREAMREQUEST']._serialized_start=220 - _globals['_STREAMREQUEST']._serialized_end=1465 - _globals['_STREAMRESPONSE']._serialized_start=1468 - _globals['_STREAMRESPONSE']._serialized_end=2593 - _globals['_ORDERBOOKUPDATE']._serialized_start=2595 - _globals['_ORDERBOOKUPDATE']._serialized_end=2692 - _globals['_ORDERBOOK']._serialized_start=2695 - _globals['_ORDERBOOK']._serialized_end=2859 - _globals['_BANKBALANCE']._serialized_start=2862 - _globals['_BANKBALANCE']._serialized_end=3006 - _globals['_SUBACCOUNTDEPOSITS']._serialized_start=3009 - _globals['_SUBACCOUNTDEPOSITS']._serialized_end=3140 - _globals['_SUBACCOUNTDEPOSIT']._serialized_start=3142 - _globals['_SUBACCOUNTDEPOSIT']._serialized_end=3247 - _globals['_SPOTORDERUPDATE']._serialized_start=3250 - _globals['_SPOTORDERUPDATE']._serialized_end=3434 - _globals['_SPOTORDER']._serialized_start=3436 - _globals['_SPOTORDER']._serialized_end=3543 - _globals['_DERIVATIVEORDERUPDATE']._serialized_start=3546 - _globals['_DERIVATIVEORDERUPDATE']._serialized_end=3742 - _globals['_DERIVATIVEORDER']._serialized_start=3745 - _globals['_DERIVATIVEORDER']._serialized_end=3893 - _globals['_POSITION']._serialized_start=3896 - _globals['_POSITION']._serialized_end=4287 - _globals['_ORACLEPRICE']._serialized_start=4289 - _globals['_ORACLEPRICE']._serialized_end=4405 - _globals['_SPOTTRADE']._serialized_start=4408 - _globals['_SPOTTRADE']._serialized_end=4924 - _globals['_DERIVATIVETRADE']._serialized_start=4927 - _globals['_DERIVATIVETRADE']._serialized_end=5437 - _globals['_ORDERFAILUREUPDATE']._serialized_start=5439 - _globals['_ORDERFAILUREUPDATE']._serialized_end=5565 - _globals['_CONDITIONALORDERTRIGGERFAILUREUPDATE']._serialized_start=5568 - _globals['_CONDITIONALORDERTRIGGERFAILUREUPDATE']._serialized_end=5834 - _globals['_TRADESFILTER']._serialized_start=5836 - _globals['_TRADESFILTER']._serialized_end=5920 - _globals['_POSITIONSFILTER']._serialized_start=5922 - _globals['_POSITIONSFILTER']._serialized_end=6009 - _globals['_ORDERSFILTER']._serialized_start=6011 - _globals['_ORDERSFILTER']._serialized_end=6095 - _globals['_ORDERBOOKFILTER']._serialized_start=6097 - _globals['_ORDERBOOKFILTER']._serialized_end=6145 - _globals['_BANKBALANCESFILTER']._serialized_start=6147 - _globals['_BANKBALANCESFILTER']._serialized_end=6195 - _globals['_SUBACCOUNTDEPOSITSFILTER']._serialized_start=6197 - _globals['_SUBACCOUNTDEPOSITSFILTER']._serialized_end=6262 - _globals['_ORACLEPRICEFILTER']._serialized_start=6264 - _globals['_ORACLEPRICEFILTER']._serialized_end=6307 - _globals['_ORDERFAILURESFILTER']._serialized_start=6309 - _globals['_ORDERFAILURESFILTER']._serialized_end=6358 - _globals['_CONDITIONALORDERTRIGGERFAILURESFILTER']._serialized_start=6360 - _globals['_CONDITIONALORDERTRIGGERFAILURESFILTER']._serialized_end=6469 - _globals['_STREAM']._serialized_start=6549 - _globals['_STREAM']._serialized_end=6644 + _globals['_MARKETFUNDINGUPDATE'].fields_by_name['funding']._loaded_options = None + _globals['_MARKETFUNDINGUPDATE'].fields_by_name['funding']._serialized_options = b'\310\336\037\000' + _globals['_MARKETFUNDINGUPDATE'].fields_by_name['funding_rate']._loaded_options = None + _globals['_MARKETFUNDINGUPDATE'].fields_by_name['funding_rate']._serialized_options = b'\310\336\037\001\332\336\037\033cosmossdk.io/math.LegacyDec' + _globals['_MARKETFUNDINGUPDATE'].fields_by_name['mark_price']._loaded_options = None + _globals['_MARKETFUNDINGUPDATE'].fields_by_name['mark_price']._serialized_options = b'\310\336\037\001\332\336\037\033cosmossdk.io/math.LegacyDec' + _globals['_ORDERUPDATESTATUS']._serialized_start=7073 + _globals['_ORDERUPDATESTATUS']._serialized_end=7149 + _globals['_STREAMREQUEST']._serialized_start=256 + _globals['_STREAMREQUEST']._serialized_end=1601 + _globals['_STREAMRESPONSE']._serialized_start=1604 + _globals['_STREAMRESPONSE']._serialized_end=2825 + _globals['_ORDERBOOKUPDATE']._serialized_start=2827 + _globals['_ORDERBOOKUPDATE']._serialized_end=2924 + _globals['_ORDERBOOK']._serialized_start=2927 + _globals['_ORDERBOOK']._serialized_end=3091 + _globals['_BANKBALANCE']._serialized_start=3094 + _globals['_BANKBALANCE']._serialized_end=3238 + _globals['_SUBACCOUNTDEPOSITS']._serialized_start=3241 + _globals['_SUBACCOUNTDEPOSITS']._serialized_end=3372 + _globals['_SUBACCOUNTDEPOSIT']._serialized_start=3374 + _globals['_SUBACCOUNTDEPOSIT']._serialized_end=3479 + _globals['_SPOTORDERUPDATE']._serialized_start=3482 + _globals['_SPOTORDERUPDATE']._serialized_end=3666 + _globals['_SPOTORDER']._serialized_start=3668 + _globals['_SPOTORDER']._serialized_end=3775 + _globals['_DERIVATIVEORDERUPDATE']._serialized_start=3778 + _globals['_DERIVATIVEORDERUPDATE']._serialized_end=3974 + _globals['_DERIVATIVEORDER']._serialized_start=3977 + _globals['_DERIVATIVEORDER']._serialized_end=4125 + _globals['_POSITION']._serialized_start=4128 + _globals['_POSITION']._serialized_end=4519 + _globals['_ORACLEPRICE']._serialized_start=4521 + _globals['_ORACLEPRICE']._serialized_end=4637 + _globals['_SPOTTRADE']._serialized_start=4640 + _globals['_SPOTTRADE']._serialized_end=5156 + _globals['_DERIVATIVETRADE']._serialized_start=5159 + _globals['_DERIVATIVETRADE']._serialized_end=5669 + _globals['_ORDERFAILUREUPDATE']._serialized_start=5671 + _globals['_ORDERFAILUREUPDATE']._serialized_end=5797 + _globals['_CONDITIONALORDERTRIGGERFAILUREUPDATE']._serialized_start=5800 + _globals['_CONDITIONALORDERTRIGGERFAILUREUPDATE']._serialized_end=6066 + _globals['_MARKETFUNDINGUPDATE']._serialized_start=6069 + _globals['_MARKETFUNDINGUPDATE']._serialized_end=6382 + _globals['_TRADESFILTER']._serialized_start=6384 + _globals['_TRADESFILTER']._serialized_end=6468 + _globals['_POSITIONSFILTER']._serialized_start=6470 + _globals['_POSITIONSFILTER']._serialized_end=6557 + _globals['_ORDERSFILTER']._serialized_start=6559 + _globals['_ORDERSFILTER']._serialized_end=6643 + _globals['_ORDERBOOKFILTER']._serialized_start=6645 + _globals['_ORDERBOOKFILTER']._serialized_end=6693 + _globals['_BANKBALANCESFILTER']._serialized_start=6695 + _globals['_BANKBALANCESFILTER']._serialized_end=6743 + _globals['_SUBACCOUNTDEPOSITSFILTER']._serialized_start=6745 + _globals['_SUBACCOUNTDEPOSITSFILTER']._serialized_end=6810 + _globals['_ORACLEPRICEFILTER']._serialized_start=6812 + _globals['_ORACLEPRICEFILTER']._serialized_end=6855 + _globals['_ORDERFAILURESFILTER']._serialized_start=6857 + _globals['_ORDERFAILURESFILTER']._serialized_end=6906 + _globals['_CONDITIONALORDERTRIGGERFAILURESFILTER']._serialized_start=6908 + _globals['_CONDITIONALORDERTRIGGERFAILURESFILTER']._serialized_end=7017 + _globals['_MARKETFUNDINGFILTER']._serialized_start=7019 + _globals['_MARKETFUNDINGFILTER']._serialized_end=7071 + _globals['_STREAM']._serialized_start=7151 + _globals['_STREAM']._serialized_end=7246 # @@protoc_insertion_point(module_scope) diff --git a/tests/client/chain/stream_grpc/configurable_chain_stream_query_servicer.py b/tests/client/chain/stream_grpc/configurable_chain_stream_query_servicer.py index 943b91c0..0a4e6889 100644 --- a/tests/client/chain/stream_grpc/configurable_chain_stream_query_servicer.py +++ b/tests/client/chain/stream_grpc/configurable_chain_stream_query_servicer.py @@ -22,7 +22,9 @@ class ConfigurableChainStreamV2QueryServicer(chain_stream_v2_grpc.StreamServicer def __init__(self): super().__init__() self.stream_responses = deque() + self.stream_requests = deque() async def StreamV2(self, request: chain_stream_v2_pb.StreamRequest, context=None, metadata=None): + self.stream_requests.append(request) for event in self.stream_responses: yield event diff --git a/tests/client/chain/stream_grpc/test_chain_grpc_chain_stream.py b/tests/client/chain/stream_grpc/test_chain_grpc_chain_stream.py index f42b61e7..36eaf52a 100644 --- a/tests/client/chain/stream_grpc/test_chain_grpc_chain_stream.py +++ b/tests/client/chain/stream_grpc/test_chain_grpc_chain_stream.py @@ -9,7 +9,11 @@ from pyinjective.core.network import DisabledCookieAssistant, Network from pyinjective.proto.cosmos.base.v1beta1 import coin_pb2 as coin_pb from pyinjective.proto.injective.exchange.v1beta1 import exchange_pb2 as exchange_pb -from pyinjective.proto.injective.exchange.v2 import exchange_pb2 as exchange_v2_pb, order_pb2 as order_v2_pb +from pyinjective.proto.injective.exchange.v2 import ( + exchange_pb2 as exchange_v2_pb, + market_pb2 as market_v2_pb, + order_pb2 as order_v2_pb, +) from pyinjective.proto.injective.stream.v1beta1 import query_pb2 as chain_stream_pb from pyinjective.proto.injective.stream.v2 import query_pb2 as chain_stream_v2_pb from tests.client.chain.stream_grpc.configurable_chain_stream_query_servicer import ( @@ -818,6 +822,7 @@ async def test_stream_v2( "errorDescription": conditional_order_trigger_failure_update.error_description, }, ], + "marketFundingUpdates": [], } asyncio.get_event_loop().create_task( @@ -845,6 +850,67 @@ async def test_stream_v2( assert first_update == expected_update assert end_event.is_set() + @pytest.mark.asyncio + async def test_stream_v2_market_funding_updates( + self, + chain_stream_servicer, + chain_stream_v2_servicer, + ): + market_id = "0x790aee464fbbd02cf4476444554c71d1225f7edfe15e6dc7f874c455fd883d31" + funding = market_v2_pb.PerpetualMarketFunding( + cumulative_funding="0.00125", + cumulative_price="123.45", + last_timestamp=1708099200, + ) + market_funding_update = chain_stream_v2_pb.MarketFundingUpdate( + market_id=market_id, + funding=funding, + is_hourly_funding=True, + funding_rate="0.000125", + mark_price="25.42", + ) + chain_stream_v2_servicer.stream_responses.append( + chain_stream_v2_pb.StreamResponse( + block_height=19114391, + block_time=1701457189786, + market_funding_updates=[market_funding_update], + ) + ) + + api = self._api_instance(servicer=chain_stream_servicer, servicer_v2=chain_stream_v2_servicer) + events = asyncio.Queue() + end_event = asyncio.Event() + market_funding_filter = chain_stream_v2_pb.MarketFundingFilter(market_ids=[market_id]) + + asyncio.get_event_loop().create_task( + api.stream_v2( + callback=lambda update: events.put_nowait(update), + on_end_callback=lambda: end_event.set(), + on_status_callback=lambda exception: pytest.fail(str(exception)), + market_funding_filter=market_funding_filter, + ) + ) + + first_update = await asyncio.wait_for(events.get(), timeout=1) + + assert first_update["blockHeight"] == "19114391" + assert first_update["blockTime"] == "1701457189786" + assert first_update["marketFundingUpdates"] == [ + { + "marketId": market_id, + "funding": { + "cumulativeFunding": funding.cumulative_funding, + "cumulativePrice": funding.cumulative_price, + "lastTimestamp": str(funding.last_timestamp), + }, + "isHourlyFunding": True, + "fundingRate": market_funding_update.funding_rate, + "markPrice": market_funding_update.mark_price, + } + ] + assert chain_stream_v2_servicer.stream_requests.popleft().market_funding_filter == market_funding_filter + assert end_event.is_set() + def _api_instance(self, servicer, servicer_v2): network = Network.devnet() channel = grpc.aio.insecure_channel(network.grpc_endpoint) diff --git a/tests/test_composer_v2.py b/tests/test_composer_v2.py index c560a7d4..975c397e 100644 --- a/tests/test_composer_v2.py +++ b/tests/test_composer_v2.py @@ -2771,3 +2771,34 @@ def test_chain_stream_conditional_order_trigger_failures_filter_default(self, ba always_print_fields_with_no_presence=True, ) assert dict_message == expected_message + + def test_chain_stream_market_funding_filter(self, basic_composer): + market_ids = [ + "0x0ee7ca44147bab6ec81ac293b5fe7915488e612af59964b2d663d6008d861dee", + "0x790aee464fbbd02cf4476444554c71d1225f7edfe15e6dc7f874c455fd883d31", + ] + + filter_result = basic_composer.chain_stream_market_funding_filter(market_ids=market_ids) + + expected_message = { + "marketIds": market_ids, + } + + dict_message = json_format.MessageToDict( + message=filter_result, + always_print_fields_with_no_presence=True, + ) + assert dict_message == expected_message + + def test_chain_stream_market_funding_filter_default(self, basic_composer): + filter_result = basic_composer.chain_stream_market_funding_filter() + + expected_message = { + "marketIds": ["*"], + } + + dict_message = json_format.MessageToDict( + message=filter_result, + always_print_fields_with_no_presence=True, + ) + assert dict_message == expected_message