Skip to content

Commit b0ffc20

Browse files
authored
Merge pull request #279 from InjectiveLabs/feat/add_trade_v2_indexer_endpoints
feat/add trade v2 indexer endpoints
2 parents 0204942 + 99f3021 commit b0ffc20

40 files changed

+1899
-133
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ clean-all:
2828
$(call clean_repos)
2929

3030
clone-injective-core:
31-
git clone https://github.com/InjectiveLabs/injective-core.git -b v1.12.5-testnet --depth 1 --single-branch
31+
git clone https://github.com/InjectiveLabs/injective-core.git -b v1.12.6-testnet --depth 1 --single-branch
3232

3333
clone-injective-indexer:
34-
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.12.45-rc5 --depth 1 --single-branch
34+
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.12.59 --depth 1 --single-branch
3535

3636
clone-cometbft:
3737
git clone https://github.com/cometbft/cometbft.git -b v0.37.2 --depth 1 --single-branch

pyinjective/async_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ async def fetch_spot_trades(
13691369
cid: Optional[str] = None,
13701370
pagination: Optional[PaginationOption] = None,
13711371
) -> Dict[str, Any]:
1372-
return await self.exchange_spot_api.fetch_trades(
1372+
return await self.exchange_spot_api.fetch_trades_v2(
13731373
market_ids=market_ids,
13741374
subaccount_ids=subaccount_ids,
13751375
execution_side=execution_side,
@@ -1617,7 +1617,7 @@ async def listen_spot_trades_updates(
16171617
cid: Optional[str] = None,
16181618
pagination: Optional[PaginationOption] = None,
16191619
):
1620-
await self.exchange_spot_stream_api.stream_trades(
1620+
await self.exchange_spot_stream_api.stream_trades_v2(
16211621
callback=callback,
16221622
on_end_callback=on_end_callback,
16231623
on_status_callback=on_status_callback,
@@ -1915,7 +1915,7 @@ async def fetch_derivative_trades(
19151915
cid: Optional[str] = None,
19161916
pagination: Optional[PaginationOption] = None,
19171917
) -> Dict[str, Any]:
1918-
return await self.exchange_derivative_api.fetch_trades(
1918+
return await self.exchange_derivative_api.fetch_trades_v2(
19191919
market_ids=market_ids,
19201920
subaccount_ids=subaccount_ids,
19211921
execution_side=execution_side,
@@ -2088,7 +2088,7 @@ async def listen_derivative_trades_updates(
20882088
cid: Optional[str] = None,
20892089
pagination: Optional[PaginationOption] = None,
20902090
):
2091-
return await self.exchange_derivative_stream_api.stream_trades(
2091+
return await self.exchange_derivative_stream_api.stream_trades_v2(
20922092
callback=callback,
20932093
on_end_callback=on_end_callback,
20942094
on_status_callback=on_status_callback,

pyinjective/client/indexer/grpc/indexer_grpc_derivative_api.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,5 +287,37 @@ async def fetch_orders_history(
287287

288288
return response
289289

290+
async def fetch_trades_v2(
291+
self,
292+
market_ids: Optional[List[str]] = None,
293+
subaccount_ids: Optional[List[str]] = None,
294+
execution_side: Optional[str] = None,
295+
direction: Optional[str] = None,
296+
execution_types: Optional[List[str]] = None,
297+
trade_id: Optional[str] = None,
298+
account_address: Optional[str] = None,
299+
cid: Optional[str] = None,
300+
pagination: Optional[PaginationOption] = None,
301+
) -> Dict[str, Any]:
302+
pagination = pagination or PaginationOption()
303+
request = exchange_derivative_pb.TradesV2Request(
304+
market_ids=market_ids,
305+
subaccount_ids=subaccount_ids,
306+
execution_side=execution_side,
307+
direction=direction,
308+
skip=pagination.skip,
309+
limit=pagination.limit,
310+
start_time=pagination.start_time,
311+
end_time=pagination.end_time,
312+
execution_types=execution_types,
313+
trade_id=trade_id,
314+
account_address=account_address,
315+
cid=cid,
316+
)
317+
318+
response = await self._execute_call(call=self._stub.TradesV2, request=request)
319+
320+
return response
321+
290322
async def _execute_call(self, call: Callable, request) -> Dict[str, Any]:
291323
return await self._assistant.execute_call(call=call, request=request)

pyinjective/client/indexer/grpc/indexer_grpc_spot_api.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,5 +204,37 @@ async def fetch_atomic_swap_history(
204204

205205
return response
206206

207+
async def fetch_trades_v2(
208+
self,
209+
market_ids: Optional[List[str]] = None,
210+
subaccount_ids: Optional[List[str]] = None,
211+
execution_side: Optional[str] = None,
212+
direction: Optional[str] = None,
213+
execution_types: Optional[List[str]] = None,
214+
trade_id: Optional[str] = None,
215+
account_address: Optional[str] = None,
216+
cid: Optional[str] = None,
217+
pagination: Optional[PaginationOption] = None,
218+
) -> Dict[str, Any]:
219+
pagination = pagination or PaginationOption()
220+
request = exchange_spot_pb.TradesV2Request(
221+
market_ids=market_ids,
222+
subaccount_ids=subaccount_ids,
223+
execution_side=execution_side,
224+
direction=direction,
225+
skip=pagination.skip,
226+
limit=pagination.limit,
227+
start_time=pagination.start_time,
228+
end_time=pagination.end_time,
229+
execution_types=execution_types,
230+
trade_id=trade_id,
231+
account_address=account_address,
232+
cid=cid,
233+
)
234+
235+
response = await self._execute_call(call=self._stub.TradesV2, request=request)
236+
237+
return response
238+
207239
async def _execute_call(self, call: Callable, request) -> Dict[str, Any]:
208240
return await self._assistant.execute_call(call=call, request=request)

pyinjective/client/indexer/grpc_stream/indexer_grpc_derivative_stream.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,42 @@ async def stream_orders_history(
194194
on_end_callback=on_end_callback,
195195
on_status_callback=on_status_callback,
196196
)
197+
198+
async def stream_trades_v2(
199+
self,
200+
callback: Callable,
201+
on_end_callback: Optional[Callable] = None,
202+
on_status_callback: Optional[Callable] = None,
203+
market_ids: Optional[List[str]] = None,
204+
execution_side: Optional[str] = None,
205+
direction: Optional[str] = None,
206+
subaccount_ids: Optional[List[str]] = None,
207+
execution_types: Optional[List[str]] = None,
208+
trade_id: Optional[str] = None,
209+
account_address: Optional[str] = None,
210+
cid: Optional[str] = None,
211+
pagination: Optional[PaginationOption] = None,
212+
):
213+
pagination = pagination or PaginationOption()
214+
request = exchange_derivative_pb.StreamTradesV2Request(
215+
execution_side=execution_side,
216+
direction=direction,
217+
skip=pagination.skip,
218+
limit=pagination.limit,
219+
start_time=pagination.start_time,
220+
end_time=pagination.end_time,
221+
market_ids=market_ids,
222+
subaccount_ids=subaccount_ids,
223+
execution_types=execution_types,
224+
trade_id=trade_id,
225+
account_address=account_address,
226+
cid=cid,
227+
)
228+
229+
await self._assistant.listen_stream(
230+
call=self._stub.StreamTradesV2,
231+
request=request,
232+
callback=callback,
233+
on_end_callback=on_end_callback,
234+
on_status_callback=on_status_callback,
235+
)

pyinjective/client/indexer/grpc_stream/indexer_grpc_spot_stream.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,42 @@ async def stream_orders_history(
172172
on_end_callback=on_end_callback,
173173
on_status_callback=on_status_callback,
174174
)
175+
176+
async def stream_trades_v2(
177+
self,
178+
callback: Callable,
179+
on_end_callback: Optional[Callable] = None,
180+
on_status_callback: Optional[Callable] = None,
181+
market_ids: Optional[List[str]] = None,
182+
subaccount_ids: Optional[List[str]] = None,
183+
execution_side: Optional[str] = None,
184+
direction: Optional[str] = None,
185+
execution_types: Optional[List[str]] = None,
186+
trade_id: Optional[str] = None,
187+
account_address: Optional[str] = None,
188+
cid: Optional[str] = None,
189+
pagination: Optional[PaginationOption] = None,
190+
):
191+
pagination = pagination or PaginationOption()
192+
request = exchange_spot_pb.StreamTradesV2Request(
193+
execution_side=execution_side,
194+
direction=direction,
195+
skip=pagination.skip,
196+
limit=pagination.limit,
197+
start_time=pagination.start_time,
198+
end_time=pagination.end_time,
199+
market_ids=market_ids,
200+
subaccount_ids=subaccount_ids,
201+
execution_types=execution_types,
202+
trade_id=trade_id,
203+
account_address=account_address,
204+
cid=cid,
205+
)
206+
207+
await self._assistant.listen_stream(
208+
call=self._stub.StreamTradesV2,
209+
request=request,
210+
callback=callback,
211+
on_end_callback=on_end_callback,
212+
on_status_callback=on_status_callback,
213+
)

pyinjective/proto/cosmos/ics23/v1/proofs_pb2.py

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)