File tree Expand file tree Collapse file tree 4 files changed +75
-5
lines changed
Expand file tree Collapse file tree 4 files changed +75
-5
lines changed Original file line number Diff line number Diff line change 127127 "@injectivelabs/grpc-web" : " ^0.0.1" ,
128128 "@injectivelabs/grpc-web-node-http-transport" : " ^0.0.2" ,
129129 "@injectivelabs/grpc-web-react-native-transport" : " ^0.0.2" ,
130- "@injectivelabs/indexer-proto-ts" : " 1.13.4 " ,
130+ "@injectivelabs/indexer-proto-ts" : " 1.13.5 " ,
131131 "@injectivelabs/mito-proto-ts" : " 1.13.2" ,
132132 "@injectivelabs/networks" : " ^1.14.34-beta.5" ,
133133 "@injectivelabs/olp-proto-ts" : " 1.13.1" ,
Original file line number Diff line number Diff line change @@ -48,6 +48,12 @@ export type PositionsStreamCallback = (
4848 > ,
4949) => void
5050
51+ export type PositionsV2StreamCallback = (
52+ response : ReturnType <
53+ typeof IndexerDerivativeStreamTransformer . positionV2StreamCallback
54+ > ,
55+ ) => void
56+
5157export type MarketStreamCallback = (
5258 response : InjectiveDerivativeExchangeRpc . StreamMarketResponse ,
5359) => void
@@ -445,4 +451,55 @@ export class IndexerGrpcDerivativesStream {
445451
446452 return subscription as unknown as Subscription
447453 }
454+
455+ streamDerivativePositionsV2 ( {
456+ marketId,
457+ subaccountId,
458+ callback,
459+ address,
460+ onEndCallback,
461+ onStatusCallback,
462+ } : {
463+ marketId ?: string
464+ address ?: string
465+ subaccountId ?: string
466+ callback : PositionsV2StreamCallback
467+ onEndCallback ?: ( status ?: StreamStatusResponse ) => void
468+ onStatusCallback ?: ( status : StreamStatusResponse ) => void
469+ } ) : Subscription {
470+ const request =
471+ InjectiveDerivativeExchangeRpc . StreamPositionsV2Request . create ( )
472+
473+ if ( marketId ) {
474+ request . marketId = marketId
475+ }
476+
477+ if ( address ) {
478+ request . accountAddress = address
479+ }
480+
481+ if ( subaccountId ) {
482+ request . subaccountId = subaccountId
483+ }
484+
485+ const subscription = this . client . StreamPositionsV2 ( request ) . subscribe ( {
486+ next ( response : InjectiveDerivativeExchangeRpc . StreamPositionsV2Response ) {
487+ callback (
488+ IndexerDerivativeStreamTransformer . positionV2StreamCallback ( response ) ,
489+ )
490+ } ,
491+ error ( err ) {
492+ if ( onStatusCallback ) {
493+ onStatusCallback ( err )
494+ }
495+ } ,
496+ complete ( ) {
497+ if ( onEndCallback ) {
498+ onEndCallback ( )
499+ }
500+ } ,
501+ } )
502+
503+ return subscription as unknown as Subscription
504+ }
448505}
Original file line number Diff line number Diff line change @@ -98,4 +98,17 @@ export class IndexerDerivativeStreamTransformer {
9898 timestamp : response . timestamp ,
9999 }
100100 }
101+
102+ static positionV2StreamCallback = (
103+ response : InjectiveDerivativeExchangeRpc . StreamPositionsV2Response ,
104+ ) => {
105+ const position = response . position
106+
107+ return {
108+ position : position
109+ ? IndexerGrpcDerivativeTransformer . grpcPositionV2ToPositionV2 ( position )
110+ : undefined ,
111+ timestamp : response . timestamp ,
112+ }
113+ }
101114}
Original file line number Diff line number Diff line change 22202220 dependencies:
22212221 browser-headers "^0.4.1"
22222222
2223- "@injectivelabs/indexer-proto-ts@1.13.4 ":
2224- version "1.13.4 "
2225- resolved "https://registry.yarnpkg.com /@injectivelabs/indexer-proto-ts/-/indexer-proto-ts-1.13.4 .tgz#75f7d5caa23843b862fea6199975a88c5c88290e "
2226- integrity sha512-4i7jc2LQd3KRziSUCjQOt2VfhRFlJVwuWDPjKnAJRYCnbaJeZRxtZOY+2kFNthXDV2dYJkoiu+mOUHuGvWUM7Q ==
2223+ "@injectivelabs/indexer-proto-ts@1.13.5 ":
2224+ version "1.13.5 "
2225+ resolved "https://registry.npmjs.org /@injectivelabs/indexer-proto-ts/-/indexer-proto-ts-1.13.5 .tgz#1c5d43b7a274270ee919b973272b959bcf8553cd "
2226+ integrity sha512-Z/oSKRS2dNaMcC0zc5OYFpE2UVilDb7IzLhIisd0HBavZ9KU1UeD3WTTGUQjIT3qZv/mhOiTlCqTk+zhbdCWHQ ==
22272227 dependencies:
22282228 "@injectivelabs/grpc-web" "^0.0.1"
22292229 google-protobuf "^3.14.0"
You can’t perform that action at this time.
0 commit comments