diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e00a2ae..8be39513 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ All notable changes to this project will be documented in this file. +## [1.1.0] - 2024-01-15 +### Added +- Added new functions in all Market classes to convert values from extended chain format (the ones provided by chain streams) into human-readable format + +### Changed +- Updated proto definitions for Indexer node using version v1.12.79.1 +- Updated market and tokens INI configuration files + + ## [1.0.1] - 2024-01-08 ### Added - Added low level API components for all modules (chain, exchain and explorer) to make the Python SDK compatible with the TypeScript SDK. diff --git a/Makefile b/Makefile index c8c904d6..9ae659d1 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ clone-injective-core: git clone https://github.com/InjectiveLabs/injective-core.git -b v1.12.0 --depth 1 --single-branch clone-injective-indexer: - git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.12.72 --depth 1 --single-branch + git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.12.79.1 --depth 1 --single-branch clone-cometbft: git clone https://github.com/InjectiveLabs/cometbft.git -b v0.37.2-inj --depth 1 --single-branch diff --git a/pyinjective/core/market.py b/pyinjective/core/market.py index 3faf21d2..2bd4fe1b 100644 --- a/pyinjective/core/market.py +++ b/pyinjective/core/market.py @@ -42,6 +42,15 @@ def price_from_chain_format(self, chain_value: Decimal) -> Decimal: decimals = self.base_token.decimals - self.quote_token.decimals return chain_value * Decimal(f"1e{decimals}") + def quantity_from_extended_chain_format(self, chain_value: Decimal) -> Decimal: + return self._from_extended_chain_format(chain_value=self.quantity_from_chain_format(chain_value=chain_value)) + + def price_from_extended_chain_format(self, chain_value: Decimal) -> Decimal: + return self._from_extended_chain_format(chain_value=self.price_from_chain_format(chain_value=chain_value)) + + def _from_extended_chain_format(self, chain_value: Decimal) -> Decimal: + return chain_value / Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") + @dataclass(eq=True, frozen=True) class DerivativeMarket: @@ -107,6 +116,18 @@ def price_from_chain_format(self, chain_value: Decimal) -> Decimal: def margin_from_chain_format(self, chain_value: Decimal) -> Decimal: return chain_value * Decimal(f"1e-{self.quote_token.decimals}") + def quantity_from_extended_chain_format(self, chain_value: Decimal) -> Decimal: + return self._from_extended_chain_format(chain_value=self.quantity_from_chain_format(chain_value=chain_value)) + + def price_from_extended_chain_format(self, chain_value: Decimal) -> Decimal: + return self._from_extended_chain_format(chain_value=self.price_from_chain_format(chain_value=chain_value)) + + def margin_from_extended_chain_format(self, chain_value: Decimal) -> Decimal: + return self._from_extended_chain_format(chain_value=self.margin_from_chain_format(chain_value=chain_value)) + + def _from_extended_chain_format(self, chain_value: Decimal) -> Decimal: + return chain_value / Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") + @dataclass(eq=True, frozen=True) class BinaryOptionMarket: @@ -179,3 +200,18 @@ def quantity_from_chain_format(self, chain_value: Decimal, special_denom: Option def price_from_chain_format(self, chain_value: Decimal, special_denom: Optional[Denom] = None) -> Decimal: decimals = self.quote_token.decimals if special_denom is None else special_denom.quote return chain_value * Decimal(f"1e-{decimals}") + + def quantity_from_extended_chain_format( + self, chain_value: Decimal, special_denom: Optional[Denom] = None + ) -> Decimal: + return self._from_extended_chain_format( + chain_value=self.quantity_from_chain_format(chain_value=chain_value, special_denom=special_denom) + ) + + def price_from_extended_chain_format(self, chain_value: Decimal, special_denom: Optional[Denom] = None) -> Decimal: + return self._from_extended_chain_format( + chain_value=self.price_from_chain_format(chain_value=chain_value, special_denom=special_denom) + ) + + def _from_extended_chain_format(self, chain_value: Decimal) -> Decimal: + return chain_value / Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") diff --git a/pyinjective/denoms_devnet.ini b/pyinjective/denoms_devnet.ini index 62979d72..d6205aeb 100644 --- a/pyinjective/denoms_devnet.ini +++ b/pyinjective/denoms_devnet.ini @@ -169,6 +169,15 @@ min_display_price_tick_size = 0.001 min_quantity_tick_size = 10000000000000 min_display_quantity_tick_size = 0.00001 +[0xdf9317eac1739a23bc385e264afde5d480c0b3d2322660b5efd206071d4e70b7] +description = 'Devnet Spot NINJA/INJ' +base = 6 +quote = 18 +min_price_tick_size = 1000000 +min_display_price_tick_size = 0.000001 +min_quantity_tick_size = 10000000 +min_display_quantity_tick_size = 10 + [0x1422a13427d5eabd4d8de7907c8340f7e58cb15553a9fd4ad5c90406561886f9] description = 'Devnet Derivative COMP/USDT PERP' base = 0 @@ -299,6 +308,10 @@ decimals = 18 peggy_denom = peggy0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0 decimals = 18 +[NINJA] +peggy_denom = factory/inj1xtel2knkt8hmc9dnzpjz6kdmacgcfmlv5f308w/ninja +decimals = 6 + [PROJ] peggy_denom = proj decimals = 18 diff --git a/pyinjective/denoms_mainnet.ini b/pyinjective/denoms_mainnet.ini index 0aea6fae..a9ae091d 100644 --- a/pyinjective/denoms_mainnet.ini +++ b/pyinjective/denoms_mainnet.ini @@ -558,12 +558,12 @@ min_display_quantity_tick_size = 1 [0x75f6a79b552dac417df219ab384be19cb13b53dec7cf512d73a965aee8bc83af] description = 'Mainnet Spot USDY/USDT' -base = 6 +base = 18 quote = 6 min_price_tick_size = 0.0000000000000001 -min_display_price_tick_size = 0.0000000000000001 +min_display_price_tick_size = 0.0001 min_quantity_tick_size = 100000000000000000 -min_display_quantity_tick_size = 100000000000 +min_display_quantity_tick_size = 0.1 [0x689ea50a30b0aeaf162e57100fefe5348a00099774f1c1ebcd90c4b480fda46a] description = 'Mainnet Spot WHALE/USDT' @@ -587,10 +587,10 @@ min_display_quantity_tick_size = 0.01 description = 'Mainnet Spot KIRA/INJ' base = 6 quote = 18 -min_price_tick_size = 1000000 -min_display_price_tick_size = 0.000001 -min_quantity_tick_size = 10000000 -min_display_quantity_tick_size = 10 +min_price_tick_size = 10000 +min_display_price_tick_size = 0.00000001 +min_quantity_tick_size = 1000000000 +min_display_quantity_tick_size = 1000 [0xdf9317eac1739a23bc385e264afde5d480c0b3d2322660b5efd206071d4e70b7] description = 'Mainnet Spot NINJA/INJ' @@ -605,10 +605,10 @@ min_display_quantity_tick_size = 10 description = 'Mainnet Spot KATANA/INJ' base = 6 quote = 18 -min_price_tick_size = 1000000 -min_display_price_tick_size = 0.000001 -min_quantity_tick_size = 10000000 -min_display_quantity_tick_size = 10 +min_price_tick_size = 10000 +min_display_price_tick_size = 0.00000001 +min_quantity_tick_size = 1000000000 +min_display_quantity_tick_size = 1000 [0x23983c260fc8a6627befa50cfc0374feef834dc1dc90835238c8559cc073e08f] description = 'Mainnet Spot BRETT/INJ' @@ -619,6 +619,15 @@ min_display_price_tick_size = 0.000001 min_quantity_tick_size = 10000000 min_display_quantity_tick_size = 10 +[0x6de141d12691dd13fffcc4e3ceeb09191ff445e1f10dfbecedc63a1e365fb6cd] +description = 'Mainnet Spot ZIG/INJ' +base = 18 +quote = 18 +min_price_tick_size = 0.000001 +min_display_price_tick_size = 0.000001 +min_quantity_tick_size = 10000000000000000000 +min_display_quantity_tick_size = 10 + [0x02b56c5e6038f0dd795efb521718b33412126971608750538409f4b81ab5da2f] description = 'Mainnet Spot nINJ/INJ' base = 18 @@ -628,6 +637,42 @@ min_display_price_tick_size = 0.0001 min_quantity_tick_size = 1000000000000000 min_display_quantity_tick_size = 0.001 +[0x9b13c89f8f10386b61dd3a58aae56d5c7995133534ed65ac9835bb8d54890961] +description = 'Mainnet Spot SNOWY/INJ' +base = 6 +quote = 18 +min_price_tick_size = 1000000 +min_display_price_tick_size = 0.000001 +min_quantity_tick_size = 1000000 +min_display_quantity_tick_size = 1 + +[0xb3f38c081a1817bb0fc717bf869e93f5557c10851db4e15922e1d9d2297bd802] +description = 'Mainnet Spot AUTISM/INJ' +base = 6 +quote = 18 +min_price_tick_size = 1000000 +min_display_price_tick_size = 0.000001 +min_quantity_tick_size = 10000000 +min_display_quantity_tick_size = 10 + +[0xd0ba680312852ffb0709446fff518e6c4d798fb70cfd2699aba3717a2517cfd5] +description = 'Mainnet Spot APP/INJ' +base = 18 +quote = 6 +min_price_tick_size = 0.000000000000000001 +min_display_price_tick_size = 0.000001 +min_quantity_tick_size = 10000000000000000000 +min_display_quantity_tick_size = 10 + +[0x05288e393771f09c923d1189e4265b7c2646b6699f08971fd2adf0bfd4b1ce7a] +description = 'Mainnet Spot APP/INJ ' +base = 18 +quote = 18 +min_price_tick_size = 0.000001 +min_display_price_tick_size = 0.000001 +min_quantity_tick_size = 10000000000000000000 +min_display_quantity_tick_size = 10 + [0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce] description = 'Mainnet Derivative BTC/USDT PERP' base = 0 @@ -682,15 +727,6 @@ min_display_price_tick_size = 0.001 min_quantity_tick_size = 0.01 min_display_quantity_tick_size = 0.01 -[0xcf18525b53e54ad7d27477426ade06d69d8d56d2f3bf35fe5ce2ad9eb97c2fbc] -description = 'Mainnet Derivative OSMO/USDT PERP' -base = 0 -quote = 6 -min_price_tick_size = 1000 -min_display_price_tick_size = 0.001 -min_quantity_tick_size = 0.01 -min_display_quantity_tick_size = 0.01 - [0x06c5a306492ddc2b8dc56969766959163287ed68a6b59baa2f42330dda0aebe0] description = 'Mainnet Derivative SOL/USDT PERP' base = 0 @@ -727,24 +763,6 @@ min_display_price_tick_size = 0.0001 min_quantity_tick_size = 1 min_display_quantity_tick_size = 1 -[0x332230109e7afb839b4750d4cf961666b608071ecb64dac55662dac37529639e] -description = 'Mainnet Derivative BTC/USDTkv PERP' -base = 0 -quote = 6 -min_price_tick_size = 1000000 -min_display_price_tick_size = 1 -min_quantity_tick_size = 0.0001 -min_display_quantity_tick_size = 0.0001 - -[0xca3682d053e8c804ea9cd322cfc0476d9016b99210fe42774a61b06e8868fef3] -description = 'Mainnet Derivative ETH/USDTkv PERP' -base = 0 -quote = 6 -min_price_tick_size = 100000 -min_display_price_tick_size = 0.1 -min_quantity_tick_size = 0.0001 -min_display_quantity_tick_size = 0.0001 - [0x4fe7aff4dd27be7cbb924336e7fe2d160387bb1750811cf165ce58d4c612aebb] description = 'Mainnet Derivative AXL/USDT PERP' base = 0 @@ -780,6 +798,10 @@ decimals = 18 peggy_denom = peggy0x4d224452801ACEd8B2F0aebE155379bb5D594381 decimals = 18 +[APP] +peggy_denom = peggy0xC5d27F27F08D1FD1E3EbBAa50b3442e6c0D50439 +decimals = 18 + [ARB] peggy_denom = factory/inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk/inj1d5vz0uzwlpfvgwrwulxg6syy82axa58y4fuszd decimals = 8 @@ -788,6 +810,10 @@ decimals = 8 peggy_denom = ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9 decimals = 6 +[AUTISM] +peggy_denom = factory/inj14lf8xm6fcvlggpa7guxzjqwjmtr24gnvf56hvz/autism +decimals = 6 + [AXS] peggy_denom = peggy0xBB0E17EF65F82Ab018d8EDd776e8DD940327B28b decimals = 18 @@ -853,8 +879,8 @@ peggy_denom = ibc/9A115B56E769B92621FFF90567E2D60EFD146E86E867491DB69EEDA9ADC362 decimals = 6 [LDO] -peggy_denom = factory/inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk/inj1q6zlut7gtkzknkk773jecujwsdkgq882akqksk -decimals = 6 +peggy_denom = factory/inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk/inj1me6t602jlndzxgv2d7ekcnkjuqdp7vfh4txpyy +decimals = 8 [LINK] peggy_denom = peggy0x514910771AF9Ca656af840dff83E8264EcF986CA @@ -864,10 +890,6 @@ decimals = 18 peggy_denom = ibc/B8AF5D92165F35AB31F3FC7C7B444B9D240760FA5D406C49D24862BD0284E395 decimals = 6 -[Lido DAO] -peggy_denom = factory/inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk/inj1me6t602jlndzxgv2d7ekcnkjuqdp7vfh4txpyy -decimals = 8 - [MATIC] peggy_denom = peggy0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0 decimals = 18 @@ -896,6 +918,10 @@ decimals = 6 peggy_denom = peggy0x4a220E6096B25EADb88358cb44068A3248254675 decimals = 18 +[SNOWY] +peggy_denom = factory/inj1ml33x7lkxk6x2x95d3alw4h84evlcdz2gnehmk/SNOWY +decimals = 6 + [SNX] peggy_denom = peggy0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F decimals = 18 @@ -944,10 +970,6 @@ decimals = 6 peggy_denom = peggy0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 decimals = 6 -[USDCet] -peggy_denom = factory/inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk/inj1q6zlut7gtkzknkk773jecujwsdkgq882akqksk -decimals = 6 - [USDCso] peggy_denom = factory/inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk/inj12pwnhtv7yat2s30xuf4gdk9qm85v4j3e60dgvu decimals = 6 @@ -992,6 +1014,10 @@ decimals = 18 peggy_denom = ibc/B786E7CBBF026F6F15A8DA248E0F18C62A0F7A70CB2DABD9239398C8B5150ABB decimals = 6 +[ZIG] +peggy_denom = peggy0xb2617246d0c6c0087f18703d576831899ca94f01 +decimals = 18 + [axlUSDC] peggy_denom = ibc/7E1AF94AD246BE522892751046F0C959B768642E5671CC3742264068D49553C0 decimals = 6 diff --git a/pyinjective/denoms_testnet.ini b/pyinjective/denoms_testnet.ini index 39ec2278..d81212d8 100644 --- a/pyinjective/denoms_testnet.ini +++ b/pyinjective/denoms_testnet.ini @@ -393,10 +393,6 @@ decimals = 18 peggy_denom = factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/atom decimals = 8 -[Cosmos] -peggy_denom = factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/atom -decimals = 8 - [INJ] peggy_denom = inj decimals = 18 @@ -405,10 +401,6 @@ decimals = 18 peggy_denom = factory/inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z/mitotest1 decimals = 18 -[MT1] -peggy_denom = factory/inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z/mitotest1 -decimals = 18 - [PROJ] peggy_denom = factory/inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z/proj decimals = 18 @@ -441,14 +433,10 @@ decimals = 8 peggy_denom = factory/inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z/zen decimals = 18 +[factory/inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z/uzen] +peggy_denom = factory/inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z/uzen +decimals = 18 + [stINJ] peggy_denom = factory/inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z/stinj decimals = 18 - -[wBTC] -peggy_denom = factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/wbtc -decimals = 8 - -[wETH] -peggy_denom = factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/weth -decimals = 8 diff --git a/pyinjective/proto/exchange/health_pb2.py b/pyinjective/proto/exchange/health_pb2.py new file mode 100644 index 00000000..87b1d0fd --- /dev/null +++ b/pyinjective/proto/exchange/health_pb2.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: exchange/health.proto +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x15\x65xchange/health.proto\x12\x06\x61pi.v1\"\x12\n\x10GetStatusRequest\"b\n\x11GetStatusResponse\x12\t\n\x01s\x18\x01 \x01(\t\x12\x0e\n\x06\x65rrmsg\x18\x02 \x01(\t\x12\"\n\x04\x64\x61ta\x18\x03 \x01(\x0b\x32\x14.api.v1.HealthStatus\x12\x0e\n\x06status\x18\x04 \x01(\t\"p\n\x0cHealthStatus\x12\x14\n\x0clocal_height\x18\x01 \x01(\x11\x12\x17\n\x0flocal_timestamp\x18\x02 \x01(\x11\x12\x16\n\x0ehoracle_height\x18\x03 \x01(\x11\x12\x19\n\x11horacle_timestamp\x18\x04 \x01(\x11\x32J\n\x06Health\x12@\n\tGetStatus\x12\x18.api.v1.GetStatusRequest\x1a\x19.api.v1.GetStatusResponseB\x0bZ\t/api.v1pbb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'exchange.health_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + DESCRIPTOR._serialized_options = b'Z\t/api.v1pb' + _globals['_GETSTATUSREQUEST']._serialized_start=33 + _globals['_GETSTATUSREQUEST']._serialized_end=51 + _globals['_GETSTATUSRESPONSE']._serialized_start=53 + _globals['_GETSTATUSRESPONSE']._serialized_end=151 + _globals['_HEALTHSTATUS']._serialized_start=153 + _globals['_HEALTHSTATUS']._serialized_end=265 + _globals['_HEALTH']._serialized_start=267 + _globals['_HEALTH']._serialized_end=341 +# @@protoc_insertion_point(module_scope) diff --git a/pyinjective/proto/exchange/health_pb2_grpc.py b/pyinjective/proto/exchange/health_pb2_grpc.py new file mode 100644 index 00000000..eaf0f7c5 --- /dev/null +++ b/pyinjective/proto/exchange/health_pb2_grpc.py @@ -0,0 +1,70 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" +import grpc + +from exchange import health_pb2 as exchange_dot_health__pb2 + + +class HealthStub(object): + """HealthAPI allows to check if backend data is up-to-date and reliable or not. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.GetStatus = channel.unary_unary( + '/api.v1.Health/GetStatus', + request_serializer=exchange_dot_health__pb2.GetStatusRequest.SerializeToString, + response_deserializer=exchange_dot_health__pb2.GetStatusResponse.FromString, + ) + + +class HealthServicer(object): + """HealthAPI allows to check if backend data is up-to-date and reliable or not. + """ + + def GetStatus(self, request, context): + """Get current backend health status + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_HealthServicer_to_server(servicer, server): + rpc_method_handlers = { + 'GetStatus': grpc.unary_unary_rpc_method_handler( + servicer.GetStatus, + request_deserializer=exchange_dot_health__pb2.GetStatusRequest.FromString, + response_serializer=exchange_dot_health__pb2.GetStatusResponse.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'api.v1.Health', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + + + # This class is part of an EXPERIMENTAL API. +class Health(object): + """HealthAPI allows to check if backend data is up-to-date and reliable or not. + """ + + @staticmethod + def GetStatus(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/api.v1.Health/GetStatus', + exchange_dot_health__pb2.GetStatusRequest.SerializeToString, + exchange_dot_health__pb2.GetStatusResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/pyinjective/proto/exchange/injective_campaign_rpc_pb2.py b/pyinjective/proto/exchange/injective_campaign_rpc_pb2.py index 6fbcac44..e0f09fad 100644 --- a/pyinjective/proto/exchange/injective_campaign_rpc_pb2.py +++ b/pyinjective/proto/exchange/injective_campaign_rpc_pb2.py @@ -13,7 +13,7 @@ -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n%exchange/injective_campaign_rpc.proto\x12\x16injective_campaign_rpc\"n\n\x0eRankingRequest\x12\x13\n\x0b\x63\x61mpaign_id\x18\x01 \x01(\t\x12\x11\n\tmarket_id\x18\x02 \x01(\t\x12\x17\n\x0f\x61\x63\x63ount_address\x18\x03 \x01(\t\x12\r\n\x05limit\x18\x04 \x01(\x11\x12\x0c\n\x04skip\x18\x05 \x01(\x04\"\xaa\x01\n\x0fRankingResponse\x12\x32\n\x08\x63\x61mpaign\x18\x01 \x01(\x0b\x32 .injective_campaign_rpc.Campaign\x12\x33\n\x05users\x18\x02 \x03(\x0b\x32$.injective_campaign_rpc.CampaignUser\x12.\n\x06paging\x18\x03 \x01(\x0b\x32\x1e.injective_campaign_rpc.Paging\"\x99\x01\n\x08\x43\x61mpaign\x12\x13\n\x0b\x63\x61mpaign_id\x18\x01 \x01(\t\x12\x11\n\tmarket_id\x18\x02 \x01(\t\x12\x13\n\x0btotal_score\x18\x04 \x01(\t\x12\x14\n\x0clast_updated\x18\x05 \x01(\x12\x12\x12\n\nstart_date\x18\x06 \x01(\x12\x12\x10\n\x08\x65nd_date\x18\x07 \x01(\x12\x12\x14\n\x0cis_claimable\x18\x08 \x01(\x08\"\xd3\x01\n\x0c\x43\x61mpaignUser\x12\x13\n\x0b\x63\x61mpaign_id\x18\x01 \x01(\t\x12\x11\n\tmarket_id\x18\x02 \x01(\t\x12\x17\n\x0f\x61\x63\x63ount_address\x18\x03 \x01(\t\x12\r\n\x05score\x18\x04 \x01(\t\x12\x18\n\x10\x63ontract_updated\x18\x05 \x01(\x08\x12\x14\n\x0c\x62lock_height\x18\x06 \x01(\x12\x12\x12\n\nblock_time\x18\x07 \x01(\x12\x12\x18\n\x10purchased_amount\x18\x08 \x01(\t\x12\x15\n\rgalxe_updated\x18\t \x01(\x08\"\\\n\x06Paging\x12\r\n\x05total\x18\x01 \x01(\x12\x12\x0c\n\x04\x66rom\x18\x02 \x01(\x11\x12\n\n\x02to\x18\x03 \x01(\x11\x12\x1b\n\x13\x63ount_by_subaccount\x18\x04 \x01(\x12\x12\x0c\n\x04next\x18\x05 \x03(\t\"\\\n\x11ListGuildsRequest\x12\x19\n\x11\x63\x61mpaign_contract\x18\x01 \x01(\t\x12\r\n\x05limit\x18\x02 \x01(\x11\x12\x0c\n\x04skip\x18\x03 \x01(\x11\x12\x0f\n\x07sort_by\x18\x04 \x01(\t\"\xca\x01\n\x12ListGuildsResponse\x12-\n\x06guilds\x18\x01 \x03(\x0b\x32\x1d.injective_campaign_rpc.Guild\x12.\n\x06paging\x18\x02 \x01(\x0b\x32\x1e.injective_campaign_rpc.Paging\x12\x12\n\nupdated_at\x18\x03 \x01(\x12\x12\x41\n\x10\x63\x61mpaign_summary\x18\x04 \x01(\x0b\x32\'.injective_campaign_rpc.CampaignSummary\"\xb9\x02\n\x05Guild\x12\x19\n\x11\x63\x61mpaign_contract\x18\x01 \x01(\t\x12\x10\n\x08guild_id\x18\x02 \x01(\t\x12\x16\n\x0emaster_address\x18\x03 \x01(\t\x12\x12\n\ncreated_at\x18\x04 \x01(\x12\x12\x11\n\ttvl_score\x18\x05 \x01(\t\x12\x14\n\x0cvolume_score\x18\x06 \x01(\t\x12\x16\n\x0erank_by_volume\x18\x07 \x01(\x11\x12\x13\n\x0brank_by_tvl\x18\x08 \x01(\x11\x12\x0c\n\x04logo\x18\t \x01(\t\x12\x11\n\ttotal_tvl\x18\n \x01(\t\x12\x12\n\nupdated_at\x18\x0b \x01(\x12\x12\x0c\n\x04name\x18\x0e \x01(\t\x12\x11\n\tis_active\x18\r \x01(\x08\x12\x16\n\x0emaster_balance\x18\x0f \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x10 \x01(\t\"\xf8\x01\n\x0f\x43\x61mpaignSummary\x12\x13\n\x0b\x63\x61mpaign_id\x18\x01 \x01(\t\x12\x19\n\x11\x63\x61mpaign_contract\x18\x02 \x01(\t\x12\x1a\n\x12total_guilds_count\x18\x03 \x01(\x11\x12\x11\n\ttotal_tvl\x18\x04 \x01(\t\x12\x19\n\x11total_average_tvl\x18\x05 \x01(\t\x12\x14\n\x0ctotal_volume\x18\x06 \x01(\t\x12\x12\n\nupdated_at\x18\x07 \x01(\x12\x12\x1b\n\x13total_members_count\x18\x08 \x01(\x11\x12\x12\n\nstart_time\x18\t \x01(\x12\x12\x10\n\x08\x65nd_time\x18\n \x01(\x12\"\x90\x01\n\x17ListGuildMembersRequest\x12\x19\n\x11\x63\x61mpaign_contract\x18\x01 \x01(\t\x12\x10\n\x08guild_id\x18\x02 \x01(\t\x12\r\n\x05limit\x18\x03 \x01(\x11\x12\x0c\n\x04skip\x18\x04 \x01(\x11\x12\x1a\n\x12include_guild_info\x18\x05 \x01(\x08\x12\x0f\n\x07sort_by\x18\x06 \x01(\t\"\xb3\x01\n\x18ListGuildMembersResponse\x12\x34\n\x07members\x18\x01 \x03(\x0b\x32#.injective_campaign_rpc.GuildMember\x12.\n\x06paging\x18\x02 \x01(\x0b\x32\x1e.injective_campaign_rpc.Paging\x12\x31\n\nguild_info\x18\x03 \x01(\x0b\x32\x1d.injective_campaign_rpc.Guild\"\xc0\x02\n\x0bGuildMember\x12\x19\n\x11\x63\x61mpaign_contract\x18\x01 \x01(\t\x12\x10\n\x08guild_id\x18\x02 \x01(\t\x12\x0f\n\x07\x61\x64\x64ress\x18\x03 \x01(\t\x12\x11\n\tjoined_at\x18\x04 \x01(\x12\x12\x11\n\ttvl_score\x18\x05 \x01(\t\x12\x14\n\x0cvolume_score\x18\x06 \x01(\t\x12\x11\n\ttotal_tvl\x18\x07 \x01(\t\x12\x1f\n\x17volume_score_percentage\x18\x08 \x01(\x01\x12\x1c\n\x14tvl_score_percentage\x18\t \x01(\x01\x12\x30\n\ntvl_reward\x18\n \x03(\x0b\x32\x1c.injective_campaign_rpc.Coin\x12\x33\n\rvolume_reward\x18\x0b \x03(\x0b\x32\x1c.injective_campaign_rpc.Coin\"%\n\x04\x43oin\x12\r\n\x05\x64\x65nom\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\t\"C\n\x15GetGuildMemberRequest\x12\x19\n\x11\x63\x61mpaign_contract\x18\x01 \x01(\t\x12\x0f\n\x07\x61\x64\x64ress\x18\x02 \x01(\t\"K\n\x16GetGuildMemberResponse\x12\x31\n\x04info\x18\x01 \x01(\x0b\x32#.injective_campaign_rpc.GuildMember2\xbf\x03\n\x14InjectiveCampaignRPC\x12Z\n\x07Ranking\x12&.injective_campaign_rpc.RankingRequest\x1a\'.injective_campaign_rpc.RankingResponse\x12\x63\n\nListGuilds\x12).injective_campaign_rpc.ListGuildsRequest\x1a*.injective_campaign_rpc.ListGuildsResponse\x12u\n\x10ListGuildMembers\x12/.injective_campaign_rpc.ListGuildMembersRequest\x1a\x30.injective_campaign_rpc.ListGuildMembersResponse\x12o\n\x0eGetGuildMember\x12-.injective_campaign_rpc.GetGuildMemberRequest\x1a..injective_campaign_rpc.GetGuildMemberResponseB\x1bZ\x19/injective_campaign_rpcpbb\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n%exchange/injective_campaign_rpc.proto\x12\x16injective_campaign_rpc\"n\n\x0eRankingRequest\x12\x13\n\x0b\x63\x61mpaign_id\x18\x01 \x01(\t\x12\x11\n\tmarket_id\x18\x02 \x01(\t\x12\x17\n\x0f\x61\x63\x63ount_address\x18\x03 \x01(\t\x12\r\n\x05limit\x18\x04 \x01(\x11\x12\x0c\n\x04skip\x18\x05 \x01(\x04\"\xaa\x01\n\x0fRankingResponse\x12\x32\n\x08\x63\x61mpaign\x18\x01 \x01(\x0b\x32 .injective_campaign_rpc.Campaign\x12\x33\n\x05users\x18\x02 \x03(\x0b\x32$.injective_campaign_rpc.CampaignUser\x12.\n\x06paging\x18\x03 \x01(\x0b\x32\x1e.injective_campaign_rpc.Paging\"\x80\x02\n\x08\x43\x61mpaign\x12\x13\n\x0b\x63\x61mpaign_id\x18\x01 \x01(\t\x12\x11\n\tmarket_id\x18\x02 \x01(\t\x12\x13\n\x0btotal_score\x18\x04 \x01(\t\x12\x14\n\x0clast_updated\x18\x05 \x01(\x12\x12\x12\n\nstart_date\x18\x06 \x01(\x12\x12\x10\n\x08\x65nd_date\x18\x07 \x01(\x12\x12\x14\n\x0cis_claimable\x18\x08 \x01(\x08\x12\x10\n\x08round_id\x18\t \x01(\x11\x12\x10\n\x08\x63ontract\x18\n \x01(\t\x12-\n\x07rewards\x18\x0b \x03(\x0b\x32\x1c.injective_campaign_rpc.Coin\x12\x12\n\nuser_score\x18\x0c \x01(\t\"%\n\x04\x43oin\x12\r\n\x05\x64\x65nom\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\t\"\xd3\x01\n\x0c\x43\x61mpaignUser\x12\x13\n\x0b\x63\x61mpaign_id\x18\x01 \x01(\t\x12\x11\n\tmarket_id\x18\x02 \x01(\t\x12\x17\n\x0f\x61\x63\x63ount_address\x18\x03 \x01(\t\x12\r\n\x05score\x18\x04 \x01(\t\x12\x18\n\x10\x63ontract_updated\x18\x05 \x01(\x08\x12\x14\n\x0c\x62lock_height\x18\x06 \x01(\x12\x12\x12\n\nblock_time\x18\x07 \x01(\x12\x12\x18\n\x10purchased_amount\x18\x08 \x01(\t\x12\x15\n\rgalxe_updated\x18\t \x01(\x08\"\\\n\x06Paging\x12\r\n\x05total\x18\x01 \x01(\x12\x12\x0c\n\x04\x66rom\x18\x02 \x01(\x11\x12\n\n\x02to\x18\x03 \x01(\x11\x12\x1b\n\x13\x63ount_by_subaccount\x18\x04 \x01(\x12\x12\x0c\n\x04next\x18\x05 \x03(\t\"R\n\x10\x43\x61mpaignsRequest\x12\x10\n\x08round_id\x18\x01 \x01(\x12\x12\x17\n\x0f\x61\x63\x63ount_address\x18\x02 \x01(\t\x12\x13\n\x0bto_round_id\x18\x03 \x01(\x11\"\x7f\n\x11\x43\x61mpaignsResponse\x12\x33\n\tcampaigns\x18\x01 \x03(\x0b\x32 .injective_campaign_rpc.Campaign\x12\x35\n\x0f\x61\x63\x63ount_rewards\x18\x02 \x03(\x0b\x32\x1c.injective_campaign_rpc.Coin\"\\\n\x11ListGuildsRequest\x12\x19\n\x11\x63\x61mpaign_contract\x18\x01 \x01(\t\x12\r\n\x05limit\x18\x02 \x01(\x11\x12\x0c\n\x04skip\x18\x03 \x01(\x11\x12\x0f\n\x07sort_by\x18\x04 \x01(\t\"\xca\x01\n\x12ListGuildsResponse\x12-\n\x06guilds\x18\x01 \x03(\x0b\x32\x1d.injective_campaign_rpc.Guild\x12.\n\x06paging\x18\x02 \x01(\x0b\x32\x1e.injective_campaign_rpc.Paging\x12\x12\n\nupdated_at\x18\x03 \x01(\x12\x12\x41\n\x10\x63\x61mpaign_summary\x18\x04 \x01(\x0b\x32\'.injective_campaign_rpc.CampaignSummary\"\xb9\x02\n\x05Guild\x12\x19\n\x11\x63\x61mpaign_contract\x18\x01 \x01(\t\x12\x10\n\x08guild_id\x18\x02 \x01(\t\x12\x16\n\x0emaster_address\x18\x03 \x01(\t\x12\x12\n\ncreated_at\x18\x04 \x01(\x12\x12\x11\n\ttvl_score\x18\x05 \x01(\t\x12\x14\n\x0cvolume_score\x18\x06 \x01(\t\x12\x16\n\x0erank_by_volume\x18\x07 \x01(\x11\x12\x13\n\x0brank_by_tvl\x18\x08 \x01(\x11\x12\x0c\n\x04logo\x18\t \x01(\t\x12\x11\n\ttotal_tvl\x18\n \x01(\t\x12\x12\n\nupdated_at\x18\x0b \x01(\x12\x12\x0c\n\x04name\x18\x0e \x01(\t\x12\x11\n\tis_active\x18\r \x01(\x08\x12\x16\n\x0emaster_balance\x18\x0f \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x10 \x01(\t\"\xf8\x01\n\x0f\x43\x61mpaignSummary\x12\x13\n\x0b\x63\x61mpaign_id\x18\x01 \x01(\t\x12\x19\n\x11\x63\x61mpaign_contract\x18\x02 \x01(\t\x12\x1a\n\x12total_guilds_count\x18\x03 \x01(\x11\x12\x11\n\ttotal_tvl\x18\x04 \x01(\t\x12\x19\n\x11total_average_tvl\x18\x05 \x01(\t\x12\x14\n\x0ctotal_volume\x18\x06 \x01(\t\x12\x12\n\nupdated_at\x18\x07 \x01(\x12\x12\x1b\n\x13total_members_count\x18\x08 \x01(\x11\x12\x12\n\nstart_time\x18\t \x01(\x12\x12\x10\n\x08\x65nd_time\x18\n \x01(\x12\"\x90\x01\n\x17ListGuildMembersRequest\x12\x19\n\x11\x63\x61mpaign_contract\x18\x01 \x01(\t\x12\x10\n\x08guild_id\x18\x02 \x01(\t\x12\r\n\x05limit\x18\x03 \x01(\x11\x12\x0c\n\x04skip\x18\x04 \x01(\x11\x12\x1a\n\x12include_guild_info\x18\x05 \x01(\x08\x12\x0f\n\x07sort_by\x18\x06 \x01(\t\"\xb3\x01\n\x18ListGuildMembersResponse\x12\x34\n\x07members\x18\x01 \x03(\x0b\x32#.injective_campaign_rpc.GuildMember\x12.\n\x06paging\x18\x02 \x01(\x0b\x32\x1e.injective_campaign_rpc.Paging\x12\x31\n\nguild_info\x18\x03 \x01(\x0b\x32\x1d.injective_campaign_rpc.Guild\"\xc0\x02\n\x0bGuildMember\x12\x19\n\x11\x63\x61mpaign_contract\x18\x01 \x01(\t\x12\x10\n\x08guild_id\x18\x02 \x01(\t\x12\x0f\n\x07\x61\x64\x64ress\x18\x03 \x01(\t\x12\x11\n\tjoined_at\x18\x04 \x01(\x12\x12\x11\n\ttvl_score\x18\x05 \x01(\t\x12\x14\n\x0cvolume_score\x18\x06 \x01(\t\x12\x11\n\ttotal_tvl\x18\x07 \x01(\t\x12\x1f\n\x17volume_score_percentage\x18\x08 \x01(\x01\x12\x1c\n\x14tvl_score_percentage\x18\t \x01(\x01\x12\x30\n\ntvl_reward\x18\n \x03(\x0b\x32\x1c.injective_campaign_rpc.Coin\x12\x33\n\rvolume_reward\x18\x0b \x03(\x0b\x32\x1c.injective_campaign_rpc.Coin\"C\n\x15GetGuildMemberRequest\x12\x19\n\x11\x63\x61mpaign_contract\x18\x01 \x01(\t\x12\x0f\n\x07\x61\x64\x64ress\x18\x02 \x01(\t\"K\n\x16GetGuildMemberResponse\x12\x31\n\x04info\x18\x01 \x01(\x0b\x32#.injective_campaign_rpc.GuildMember2\xa1\x04\n\x14InjectiveCampaignRPC\x12Z\n\x07Ranking\x12&.injective_campaign_rpc.RankingRequest\x1a\'.injective_campaign_rpc.RankingResponse\x12`\n\tCampaigns\x12(.injective_campaign_rpc.CampaignsRequest\x1a).injective_campaign_rpc.CampaignsResponse\x12\x63\n\nListGuilds\x12).injective_campaign_rpc.ListGuildsRequest\x1a*.injective_campaign_rpc.ListGuildsResponse\x12u\n\x10ListGuildMembers\x12/.injective_campaign_rpc.ListGuildMembersRequest\x1a\x30.injective_campaign_rpc.ListGuildMembersResponse\x12o\n\x0eGetGuildMember\x12-.injective_campaign_rpc.GetGuildMemberRequest\x1a..injective_campaign_rpc.GetGuildMemberResponseB\x1bZ\x19/injective_campaign_rpcpbb\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) @@ -27,31 +27,35 @@ _globals['_RANKINGRESPONSE']._serialized_start=178 _globals['_RANKINGRESPONSE']._serialized_end=348 _globals['_CAMPAIGN']._serialized_start=351 - _globals['_CAMPAIGN']._serialized_end=504 - _globals['_CAMPAIGNUSER']._serialized_start=507 - _globals['_CAMPAIGNUSER']._serialized_end=718 - _globals['_PAGING']._serialized_start=720 - _globals['_PAGING']._serialized_end=812 - _globals['_LISTGUILDSREQUEST']._serialized_start=814 - _globals['_LISTGUILDSREQUEST']._serialized_end=906 - _globals['_LISTGUILDSRESPONSE']._serialized_start=909 - _globals['_LISTGUILDSRESPONSE']._serialized_end=1111 - _globals['_GUILD']._serialized_start=1114 - _globals['_GUILD']._serialized_end=1427 - _globals['_CAMPAIGNSUMMARY']._serialized_start=1430 - _globals['_CAMPAIGNSUMMARY']._serialized_end=1678 - _globals['_LISTGUILDMEMBERSREQUEST']._serialized_start=1681 - _globals['_LISTGUILDMEMBERSREQUEST']._serialized_end=1825 - _globals['_LISTGUILDMEMBERSRESPONSE']._serialized_start=1828 - _globals['_LISTGUILDMEMBERSRESPONSE']._serialized_end=2007 - _globals['_GUILDMEMBER']._serialized_start=2010 - _globals['_GUILDMEMBER']._serialized_end=2330 - _globals['_COIN']._serialized_start=2332 - _globals['_COIN']._serialized_end=2369 - _globals['_GETGUILDMEMBERREQUEST']._serialized_start=2371 - _globals['_GETGUILDMEMBERREQUEST']._serialized_end=2438 - _globals['_GETGUILDMEMBERRESPONSE']._serialized_start=2440 - _globals['_GETGUILDMEMBERRESPONSE']._serialized_end=2515 - _globals['_INJECTIVECAMPAIGNRPC']._serialized_start=2518 - _globals['_INJECTIVECAMPAIGNRPC']._serialized_end=2965 + _globals['_CAMPAIGN']._serialized_end=607 + _globals['_COIN']._serialized_start=609 + _globals['_COIN']._serialized_end=646 + _globals['_CAMPAIGNUSER']._serialized_start=649 + _globals['_CAMPAIGNUSER']._serialized_end=860 + _globals['_PAGING']._serialized_start=862 + _globals['_PAGING']._serialized_end=954 + _globals['_CAMPAIGNSREQUEST']._serialized_start=956 + _globals['_CAMPAIGNSREQUEST']._serialized_end=1038 + _globals['_CAMPAIGNSRESPONSE']._serialized_start=1040 + _globals['_CAMPAIGNSRESPONSE']._serialized_end=1167 + _globals['_LISTGUILDSREQUEST']._serialized_start=1169 + _globals['_LISTGUILDSREQUEST']._serialized_end=1261 + _globals['_LISTGUILDSRESPONSE']._serialized_start=1264 + _globals['_LISTGUILDSRESPONSE']._serialized_end=1466 + _globals['_GUILD']._serialized_start=1469 + _globals['_GUILD']._serialized_end=1782 + _globals['_CAMPAIGNSUMMARY']._serialized_start=1785 + _globals['_CAMPAIGNSUMMARY']._serialized_end=2033 + _globals['_LISTGUILDMEMBERSREQUEST']._serialized_start=2036 + _globals['_LISTGUILDMEMBERSREQUEST']._serialized_end=2180 + _globals['_LISTGUILDMEMBERSRESPONSE']._serialized_start=2183 + _globals['_LISTGUILDMEMBERSRESPONSE']._serialized_end=2362 + _globals['_GUILDMEMBER']._serialized_start=2365 + _globals['_GUILDMEMBER']._serialized_end=2685 + _globals['_GETGUILDMEMBERREQUEST']._serialized_start=2687 + _globals['_GETGUILDMEMBERREQUEST']._serialized_end=2754 + _globals['_GETGUILDMEMBERRESPONSE']._serialized_start=2756 + _globals['_GETGUILDMEMBERRESPONSE']._serialized_end=2831 + _globals['_INJECTIVECAMPAIGNRPC']._serialized_start=2834 + _globals['_INJECTIVECAMPAIGNRPC']._serialized_end=3379 # @@protoc_insertion_point(module_scope) diff --git a/pyinjective/proto/exchange/injective_campaign_rpc_pb2_grpc.py b/pyinjective/proto/exchange/injective_campaign_rpc_pb2_grpc.py index 922d583c..ee20803b 100644 --- a/pyinjective/proto/exchange/injective_campaign_rpc_pb2_grpc.py +++ b/pyinjective/proto/exchange/injective_campaign_rpc_pb2_grpc.py @@ -20,6 +20,11 @@ def __init__(self, channel): request_serializer=exchange_dot_injective__campaign__rpc__pb2.RankingRequest.SerializeToString, response_deserializer=exchange_dot_injective__campaign__rpc__pb2.RankingResponse.FromString, ) + self.Campaigns = channel.unary_unary( + '/injective_campaign_rpc.InjectiveCampaignRPC/Campaigns', + request_serializer=exchange_dot_injective__campaign__rpc__pb2.CampaignsRequest.SerializeToString, + response_deserializer=exchange_dot_injective__campaign__rpc__pb2.CampaignsResponse.FromString, + ) self.ListGuilds = channel.unary_unary( '/injective_campaign_rpc.InjectiveCampaignRPC/ListGuilds', request_serializer=exchange_dot_injective__campaign__rpc__pb2.ListGuildsRequest.SerializeToString, @@ -48,6 +53,13 @@ def Ranking(self, request, context): context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') + def Campaigns(self, request, context): + """List current round active campaigns + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + def ListGuilds(self, request, context): """List guilds by campaign """ @@ -77,6 +89,11 @@ def add_InjectiveCampaignRPCServicer_to_server(servicer, server): request_deserializer=exchange_dot_injective__campaign__rpc__pb2.RankingRequest.FromString, response_serializer=exchange_dot_injective__campaign__rpc__pb2.RankingResponse.SerializeToString, ), + 'Campaigns': grpc.unary_unary_rpc_method_handler( + servicer.Campaigns, + request_deserializer=exchange_dot_injective__campaign__rpc__pb2.CampaignsRequest.FromString, + response_serializer=exchange_dot_injective__campaign__rpc__pb2.CampaignsResponse.SerializeToString, + ), 'ListGuilds': grpc.unary_unary_rpc_method_handler( servicer.ListGuilds, request_deserializer=exchange_dot_injective__campaign__rpc__pb2.ListGuildsRequest.FromString, @@ -120,6 +137,23 @@ def Ranking(request, options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + @staticmethod + def Campaigns(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/injective_campaign_rpc.InjectiveCampaignRPC/Campaigns', + exchange_dot_injective__campaign__rpc__pb2.CampaignsRequest.SerializeToString, + exchange_dot_injective__campaign__rpc__pb2.CampaignsResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + @staticmethod def ListGuilds(request, target, diff --git a/pyproject.toml b/pyproject.toml index ead03c5c..a15c4162 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "injective-py" -version = "1.0.1" +version = "1.1.0" description = "Injective Python SDK, with Exchange API Client" authors = ["Injective Labs "] license = "Apache-2.0" diff --git a/tests/core/test_market.py b/tests/core/test_market.py index 93d958df..ede8aea5 100644 --- a/tests/core/test_market.py +++ b/tests/core/test_market.py @@ -1,5 +1,6 @@ from decimal import Decimal +from pyinjective.constant import ADDITIONAL_CHAIN_FORMAT_DECIMALS from pyinjective.core.market import BinaryOptionMarket, DerivativeMarket, SpotMarket from pyinjective.utils.denom import Denom from tests.model_fixtures.markets_fixtures import btc_usdt_perp_market # noqa: F401 @@ -53,6 +54,31 @@ def test_convert_price_from_chain_format(self, inj_usdt_spot_market: SpotMarket) assert expected_price == human_readable_price + def test_convert_quantity_from_extended_chain_format(self, inj_usdt_spot_market: SpotMarket): + expected_quantity = Decimal("123.456") + + chain_format_quantity = ( + expected_quantity + * Decimal(f"1e{inj_usdt_spot_market.base_token.decimals}") + * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") + ) + human_readable_quantity = inj_usdt_spot_market.quantity_from_extended_chain_format( + chain_value=chain_format_quantity + ) + + assert expected_quantity == human_readable_quantity + + def test_convert_price_from_extended_chain_format(self, inj_usdt_spot_market: SpotMarket): + expected_price = Decimal("123.456") + + price_decimals = inj_usdt_spot_market.quote_token.decimals - inj_usdt_spot_market.base_token.decimals + chain_format_price = ( + expected_price * Decimal(f"1e{price_decimals}") * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") + ) + human_readable_price = inj_usdt_spot_market.price_from_extended_chain_format(chain_value=chain_format_price) + + assert expected_price == human_readable_price + class TestDerivativeMarket: def test_convert_quantity_to_chain_format(self, btc_usdt_perp_market: DerivativeMarket): @@ -118,6 +144,38 @@ def test_convert_margin_from_chain_format(self, btc_usdt_perp_market: Derivative assert expected_margin == human_readable_margin + def test_convert_quantity_from_extended_chain_format(self, btc_usdt_perp_market: DerivativeMarket): + expected_quantity = Decimal("123.456") + + chain_format_quantity = expected_quantity * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") + human_readable_quantity = btc_usdt_perp_market.quantity_from_extended_chain_format( + chain_value=chain_format_quantity + ) + + assert expected_quantity == human_readable_quantity + + def test_convert_price_from_extended_chain_format(self, btc_usdt_perp_market: DerivativeMarket): + expected_price = Decimal("123.456") + + price_decimals = btc_usdt_perp_market.quote_token.decimals + chain_format_price = ( + expected_price * Decimal(f"1e{price_decimals}") * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") + ) + human_readable_price = btc_usdt_perp_market.price_from_extended_chain_format(chain_value=chain_format_price) + + assert expected_price == human_readable_price + + def test_convert_margin_from_extended_chain_format(self, btc_usdt_perp_market: DerivativeMarket): + expected_margin = Decimal("123.456") + + price_decimals = btc_usdt_perp_market.quote_token.decimals + chain_format_margin = ( + expected_margin * Decimal(f"1e{price_decimals}") * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") + ) + human_readable_margin = btc_usdt_perp_market.margin_from_extended_chain_format(chain_value=chain_format_margin) + + assert expected_margin == human_readable_margin + class TestBinaryOptionMarket: def test_convert_quantity_to_chain_format_with_fixed_denom(self, first_match_bet_market: BinaryOptionMarket): @@ -314,3 +372,76 @@ def test_convert_price_from_chain_format_without_fixed_denom(self, first_match_b human_readable_price = first_match_bet_market.price_from_chain_format(chain_value=chain_formatted_price) assert original_price == human_readable_price + + def test_convert_quantity_from_extended_chain_format_with_fixed_denom( + self, first_match_bet_market: BinaryOptionMarket + ): + original_quantity = Decimal("123.456789") + fixed_denom = Denom( + description="Fixed denom", + base=2, + quote=4, + min_quantity_tick_size=100, + min_price_tick_size=10000, + ) + + chain_formatted_quantity = ( + original_quantity * Decimal(f"1e{fixed_denom.base}") * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") + ) + + human_readable_quantity = first_match_bet_market.quantity_from_extended_chain_format( + chain_value=chain_formatted_quantity, special_denom=fixed_denom + ) + + assert original_quantity == human_readable_quantity + + def test_convert_quantity_from_extended_chain_format_without_fixed_denom( + self, first_match_bet_market: BinaryOptionMarket + ): + original_quantity = Decimal("123.456789") + + chain_formatted_quantity = original_quantity * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") + + human_readable_quantity = first_match_bet_market.quantity_from_extended_chain_format( + chain_value=chain_formatted_quantity + ) + + assert original_quantity == human_readable_quantity + + def test_convert_price_from_extended_chain_format_with_fixed_denom( + self, first_match_bet_market: BinaryOptionMarket + ): + original_price = Decimal("123.456789") + fixed_denom = Denom( + description="Fixed denom", + base=2, + quote=4, + min_quantity_tick_size=100, + min_price_tick_size=10000, + ) + + chain_formatted_price = ( + original_price * Decimal(f"1e{fixed_denom.quote}") * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") + ) + + human_readable_price = first_match_bet_market.price_from_extended_chain_format( + chain_value=chain_formatted_price, special_denom=fixed_denom + ) + + assert original_price == human_readable_price + + def test_convert_price_from_extended_chain_format_without_fixed_denom( + self, first_match_bet_market: BinaryOptionMarket + ): + original_price = Decimal("123.456789") + chain_formatted_price = ( + original_price + * Decimal(f"1e{first_match_bet_market.quote_token.decimals}") + * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") + ) + + human_readable_price = first_match_bet_market.price_from_extended_chain_format( + chain_value=chain_formatted_price + ) + + assert original_price == human_readable_price