-
Notifications
You must be signed in to change notification settings - Fork 204
feat/tc-derivatives-endpoints #625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4a75ed6
feat: add tc derivatives endpoints + stream (positions/order-history/…
Frederick-88 ed4d540
feat: add special agent to process proto diffs per indexer-proto-ts-v…
Frederick-88 fefb7d4
fix: minor
Frederick-88 aaa14af
chore: package bump
Frederick-88 3f0039b
chore: setup tc abacus protov2
ThomasRalee 81727eb
chore: add tc abacus for referral or points
Frederick-88 044c29a
chore: update tc derivatives endpoints + stream (positions/order-hist…
Frederick-88 6e541e2
chore: add more package support on special agent to process proto dif…
Frederick-88 561d6c3
chore: update as per PR feedback
Frederick-88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
167 changes: 167 additions & 0 deletions
167
packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcTcDerivativesApi.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| import * as InjectiveTCDerivativesRpcPb from '@injectivelabs/indexer-proto-ts-v2/generated/injective_tc_derivatives_rpc_pb' | ||
| import { InjectiveTCDerivativesRPCClient } from '@injectivelabs/indexer-proto-ts-v2/generated/injective_tc_derivatives_rpc_pb.client' | ||
| import { IndexerModule } from '../types/index.js' | ||
| import BaseIndexerGrpcConsumer from '../../base/BaseIndexerGrpcConsumer.js' | ||
| import { IndexerGrpcTcDerivativesTransformer } from '../transformers/index.js' | ||
|
|
||
| /** | ||
| * @category Indexer Grpc API | ||
| */ | ||
| export class IndexerGrpcTcDerivativesApi extends BaseIndexerGrpcConsumer { | ||
| protected module: string = IndexerModule.TcDerivatives | ||
|
|
||
| private get client() { | ||
| return this.initClient(InjectiveTCDerivativesRPCClient) | ||
| } | ||
|
|
||
| async fetchOrdersHistory(params?: { | ||
| token?: string | ||
| perPage?: number | ||
| marketId?: string | ||
| direction?: string | ||
| }) { | ||
| const { marketId, direction, perPage, token } = params || {} | ||
|
|
||
| const request = InjectiveTCDerivativesRpcPb.OrdersHistoryRequest.create() | ||
|
|
||
| if (marketId) { | ||
| request.marketIds = [marketId] | ||
| } | ||
|
|
||
| if (direction) { | ||
| request.direction = direction | ||
| } | ||
|
|
||
| if (perPage) { | ||
| request.perPage = perPage | ||
| } | ||
|
|
||
| if (token) { | ||
| request.token = token | ||
| } | ||
|
|
||
| const response = await this.executeGrpcCall< | ||
| InjectiveTCDerivativesRpcPb.OrdersHistoryRequest, | ||
| InjectiveTCDerivativesRpcPb.OrdersHistoryResponse | ||
| >(request, this.client.ordersHistory.bind(this.client)) | ||
|
|
||
| return IndexerGrpcTcDerivativesTransformer.ordersHistoryResponseToOrdersHistory( | ||
| response, | ||
| ) | ||
| } | ||
|
|
||
| async fetchTradesHistory(params?: { | ||
| token?: string | ||
| perPage?: number | ||
| marketId?: string | ||
| direction?: string | ||
| }) { | ||
| const { marketId, direction, perPage, token } = params || {} | ||
|
|
||
| const request = InjectiveTCDerivativesRpcPb.TradesRequest.create() | ||
|
|
||
| if (marketId) { | ||
| request.marketIds = [marketId] | ||
| } | ||
|
|
||
| if (direction) { | ||
| request.direction = direction | ||
| } | ||
|
|
||
| if (perPage) { | ||
| request.perPage = perPage | ||
| } | ||
|
|
||
| if (token) { | ||
| request.token = token | ||
| } | ||
|
|
||
| const response = await this.executeGrpcCall< | ||
| InjectiveTCDerivativesRpcPb.TradesRequest, | ||
| InjectiveTCDerivativesRpcPb.TradesResponse | ||
| >(request, this.client.trades.bind(this.client)) | ||
|
|
||
| return IndexerGrpcTcDerivativesTransformer.tradesResponseToTrades(response) | ||
| } | ||
|
|
||
| async fetchPositions(params?: { | ||
| token?: string | ||
| perPage?: number | ||
| marketId?: string | ||
| direction?: string | ||
| withCount?: boolean | ||
| accountAddress?: string | ||
| }) { | ||
| const { marketId, direction, perPage, token, accountAddress, withCount } = | ||
| params || {} | ||
|
|
||
| const request = InjectiveTCDerivativesRpcPb.PositionsRequest.create() | ||
|
|
||
| if (marketId) { | ||
| request.marketIds = [marketId] | ||
| } | ||
|
|
||
| if (direction) { | ||
| request.direction = direction | ||
| } | ||
|
|
||
| if (accountAddress) { | ||
| request.accountAddress = accountAddress | ||
| } | ||
|
|
||
| if (withCount !== undefined) { | ||
| request.withCount = withCount | ||
| } | ||
|
|
||
| if (perPage) { | ||
| request.perPage = perPage | ||
| } | ||
|
|
||
| if (token) { | ||
| request.token = token | ||
| } | ||
|
|
||
| const response = await this.executeGrpcCall< | ||
| InjectiveTCDerivativesRpcPb.PositionsRequest, | ||
| InjectiveTCDerivativesRpcPb.PositionsResponse | ||
| >(request, this.client.positions.bind(this.client)) | ||
|
|
||
| return IndexerGrpcTcDerivativesTransformer.positionsResponseToPositions( | ||
| response, | ||
| ) | ||
| } | ||
|
|
||
| async fetchOrders(params?: { | ||
| token?: string | ||
| perPage?: number | ||
| marketId?: string | ||
| direction?: string | ||
| }) { | ||
| const { marketId, direction, perPage, token } = params || {} | ||
|
|
||
| const request = InjectiveTCDerivativesRpcPb.OrdersRequest.create() | ||
|
|
||
| if (marketId) { | ||
| request.marketIds = [marketId] | ||
| } | ||
|
|
||
| if (direction) { | ||
| request.direction = direction | ||
| } | ||
|
|
||
| if (perPage) { | ||
| request.perPage = perPage | ||
| } | ||
|
|
||
| if (token) { | ||
| request.token = token | ||
| } | ||
|
|
||
| const response = await this.executeGrpcCall< | ||
| InjectiveTCDerivativesRpcPb.OrdersRequest, | ||
| InjectiveTCDerivativesRpcPb.OrdersResponse | ||
| >(request, this.client.orders.bind(this.client)) | ||
|
|
||
| return IndexerGrpcTcDerivativesTransformer.ordersResponseToOrders(response) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.