@nadohq/indexer-client 0.1.0-alpha.31 → 0.1.0-alpha.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/IndexerClient.ts"],"sourcesContent":["import {\n NLP_PRODUCT_ID,\n ProductEngineType,\n QUOTE_PRODUCT_ID,\n subaccountFromHex,\n toBigDecimal,\n toIntegerString,\n} from '@nadohq/shared';\n\nimport { IndexerBaseClient } from './IndexerBaseClient';\nimport {\n BaseIndexerPaginatedEvent,\n CollateralEventType,\n GetIndexerPaginatedInterestFundingPaymentsResponse,\n GetIndexerPaginatedLeaderboardParams,\n GetIndexerPaginatedLeaderboardResponse,\n GetIndexerPaginatedOrdersParams,\n GetIndexerPaginatedOrdersResponse,\n GetIndexerSubaccountCollateralEventsParams,\n GetIndexerSubaccountCollateralEventsResponse,\n GetIndexerSubaccountInterestFundingPaymentsParams,\n GetIndexerSubaccountLiquidationEventsParams,\n GetIndexerSubaccountLiquidationEventsResponse,\n GetIndexerSubaccountMatchEventParams,\n GetIndexerSubaccountMatchEventsResponse,\n GetIndexerSubaccountNlpEventsParams,\n GetIndexerSubaccountNlpEventsResponse,\n GetIndexerSubaccountSettlementEventsParams,\n GetIndexerSubaccountSettlementEventsResponse,\n IndexerCollateralEvent,\n IndexerEventPerpStateSnapshot,\n IndexerEventSpotStateSnapshot,\n IndexerEventWithTx,\n IndexerLiquidationEvent,\n IndexerNlpEvent,\n IndexerSettlementEvent,\n PaginatedIndexerEventsResponse,\n} from './types';\n\n/**\n * Indexer client providing paginated queries for historical data from the Nado indexer service\n */\nexport class IndexerClient extends IndexerBaseClient {\n async getPaginatedSubaccountMatchEvents(\n params: GetIndexerSubaccountMatchEventParams,\n ): Promise<GetIndexerSubaccountMatchEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n isolated,\n productIds,\n } = params;\n\n const limit = requestedLimit + 1;\n const events = await this.getMatchEvents({\n startCursor,\n maxTimestampInclusive,\n limit,\n subaccount: { subaccountName, subaccountOwner },\n productIds,\n isolated,\n });\n\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n async getPaginatedSubaccountNlpEvents(\n params: GetIndexerSubaccountNlpEventsParams,\n ): Promise<GetIndexerSubaccountNlpEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n } = params;\n\n // There are 2 events per mint/burn for spot - one associated with the NLP product & the other with the primary quote\n const limit = requestedLimit + 1;\n const baseResponse = await this.getEvents({\n startCursor,\n maxTimestampInclusive,\n eventTypes: ['mint_nlp', 'burn_nlp'],\n limit: {\n type: 'txs',\n value: limit,\n },\n subaccount: { subaccountName, subaccountOwner },\n });\n\n // Now aggregate results by the submission index, use map to maintain insertion order\n const eventsBySubmissionIdx = new Map<string, IndexerNlpEvent>();\n\n baseResponse.forEach((event) => {\n const mappedEvent = (() => {\n const existingEvent = eventsBySubmissionIdx.get(event.submissionIndex);\n if (existingEvent) {\n return existingEvent;\n }\n\n const newEvent: IndexerNlpEvent = {\n nlpDelta: toBigDecimal(0),\n primaryQuoteDelta: toBigDecimal(0),\n timestamp: event.timestamp,\n submissionIndex: event.submissionIndex,\n tx: event.tx,\n ...subaccountFromHex(event.subaccount),\n };\n eventsBySubmissionIdx.set(event.submissionIndex, newEvent);\n\n return newEvent;\n })();\n\n const balanceDelta = event.state.postBalance.amount.minus(\n event.state.preBalance.amount,\n );\n\n const productId = event.state.market.productId;\n if (productId === QUOTE_PRODUCT_ID) {\n mappedEvent.primaryQuoteDelta = balanceDelta;\n } else if (productId === NLP_PRODUCT_ID) {\n mappedEvent.nlpDelta = balanceDelta;\n } else {\n throw Error(`Invalid product ID for NLP event ${productId}`);\n }\n });\n\n // Force cast to get rid of the `Partial`\n const events = Array.from(eventsBySubmissionIdx.values());\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n async getPaginatedSubaccountCollateralEvents(\n params: GetIndexerSubaccountCollateralEventsParams,\n ): Promise<GetIndexerSubaccountCollateralEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n eventTypes,\n isolated,\n } = params;\n\n const limit = requestedLimit + 1;\n const baseResponse = await this.getEvents({\n startCursor,\n maxTimestampInclusive,\n eventTypes: eventTypes ?? [\n 'deposit_collateral',\n 'withdraw_collateral',\n 'transfer_quote',\n ],\n limit: {\n type: 'txs',\n value: limit,\n },\n subaccount: { subaccountName, subaccountOwner },\n isolated,\n });\n\n const events = baseResponse.map((event): IndexerCollateralEvent => {\n if (event.state.type !== ProductEngineType.SPOT) {\n throw Error('Incorrect event state for collateral event');\n }\n\n return {\n timestamp: event.timestamp,\n // This cast is safe as the query param restricts to collateral events\n eventType: event.eventType as CollateralEventType,\n submissionIndex: event.submissionIndex,\n snapshot: event.state,\n amount: event.state.postBalance.amount.minus(\n event.state.preBalance.amount,\n ),\n newAmount: event.state.postBalance.amount,\n tx: event.tx,\n ...subaccountFromHex(event.subaccount),\n };\n });\n\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n async getPaginatedSubaccountOrders(\n params: GetIndexerPaginatedOrdersParams,\n ): Promise<GetIndexerPaginatedOrdersResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n productIds,\n triggerTypes,\n isolated,\n } = params;\n\n const limit = requestedLimit + 1;\n const baseResponse = await this.getOrders({\n startCursor,\n maxTimestampInclusive,\n subaccount: { subaccountName, subaccountOwner },\n limit,\n productIds,\n triggerTypes,\n isolated,\n });\n\n // Same pagination meta logic as events, but duplicate for now as this return type is slightly different\n const truncatedOrders = baseResponse.slice(0, requestedLimit);\n const hasMore = baseResponse.length > truncatedOrders.length;\n return {\n meta: {\n hasMore,\n nextCursor: baseResponse[truncatedOrders.length]?.submissionIndex,\n },\n orders: truncatedOrders,\n };\n }\n\n async getPaginatedSubaccountSettlementEvents(\n params: GetIndexerSubaccountSettlementEventsParams,\n ): Promise<GetIndexerSubaccountSettlementEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n } = params;\n\n // Each settlement has a quote & perp balance change, so 2 events per settlement tx\n const limit = requestedLimit + 1;\n const baseResponse = await this.getEvents({\n startCursor,\n maxTimestampInclusive,\n eventTypes: ['settle_pnl'],\n limit: {\n type: 'txs',\n value: limit,\n },\n subaccount: { subaccountName, subaccountOwner },\n });\n\n const events = baseResponse\n .map((event): IndexerSettlementEvent | undefined => {\n if (event.state.market.productId === QUOTE_PRODUCT_ID) {\n return;\n }\n if (event.state.type !== ProductEngineType.PERP) {\n throw Error('Incorrect event state for settlement event');\n }\n\n return {\n timestamp: event.timestamp,\n submissionIndex: event.submissionIndex,\n snapshot: event.state,\n // Spot quote delta = -vQuote delta\n quoteDelta: event.state.preBalance.vQuoteBalance.minus(\n event.state.postBalance.vQuoteBalance,\n ),\n isolated: event.isolated,\n tx: event.tx,\n ...subaccountFromHex(event.subaccount),\n };\n })\n .filter((event): event is IndexerSettlementEvent => !!event);\n\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n async getPaginatedSubaccountLiquidationEvents(\n params: GetIndexerSubaccountLiquidationEventsParams,\n ): Promise<GetIndexerSubaccountLiquidationEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n } = params;\n\n // There is 1 event emitted per product, including quote\n // However, if the balance change is 0, then the liquidation did not touch the product\n // A tx operates on a given health group, so only a spot & its associated perp can be actually liquidated within a single tx\n // with an associated quote balance change\n const limit = requestedLimit + 1;\n const baseResponse = await this.getEvents({\n startCursor,\n maxTimestampInclusive,\n eventTypes: ['liquidate_subaccount'],\n limit: {\n type: 'txs',\n value: limit,\n },\n subaccount: { subaccountName, subaccountOwner },\n });\n\n // Now aggregate results by the submission index, use map to maintain insertion order\n const eventsBySubmissionIdx = new Map<\n string,\n Partial<IndexerLiquidationEvent>\n >();\n\n baseResponse.forEach((event) => {\n const mappedEvent = (() => {\n const existingEvent = eventsBySubmissionIdx.get(event.submissionIndex);\n if (existingEvent) {\n return existingEvent;\n }\n\n const newEvent: Partial<IndexerLiquidationEvent> = {\n perp: undefined,\n spot: undefined,\n quote: undefined,\n timestamp: event.timestamp,\n submissionIndex: event.submissionIndex,\n };\n\n return newEvent;\n })();\n\n // The original balance is the negated delta\n const balanceDelta = event.state.postBalance.amount.minus(\n event.state.preBalance.amount,\n );\n\n // Event without balance change - not part of this liq\n // However, we could have zero balance changes for the quote product if this was a partial liquidation\n if (\n balanceDelta.isZero() &&\n event.state.market.productId !== QUOTE_PRODUCT_ID\n ) {\n return;\n }\n\n if (event.state.type === ProductEngineType.PERP) {\n mappedEvent.perp = {\n amountLiquidated: balanceDelta.negated(),\n // This cast is safe because we're checking for event.state.type\n indexerEvent:\n event as IndexerEventWithTx<IndexerEventPerpStateSnapshot>,\n };\n } else if (event.state.market.productId === QUOTE_PRODUCT_ID) {\n mappedEvent.quote = {\n balanceDelta,\n indexerEvent:\n event as IndexerEventWithTx<IndexerEventSpotStateSnapshot>,\n };\n } else {\n mappedEvent.spot = {\n amountLiquidated: balanceDelta.negated(),\n indexerEvent:\n event as IndexerEventWithTx<IndexerEventSpotStateSnapshot>,\n };\n }\n\n eventsBySubmissionIdx.set(event.submissionIndex, mappedEvent);\n });\n\n // Force cast to get rid of the `Partial`\n const events = Array.from(\n eventsBySubmissionIdx.values(),\n ) as IndexerLiquidationEvent[];\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n /**\n * Get all interest funding payments for a given subaccount with the standard pagination response\n * This is a simple wrapper over the underlying `getInterestFundingPayments` function. Very little\n * additional processing is needed because the endpoint is well structured for pagination\n *\n * @param params\n */\n async getPaginatedSubaccountInterestFundingPayments(\n params: GetIndexerSubaccountInterestFundingPaymentsParams,\n ): Promise<GetIndexerPaginatedInterestFundingPaymentsResponse> {\n const {\n limit,\n productIds,\n startCursor,\n maxTimestampInclusive,\n subaccountName,\n subaccountOwner,\n } = params;\n const baseResponse = await this.getInterestFundingPayments({\n limit,\n productIds,\n startCursor,\n maxTimestampInclusive,\n subaccount: {\n subaccountName,\n subaccountOwner,\n },\n });\n\n return {\n ...baseResponse,\n meta: {\n hasMore: baseResponse.nextCursor != null,\n nextCursor: baseResponse.nextCursor ?? undefined,\n },\n };\n }\n\n /**\n * Paginated leaderboard query that paginates on rank number.\n *\n * @param params\n */\n async getPaginatedLeaderboard(\n params: GetIndexerPaginatedLeaderboardParams,\n ): Promise<GetIndexerPaginatedLeaderboardResponse> {\n const requestedLimit = params.limit;\n\n const baseResponse = await this.getLeaderboard({\n contestId: params.contestId,\n rankType: params.rankType,\n // Query for 1 more result for proper pagination\n limit: requestedLimit + 1,\n // Start cursor is the next rank number\n startCursor: params.startCursor,\n });\n\n // Next cursor is the rank number of the (requestedLimit+1)th item\n const nextCursor =\n params.rankType === 'pnl'\n ? baseResponse.participants[requestedLimit]?.pnlRank\n : baseResponse.participants[requestedLimit]?.roiRank;\n\n return {\n ...baseResponse,\n // Truncate the response to the requested limit\n participants: baseResponse.participants.slice(0, requestedLimit),\n meta: {\n hasMore: baseResponse.participants.length > requestedLimit,\n nextCursor:\n nextCursor !== undefined ? toIntegerString(nextCursor) : undefined,\n },\n };\n }\n\n /**\n * A util function to generate the standard pagination response for events\n * @param events\n * @param requestedLimit given by consumers of the SDK\n * @private\n */\n private getPaginationEventsResponse<T extends BaseIndexerPaginatedEvent>(\n events: T[],\n requestedLimit: number,\n ): PaginatedIndexerEventsResponse<T> {\n const truncatedEvents = events.slice(0, requestedLimit);\n const hasMore = events.length > truncatedEvents.length;\n\n return {\n events: truncatedEvents,\n meta: {\n hasMore,\n // We want the NEXT available cursor, so we use the first event after the truncation cutoff\n // If len(events) === len(truncatedEvents), there are no more entries and this is undefined\n nextCursor: events[truncatedEvents.length]?.submissionI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KAAK,eAAe;AAAA,MAC7C,WAAW,OAAO;AAAA,MAClB,UAAU,OAAO;AAAA;AAAA,MAEjB,OAAO,iBAAiB;AAAA;AAAA,MAExB,aAAa,OAAO;AAAA,IACtB,CAAC;AAGD,UAAM,aACJ,OAAO,aAAa,QAChB,aAAa,aAAa,cAAc,GAAG,UAC3C,aAAa,aAAa,cAAc,GAAG;AAEjD,WAAO;AAAA,MACL,GAAG;AAAA;AAAA,MAEH,cAAc,aAAa,aAAa,MAAM,GAAG,cAAc;AAAA,MAC/D,MAAM;AAAA,QACJ,SAAS,aAAa,aAAa,SAAS;AAAA,QAC5C,YACE,eAAe,aAAY,+BAAgB,UAAU,IAAI;AAAA,MAC7D;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQQ,4BACN,QACA,gBACmC;AACnC,UAAM,kBAAkB,OAAO,MAAM,GAAG,cAAc;AACtD,UAAM,UAAU,OAAO,SAAS,gBAAgB;AAEhD,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,MAAM;AAAA,QACJ;AAAA;AAAA;AAAA,QAGA,YAAY,OAAO,gBAAgB,MAAM,GAAG;AAAA,MAC9C;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/IndexerClient.ts"],"sourcesContent":["import {\n NLP_PRODUCT_ID,\n ProductEngineType,\n QUOTE_PRODUCT_ID,\n subaccountFromHex,\n toBigDecimal,\n toIntegerString,\n} from '@nadohq/shared';\n\nimport { IndexerBaseClient } from './IndexerBaseClient';\nimport {\n BaseIndexerPaginatedEvent,\n CollateralEventType,\n GetIndexerPaginatedInterestFundingPaymentsResponse,\n GetIndexerPaginatedLeaderboardParams,\n GetIndexerPaginatedLeaderboardResponse,\n GetIndexerPaginatedOrdersParams,\n GetIndexerPaginatedOrdersResponse,\n GetIndexerSubaccountCollateralEventsParams,\n GetIndexerSubaccountCollateralEventsResponse,\n GetIndexerSubaccountInterestFundingPaymentsParams,\n GetIndexerSubaccountLiquidationEventsParams,\n GetIndexerSubaccountLiquidationEventsResponse,\n GetIndexerSubaccountMatchEventParams,\n GetIndexerSubaccountMatchEventsResponse,\n GetIndexerSubaccountNlpEventsParams,\n GetIndexerSubaccountNlpEventsResponse,\n GetIndexerSubaccountSettlementEventsParams,\n GetIndexerSubaccountSettlementEventsResponse,\n IndexerCollateralEvent,\n IndexerEventPerpStateSnapshot,\n IndexerEventSpotStateSnapshot,\n IndexerEventWithTx,\n IndexerLiquidationEvent,\n IndexerNlpEvent,\n IndexerSettlementEvent,\n PaginatedIndexerEventsResponse,\n} from './types';\n\n/**\n * Indexer client providing paginated queries for historical data from the Nado indexer service\n */\nexport class IndexerClient extends IndexerBaseClient {\n async getPaginatedSubaccountMatchEvents(\n params: GetIndexerSubaccountMatchEventParams,\n ): Promise<GetIndexerSubaccountMatchEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n isolated,\n productIds,\n } = params;\n\n const limit = requestedLimit + 1;\n const events = await this.getMatchEvents({\n startCursor,\n maxTimestampInclusive,\n limit,\n subaccounts: [{ subaccountName, subaccountOwner }],\n productIds,\n isolated,\n });\n\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n async getPaginatedSubaccountNlpEvents(\n params: GetIndexerSubaccountNlpEventsParams,\n ): Promise<GetIndexerSubaccountNlpEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n } = params;\n\n // There are 2 events per mint/burn for spot - one associated with the NLP product & the other with the primary quote\n const limit = requestedLimit + 1;\n const baseResponse = await this.getEvents({\n startCursor,\n maxTimestampInclusive,\n eventTypes: ['mint_nlp', 'burn_nlp'],\n limit: {\n type: 'txs',\n value: limit,\n },\n subaccounts: [{ subaccountName, subaccountOwner }],\n });\n\n // Now aggregate results by the submission index, use map to maintain insertion order\n const eventsBySubmissionIdx = new Map<string, IndexerNlpEvent>();\n\n baseResponse.forEach((event) => {\n const mappedEvent = (() => {\n const existingEvent = eventsBySubmissionIdx.get(event.submissionIndex);\n if (existingEvent) {\n return existingEvent;\n }\n\n const newEvent: IndexerNlpEvent = {\n nlpDelta: toBigDecimal(0),\n primaryQuoteDelta: toBigDecimal(0),\n timestamp: event.timestamp,\n submissionIndex: event.submissionIndex,\n tx: event.tx,\n ...subaccountFromHex(event.subaccount),\n };\n eventsBySubmissionIdx.set(event.submissionIndex, newEvent);\n\n return newEvent;\n })();\n\n const balanceDelta = event.state.postBalance.amount.minus(\n event.state.preBalance.amount,\n );\n\n const productId = event.state.market.productId;\n if (productId === QUOTE_PRODUCT_ID) {\n mappedEvent.primaryQuoteDelta = balanceDelta;\n } else if (productId === NLP_PRODUCT_ID) {\n mappedEvent.nlpDelta = balanceDelta;\n } else {\n throw Error(`Invalid product ID for NLP event ${productId}`);\n }\n });\n\n // Force cast to get rid of the `Partial`\n const events = Array.from(eventsBySubmissionIdx.values());\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n async getPaginatedSubaccountCollateralEvents(\n params: GetIndexerSubaccountCollateralEventsParams,\n ): Promise<GetIndexerSubaccountCollateralEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n eventTypes,\n isolated,\n } = params;\n\n const limit = requestedLimit + 1;\n const baseResponse = await this.getEvents({\n startCursor,\n maxTimestampInclusive,\n eventTypes: eventTypes ?? [\n 'deposit_collateral',\n 'withdraw_collateral',\n 'transfer_quote',\n ],\n limit: {\n type: 'txs',\n value: limit,\n },\n subaccounts: [{ subaccountName, subaccountOwner }],\n isolated,\n });\n\n const events = baseResponse.map((event): IndexerCollateralEvent => {\n if (event.state.type !== ProductEngineType.SPOT) {\n throw Error('Incorrect event state for collateral event');\n }\n\n return {\n timestamp: event.timestamp,\n // This cast is safe as the query param restricts to collateral events\n eventType: event.eventType as CollateralEventType,\n submissionIndex: event.submissionIndex,\n snapshot: event.state,\n amount: event.state.postBalance.amount.minus(\n event.state.preBalance.amount,\n ),\n newAmount: event.state.postBalance.amount,\n tx: event.tx,\n ...subaccountFromHex(event.subaccount),\n };\n });\n\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n async getPaginatedSubaccountOrders(\n params: GetIndexerPaginatedOrdersParams,\n ): Promise<GetIndexerPaginatedOrdersResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n productIds,\n triggerTypes,\n isolated,\n } = params;\n\n const limit = requestedLimit + 1;\n const baseResponse = await this.getOrders({\n startCursor,\n maxTimestampInclusive,\n subaccounts: [{ subaccountName, subaccountOwner }],\n limit,\n productIds,\n triggerTypes,\n isolated,\n });\n\n // Same pagination meta logic as events, but duplicate for now as this return type is slightly different\n const truncatedOrders = baseResponse.slice(0, requestedLimit);\n const hasMore = baseResponse.length > truncatedOrders.length;\n return {\n meta: {\n hasMore,\n nextCursor: baseResponse[truncatedOrders.length]?.submissionIndex,\n },\n orders: truncatedOrders,\n };\n }\n\n async getPaginatedSubaccountSettlementEvents(\n params: GetIndexerSubaccountSettlementEventsParams,\n ): Promise<GetIndexerSubaccountSettlementEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n } = params;\n\n // Each settlement has a quote & perp balance change, so 2 events per settlement tx\n const limit = requestedLimit + 1;\n const baseResponse = await this.getEvents({\n startCursor,\n maxTimestampInclusive,\n eventTypes: ['settle_pnl'],\n limit: {\n type: 'txs',\n value: limit,\n },\n subaccounts: [{ subaccountName, subaccountOwner }],\n });\n\n const events = baseResponse\n .map((event): IndexerSettlementEvent | undefined => {\n if (event.state.market.productId === QUOTE_PRODUCT_ID) {\n return;\n }\n if (event.state.type !== ProductEngineType.PERP) {\n throw Error('Incorrect event state for settlement event');\n }\n\n return {\n timestamp: event.timestamp,\n submissionIndex: event.submissionIndex,\n snapshot: event.state,\n // Spot quote delta = -vQuote delta\n quoteDelta: event.state.preBalance.vQuoteBalance.minus(\n event.state.postBalance.vQuoteBalance,\n ),\n isolated: event.isolated,\n tx: event.tx,\n ...subaccountFromHex(event.subaccount),\n };\n })\n .filter((event): event is IndexerSettlementEvent => !!event);\n\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n async getPaginatedSubaccountLiquidationEvents(\n params: GetIndexerSubaccountLiquidationEventsParams,\n ): Promise<GetIndexerSubaccountLiquidationEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n } = params;\n\n // There is 1 event emitted per product, including quote\n // However, if the balance change is 0, then the liquidation did not touch the product\n // A tx operates on a given health group, so only a spot & its associated perp can be actually liquidated within a single tx\n // with an associated quote balance change\n const limit = requestedLimit + 1;\n const baseResponse = await this.getEvents({\n startCursor,\n maxTimestampInclusive,\n eventTypes: ['liquidate_subaccount'],\n limit: {\n type: 'txs',\n value: limit,\n },\n subaccounts: [{ subaccountName, subaccountOwner }],\n });\n\n // Now aggregate results by the submission index, use map to maintain insertion order\n const eventsBySubmissionIdx = new Map<\n string,\n Partial<IndexerLiquidationEvent>\n >();\n\n baseResponse.forEach((event) => {\n const mappedEvent = (() => {\n const existingEvent = eventsBySubmissionIdx.get(event.submissionIndex);\n if (existingEvent) {\n return existingEvent;\n }\n\n const newEvent: Partial<IndexerLiquidationEvent> = {\n perp: undefined,\n spot: undefined,\n quote: undefined,\n timestamp: event.timestamp,\n submissionIndex: event.submissionIndex,\n };\n\n return newEvent;\n })();\n\n // The original balance is the negated delta\n const balanceDelta = event.state.postBalance.amount.minus(\n event.state.preBalance.amount,\n );\n\n // Event without balance change - not part of this liq\n // However, we could have zero balance changes for the quote product if this was a partial liquidation\n if (\n balanceDelta.isZero() &&\n event.state.market.productId !== QUOTE_PRODUCT_ID\n ) {\n return;\n }\n\n if (event.state.type === ProductEngineType.PERP) {\n mappedEvent.perp = {\n amountLiquidated: balanceDelta.negated(),\n // This cast is safe because we're checking for event.state.type\n indexerEvent:\n event as IndexerEventWithTx<IndexerEventPerpStateSnapshot>,\n };\n } else if (event.state.market.productId === QUOTE_PRODUCT_ID) {\n mappedEvent.quote = {\n balanceDelta,\n indexerEvent:\n event as IndexerEventWithTx<IndexerEventSpotStateSnapshot>,\n };\n } else {\n mappedEvent.spot = {\n amountLiquidated: balanceDelta.negated(),\n indexerEvent:\n event as IndexerEventWithTx<IndexerEventSpotStateSnapshot>,\n };\n }\n\n eventsBySubmissionIdx.set(event.submissionIndex, mappedEvent);\n });\n\n // Force cast to get rid of the `Partial`\n const events = Array.from(\n eventsBySubmissionIdx.values(),\n ) as IndexerLiquidationEvent[];\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n /**\n * Get all interest funding payments for a given subaccount with the standard pagination response\n * This is a simple wrapper over the underlying `getInterestFundingPayments` function. Very little\n * additional processing is needed because the endpoint is well structured for pagination\n *\n * @param params\n */\n async getPaginatedSubaccountInterestFundingPayments(\n params: GetIndexerSubaccountInterestFundingPaymentsParams,\n ): Promise<GetIndexerPaginatedInterestFundingPaymentsResponse> {\n const {\n limit,\n productIds,\n startCursor,\n maxTimestampInclusive,\n subaccountName,\n subaccountOwner,\n } = params;\n const baseResponse = await this.getInterestFundingPayments({\n limit,\n productIds,\n startCursor,\n maxTimestampInclusive,\n subaccount: {\n subaccountName,\n subaccountOwner,\n },\n });\n\n return {\n ...baseResponse,\n meta: {\n hasMore: baseResponse.nextCursor != null,\n nextCursor: baseResponse.nextCursor ?? undefined,\n },\n };\n }\n\n /**\n * Paginated leaderboard query that paginates on rank number.\n *\n * @param params\n */\n async getPaginatedLeaderboard(\n params: GetIndexerPaginatedLeaderboardParams,\n ): Promise<GetIndexerPaginatedLeaderboardResponse> {\n const requestedLimit = params.limit;\n\n const baseResponse = await this.getLeaderboard({\n contestId: params.contestId,\n rankType: params.rankType,\n // Query for 1 more result for proper pagination\n limit: requestedLimit + 1,\n // Start cursor is the next rank number\n startCursor: params.startCursor,\n });\n\n // Next cursor is the rank number of the (requestedLimit+1)th item\n const nextCursor =\n params.rankType === 'pnl'\n ? baseResponse.participants[requestedLimit]?.pnlRank\n : baseResponse.participants[requestedLimit]?.roiRank;\n\n return {\n ...baseResponse,\n // Truncate the response to the requested limit\n participants: baseResponse.participants.slice(0, requestedLimit),\n meta: {\n hasMore: baseResponse.participants.length > requestedLimit,\n nextCursor:\n nextCursor !== undefined ? toIntegerString(nextCursor) : undefined,\n },\n };\n }\n\n /**\n * A util function to generate the standard pagination response for events\n * @param events\n * @param requestedLimit given by consumers of the SDK\n * @private\n */\n private getPaginationEventsResponse<T extends BaseIndexerPaginatedEvent>(\n events: T[],\n requestedLimit: number,\n ): PaginatedIndexerEventsResponse<T> {\n const truncatedEvents = events.slice(0, requestedLimit);\n const hasMore = events.length > truncatedEvents.length;\n\n return {\n events: truncatedEvents,\n meta: {\n hasMore,\n // We want the NEXT available cursor, so we use the first event after the truncation cutoff\n // If len(events) === len(truncatedEvents), there are no more entries and this is undefined\n nextCursor: events[truncatedEvents.length]?.submissionIndex,\n },\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAOO;AAEP,+BAAkC;AAiC3B,IAAM,gBAAN,cAA4B,2CAAkB;AAAA,EACnD,MAAM,kCACJ,QACkD;AAClD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI;AAEJ,UAAM,QAAQ,iBAAiB;AAC/B,UAAM,SAAS,MAAM,KAAK,eAAe;AAAA,MACvC;AAAA,MACA;AAAA,MACA;AAAA,MACA,aAAa,CAAC,EAAE,gBAAgB,gBAAgB,CAAC;AAAA,MACjD;AAAA,MACA;AAAA,IACF,CAAC;AAED,WAAO,KAAK,4BAA4B,QAAQ,cAAc;AAAA,EAChE;AAAA,EAEA,MAAM,gCACJ,QACgD;AAChD,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EAQQ,4BACN,QACA,gBACmC;AACnC,UAAM,kBAAkB,OAAO,MAAM,GAAG,cAAc;AACtD,UAAM,UAAU,OAAO,SAAS,gBAAgB;AAEhD,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,MAAM;AAAA,QACJ;AAAA;AAAA;AAAA,QAGA,YAAY,OAAO,gBAAgB,MAAM,GAAG;AAAA,MAC9C;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -24,7 +24,7 @@ var IndexerClient = class extends IndexerBaseClient {
24
24
  startCursor,
25
25
  maxTimestampInclusive,
26
26
  limit,
27
- subaccount: { subaccountName, subaccountOwner },
27
+ subaccounts: [{ subaccountName, subaccountOwner }],
28
28
  productIds,
29
29
  isolated
30
30
  });
@@ -47,7 +47,7 @@ var IndexerClient = class extends IndexerBaseClient {
47
47
  type: "txs",
48
48
  value: limit
49
49
  },
50
- subaccount: { subaccountName, subaccountOwner }
50
+ subaccounts: [{ subaccountName, subaccountOwner }]
51
51
  });
52
52
  const eventsBySubmissionIdx = /* @__PURE__ */ new Map();
53
53
  baseResponse.forEach((event) => {
@@ -105,7 +105,7 @@ var IndexerClient = class extends IndexerBaseClient {
105
105
  type: "txs",
106
106
  value: limit
107
107
  },
108
- subaccount: { subaccountName, subaccountOwner },
108
+ subaccounts: [{ subaccountName, subaccountOwner }],
109
109
  isolated
110
110
  });
111
111
  const events = baseResponse.map((event) => {
@@ -143,7 +143,7 @@ var IndexerClient = class extends IndexerBaseClient {
143
143
  const baseResponse = await this.getOrders({
144
144
  startCursor,
145
145
  maxTimestampInclusive,
146
- subaccount: { subaccountName, subaccountOwner },
146
+ subaccounts: [{ subaccountName, subaccountOwner }],
147
147
  limit,
148
148
  productIds,
149
149
  triggerTypes,
@@ -176,7 +176,7 @@ var IndexerClient = class extends IndexerBaseClient {
176
176
  type: "txs",
177
177
  value: limit
178
178
  },
179
- subaccount: { subaccountName, subaccountOwner }
179
+ subaccounts: [{ subaccountName, subaccountOwner }]
180
180
  });
181
181
  const events = baseResponse.map((event) => {
182
182
  if (event.state.market.productId === QUOTE_PRODUCT_ID) {
@@ -217,7 +217,7 @@ var IndexerClient = class extends IndexerBaseClient {
217
217
  type: "txs",
218
218
  value: limit
219
219
  },
220
- subaccount: { subaccountName, subaccountOwner }
220
+ subaccounts: [{ subaccountName, subaccountOwner }]
221
221
  });
222
222
  const eventsBySubmissionIdx = /* @__PURE__ */ new Map();
223
223
  baseResponse.forEach((event) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/IndexerClient.ts"],"sourcesContent":["import {\n NLP_PRODUCT_ID,\n ProductEngineType,\n QUOTE_PRODUCT_ID,\n subaccountFromHex,\n toBigDecimal,\n toIntegerString,\n} from '@nadohq/shared';\n\nimport { IndexerBaseClient } from './IndexerBaseClient';\nimport {\n BaseIndexerPaginatedEvent,\n CollateralEventType,\n GetIndexerPaginatedInterestFundingPaymentsResponse,\n GetIndexerPaginatedLeaderboardParams,\n GetIndexerPaginatedLeaderboardResponse,\n GetIndexerPaginatedOrdersParams,\n GetIndexerPaginatedOrdersResponse,\n GetIndexerSubaccountCollateralEventsParams,\n GetIndexerSubaccountCollateralEventsResponse,\n GetIndexerSubaccountInterestFundingPaymentsParams,\n GetIndexerSubaccountLiquidationEventsParams,\n GetIndexerSubaccountLiquidationEventsResponse,\n GetIndexerSubaccountMatchEventParams,\n GetIndexerSubaccountMatchEventsResponse,\n GetIndexerSubaccountNlpEventsParams,\n GetIndexerSubaccountNlpEventsResponse,\n GetIndexerSubaccountSettlementEventsParams,\n GetIndexerSubaccountSettlementEventsResponse,\n IndexerCollateralEvent,\n IndexerEventPerpStateSnapshot,\n IndexerEventSpotStateSnapshot,\n IndexerEventWithTx,\n IndexerLiquidationEvent,\n IndexerNlpEvent,\n IndexerSettlementEvent,\n PaginatedIndexerEventsResponse,\n} from './types';\n\n/**\n * Indexer client providing paginated queries for historical data from the Nado indexer service\n */\nexport class IndexerClient extends IndexerBaseClient {\n async getPaginatedSubaccountMatchEvents(\n params: GetIndexerSubaccountMatchEventParams,\n ): Promise<GetIndexerSubaccountMatchEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n isolated,\n productIds,\n } = params;\n\n const limit = requestedLimit + 1;\n const events = await this.getMatchEvents({\n startCursor,\n maxTimestampInclusive,\n limit,\n subaccount: { subaccountName, subaccountOwner },\n productIds,\n isolated,\n });\n\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n async getPaginatedSubaccountNlpEvents(\n params: GetIndexerSubaccountNlpEventsParams,\n ): Promise<GetIndexerSubaccountNlpEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n } = params;\n\n // There are 2 events per mint/burn for spot - one associated with the NLP product & the other with the primary quote\n const limit = requestedLimit + 1;\n const baseResponse = await this.getEvents({\n startCursor,\n maxTimestampInclusive,\n eventTypes: ['mint_nlp', 'burn_nlp'],\n limit: {\n type: 'txs',\n value: limit,\n },\n subaccount: { subaccountName, subaccountOwner },\n });\n\n // Now aggregate results by the submission index, use map to maintain insertion order\n const eventsBySubmissionIdx = new Map<string, IndexerNlpEvent>();\n\n baseResponse.forEach((event) => {\n const mappedEvent = (() => {\n const existingEvent = eventsBySubmissionIdx.get(event.submissionIndex);\n if (existingEvent) {\n return existingEvent;\n }\n\n const newEvent: IndexerNlpEvent = {\n nlpDelta: toBigDecimal(0),\n primaryQuoteDelta: toBigDecimal(0),\n timestamp: event.timestamp,\n submissionIndex: event.submissionIndex,\n tx: event.tx,\n ...subaccountFromHex(event.subaccount),\n };\n eventsBySubmissionIdx.set(event.submissionIndex, newEvent);\n\n return newEvent;\n })();\n\n const balanceDelta = event.state.postBalance.amount.minus(\n event.state.preBalance.amount,\n );\n\n const productId = event.state.market.productId;\n if (productId === QUOTE_PRODUCT_ID) {\n mappedEvent.primaryQuoteDelta = balanceDelta;\n } else if (productId === NLP_PRODUCT_ID) {\n mappedEvent.nlpDelta = balanceDelta;\n } else {\n throw Error(`Invalid product ID for NLP event ${productId}`);\n }\n });\n\n // Force cast to get rid of the `Partial`\n const events = Array.from(eventsBySubmissionIdx.values());\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n async getPaginatedSubaccountCollateralEvents(\n params: GetIndexerSubaccountCollateralEventsParams,\n ): Promise<GetIndexerSubaccountCollateralEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n eventTypes,\n isolated,\n } = params;\n\n const limit = requestedLimit + 1;\n const baseResponse = await this.getEvents({\n startCursor,\n maxTimestampInclusive,\n eventTypes: eventTypes ?? [\n 'deposit_collateral',\n 'withdraw_collateral',\n 'transfer_quote',\n ],\n limit: {\n type: 'txs',\n value: limit,\n },\n subaccount: { subaccountName, subaccountOwner },\n isolated,\n });\n\n const events = baseResponse.map((event): IndexerCollateralEvent => {\n if (event.state.type !== ProductEngineType.SPOT) {\n throw Error('Incorrect event state for collateral event');\n }\n\n return {\n timestamp: event.timestamp,\n // This cast is safe as the query param restricts to collateral events\n eventType: event.eventType as CollateralEventType,\n submissionIndex: event.submissionIndex,\n snapshot: event.state,\n amount: event.state.postBalance.amount.minus(\n event.state.preBalance.amount,\n ),\n newAmount: event.state.postBalance.amount,\n tx: event.tx,\n ...subaccountFromHex(event.subaccount),\n };\n });\n\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n async getPaginatedSubaccountOrders(\n params: GetIndexerPaginatedOrdersParams,\n ): Promise<GetIndexerPaginatedOrdersResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n productIds,\n triggerTypes,\n isolated,\n } = params;\n\n const limit = requestedLimit + 1;\n const baseResponse = await this.getOrders({\n startCursor,\n maxTimestampInclusive,\n subaccount: { subaccountName, subaccountOwner },\n limit,\n productIds,\n triggerTypes,\n isolated,\n });\n\n // Same pagination meta logic as events, but duplicate for now as this return type is slightly different\n const truncatedOrders = baseResponse.slice(0, requestedLimit);\n const hasMore = baseResponse.length > truncatedOrders.length;\n return {\n meta: {\n hasMore,\n nextCursor: baseResponse[truncatedOrders.length]?.submissionIndex,\n },\n orders: truncatedOrders,\n };\n }\n\n async getPaginatedSubaccountSettlementEvents(\n params: GetIndexerSubaccountSettlementEventsParams,\n ): Promise<GetIndexerSubaccountSettlementEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n } = params;\n\n // Each settlement has a quote & perp balance change, so 2 events per settlement tx\n const limit = requestedLimit + 1;\n const baseResponse = await this.getEvents({\n startCursor,\n maxTimestampInclusive,\n eventTypes: ['settle_pnl'],\n limit: {\n type: 'txs',\n value: limit,\n },\n subaccount: { subaccountName, subaccountOwner },\n });\n\n const events = baseResponse\n .map((event): IndexerSettlementEvent | undefined => {\n if (event.state.market.productId === QUOTE_PRODUCT_ID) {\n return;\n }\n if (event.state.type !== ProductEngineType.PERP) {\n throw Error('Incorrect event state for settlement event');\n }\n\n return {\n timestamp: event.timestamp,\n submissionIndex: event.submissionIndex,\n snapshot: event.state,\n // Spot quote delta = -vQuote delta\n quoteDelta: event.state.preBalance.vQuoteBalance.minus(\n event.state.postBalance.vQuoteBalance,\n ),\n isolated: event.isolated,\n tx: event.tx,\n ...subaccountFromHex(event.subaccount),\n };\n })\n .filter((event): event is IndexerSettlementEvent => !!event);\n\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n async getPaginatedSubaccountLiquidationEvents(\n params: GetIndexerSubaccountLiquidationEventsParams,\n ): Promise<GetIndexerSubaccountLiquidationEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n } = params;\n\n // There is 1 event emitted per product, including quote\n // However, if the balance change is 0, then the liquidation did not touch the product\n // A tx operates on a given health group, so only a spot & its associated perp can be actually liquidated within a single tx\n // with an associated quote balance change\n const limit = requestedLimit + 1;\n const baseResponse = await this.getEvents({\n startCursor,\n maxTimestampInclusive,\n eventTypes: ['liquidate_subaccount'],\n limit: {\n type: 'txs',\n value: limit,\n },\n subaccount: { subaccountName, subaccountOwner },\n });\n\n // Now aggregate results by the submission index, use map to maintain insertion order\n const eventsBySubmissionIdx = new Map<\n string,\n Partial<IndexerLiquidationEvent>\n >();\n\n baseResponse.forEach((event) => {\n const mappedEvent = (() => {\n const existingEvent = eventsBySubmissionIdx.get(event.submissionIndex);\n if (existingEvent) {\n return existingEvent;\n }\n\n const newEvent: Partial<IndexerLiquidationEvent> = {\n perp: undefined,\n spot: undefined,\n quote: undefined,\n timestamp: event.timestamp,\n submissionIndex: event.submissionIndex,\n };\n\n return newEvent;\n })();\n\n // The original balance is the negated delta\n const balanceDelta = event.state.postBalance.amount.minus(\n event.state.preBalance.amount,\n );\n\n // Event without balance change - not part of this liq\n // However, we could have zero balance changes for the quote product if this was a partial liquidation\n if (\n balanceDelta.isZero() &&\n event.state.market.productId !== QUOTE_PRODUCT_ID\n ) {\n return;\n }\n\n if (event.state.type === ProductEngineType.PERP) {\n mappedEvent.perp = {\n amountLiquidated: balanceDelta.negated(),\n // This cast is safe because we're checking for event.state.type\n indexerEvent:\n event as IndexerEventWithTx<IndexerEventPerpStateSnapshot>,\n };\n } else if (event.state.market.productId === QUOTE_PRODUCT_ID) {\n mappedEvent.quote = {\n balanceDelta,\n indexerEvent:\n event as IndexerEventWithTx<IndexerEventSpotStateSnapshot>,\n };\n } else {\n mappedEvent.spot = {\n amountLiquidated: balanceDelta.negated(),\n indexerEvent:\n event as IndexerEventWithTx<IndexerEventSpotStateSnapshot>,\n };\n }\n\n eventsBySubmissionIdx.set(event.submissionIndex, mappedEvent);\n });\n\n // Force cast to get rid of the `Partial`\n const events = Array.from(\n eventsBySubmissionIdx.values(),\n ) as IndexerLiquidationEvent[];\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n /**\n * Get all interest funding payments for a given subaccount with the standard pagination response\n * This is a simple wrapper over the underlying `getInterestFundingPayments` function. Very little\n * additional processing is needed because the endpoint is well structured for pagination\n *\n * @param params\n */\n async getPaginatedSubaccountInterestFundingPayments(\n params: GetIndexerSubaccountInterestFundingPaymentsParams,\n ): Promise<GetIndexerPaginatedInterestFundingPaymentsResponse> {\n const {\n limit,\n productIds,\n startCursor,\n maxTimestampInclusive,\n subaccountName,\n subaccountOwner,\n } = params;\n const baseResponse = await this.getInterestFundingPayments({\n limit,\n productIds,\n startCursor,\n maxTimestampInclusive,\n subaccount: {\n subaccountName,\n subaccountOwner,\n },\n });\n\n return {\n ...baseResponse,\n meta: {\n hasMore: baseResponse.nextCursor != null,\n nextCursor: baseResponse.nextCursor ?? undefined,\n },\n };\n }\n\n /**\n * Paginated leaderboard query that paginates on rank number.\n *\n * @param params\n */\n async getPaginatedLeaderboard(\n params: GetIndexerPaginatedLeaderboardParams,\n ): Promise<GetIndexerPaginatedLeaderboardResponse> {\n const requestedLimit = params.limit;\n\n const baseResponse = await this.getLeaderboard({\n contestId: params.contestId,\n rankType: params.rankType,\n // Query for 1 more result for proper pagination\n limit: requestedLimit + 1,\n // Start cursor is the next rank number\n startCursor: params.startCursor,\n });\n\n // Next cursor is the rank number of the (requestedLimit+1)th item\n const nextCursor =\n params.rankType === 'pnl'\n ? baseResponse.participants[requestedLimit]?.pnlRank\n : baseResponse.participants[requestedLimit]?.roiRank;\n\n return {\n ...baseResponse,\n // Truncate the response to the requested limit\n participants: baseResponse.participants.slice(0, requestedLimit),\n meta: {\n hasMore: baseResponse.participants.length > requestedLimit,\n nextCursor:\n nextCursor !== undefined ? toIntegerString(nextCursor) : undefined,\n },\n };\n }\n\n /**\n * A util function to generate the standard pagination response for events\n * @param events\n * @param requestedLimit given by consumers of the SDK\n * @private\n */\n private getPaginationEventsResponse<T extends BaseIndexerPaginatedEvent>(\n events: T[],\n requestedLimit: number,\n ): PaginatedIndexerEventsResponse<T> {\n const truncatedEvents = events.slice(0, requestedLimit);\n const hasMore = events.length > truncatedEvents.length;\n\n return {\n events: truncatedEvents,\n meta: {\n hasMore,\n // We want the NEXT available cursor, so we use the first event after the truncation cutoff\n // If len(events) === len(truncatedEvents), there are no more entries and this is undefined\n nextCursor: events[truncatedEvents.length]?.submissionIndex,\n },\n };\n }\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,yBAAyB;AAiC3B,IAAM,gBAAN,cAA4B,kBAAkB;AAAA,EACnD,MAAM,kCACJ,QACkD;AAClD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI;AAEJ,UAAM,QAAQ,iBAAiB;AAC/B,UAAM,SAAS,MAAM,KAAK,eAAe;AAAA,MACvC;AAAA,MACA;AAAA,MACA;AAAA,MACA,YAAY,EAAE,gBAAgB,gBAAgB;AAAA,MAC9C;AAAA,MACA;AAAA,IACF,CAAC;AAED,WAAO,KAAK,4BAA4B,QAAQ,cAAc;AAAA,EAChE;AAAA,EAEA,MAAM,gCACJ,QACgD;AAChD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,IACF,IAAI;AAGJ,UAAM,QAAQ,iBAAiB;AAC/B,UAAM,eAAe,MAAM,KAAK,UAAU;AAAA,MACxC;AAAA,MACA;AAAA,MACA,YAAY,CAAC,YAAY,UAAU;AAAA,MACnC,OAAO;AAAA,QACL,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,MACA,YAAY,EAAE,gBAAgB,gBAAgB;AAAA,IAChD,CAAC;AAGD,UAAM,wBAAwB,oBAAI,IAA6B;AAE/D,iBAAa,QAAQ,CAAC,UAAU;AAC9B,YAAM,eAAe,MAAM;AACzB,cAAM,gBAAgB,sBAAsB,IAAI,MAAM,eAAe;AACrE,YAAI,eAAe;AACjB,iBAAO;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ACpC,YAAY,aAAa,cAAc;AAAA,MACzC;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,wBACJ,QACiD;AACjD,UAAM,iBAAiB,OAAO;AAE9B,UAAM,eAAe,MAAM,KAAK,eAAe;AAAA,MAC7C,WAAW,OAAO;AAAA,MAClB,UAAU,OAAO;AAAA;AAAA,MAEjB,OAAO,iBAAiB;AAAA;AAAA,MAExB,aAAa,OAAO;AAAA,IACtB,CAAC;AAGD,UAAM,aACJ,OAAO,aAAa,QAChB,aAAa,aAAa,cAAc,GAAG,UAC3C,aAAa,aAAa,cAAc,GAAG;AAEjD,WAAO;AAAA,MACL,GAAG;AAAA;AAAA,MAEH,cAAc,aAAa,aAAa,MAAM,GAAG,cAAc;AAAA,MAC/D,MAAM;AAAA,QACJ,SAAS,aAAa,aAAa,SAAS;AAAA,QAC5C,YACE,eAAe,SAAY,gBAAgB,UAAU,IAAI;AAAA,MAC7D;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQQ,4BACN,QACA,gBACmC;AACnC,UAAM,kBAAkB,OAAO,MAAM,GAAG,cAAc;AACtD,UAAM,UAAU,OAAO,SAAS,gBAAgB;AAEhD,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,MAAM;AAAA,QACJ;AAAA;AAAA;AAAA,QAGA,YAAY,OAAO,gBAAgB,MAAM,GAAG;AAAA,MAC9C;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/IndexerClient.ts"],"sourcesContent":["import {\n NLP_PRODUCT_ID,\n ProductEngineType,\n QUOTE_PRODUCT_ID,\n subaccountFromHex,\n toBigDecimal,\n toIntegerString,\n} from '@nadohq/shared';\n\nimport { IndexerBaseClient } from './IndexerBaseClient';\nimport {\n BaseIndexerPaginatedEvent,\n CollateralEventType,\n GetIndexerPaginatedInterestFundingPaymentsResponse,\n GetIndexerPaginatedLeaderboardParams,\n GetIndexerPaginatedLeaderboardResponse,\n GetIndexerPaginatedOrdersParams,\n GetIndexerPaginatedOrdersResponse,\n GetIndexerSubaccountCollateralEventsParams,\n GetIndexerSubaccountCollateralEventsResponse,\n GetIndexerSubaccountInterestFundingPaymentsParams,\n GetIndexerSubaccountLiquidationEventsParams,\n GetIndexerSubaccountLiquidationEventsResponse,\n GetIndexerSubaccountMatchEventParams,\n GetIndexerSubaccountMatchEventsResponse,\n GetIndexerSubaccountNlpEventsParams,\n GetIndexerSubaccountNlpEventsResponse,\n GetIndexerSubaccountSettlementEventsParams,\n GetIndexerSubaccountSettlementEventsResponse,\n IndexerCollateralEvent,\n IndexerEventPerpStateSnapshot,\n IndexerEventSpotStateSnapshot,\n IndexerEventWithTx,\n IndexerLiquidationEvent,\n IndexerNlpEvent,\n IndexerSettlementEvent,\n PaginatedIndexerEventsResponse,\n} from './types';\n\n/**\n * Indexer client providing paginated queries for historical data from the Nado indexer service\n */\nexport class IndexerClient extends IndexerBaseClient {\n async getPaginatedSubaccountMatchEvents(\n params: GetIndexerSubaccountMatchEventParams,\n ): Promise<GetIndexerSubaccountMatchEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n isolated,\n productIds,\n } = params;\n\n const limit = requestedLimit + 1;\n const events = await this.getMatchEvents({\n startCursor,\n maxTimestampInclusive,\n limit,\n subaccounts: [{ subaccountName, subaccountOwner }],\n productIds,\n isolated,\n });\n\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n async getPaginatedSubaccountNlpEvents(\n params: GetIndexerSubaccountNlpEventsParams,\n ): Promise<GetIndexerSubaccountNlpEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n } = params;\n\n // There are 2 events per mint/burn for spot - one associated with the NLP product & the other with the primary quote\n const limit = requestedLimit + 1;\n const baseResponse = await this.getEvents({\n startCursor,\n maxTimestampInclusive,\n eventTypes: ['mint_nlp', 'burn_nlp'],\n limit: {\n type: 'txs',\n value: limit,\n },\n subaccounts: [{ subaccountName, subaccountOwner }],\n });\n\n // Now aggregate results by the submission index, use map to maintain insertion order\n const eventsBySubmissionIdx = new Map<string, IndexerNlpEvent>();\n\n baseResponse.forEach((event) => {\n const mappedEvent = (() => {\n const existingEvent = eventsBySubmissionIdx.get(event.submissionIndex);\n if (existingEvent) {\n return existingEvent;\n }\n\n const newEvent: IndexerNlpEvent = {\n nlpDelta: toBigDecimal(0),\n primaryQuoteDelta: toBigDecimal(0),\n timestamp: event.timestamp,\n submissionIndex: event.submissionIndex,\n tx: event.tx,\n ...subaccountFromHex(event.subaccount),\n };\n eventsBySubmissionIdx.set(event.submissionIndex, newEvent);\n\n return newEvent;\n })();\n\n const balanceDelta = event.state.postBalance.amount.minus(\n event.state.preBalance.amount,\n );\n\n const productId = event.state.market.productId;\n if (productId === QUOTE_PRODUCT_ID) {\n mappedEvent.primaryQuoteDelta = balanceDelta;\n } else if (productId === NLP_PRODUCT_ID) {\n mappedEvent.nlpDelta = balanceDelta;\n } else {\n throw Error(`Invalid product ID for NLP event ${productId}`);\n }\n });\n\n // Force cast to get rid of the `Partial`\n const events = Array.from(eventsBySubmissionIdx.values());\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n async getPaginatedSubaccountCollateralEvents(\n params: GetIndexerSubaccountCollateralEventsParams,\n ): Promise<GetIndexerSubaccountCollateralEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n eventTypes,\n isolated,\n } = params;\n\n const limit = requestedLimit + 1;\n const baseResponse = await this.getEvents({\n startCursor,\n maxTimestampInclusive,\n eventTypes: eventTypes ?? [\n 'deposit_collateral',\n 'withdraw_collateral',\n 'transfer_quote',\n ],\n limit: {\n type: 'txs',\n value: limit,\n },\n subaccounts: [{ subaccountName, subaccountOwner }],\n isolated,\n });\n\n const events = baseResponse.map((event): IndexerCollateralEvent => {\n if (event.state.type !== ProductEngineType.SPOT) {\n throw Error('Incorrect event state for collateral event');\n }\n\n return {\n timestamp: event.timestamp,\n // This cast is safe as the query param restricts to collateral events\n eventType: event.eventType as CollateralEventType,\n submissionIndex: event.submissionIndex,\n snapshot: event.state,\n amount: event.state.postBalance.amount.minus(\n event.state.preBalance.amount,\n ),\n newAmount: event.state.postBalance.amount,\n tx: event.tx,\n ...subaccountFromHex(event.subaccount),\n };\n });\n\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n async getPaginatedSubaccountOrders(\n params: GetIndexerPaginatedOrdersParams,\n ): Promise<GetIndexerPaginatedOrdersResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n productIds,\n triggerTypes,\n isolated,\n } = params;\n\n const limit = requestedLimit + 1;\n const baseResponse = await this.getOrders({\n startCursor,\n maxTimestampInclusive,\n subaccounts: [{ subaccountName, subaccountOwner }],\n limit,\n productIds,\n triggerTypes,\n isolated,\n });\n\n // Same pagination meta logic as events, but duplicate for now as this return type is slightly different\n const truncatedOrders = baseResponse.slice(0, requestedLimit);\n const hasMore = baseResponse.length > truncatedOrders.length;\n return {\n meta: {\n hasMore,\n nextCursor: baseResponse[truncatedOrders.length]?.submissionIndex,\n },\n orders: truncatedOrders,\n };\n }\n\n async getPaginatedSubaccountSettlementEvents(\n params: GetIndexerSubaccountSettlementEventsParams,\n ): Promise<GetIndexerSubaccountSettlementEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n } = params;\n\n // Each settlement has a quote & perp balance change, so 2 events per settlement tx\n const limit = requestedLimit + 1;\n const baseResponse = await this.getEvents({\n startCursor,\n maxTimestampInclusive,\n eventTypes: ['settle_pnl'],\n limit: {\n type: 'txs',\n value: limit,\n },\n subaccounts: [{ subaccountName, subaccountOwner }],\n });\n\n const events = baseResponse\n .map((event): IndexerSettlementEvent | undefined => {\n if (event.state.market.productId === QUOTE_PRODUCT_ID) {\n return;\n }\n if (event.state.type !== ProductEngineType.PERP) {\n throw Error('Incorrect event state for settlement event');\n }\n\n return {\n timestamp: event.timestamp,\n submissionIndex: event.submissionIndex,\n snapshot: event.state,\n // Spot quote delta = -vQuote delta\n quoteDelta: event.state.preBalance.vQuoteBalance.minus(\n event.state.postBalance.vQuoteBalance,\n ),\n isolated: event.isolated,\n tx: event.tx,\n ...subaccountFromHex(event.subaccount),\n };\n })\n .filter((event): event is IndexerSettlementEvent => !!event);\n\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n async getPaginatedSubaccountLiquidationEvents(\n params: GetIndexerSubaccountLiquidationEventsParams,\n ): Promise<GetIndexerSubaccountLiquidationEventsResponse> {\n const {\n startCursor,\n maxTimestampInclusive,\n limit: requestedLimit,\n subaccountName,\n subaccountOwner,\n } = params;\n\n // There is 1 event emitted per product, including quote\n // However, if the balance change is 0, then the liquidation did not touch the product\n // A tx operates on a given health group, so only a spot & its associated perp can be actually liquidated within a single tx\n // with an associated quote balance change\n const limit = requestedLimit + 1;\n const baseResponse = await this.getEvents({\n startCursor,\n maxTimestampInclusive,\n eventTypes: ['liquidate_subaccount'],\n limit: {\n type: 'txs',\n value: limit,\n },\n subaccounts: [{ subaccountName, subaccountOwner }],\n });\n\n // Now aggregate results by the submission index, use map to maintain insertion order\n const eventsBySubmissionIdx = new Map<\n string,\n Partial<IndexerLiquidationEvent>\n >();\n\n baseResponse.forEach((event) => {\n const mappedEvent = (() => {\n const existingEvent = eventsBySubmissionIdx.get(event.submissionIndex);\n if (existingEvent) {\n return existingEvent;\n }\n\n const newEvent: Partial<IndexerLiquidationEvent> = {\n perp: undefined,\n spot: undefined,\n quote: undefined,\n timestamp: event.timestamp,\n submissionIndex: event.submissionIndex,\n };\n\n return newEvent;\n })();\n\n // The original balance is the negated delta\n const balanceDelta = event.state.postBalance.amount.minus(\n event.state.preBalance.amount,\n );\n\n // Event without balance change - not part of this liq\n // However, we could have zero balance changes for the quote product if this was a partial liquidation\n if (\n balanceDelta.isZero() &&\n event.state.market.productId !== QUOTE_PRODUCT_ID\n ) {\n return;\n }\n\n if (event.state.type === ProductEngineType.PERP) {\n mappedEvent.perp = {\n amountLiquidated: balanceDelta.negated(),\n // This cast is safe because we're checking for event.state.type\n indexerEvent:\n event as IndexerEventWithTx<IndexerEventPerpStateSnapshot>,\n };\n } else if (event.state.market.productId === QUOTE_PRODUCT_ID) {\n mappedEvent.quote = {\n balanceDelta,\n indexerEvent:\n event as IndexerEventWithTx<IndexerEventSpotStateSnapshot>,\n };\n } else {\n mappedEvent.spot = {\n amountLiquidated: balanceDelta.negated(),\n indexerEvent:\n event as IndexerEventWithTx<IndexerEventSpotStateSnapshot>,\n };\n }\n\n eventsBySubmissionIdx.set(event.submissionIndex, mappedEvent);\n });\n\n // Force cast to get rid of the `Partial`\n const events = Array.from(\n eventsBySubmissionIdx.values(),\n ) as IndexerLiquidationEvent[];\n return this.getPaginationEventsResponse(events, requestedLimit);\n }\n\n /**\n * Get all interest funding payments for a given subaccount with the standard pagination response\n * This is a simple wrapper over the underlying `getInterestFundingPayments` function. Very little\n * additional processing is needed because the endpoint is well structured for pagination\n *\n * @param params\n */\n async getPaginatedSubaccountInterestFundingPayments(\n params: GetIndexerSubaccountInterestFundingPaymentsParams,\n ): Promise<GetIndexerPaginatedInterestFundingPaymentsResponse> {\n const {\n limit,\n productIds,\n startCursor,\n maxTimestampInclusive,\n subaccountName,\n subaccountOwner,\n } = params;\n const baseResponse = await this.getInterestFundingPayments({\n limit,\n productIds,\n startCursor,\n maxTimestampInclusive,\n subaccount: {\n subaccountName,\n subaccountOwner,\n },\n });\n\n return {\n ...baseResponse,\n meta: {\n hasMore: baseResponse.nextCursor != null,\n nextCursor: baseResponse.nextCursor ?? undefined,\n },\n };\n }\n\n /**\n * Paginated leaderboard query that paginates on rank number.\n *\n * @param params\n */\n async getPaginatedLeaderboard(\n params: GetIndexerPaginatedLeaderboardParams,\n ): Promise<GetIndexerPaginatedLeaderboardResponse> {\n const requestedLimit = params.limit;\n\n const baseResponse = await this.getLeaderboard({\n contestId: params.contestId,\n rankType: params.rankType,\n // Query for 1 more result for proper pagination\n limit: requestedLimit + 1,\n // Start cursor is the next rank number\n startCursor: params.startCursor,\n });\n\n // Next cursor is the rank number of the (requestedLimit+1)th item\n const nextCursor =\n params.rankType === 'pnl'\n ? baseResponse.participants[requestedLimit]?.pnlRank\n : baseResponse.participants[requestedLimit]?.roiRank;\n\n return {\n ...baseResponse,\n // Truncate the response to the requested limit\n participants: baseResponse.participants.slice(0, requestedLimit),\n meta: {\n hasMore: baseResponse.participants.length > requestedLimit,\n nextCursor:\n nextCursor !== undefined ? toIntegerString(nextCursor) : undefined,\n },\n };\n }\n\n /**\n * A util function to generate the standard pagination response for events\n * @param events\n * @param requestedLimit given by consumers of the SDK\n * @private\n */\n private getPaginationEventsResponse<T extends BaseIndexerPaginatedEvent>(\n events: T[],\n requestedLimit: number,\n ): PaginatedIndexerEventsResponse<T> {\n const truncatedEvents = events.slice(0, requestedLimit);\n const hasMore = events.length > truncatedEvents.length;\n\n return {\n events: truncatedEvents,\n meta: {\n hasMore,\n // We want the NEXT available cursor, so we use the first event after the truncation cutoff\n // If len(events) === len(truncatedEvents), there are no more entries and this is undefined\n nextCursor: events[truncatedEvents.length]?.submissionIndex,\n },\n };\n }\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,yBAAyB;AAiC3B,IAAM,gBAAN,cAA4B,kBAAkB;AAAA,EACnD,MAAM,kCACJ,QACkD;AAClD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI;AAEJ,UAAM,QAAQ,iBAAiB;AAC/B,UAAM,SAAS,MAAM,KAAK,eAAe;AAAA,MACvC;AAAA,MACA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cAAc;AAAA,MAC/D,MAAM;AAAA,QACJ,SAAS,aAAa,aAAa,SAAS;AAAA,QAC5C,YACE,eAAe,SAAY,gBAAgB,UAAU,IAAI;AAAA,MAC7D;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQQ,4BACN,QACA,gBACmC;AACnC,UAAM,kBAAkB,OAAO,MAAM,GAAG,cAAc;AACtD,UAAM,UAAU,OAAO,SAAS,gBAAgB;AAEhD,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,MAAM;AAAA,QACJ;AAAA;AAAA;AAAA,QAGA,YAAY,OAAO,gBAAgB,MAAM,GAAG;AAAA,MAC9C;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/clientTypes.ts"],"sourcesContent":["import {\n BigDecimal,\n EIP712OrderValues,\n Market,\n OrderAppendix,\n PerpBalance,\n PerpMarket,\n ProductEngineType,\n SpotBalance,\n SpotMarket,\n Subaccount,\n} from '@nadohq/shared';\nimport { Address, Hex } from 'viem';\nimport { CandlestickPeriod } from './CandlestickPeriod';\nimport { IndexerEventType } from './IndexerEventType';\nimport { IndexerLeaderboardRankType } from './IndexerLeaderboardType';\nimport { NadoTx, NadoWithdrawCollateralTx } from './NadoTx';\nimport {\n IndexerServerFastWithdrawalSignatureParams,\n IndexerServerListSubaccountsParams,\n IndexerServerTriggerTypeFilter,\n} from './serverTypes';\n\n/**\n * Base types\n */\n\nexport type IndexerSpotBalance = Omit<SpotBalance, 'healthContributions'>;\n\nexport type IndexerPerpBalance = Omit<PerpBalance, 'healthContributions'>;\n\nexport interface IndexerEventSpotStateSnapshot {\n type: ProductEngineType.SPOT;\n preBalance: IndexerSpotBalance;\n postBalance: IndexerSpotBalance;\n market: SpotMarket;\n}\n\nexport interface IndexerEventPerpStateSnapshot {\n type: ProductEngineType.PERP;\n preBalance: IndexerPerpBalance;\n postBalance: IndexerPerpBalance;\n market: PerpMarket;\n}\n\nexport type IndexerEventBalanceStateSnapshot =\n | IndexerEventSpotStateSnapshot\n | IndexerEventPerpStateSnapshot;\n\nexport interface IndexerBalanceTrackedVars {\n netInterestUnrealized: BigDecimal;\n netInterestCumulative: BigDecimal;\n netFundingUnrealized: BigDecimal;\n netFundingCumulative: BigDecimal;\n netEntryUnrealized: BigDecimal;\n netEntryCumulative: BigDecimal;\n quoteVolumeCumulative: BigDecimal;\n}\n\nexport interface IndexerEvent<\n TStateType extends\n IndexerEventBalanceStateSnapshot = IndexerEventBalanceStateSnapshot,\n> {\n subaccount: string;\n isolated: boolean;\n // The product ID associated with the isolated perp market. This is only used when productId === QUOTE_PRODUCT_ID and isolated === true\n isolatedProductId: number | null;\n productId: number;\n submissionIndex: string;\n eventType: IndexerEventType;\n state: TStateType;\n trackedVars: IndexerBalanceTrackedVars;\n}\n\nexport interface IndexerEventWithTx<\n TStateType extends\n IndexerEventBalanceStateSnapshot = IndexerEventBalanceStateSnapshot,\n> extends IndexerEvent<TStateType> {\n timestamp: BigDecimal;\n tx: NadoTx;\n}\n\n/**\n * List subaccounts\n */\n\nexport type ListIndexerSubaccountsParams = IndexerServerListSubaccountsParams;\n\nexport type ListIndexerSubaccountsResponse = ({\n hexId: string;\n} & Subaccount)[];\n\n/**\n * Subaccount snapshots\n */\n\nexport interface GetIndexerMultiSubaccountSnapshotsParams {\n subaccounts: Subaccount[];\n // A series of timestamps for which to return a summary of each subaccount\n timestamps: number[];\n // If not given, will return both isolated & non-iso balances\n isolated?: boolean;\n}\n\nexport type IndexerSnapshotBalance<\n TStateType extends\n IndexerEventBalanceStateSnapshot = IndexerEventBalanceStateSnapshot,\n> = IndexerEvent<TStateType>;\n\nexport interface IndexerSubaccountSnapshot {\n timestamp: BigDecimal;\n balances: IndexerSnapshotBalance[];\n}\n\nexport interface GetIndexerMultiSubaccountSnapshotsResponse {\n // Utility for retrieving a subaccount's hex ID, in the same order as the request params\n subaccountHexIds: string[];\n // Map of subaccount hex -> timestamp requested -> summary for that time\n snapshots: Record<string, Record<string, IndexerSubaccountSnapshot>>;\n}\n\n/**\n * Perp prices\n */\n\nexport interface GetIndexerPerpPricesParams {\n productId: number;\n}\n\nexport interface IndexerPerpPrices {\n productId: number;\n indexPrice: BigDecimal;\n markPrice: BigDecimal;\n // Seconds\n updateTime: BigDecimal;\n}\n\nexport type GetIndexerPerpPricesResponse = IndexerPerpPrices;\n\nexport interface GetIndexerMultiProductPerpPricesParams {\n productIds: number[];\n}\n\n// Map of productId -> IndexerPerpPrices\nexport type GetIndexerMultiProductPerpPricesResponse = Record<\n number,\n IndexerPerpPrices\n>;\n\n/**\n * Oracle prices\n */\n\nexport interface GetIndexerOraclePricesParams {\n productIds: number[];\n}\n\nexport interface IndexerOraclePrice {\n productId: number;\n oraclePrice: BigDecimal;\n // Seconds\n updateTime: BigDecimal;\n}\n\nexport type GetIndexerOraclePricesResponse = IndexerOraclePrice[];\n\n/**\n * Funding rates\n */\n\nexport interface GetIndexerFundingRateParams {\n productId: number;\n}\n\nexport interface IndexerFundingRate {\n productId: number;\n fundingRate: BigDecimal;\n // Seconds\n updateTime: BigDecimal;\n}\n\nexport type GetIndexerFundingRateResponse = IndexerFundingRate;\n\nexport interface GetIndexerMultiProductFundingRatesParams {\n productIds: number[];\n}\n\n// Map of productId -> IndexerFundingRate\nexport type GetIndexerMultiProductFundingRatesResponse = Record<\n number,\n IndexerFundingRate\n>;\n\n/**\n * Candlesticks\n */\n\nexport interface GetIndexerCandlesticksParams {\n productId: number;\n period: CandlestickPeriod;\n // Seconds\n maxTimeInclusive?: number;\n limit: number;\n}\n\n// Semi-Tradingview compatible bars\nexport interface Candlestick {\n // In SECONDS, for TV compat, this needs to be in millis\n time: BigDecimal;\n open: BigDecimal;\n high: BigDecimal;\n low: BigDecimal;\n close: BigDecimal;\n volume: BigDecimal;\n}\n\nexport type GetIndexerCandlesticksResponse = Candlestick[];\n\nexport type GetIndexerEdgeCandlesticksResponse = GetIndexerCandlesticksResponse;\n\nexport type GetIndexerEdgeCandlesticksParams = GetIndexerCandlesticksParams;\n\n/**\n * Product snapshots\n */\n\nexport interface GetIndexerProductSnapshotsParams {\n // Max submission index, inclusive\n startCursor?: string;\n productId: number;\n maxTimestampInclusive?: number;\n limit: number;\n}\n\nexport interface IndexerProductSnapshot extends Market {\n submissionIndex: string;\n}\n\nexport type GetIndexerProductSnapshotsResponse = IndexerProductSnapshot[];\n\nexport interface GetIndexerMultiProductSnapshotsParams {\n productIds: number[];\n maxTimestampInclusive?: number[];\n}\n\n// Map of timestamp -> (productId -> IndexerProductSnapshot)\nexport type GetIndexerMultiProductSnapshotsResponse = Record<\n string,\n Record<number, IndexerProductSnapshot>\n>;\n\nexport interface IndexerSnapshotsIntervalParams {\n /** Currently accepts all integers, in seconds */\n granularity: number;\n /**\n * Optional upper bound for snapshot timestamps (in seconds).\n * Without this, snapshots will default to align with last UTC midnight,\n * which can make \"Last 24h\" metrics inaccurate.\n */\n maxTimeInclusive?: number;\n limit: number;\n}\n\n/**\n * Market snapshots\n */\n\nexport interface GetIndexerMarketSnapshotsParams\n extends IndexerSnapshotsIntervalParams {\n // Defaults to all\n productIds?: number[];\n}\n\nexport interface IndexerMarketSnapshot {\n timestamp: BigDecimal;\n cumulativeUsers: BigDecimal;\n dailyActiveUsers: BigDecimal;\n tvl: BigDecimal;\n cumulativeVolumes: Record<number, BigDecimal>;\n cumulativeTakerFees: Record<number, BigDecimal>;\n cumulativeSequencerFees: Record<number, BigDecimal>;\n cumulativeMakerFees: Record<number, BigDecimal>;\n cumulativeTrades: Record<number, BigDecimal>;\n cumulativeLiquidationAmounts: Record<number, BigDecimal>;\n openInterestsQuote: Record<number, BigDecimal>;\n totalDeposits: Record<number, BigDecimal>;\n totalBorrows: Record<number, BigDecimal>;\n fundingRates: Record<number, BigDecimal>;\n depositRates: Record<number, BigDecimal>;\n borrowRates: Record<number, BigDecimal>;\n cumulativeTradeSizes: Record<number, BigDecimal>;\n cumulativeInflows: Record<number, BigDecimal>;\n cumulativeOutflows: Record<number, BigDecimal>;\n oraclePrices: Record<number, BigDecimal>;\n}\n\nexport type GetIndexerMarketSnapshotsResponse = IndexerMarketSnapshot[];\n\nexport type GetIndexerEdgeMarketSnapshotsParams =\n IndexerSnapshotsIntervalParams;\n\n// Map of chain id -> IndexerMarketSnapshot[]\nexport type GetIndexerEdgeMarketSnapshotResponse = Record<\n number,\n IndexerMarketSnapshot[]\n>;\n\n/**\n * Events\n */\n\n// There can be multiple events per tx, this allows a limit depending on usecase\nexport type GetIndexerEventsLimitType = 'events' | 'txs';\n\nexport interface GetIndexerEventsParams {\n // Max submission index, inclusive\n startCursor?: string;\n subaccount?: Subaccount;\n productIds?: number[];\n // If not given, will return both isolated & non-iso events\n isolated?: boolean;\n eventTypes?: IndexerEventType[];\n maxTimestampInclusive?: number;\n // Descending order for idx (time), defaults to true\n desc?: boolean;\n limit?: {\n type: GetIndexerEventsLimitType;\n value: number;\n };\n}\n\nexport type GetIndexerEventsResponse = IndexerEventWithTx[];\n\n/**\n * Historical orders\n */\n\nexport interface GetIndexerOrdersParams {\n // Max submission index, inclusive\n startCursor?: string;\n subaccount?: Subaccount;\n minTimestampInclusive?: number;\n maxTimestampInclusive?: number;\n limit?: number;\n productIds?: number[];\n triggerTypes?: IndexerServerTriggerTypeFilter[];\n // If not given, will return both isolated & non-iso orders\n isolated?: boolean;\n digests?: string[];\n}\n\nexport interface IndexerOrder {\n digest: string;\n subaccount: string;\n productId: number;\n submissionIndex: string;\n amount: BigDecimal;\n price: BigDecimal;\n expiration: number;\n // Order metadata from appendix\n appendix: OrderAppendix;\n nonce: BigDecimal;\n // Derived from the nonce\n recvTimeSeconds: number;\n // Fill amounts\n baseFilled: BigDecimal;\n // Includes fee\n quoteFilled: BigDecimal;\n // Includes sequencer fee\n totalFee: BigDecimal;\n}\n\nexport type GetIndexerOrdersResponse = IndexerOrder[];\n\n/**\n * Match events\n */\n\nexport interface GetIndexerMatchEventsParams {\n // When not given, will return all maker events\n subaccount?: Subaccount;\n productIds?: number[];\n // If not given, will return both isolated & non-iso events\n isolated?: boolean;\n maxTimestampInclusive?: number;\n limit: number;\n // Max submission index, inclusive\n startCursor?: string;\n}\n\n// There are 2 balance states per match event if the match is in a spot market, but only one if the match is in a perp market\nexport interface IndexerMatchEventBalances {\n base: IndexerSpotBalance | IndexerPerpBalance;\n quote?: IndexerSpotBalance;\n}\n\nexport interface IndexerMatchEvent extends Subaccount {\n productId: number;\n digest: string;\n isolated: boolean;\n order: EIP712OrderValues;\n baseFilled: BigDecimal;\n quoteFilled: BigDecimal;\n // Includes sequencer fee\n totalFee: BigDecimal;\n sequencerFee: BigDecimal;\n cumulativeBaseFilled: BigDecimal;\n cumulativeQuoteFilled: BigDecimal;\n cumulativeFee: BigDecimal;\n submissionIndex: string;\n timestamp: BigDecimal;\n // Tracked vars for the balance BEFORE this match event occurred\n preEventTrackedVars: Pick<\n IndexerBalanceTrackedVars,\n 'netEntryCumulative' | 'netEntryUnrealized'\n >;\n preBalances: IndexerMatchEventBalances;\n postBalances: IndexerMatchEventBalances;\n tx: NadoTx;\n}\n\nexport type GetIndexerMatchEventsResponse = IndexerMatchEvent[];\n\n/**\n * Quote price\n */\n\nexport interface GetIndexerQuotePriceResponse {\n price: BigDecimal;\n}\n\n/**\n * Linked Signer\n */\n\nexport interface GetIndexerLinkedSignerParams {\n subaccount: Subaccount;\n}\n\nexport interface GetIndexerLinkedSignerResponse {\n totalTxLimit: BigDecimal;\n remainingTxs: BigDecimal;\n // If remainingTxs is 0, this is the time until the next link signer tx can be sent\n waitTimeUntilNextTx: BigDecimal;\n // If zero address, none is configured\n signer: string;\n}\n\n/**\n * Interest / funding payments\n */\n\nexport interface GetIndexerInterestFundingPaymentsParams {\n subaccount: Subaccount;\n productIds: number[];\n maxTimestampInclusive?: number;\n limit: number;\n // Max submission index, inclusive\n startCursor?: string;\n}\n\nexport interface IndexerProductPayment {\n productId: number;\n submissionIndex: string;\n timestamp: BigDecimal;\n paymentAmount: BigDecimal;\n // For spots: previous spot balance at the moment of payment (exclusive of `paymentAmount`).\n // For perps: previous perp balance at the moment of payment + amount of perps locked in LPs (exclusive of `paymentAmount`).\n balanceAmount: BigDecimal;\n // Represents the annually interest rate for spots and annually funding rate for perps.\n annualPaymentRate: BigDecimal;\n oraclePrice: BigDecimal;\n isolated: boolean;\n // The product ID associated with the isolated perp market. This is only used when product_id === QUOTE_PRODUCT_ID and isolated === true\n isolatedProductId: number | null;\n}\n\nexport interface GetIndexerInterestFundingPaymentsResponse {\n interestPayments: IndexerProductPayment[];\n fundingPayments: IndexerProductPayment[];\n nextCursor: string | null;\n}\n\n/**\n * Referral code\n */\n\nexport interface GetIndexerReferralCodeParams {\n subaccount: Subaccount;\n}\n\nexport interface GetIndexerReferralCodeResponse {\n referralCode: string | null;\n}\n\n/**\n * Maker stats\n */\n\nexport interface GetIndexerMakerStatisticsParams {\n productId: number;\n epoch: number;\n interval: number;\n}\n\nexport interface IndexerMakerSnapshot {\n timestamp: BigDecimal;\n makerFee: BigDecimal;\n uptime: BigDecimal;\n sumQMin: BigDecimal;\n qScore: BigDecimal;\n makerShare: BigDecimal;\n expectedMakerReward: BigDecimal;\n}\n\nexport interface IndexerMaker {\n address: string;\n snapshots: IndexerMakerSnapshot[];\n}\n\nexport interface GetIndexerMakerStatisticsResponse {\n rewardCoefficient: BigDecimal;\n makers: IndexerMaker[];\n}\n\n/**\n * Leaderboards\n */\n\nexport interface GetIndexerLeaderboardParams {\n contestId: number;\n rankType: IndexerLeaderboardRankType;\n // Min rank inclusive\n startCursor?: string;\n limit?: number;\n}\n\nexport interface IndexerLeaderboardParticipant {\n subaccount: Subaccount;\n contestId: number;\n pnl: BigDecimal;\n pnlRank: BigDecimal;\n percentRoi: BigDecimal;\n roiRank: BigDecimal;\n // Float indicating the ending account value at the time the snapshot was taken i.e: at updateTime\n accountValue: BigDecimal;\n // Float indicating the trading volume at the time the snapshot was taken i.e: at updateTime.\n // Null for contests that have no volume requirement.\n volume?: BigDecimal;\n // Seconds\n updateTime: BigDecimal;\n}\n\nexport interface GetIndexerLeaderboardResponse {\n participants: IndexerLeaderboardParticipant[];\n}\n\nexport interface GetIndexerLeaderboardParticipantParams {\n contestIds: number[];\n subaccount: Subaccount;\n}\n\nexport interface GetIndexerLeaderboardParticipantResponse {\n // If the subaccount is not eligible for a given contest, it would not be included in the response.\n // contestId -> IndexerLeaderboardParticipant\n participant: Record<string, IndexerLeaderboardParticipant>;\n}\n\ninterface LeaderboardSignatureParams {\n // endpoint address\n verifyingAddr: string;\n chainId: number;\n}\n\nexport interface GetIndexerLeaderboardRegistrationParams extends Subaccount {\n contestId: number;\n}\n\nexport interface UpdateIndexerLeaderboardRegistrationParams\n extends GetIndexerLeaderboardRegistrationParams {\n updateRegistration: LeaderboardSignatureParams;\n // In millis, defaults to 90s in the future\n recvTime?: BigDecimal;\n}\n\nexport interface IndexerLeaderboardRegistration {\n subaccount: Subaccount;\n contestId: number;\n // Seconds\n updateTime: BigDecimal;\n}\n\nexport interface GetIndexerLeaderboardRegistrationResponse {\n // For non-tiered contests, null if the user is not registered for the provided contestId.\n // For tiered contests (i.e., related contests), null if the user is not registered for any of the contests in the tier group.\n registration: IndexerLeaderboardRegistration | null;\n}\n\nexport type UpdateIndexerLeaderboardRegistrationResponse =\n GetIndexerLeaderboardRegistrationResponse;\n\nexport interface GetIndexerLeaderboardContestsParams {\n contestIds: number[];\n}\n\nexport interface IndexerLeaderboardContest {\n contestId: number;\n // NOTE: Start / End times are ignored when `period` is non-zero.\n // Start time in seconds\n startTime: BigDecimal;\n // End time in seconds\n endTime: BigDecimal;\n // Contest duration in seconds; when set to 0, contest duration is [startTime,endTime];\n // Otherwise, contest runs indefinitely in the interval [lastUpdated - period, lastUpdated] if active;\n period: BigDecimal;\n // Last updated time in Seconds\n lastUpdated: BigDecimal;\n totalParticipants: BigDecimal;\n // Float indicating the min account value required to be eligible for this contest e.g: 250.0\n minRequiredAccountValue: BigDecimal;\n // Float indicating the min trading volume required to be eligible for this contest e.g: 1000.0\n minRequiredVolume: BigDecimal;\n // For market-specific contests, only the volume from these products will be counted.\n requiredProductIds: number[];\n active: boolean;\n}\n\nexport interface GetIndexerLeaderboardContestsResponse {\n contests: IndexerLeaderboardContest[];\n}\n\nexport type GetIndexerFastWithdrawalSignatureParams =\n IndexerServerFastWithdrawalSignatureParams;\n\nexport interface GetIndexerFastWithdrawalSignatureResponse {\n idx: bigint;\n tx: NadoWithdrawCollateralTx['withdraw_collateral'];\n txBytes: Hex;\n signatures: Hex[];\n}\n\n/**\n * NLP\n */\n\nexport type GetIndexerNlpSnapshotsParams = IndexerSnapshotsIntervalParams;\n\nexport interface IndexerNlpSnapshot {\n submissionIndex: string;\n timestamp: BigDecimal;\n // Total volume traded by the NLP, in terms of the primary quote\n cumulativeVolume: BigDecimal;\n cumulativeTrades: BigDecimal;\n cumulativeMintAmountQuote: BigDecimal;\n cumulativeBurnAmountQuote: BigDecimal;\n cumulativePnl: BigDecimal;\n tvl: BigDecimal;\n oraclePrice: BigDecimal;\n depositors: BigDecimal;\n}\n\nexport interface GetIndexerNlpSnapshotsResponse {\n snapshots: IndexerNlpSnapshot[];\n}\n\nexport interface GetIndexerBacklogResponse {\n // Total number of transactions stored in the indexer DB\n totalTxs: BigDecimal;\n // Current nSubmissions value from the chain (i.e., number of processed txs)\n totalSubmissions: BigDecimal;\n // Number of unprocessed transactions (totalTxs - totalSubmissions)\n backlogSize: BigDecimal;\n // UNIX timestamp (in seconds) of when the data was last updated\n updatedAt: BigDecimal;\n // Estimated time in seconds (float) to clear the entire backlog (null if unavailable)\n backlogEtaInSeconds: BigDecimal | null;\n // Current submission rate in transactions per second (float) (null if unavailable)\n txsPerSecond: BigDecimal | null;\n}\n\nexport interface GetIndexerSubaccountDDAParams {\n subaccount: Subaccount;\n}\n\nexport interface GetIndexerSubaccountDDAResponse {\n address: Address;\n}\n\n/**\n * V2 Tickers\n */\n\n/**\n * Market type for ticker filtering\n */\nexport type TickerMarketType = 'spot' | 'perp';\n\n/**\n * Parameters for querying v2 tickers endpoint\n */\nexport interface GetIndexerV2TickersParams {\n /**\n * Filter tickers by market type (spot or perp)\n * @example 'spot'\n * @example 'perp'\n */\n market?: TickerMarketType;\n /**\n * Whether to include edge products\n * @default false\n */\n edge?: boolean;\n}\n\n/**\n * Individual ticker data from v2 endpoint\n */\nexport interface IndexerV2TickerResponse {\n /** Unique product identifier */\n productId: number;\n /** Unique ticker identifier */\n tickerId: string;\n /** Base currency symbol */\n baseCurrency: string;\n /** Quote currency symbol */\n quoteCurrency: string;\n /** Last traded price */\n lastPrice: number;\n /** 24h trading volume in base currency */\n baseVolume: number;\n /** 24h trading volume in quote currency */\n quoteVolume: number;\n /** 24h price change percentage */\n priceChangePercent24h: number;\n}\n\n/**\n * Response from v2 tickers endpoint\n * Maps ticker IDs to their respective ticker data\n */\nexport type GetIndexerV2TickersResponse = Record<\n string,\n IndexerV2TickerResponse\n>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/clientTypes.ts"],"sourcesContent":["import {\n BigDecimal,\n EIP712OrderValues,\n Market,\n OrderAppendix,\n PerpBalance,\n PerpMarket,\n ProductEngineType,\n SpotBalance,\n SpotMarket,\n Subaccount,\n} from '@nadohq/shared';\nimport { Address, Hex } from 'viem';\nimport { CandlestickPeriod } from './CandlestickPeriod';\nimport { IndexerEventType } from './IndexerEventType';\nimport { IndexerLeaderboardRankType } from './IndexerLeaderboardType';\nimport { NadoTx, NadoWithdrawCollateralTx } from './NadoTx';\nimport {\n IndexerServerFastWithdrawalSignatureParams,\n IndexerServerListSubaccountsParams,\n IndexerServerTriggerTypeFilter,\n} from './serverTypes';\n\n/**\n * Base types\n */\n\nexport type IndexerSpotBalance = Omit<SpotBalance, 'healthContributions'>;\n\nexport type IndexerPerpBalance = Omit<PerpBalance, 'healthContributions'>;\n\nexport interface IndexerEventSpotStateSnapshot {\n type: ProductEngineType.SPOT;\n preBalance: IndexerSpotBalance;\n postBalance: IndexerSpotBalance;\n market: SpotMarket;\n}\n\nexport interface IndexerEventPerpStateSnapshot {\n type: ProductEngineType.PERP;\n preBalance: IndexerPerpBalance;\n postBalance: IndexerPerpBalance;\n market: PerpMarket;\n}\n\nexport type IndexerEventBalanceStateSnapshot =\n | IndexerEventSpotStateSnapshot\n | IndexerEventPerpStateSnapshot;\n\nexport interface IndexerBalanceTrackedVars {\n netInterestUnrealized: BigDecimal;\n netInterestCumulative: BigDecimal;\n netFundingUnrealized: BigDecimal;\n netFundingCumulative: BigDecimal;\n netEntryUnrealized: BigDecimal;\n netEntryCumulative: BigDecimal;\n quoteVolumeCumulative: BigDecimal;\n}\n\nexport interface IndexerEvent<\n TStateType extends\n IndexerEventBalanceStateSnapshot = IndexerEventBalanceStateSnapshot,\n> {\n subaccount: string;\n isolated: boolean;\n // The product ID associated with the isolated perp market. This is only used when productId === QUOTE_PRODUCT_ID and isolated === true\n isolatedProductId: number | null;\n productId: number;\n submissionIndex: string;\n eventType: IndexerEventType;\n state: TStateType;\n trackedVars: IndexerBalanceTrackedVars;\n}\n\nexport interface IndexerEventWithTx<\n TStateType extends\n IndexerEventBalanceStateSnapshot = IndexerEventBalanceStateSnapshot,\n> extends IndexerEvent<TStateType> {\n timestamp: BigDecimal;\n tx: NadoTx;\n}\n\n/**\n * List subaccounts\n */\n\nexport type ListIndexerSubaccountsParams = IndexerServerListSubaccountsParams;\n\nexport type ListIndexerSubaccountsResponse = ({\n hexId: string;\n} & Subaccount)[];\n\n/**\n * Subaccount snapshots\n */\n\nexport interface GetIndexerMultiSubaccountSnapshotsParams {\n subaccounts: Subaccount[];\n // A series of timestamps for which to return a summary of each subaccount\n timestamps: number[];\n // If not given, will return both isolated & non-iso balances\n isolated?: boolean;\n}\n\nexport type IndexerSnapshotBalance<\n TStateType extends\n IndexerEventBalanceStateSnapshot = IndexerEventBalanceStateSnapshot,\n> = IndexerEvent<TStateType>;\n\nexport interface IndexerSubaccountSnapshot {\n timestamp: BigDecimal;\n balances: IndexerSnapshotBalance[];\n}\n\nexport interface GetIndexerMultiSubaccountSnapshotsResponse {\n // Utility for retrieving a subaccount's hex ID, in the same order as the request params\n subaccountHexIds: string[];\n // Map of subaccount hex -> timestamp requested -> summary for that time\n snapshots: Record<string, Record<string, IndexerSubaccountSnapshot>>;\n}\n\n/**\n * Perp prices\n */\n\nexport interface GetIndexerPerpPricesParams {\n productId: number;\n}\n\nexport interface IndexerPerpPrices {\n productId: number;\n indexPrice: BigDecimal;\n markPrice: BigDecimal;\n // Seconds\n updateTime: BigDecimal;\n}\n\nexport type GetIndexerPerpPricesResponse = IndexerPerpPrices;\n\nexport interface GetIndexerMultiProductPerpPricesParams {\n productIds: number[];\n}\n\n// Map of productId -> IndexerPerpPrices\nexport type GetIndexerMultiProductPerpPricesResponse = Record<\n number,\n IndexerPerpPrices\n>;\n\n/**\n * Oracle prices\n */\n\nexport interface GetIndexerOraclePricesParams {\n productIds: number[];\n}\n\nexport interface IndexerOraclePrice {\n productId: number;\n oraclePrice: BigDecimal;\n // Seconds\n updateTime: BigDecimal;\n}\n\nexport type GetIndexerOraclePricesResponse = IndexerOraclePrice[];\n\n/**\n * Funding rates\n */\n\nexport interface GetIndexerFundingRateParams {\n productId: number;\n}\n\nexport interface IndexerFundingRate {\n productId: number;\n fundingRate: BigDecimal;\n // Seconds\n updateTime: BigDecimal;\n}\n\nexport type GetIndexerFundingRateResponse = IndexerFundingRate;\n\nexport interface GetIndexerMultiProductFundingRatesParams {\n productIds: number[];\n}\n\n// Map of productId -> IndexerFundingRate\nexport type GetIndexerMultiProductFundingRatesResponse = Record<\n number,\n IndexerFundingRate\n>;\n\n/**\n * Candlesticks\n */\n\nexport interface GetIndexerCandlesticksParams {\n productId: number;\n period: CandlestickPeriod;\n // Seconds\n maxTimeInclusive?: number;\n limit: number;\n}\n\n// Semi-Tradingview compatible bars\nexport interface Candlestick {\n // In SECONDS, for TV compat, this needs to be in millis\n time: BigDecimal;\n open: BigDecimal;\n high: BigDecimal;\n low: BigDecimal;\n close: BigDecimal;\n volume: BigDecimal;\n}\n\nexport type GetIndexerCandlesticksResponse = Candlestick[];\n\nexport type GetIndexerEdgeCandlesticksResponse = GetIndexerCandlesticksResponse;\n\nexport type GetIndexerEdgeCandlesticksParams = GetIndexerCandlesticksParams;\n\n/**\n * Product snapshots\n */\n\nexport interface GetIndexerProductSnapshotsParams {\n // Max submission index, inclusive\n startCursor?: string;\n productId: number;\n maxTimestampInclusive?: number;\n limit: number;\n}\n\nexport interface IndexerProductSnapshot extends Market {\n submissionIndex: string;\n}\n\nexport type GetIndexerProductSnapshotsResponse = IndexerProductSnapshot[];\n\nexport interface GetIndexerMultiProductSnapshotsParams {\n productIds: number[];\n maxTimestampInclusive?: number[];\n}\n\n// Map of timestamp -> (productId -> IndexerProductSnapshot)\nexport type GetIndexerMultiProductSnapshotsResponse = Record<\n string,\n Record<number, IndexerProductSnapshot>\n>;\n\nexport interface IndexerSnapshotsIntervalParams {\n /** Currently accepts all integers, in seconds */\n granularity: number;\n /**\n * Optional upper bound for snapshot timestamps (in seconds).\n * Without this, snapshots will default to align with last UTC midnight,\n * which can make \"Last 24h\" metrics inaccurate.\n */\n maxTimeInclusive?: number;\n limit: number;\n}\n\n/**\n * Market snapshots\n */\n\nexport interface GetIndexerMarketSnapshotsParams\n extends IndexerSnapshotsIntervalParams {\n // Defaults to all\n productIds?: number[];\n}\n\nexport interface IndexerMarketSnapshot {\n timestamp: BigDecimal;\n cumulativeUsers: BigDecimal;\n dailyActiveUsers: BigDecimal;\n tvl: BigDecimal;\n cumulativeVolumes: Record<number, BigDecimal>;\n cumulativeTakerFees: Record<number, BigDecimal>;\n cumulativeSequencerFees: Record<number, BigDecimal>;\n cumulativeMakerFees: Record<number, BigDecimal>;\n cumulativeTrades: Record<number, BigDecimal>;\n cumulativeLiquidationAmounts: Record<number, BigDecimal>;\n openInterestsQuote: Record<number, BigDecimal>;\n totalDeposits: Record<number, BigDecimal>;\n totalBorrows: Record<number, BigDecimal>;\n fundingRates: Record<number, BigDecimal>;\n depositRates: Record<number, BigDecimal>;\n borrowRates: Record<number, BigDecimal>;\n cumulativeTradeSizes: Record<number, BigDecimal>;\n cumulativeInflows: Record<number, BigDecimal>;\n cumulativeOutflows: Record<number, BigDecimal>;\n oraclePrices: Record<number, BigDecimal>;\n}\n\nexport type GetIndexerMarketSnapshotsResponse = IndexerMarketSnapshot[];\n\nexport type GetIndexerEdgeMarketSnapshotsParams =\n IndexerSnapshotsIntervalParams;\n\n// Map of chain id -> IndexerMarketSnapshot[]\nexport type GetIndexerEdgeMarketSnapshotResponse = Record<\n number,\n IndexerMarketSnapshot[]\n>;\n\n/**\n * Events\n */\n\n// There can be multiple events per tx, this allows a limit depending on usecase\nexport type GetIndexerEventsLimitType = 'events' | 'txs';\n\nexport interface GetIndexerEventsParams {\n // Max submission index, inclusive\n startCursor?: string;\n subaccounts?: Subaccount[];\n productIds?: number[];\n // If not given, will return both isolated & non-iso events\n isolated?: boolean;\n eventTypes?: IndexerEventType[];\n maxTimestampInclusive?: number;\n // Descending order for idx (time), defaults to true\n desc?: boolean;\n limit?: {\n type: GetIndexerEventsLimitType;\n value: number;\n };\n}\n\nexport type GetIndexerEventsResponse = IndexerEventWithTx[];\n\n/**\n * Historical orders\n */\n\nexport interface GetIndexerOrdersParams {\n // Max submission index, inclusive\n startCursor?: string;\n subaccounts?: Subaccount[];\n minTimestampInclusive?: number;\n maxTimestampInclusive?: number;\n limit?: number;\n productIds?: number[];\n triggerTypes?: IndexerServerTriggerTypeFilter[];\n // If not given, will return both isolated & non-iso orders\n isolated?: boolean;\n digests?: string[];\n}\n\nexport interface IndexerOrder {\n digest: string;\n subaccount: string;\n productId: number;\n submissionIndex: string;\n amount: BigDecimal;\n price: BigDecimal;\n expiration: number;\n // Order metadata from appendix\n appendix: OrderAppendix;\n nonce: BigDecimal;\n // Derived from the nonce\n recvTimeSeconds: number;\n // Fill amounts\n baseFilled: BigDecimal;\n // Includes fee\n quoteFilled: BigDecimal;\n // Includes sequencer fee\n totalFee: BigDecimal;\n}\n\nexport type GetIndexerOrdersResponse = IndexerOrder[];\n\n/**\n * Match events\n */\n\nexport interface GetIndexerMatchEventsParams {\n // When not given, will return all maker events\n subaccounts?: Subaccount[];\n productIds?: number[];\n // If not given, will return both isolated & non-iso events\n isolated?: boolean;\n maxTimestampInclusive?: number;\n limit: number;\n // Max submission index, inclusive\n startCursor?: string;\n}\n\n// There are 2 balance states per match event if the match is in a spot market, but only one if the match is in a perp market\nexport interface IndexerMatchEventBalances {\n base: IndexerSpotBalance | IndexerPerpBalance;\n quote?: IndexerSpotBalance;\n}\n\nexport interface IndexerMatchEvent extends Subaccount {\n productId: number;\n digest: string;\n isolated: boolean;\n order: EIP712OrderValues;\n baseFilled: BigDecimal;\n quoteFilled: BigDecimal;\n // Includes sequencer fee\n totalFee: BigDecimal;\n sequencerFee: BigDecimal;\n cumulativeBaseFilled: BigDecimal;\n cumulativeQuoteFilled: BigDecimal;\n cumulativeFee: BigDecimal;\n submissionIndex: string;\n timestamp: BigDecimal;\n // Tracked vars for the balance BEFORE this match event occurred\n preEventTrackedVars: Pick<\n IndexerBalanceTrackedVars,\n 'netEntryCumulative' | 'netEntryUnrealized'\n >;\n preBalances: IndexerMatchEventBalances;\n postBalances: IndexerMatchEventBalances;\n tx: NadoTx;\n}\n\nexport type GetIndexerMatchEventsResponse = IndexerMatchEvent[];\n\n/**\n * Quote price\n */\n\nexport interface GetIndexerQuotePriceResponse {\n price: BigDecimal;\n}\n\n/**\n * Linked Signer\n */\n\nexport interface GetIndexerLinkedSignerParams {\n subaccount: Subaccount;\n}\n\nexport interface GetIndexerLinkedSignerResponse {\n totalTxLimit: BigDecimal;\n remainingTxs: BigDecimal;\n // If remainingTxs is 0, this is the time until the next link signer tx can be sent\n waitTimeUntilNextTx: BigDecimal;\n // If zero address, none is configured\n signer: string;\n}\n\n/**\n * Interest / funding payments\n */\n\nexport interface GetIndexerInterestFundingPaymentsParams {\n subaccount: Subaccount;\n productIds: number[];\n maxTimestampInclusive?: number;\n limit: number;\n // Max submission index, inclusive\n startCursor?: string;\n}\n\nexport interface IndexerProductPayment {\n productId: number;\n submissionIndex: string;\n timestamp: BigDecimal;\n paymentAmount: BigDecimal;\n // For spots: previous spot balance at the moment of payment (exclusive of `paymentAmount`).\n // For perps: previous perp balance at the moment of payment + amount of perps locked in LPs (exclusive of `paymentAmount`).\n balanceAmount: BigDecimal;\n // Represents the annually interest rate for spots and annually funding rate for perps.\n annualPaymentRate: BigDecimal;\n oraclePrice: BigDecimal;\n isolated: boolean;\n // The product ID associated with the isolated perp market. This is only used when product_id === QUOTE_PRODUCT_ID and isolated === true\n isolatedProductId: number | null;\n}\n\nexport interface GetIndexerInterestFundingPaymentsResponse {\n interestPayments: IndexerProductPayment[];\n fundingPayments: IndexerProductPayment[];\n nextCursor: string | null;\n}\n\n/**\n * Referral code\n */\n\nexport interface GetIndexerReferralCodeParams {\n subaccount: Subaccount;\n}\n\nexport interface GetIndexerReferralCodeResponse {\n referralCode: string | null;\n}\n\n/**\n * Maker stats\n */\n\nexport interface GetIndexerMakerStatisticsParams {\n productId: number;\n epoch: number;\n interval: number;\n}\n\nexport interface IndexerMakerSnapshot {\n timestamp: BigDecimal;\n makerFee: BigDecimal;\n uptime: BigDecimal;\n sumQMin: BigDecimal;\n qScore: BigDecimal;\n makerShare: BigDecimal;\n expectedMakerReward: BigDecimal;\n}\n\nexport interface IndexerMaker {\n address: string;\n snapshots: IndexerMakerSnapshot[];\n}\n\nexport interface GetIndexerMakerStatisticsResponse {\n rewardCoefficient: BigDecimal;\n makers: IndexerMaker[];\n}\n\n/**\n * Leaderboards\n */\n\nexport interface GetIndexerLeaderboardParams {\n contestId: number;\n rankType: IndexerLeaderboardRankType;\n // Min rank inclusive\n startCursor?: string;\n limit?: number;\n}\n\nexport interface IndexerLeaderboardParticipant {\n subaccount: Subaccount;\n contestId: number;\n pnl: BigDecimal;\n pnlRank: BigDecimal;\n percentRoi: BigDecimal;\n roiRank: BigDecimal;\n // Float indicating the ending account value at the time the snapshot was taken i.e: at updateTime\n accountValue: BigDecimal;\n // Float indicating the trading volume at the time the snapshot was taken i.e: at updateTime.\n // Null for contests that have no volume requirement.\n volume?: BigDecimal;\n // Seconds\n updateTime: BigDecimal;\n}\n\nexport interface GetIndexerLeaderboardResponse {\n participants: IndexerLeaderboardParticipant[];\n}\n\nexport interface GetIndexerLeaderboardParticipantParams {\n contestIds: number[];\n subaccount: Subaccount;\n}\n\nexport interface GetIndexerLeaderboardParticipantResponse {\n // If the subaccount is not eligible for a given contest, it would not be included in the response.\n // contestId -> IndexerLeaderboardParticipant\n participant: Record<string, IndexerLeaderboardParticipant>;\n}\n\ninterface LeaderboardSignatureParams {\n // endpoint address\n verifyingAddr: string;\n chainId: number;\n}\n\nexport interface GetIndexerLeaderboardRegistrationParams extends Subaccount {\n contestId: number;\n}\n\nexport interface UpdateIndexerLeaderboardRegistrationParams\n extends GetIndexerLeaderboardRegistrationParams {\n updateRegistration: LeaderboardSignatureParams;\n // In millis, defaults to 90s in the future\n recvTime?: BigDecimal;\n}\n\nexport interface IndexerLeaderboardRegistration {\n subaccount: Subaccount;\n contestId: number;\n // Seconds\n updateTime: BigDecimal;\n}\n\nexport interface GetIndexerLeaderboardRegistrationResponse {\n // For non-tiered contests, null if the user is not registered for the provided contestId.\n // For tiered contests (i.e., related contests), null if the user is not registered for any of the contests in the tier group.\n registration: IndexerLeaderboardRegistration | null;\n}\n\nexport type UpdateIndexerLeaderboardRegistrationResponse =\n GetIndexerLeaderboardRegistrationResponse;\n\nexport interface GetIndexerLeaderboardContestsParams {\n contestIds: number[];\n}\n\nexport interface IndexerLeaderboardContest {\n contestId: number;\n // NOTE: Start / End times are ignored when `period` is non-zero.\n // Start time in seconds\n startTime: BigDecimal;\n // End time in seconds\n endTime: BigDecimal;\n // Contest duration in seconds; when set to 0, contest duration is [startTime,endTime];\n // Otherwise, contest runs indefinitely in the interval [lastUpdated - period, lastUpdated] if active;\n period: BigDecimal;\n // Last updated time in Seconds\n lastUpdated: BigDecimal;\n totalParticipants: BigDecimal;\n // Float indicating the min account value required to be eligible for this contest e.g: 250.0\n minRequiredAccountValue: BigDecimal;\n // Float indicating the min trading volume required to be eligible for this contest e.g: 1000.0\n minRequiredVolume: BigDecimal;\n // For market-specific contests, only the volume from these products will be counted.\n requiredProductIds: number[];\n active: boolean;\n}\n\nexport interface GetIndexerLeaderboardContestsResponse {\n contests: IndexerLeaderboardContest[];\n}\n\nexport type GetIndexerFastWithdrawalSignatureParams =\n IndexerServerFastWithdrawalSignatureParams;\n\nexport interface GetIndexerFastWithdrawalSignatureResponse {\n idx: bigint;\n tx: NadoWithdrawCollateralTx['withdraw_collateral'];\n txBytes: Hex;\n signatures: Hex[];\n}\n\n/**\n * NLP\n */\n\nexport type GetIndexerNlpSnapshotsParams = IndexerSnapshotsIntervalParams;\n\nexport interface IndexerNlpSnapshot {\n submissionIndex: string;\n timestamp: BigDecimal;\n // Total volume traded by the NLP, in terms of the primary quote\n cumulativeVolume: BigDecimal;\n cumulativeTrades: BigDecimal;\n cumulativeMintAmountQuote: BigDecimal;\n cumulativeBurnAmountQuote: BigDecimal;\n cumulativePnl: BigDecimal;\n tvl: BigDecimal;\n oraclePrice: BigDecimal;\n depositors: BigDecimal;\n}\n\nexport interface GetIndexerNlpSnapshotsResponse {\n snapshots: IndexerNlpSnapshot[];\n}\n\nexport interface GetIndexerBacklogResponse {\n // Total number of transactions stored in the indexer DB\n totalTxs: BigDecimal;\n // Current nSubmissions value from the chain (i.e., number of processed txs)\n totalSubmissions: BigDecimal;\n // Number of unprocessed transactions (totalTxs - totalSubmissions)\n backlogSize: BigDecimal;\n // UNIX timestamp (in seconds) of when the data was last updated\n updatedAt: BigDecimal;\n // Estimated time in seconds (float) to clear the entire backlog (null if unavailable)\n backlogEtaInSeconds: BigDecimal | null;\n // Current submission rate in transactions per second (float) (null if unavailable)\n txsPerSecond: BigDecimal | null;\n}\n\nexport interface GetIndexerSubaccountDDAParams {\n subaccount: Subaccount;\n}\n\nexport interface GetIndexerSubaccountDDAResponse {\n address: Address;\n}\n\n/**\n * V2 Tickers\n */\n\n/**\n * Market type for ticker filtering\n */\nexport type TickerMarketType = 'spot' | 'perp';\n\n/**\n * Parameters for querying v2 tickers endpoint\n */\nexport interface GetIndexerV2TickersParams {\n /**\n * Filter tickers by market type (spot or perp)\n * @example 'spot'\n * @example 'perp'\n */\n market?: TickerMarketType;\n /**\n * Whether to include edge products\n * @default false\n */\n edge?: boolean;\n}\n\n/**\n * Individual ticker data from v2 endpoint\n */\nexport interface IndexerV2TickerResponse {\n /** Unique product identifier */\n productId: number;\n /** Unique ticker identifier */\n tickerId: string;\n /** Base currency symbol */\n baseCurrency: string;\n /** Quote currency symbol */\n quoteCurrency: string;\n /** Last traded price */\n lastPrice: number;\n /** 24h trading volume in base currency */\n baseVolume: number;\n /** 24h trading volume in quote currency */\n quoteVolume: number;\n /** 24h price change percentage */\n priceChangePercent24h: number;\n}\n\n/**\n * Response from v2 tickers endpoint\n * Maps ticker IDs to their respective ticker data\n */\nexport type GetIndexerV2TickersResponse = Record<\n string,\n IndexerV2TickerResponse\n>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -204,7 +204,7 @@ type GetIndexerEdgeMarketSnapshotResponse = Record<number, IndexerMarketSnapshot
204
204
  type GetIndexerEventsLimitType = 'events' | 'txs';
205
205
  interface GetIndexerEventsParams {
206
206
  startCursor?: string;
207
- subaccount?: Subaccount;
207
+ subaccounts?: Subaccount[];
208
208
  productIds?: number[];
209
209
  isolated?: boolean;
210
210
  eventTypes?: IndexerEventType[];
@@ -221,7 +221,7 @@ type GetIndexerEventsResponse = IndexerEventWithTx[];
221
221
  */
222
222
  interface GetIndexerOrdersParams {
223
223
  startCursor?: string;
224
- subaccount?: Subaccount;
224
+ subaccounts?: Subaccount[];
225
225
  minTimestampInclusive?: number;
226
226
  maxTimestampInclusive?: number;
227
227
  limit?: number;
@@ -250,7 +250,7 @@ type GetIndexerOrdersResponse = IndexerOrder[];
250
250
  * Match events
251
251
  */
252
252
  interface GetIndexerMatchEventsParams {
253
- subaccount?: Subaccount;
253
+ subaccounts?: Subaccount[];
254
254
  productIds?: number[];
255
255
  isolated?: boolean;
256
256
  maxTimestampInclusive?: number;
@@ -204,7 +204,7 @@ type GetIndexerEdgeMarketSnapshotResponse = Record<number, IndexerMarketSnapshot
204
204
  type GetIndexerEventsLimitType = 'events' | 'txs';
205
205
  interface GetIndexerEventsParams {
206
206
  startCursor?: string;
207
- subaccount?: Subaccount;
207
+ subaccounts?: Subaccount[];
208
208
  productIds?: number[];
209
209
  isolated?: boolean;
210
210
  eventTypes?: IndexerEventType[];
@@ -221,7 +221,7 @@ type GetIndexerEventsResponse = IndexerEventWithTx[];
221
221
  */
222
222
  interface GetIndexerOrdersParams {
223
223
  startCursor?: string;
224
- subaccount?: Subaccount;
224
+ subaccounts?: Subaccount[];
225
225
  minTimestampInclusive?: number;
226
226
  maxTimestampInclusive?: number;
227
227
  limit?: number;
@@ -250,7 +250,7 @@ type GetIndexerOrdersResponse = IndexerOrder[];
250
250
  * Match events
251
251
  */
252
252
  interface GetIndexerMatchEventsParams {
253
- subaccount?: Subaccount;
253
+ subaccounts?: Subaccount[];
254
254
  productIds?: number[];
255
255
  isolated?: boolean;
256
256
  maxTimestampInclusive?: number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/serverTypes.ts"],"sourcesContent":["import {\n EIP712LeaderboardAuthenticationValues,\n SignedTx,\n} from '@nadohq/shared';\nimport { IndexerEventType } from './IndexerEventType';\nimport { IndexerLeaderboardRankType } from './IndexerLeaderboardType';\nimport { NadoWithdrawCollateralTx } from './NadoTx';\nimport {\n IndexerServerCandlestick,\n IndexerServerEvent,\n IndexerServerLeaderboardContest,\n IndexerServerLeaderboardPosition,\n IndexerServerLeaderboardRegistration,\n IndexerServerMaker,\n IndexerServerMarketSnapshot,\n IndexerServerMarketSnapshotInterval,\n IndexerServerMatchEvent,\n IndexerServerNlpSnapshot,\n IndexerServerOraclePrice,\n IndexerServerOrder,\n IndexerServerProductPayment,\n IndexerServerProductSnapshot,\n IndexerServerSnapshotsInterval,\n IndexerServerTx,\n} from './serverModelTypes';\n\n/**\n * Params\n */\n\nexport interface IndexerServerListSubaccountsParams {\n // Inclusive, defaults to 0\n start?: number;\n // Defaults to 100\n limit?: number;\n address?: string;\n}\n\nexport interface IndexerServerMultiSubaccountSnapshotsParams {\n // Subaccount hex identifiers\n subaccounts: string[];\n timestamps: number[];\n // If not given, will return both isolated & non-iso balances\n isolated?: boolean;\n}\n\nexport interface IndexerServerReferralCodeParams {\n subaccount: string;\n}\n\nexport interface IndexerServerFundingRateParams {\n product_id: number;\n}\n\nexport interface IndexerServerFundingRatesParams {\n product_ids: number[];\n}\n\nexport interface IndexerServerPriceParams {\n product_id: number;\n}\n\nexport interface IndexerServerPerpPricesParams {\n product_ids: number[];\n}\n\nexport interface IndexerServerOraclePricesParams {\n product_ids: number[];\n}\n\nexport interface IndexerServerCandlesticksParams {\n product_id: number;\n granularity: number;\n // Seconds\n max_time?: number;\n limit: number;\n}\n\nexport type IndexerEdgeServerCandlesticksParams =\n IndexerServerCandlesticksParams;\n\nexport interface IndexerServerProductsParams {\n product_id: number;\n max_time?: number;\n limit: number;\n // submission_idx for pagination, inclusive\n idx?: string;\n}\n\nexport interface IndexerServerMultiProductsParams {\n product_ids: number[];\n max_time: number[];\n}\n\nexport interface IndexerServerEventsParams {\n subaccount?: string;\n product_ids?: number[];\n // If not given, will return both isolated & non-iso events\n isolated?: boolean;\n event_types?: IndexerEventType[];\n // Descending order for idx (time), defaults to true\n desc?: boolean;\n // submission_idx for pagination, inclusive\n idx?: string;\n max_time?: number;\n limit?:\n | {\n raw: number;\n }\n | {\n txs: number;\n };\n}\n\nexport type IndexerServerTriggerTypeFilter =\n | 'none'\n | 'price_trigger'\n | 'time_trigger';\n\nexport interface IndexerServerOrdersParams {\n subaccount?: string;\n product_ids?: number[];\n trigger_types?: IndexerServerTriggerTypeFilter[];\n digests?: string[];\n max_time?: number;\n limit?: number;\n // If not given, will return both isolated & non-iso orders\n isolated?: boolean;\n // submission_idx for pagination, inclusive\n idx?: string;\n}\n\nexport interface IndexerServerMatchEventsParams {\n subaccount?: string;\n product_ids?: number[];\n // If not given, will return both isolated & non-iso events\n isolated?: boolean;\n max_time?: number;\n limit: number;\n // submission_idx for pagination, inclusive\n idx?: string;\n}\n\nexport interface IndexerServerLinkedSignerParams {\n subaccount: string;\n}\n\nexport interface IndexerServerMarketSnapshotsParams {\n interval: IndexerServerMarketSnapshotInterval;\n // Defaults to all\n product_ids?: number[];\n}\n\nexport interface IndexerEdgeServerMarketSnapshotsParams {\n interval: IndexerServerMarketSnapshotInterval;\n}\n\nexport interface IndexerServerInterestFundingParams {\n subaccount: string;\n product_ids: number[];\n // If not given, defaults to latest\n max_idx?: string;\n max_time?: number;\n limit: number;\n}\n\nexport interface IndexerServerMakerStatisticsParams {\n product_id: number;\n epoch: number;\n interval: number;\n}\n\nexport interface IndexerServerLeaderboardParams {\n contest_id: number;\n rank_type: IndexerLeaderboardRankType;\n start?: number | string;\n limit?: number | string;\n}\n\nexport interface IndexerServerLeaderboardRankParams {\n subaccount: string;\n contest_ids: number[];\n}\n\nexport interface IndexerServerLeaderboardContestsParams {\n contest_ids: number[];\n}\n\nexport interface IndexerServerLeaderboardRegistrationParams {\n subaccount: string;\n contest_id: number;\n update_registration: SignedTx<EIP712LeaderboardAuthenticationValues> | null;\n}\n\nexport interface IndexerServerFastWithdrawalSignatureParams {\n /**\n * The submission index of the WithdrawCollateral tx to be used for fast withdraw.\n */\n idx: number | string;\n}\n\nexport interface IndexerServerNlpSnapshotsParams {\n interval: IndexerServerSnapshotsInterval;\n}\n\nexport interface IndexerServerDDAQueryParams {\n subaccount: string;\n}\n\n// Request\nexport interface IndexerServerQueryRequestByType {\n account_snapshots: IndexerServerMultiSubaccountSnapshotsParams;\n backlog: Record<string, never>;\n candlesticks: IndexerServerCandlesticksParams;\n direct_deposit_address: IndexerServerDDAQueryParams;\n edge_candlesticks: IndexerEdgeServerCandlesticksParams;\n edge_market_snapshots: IndexerEdgeServerMarketSnapshotsParams;\n events: IndexerServerEventsParams;\n fast_withdrawal_signature: IndexerServerFastWithdrawalSignatureParams;\n funding_rate: IndexerServerFundingRateParams;\n funding_rates: IndexerServerFundingRatesParams;\n interest_and_funding: IndexerServerInterestFundingParams;\n leaderboard: IndexerServerLeaderboardParams;\n leaderboard_contests: IndexerServerLeaderboardContestsParams;\n leaderboard_rank: IndexerServerLeaderboardRankParams;\n leaderboard_registration: IndexerServerLeaderboardRegistrationParams;\n linked_signer_rate_limit: IndexerServerLinkedSignerParams;\n maker_statistics: IndexerServerMakerStatisticsParams;\n market_snapshots: IndexerServerMarketSnapshotsParams;\n matches: IndexerServerMatchEventsParams;\n oracle_price: IndexerServerOraclePricesParams;\n orders: IndexerServerOrdersParams;\n perp_prices: IndexerServerPerpPricesParams;\n price: IndexerServerPriceParams;\n product_snapshots: IndexerServerMultiProductsParams;\n products: IndexerServerProductsParams;\n referral_code: IndexerServerReferralCodeParams;\n subaccounts: IndexerServerListSubaccountsParams;\n quote_price: Record<string, never>;\n nlp_snapshots: IndexerServerNlpSnapshotsParams;\n}\n\nexport type IndexerServerQueryRequestType =\n keyof IndexerServerQueryRequestByType;\n\n/**\n * Responses\n */\n\nexport interface IndexerServerListSubaccountsResponse {\n subaccounts: {\n id: string;\n // Hex of subaccount bytes\n subaccount: string;\n }[];\n}\n\nexport interface IndexerServerMultiSubaccountSnapshotsResponse {\n // Map of subaccount hex -> timestamp requested -> latest events corresponding to each product\n snapshots: Record<string, Record<string, IndexerServerEvent[]>>;\n}\n\nexport interface IndexerServerReferralCodeResponse {\n referral_code: string | null;\n}\n\nexport interface IndexerServerFundingRate {\n product_id: number;\n funding_rate_x18: string;\n update_time: number;\n}\n\nexport type IndexerServerFundingRateResponse = IndexerServerFundingRate;\n\n// Map of productId -> IndexerServerFundingRate\nexport type IndexerServerFundingRatesResponse = Record<\n string,\n IndexerServerFundingRate\n>;\n\nexport interface IndexerServerPerpPrices {\n product_id: number;\n index_price_x18: string;\n mark_price_x18: string;\n update_time: number;\n}\n\nexport type IndexerServerPriceResponse = IndexerServerPerpPrices;\n\n// Map of productId -> IndexerServerPerpPrices\nexport type IndexerServerPerpPricesResponse = Record<\n string,\n IndexerServerPerpPrices\n>;\n\nexport interface IndexerServerOraclePricesResponse {\n prices: IndexerServerOraclePrice[];\n}\n\nexport interface IndexerServerCandlesticksResponse {\n candlesticks: IndexerServerCandlestick[];\n}\n\nexport type IndexerEdgeServerCandlesticksResponse =\n IndexerServerCandlesticksResponse;\n\nexport interface IndexerServerProductsResponse {\n products: IndexerServerProductSnapshot[];\n txs: IndexerServerTx[];\n}\n\n// Map of timestamp -> (productID -> IndexerServerProductSnapshot)\nexport type IndexerServerMultiProductsResponse = Record<\n string,\n Record<string, IndexerServerProductSnapshot>\n>;\n\nexport interface IndexerServerEventsResponse {\n events: IndexerServerEvent[];\n txs: IndexerServerTx[];\n}\n\nexport interface IndexerServerOrdersResponse {\n orders: IndexerServerOrder[];\n}\n\nexport interface IndexerServerMatchEventsResponse {\n matches: IndexerServerMatchEvent[];\n txs: IndexerServerTx[];\n}\n\nexport interface IndexerServerQuotePriceResponse {\n price_x18: string;\n}\n\nexport interface IndexerServerLinkedSignerResponse {\n total_tx_limit: string;\n remaining_tx: string;\n wait_time: string;\n signer: string;\n}\n\nexport interface IndexerServerMarketSnapshotsResponse {\n snapshots: IndexerServerMarketSnapshot[];\n}\n\nexport interface IndexerEdgeServerMarketSnapshotsResponse {\n snapshots: Record<number, IndexerServerMarketSnapshot[]>;\n}\n\nexport interface IndexerServerInterestFundingResponse {\n interest_payments: IndexerServerProductPayment[];\n funding_payments: IndexerServerProductPayment[];\n next_idx: string;\n}\n\nexport interface IndexerServerMakerStatisticsResponse {\n reward_coefficient: string;\n makers: IndexerServerMaker[];\n}\n\nexport interface IndexerServerLeaderboardResponse {\n positions: IndexerServerLeaderboardPosition[];\n}\n\nexport interface IndexerServerLeaderboardRegistrationResponse {\n // For non-tiered contests, null if the user is not registered for the provided contestId.\n // For tiered contests (i.e., related contests), null if the user is not registered for any of the contests in the tier group.\n registration: IndexerServerLeaderboardRegistration | null;\n}\n\nexport interface IndexerServerLeaderboardRankResponse {\n // If the subaccount is not eligible for a given contest, it would not be included in the response.\n // contestId -> IndexerServerLeaderboardPosition\n positions: Record<string, IndexerServerLeaderboardPosition>;\n}\n\nexport interface IndexerServerLeaderboardContestsResponse {\n contests: IndexerServerLeaderboardContest[];\n}\n\nexport interface IndexerServerFastWithdrawalSignatureResponse {\n idx: string;\n tx: NadoWithdrawCollateralTx['withdraw_collateral'];\n tx_bytes: string;\n signatures: string[];\n}\n\nexport interface IndexerServerNlpSnapshotsResponse {\n snapshots: IndexerServerNlpSnapshot[];\n}\n\nexport interface IndexerServerDDAResponse {\n v1_address: string;\n}\n\nexport interface IndexerServerBacklogResponse {\n // Total number of transactions stored in the indexer DB\n total_txs: string;\n // Current nSubmissions value from the chain (i.e., number of processed txs)\n total_submissions: string;\n // Number of unprocessed transactions (total_txs - total_submissions)\n backlog_size: string;\n // UNIX timestamp (in seconds) of when the data was last updated\n updated_at: string;\n // Estimated time in seconds (float) to clear the entire backlog (null if unavailable)\n backlog_eta_in_seconds: string | null;\n // Current submission rate in transactions per second (float) (null if unavailable)\n txs_per_second: string | null;\n}\n\n// Response\nexport interface IndexerServerQueryResponseByType {\n account_snapshots: IndexerServerMultiSubaccountSnapshotsResponse;\n backlog: IndexerServerBacklogResponse;\n candlesticks: IndexerServerCandlesticksResponse;\n direct_deposit_address: IndexerServerDDAResponse;\n edge_candlesticks: IndexerEdgeServerCandlesticksResponse;\n edge_market_snapshots: IndexerEdgeServerMarketSnapshotsResponse;\n events: IndexerServerEventsResponse;\n fast_withdrawal_signature: IndexerServerFastWithdrawalSignatureResponse;\n funding_rate: IndexerServerFundingRateResponse;\n funding_rates: IndexerServerFundingRatesResponse;\n interest_and_funding: IndexerServerInterestFundingResponse;\n leaderboard: IndexerServerLeaderboardResponse;\n leaderboard_contests: IndexerServerLeaderboardContestsResponse;\n leaderboard_rank: IndexerServerLeaderboardRankResponse;\n leaderboard_registration: IndexerServerLeaderboardRegistrationResponse;\n linked_signer_rate_limit: IndexerServerLinkedSignerResponse;\n maker_statistics: IndexerServerMakerStatisticsResponse;\n market_snapshots: IndexerServerMarketSnapshotsResponse;\n matches: IndexerServerMatchEventsResponse;\n oracle_price: IndexerServerOraclePricesResponse;\n orders: IndexerServerOrdersResponse;\n perp_prices: IndexerServerPerpPricesResponse;\n price: IndexerServerPriceResponse;\n product_snapshots: IndexerServerMultiProductsResponse;\n products: IndexerServerProductsResponse;\n referral_code: IndexerServerReferralCodeResponse;\n subaccounts: IndexerServerListSubaccountsResponse;\n quote_price: IndexerServerQuotePriceResponse;\n nlp_snapshots: IndexerServerNlpSnapshotsResponse;\n}\n\n/**\n * V2 API Types\n */\n\n/**\n * Individual ticker data from v2 indexer endpoint (server format)\n */\nexport interface IndexerServerV2TickerResponse {\n product_id: number;\n ticker_id: string;\n base_currency: string;\n quote_currency: string;\n last_price: number;\n base_volume: number;\n quote_volume: number;\n price_change_percent_24h: number;\n}\n\n/**\n * Response from v2 tickers endpoint (server format)\n * Maps ticker IDs to their respective ticker data\n */\nexport type IndexerServerV2TickersResponse = Record<\n string,\n IndexerServerV2TickerResponse\n>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/serverTypes.ts"],"sourcesContent":["import {\n EIP712LeaderboardAuthenticationValues,\n SignedTx,\n} from '@nadohq/shared';\nimport { IndexerEventType } from './IndexerEventType';\nimport { IndexerLeaderboardRankType } from './IndexerLeaderboardType';\nimport { NadoWithdrawCollateralTx } from './NadoTx';\nimport {\n IndexerServerCandlestick,\n IndexerServerEvent,\n IndexerServerLeaderboardContest,\n IndexerServerLeaderboardPosition,\n IndexerServerLeaderboardRegistration,\n IndexerServerMaker,\n IndexerServerMarketSnapshot,\n IndexerServerMarketSnapshotInterval,\n IndexerServerMatchEvent,\n IndexerServerNlpSnapshot,\n IndexerServerOraclePrice,\n IndexerServerOrder,\n IndexerServerProductPayment,\n IndexerServerProductSnapshot,\n IndexerServerSnapshotsInterval,\n IndexerServerTx,\n} from './serverModelTypes';\n\n/**\n * Params\n */\n\nexport interface IndexerServerListSubaccountsParams {\n // Inclusive, defaults to 0\n start?: number;\n // Defaults to 100\n limit?: number;\n address?: string;\n}\n\nexport interface IndexerServerMultiSubaccountSnapshotsParams {\n // Subaccount hex identifiers\n subaccounts: string[];\n timestamps: number[];\n // If not given, will return both isolated & non-iso balances\n isolated?: boolean;\n}\n\nexport interface IndexerServerReferralCodeParams {\n subaccount: string;\n}\n\nexport interface IndexerServerFundingRateParams {\n product_id: number;\n}\n\nexport interface IndexerServerFundingRatesParams {\n product_ids: number[];\n}\n\nexport interface IndexerServerPriceParams {\n product_id: number;\n}\n\nexport interface IndexerServerPerpPricesParams {\n product_ids: number[];\n}\n\nexport interface IndexerServerOraclePricesParams {\n product_ids: number[];\n}\n\nexport interface IndexerServerCandlesticksParams {\n product_id: number;\n granularity: number;\n // Seconds\n max_time?: number;\n limit: number;\n}\n\nexport type IndexerEdgeServerCandlesticksParams =\n IndexerServerCandlesticksParams;\n\nexport interface IndexerServerProductsParams {\n product_id: number;\n max_time?: number;\n limit: number;\n // submission_idx for pagination, inclusive\n idx?: string;\n}\n\nexport interface IndexerServerMultiProductsParams {\n product_ids: number[];\n max_time: number[];\n}\n\nexport interface IndexerServerEventsParams {\n subaccounts?: string[];\n product_ids?: number[];\n // If not given, will return both isolated & non-iso events\n isolated?: boolean;\n event_types?: IndexerEventType[];\n // Descending order for idx (time), defaults to true\n desc?: boolean;\n // submission_idx for pagination, inclusive\n idx?: string;\n max_time?: number;\n limit?:\n | {\n raw: number;\n }\n | {\n txs: number;\n };\n}\n\nexport type IndexerServerTriggerTypeFilter =\n | 'none'\n | 'price_trigger'\n | 'time_trigger';\n\nexport interface IndexerServerOrdersParams {\n subaccounts?: string[];\n product_ids?: number[];\n trigger_types?: IndexerServerTriggerTypeFilter[];\n digests?: string[];\n max_time?: number;\n limit?: number;\n // If not given, will return both isolated & non-iso orders\n isolated?: boolean;\n // submission_idx for pagination, inclusive\n idx?: string;\n}\n\nexport interface IndexerServerMatchEventsParams {\n subaccounts?: string[];\n product_ids?: number[];\n // If not given, will return both isolated & non-iso events\n isolated?: boolean;\n max_time?: number;\n limit: number;\n // submission_idx for pagination, inclusive\n idx?: string;\n}\n\nexport interface IndexerServerLinkedSignerParams {\n subaccount: string;\n}\n\nexport interface IndexerServerMarketSnapshotsParams {\n interval: IndexerServerMarketSnapshotInterval;\n // Defaults to all\n product_ids?: number[];\n}\n\nexport interface IndexerEdgeServerMarketSnapshotsParams {\n interval: IndexerServerMarketSnapshotInterval;\n}\n\nexport interface IndexerServerInterestFundingParams {\n subaccount: string;\n product_ids: number[];\n // If not given, defaults to latest\n max_idx?: string;\n max_time?: number;\n limit: number;\n}\n\nexport interface IndexerServerMakerStatisticsParams {\n product_id: number;\n epoch: number;\n interval: number;\n}\n\nexport interface IndexerServerLeaderboardParams {\n contest_id: number;\n rank_type: IndexerLeaderboardRankType;\n start?: number | string;\n limit?: number | string;\n}\n\nexport interface IndexerServerLeaderboardRankParams {\n subaccount: string;\n contest_ids: number[];\n}\n\nexport interface IndexerServerLeaderboardContestsParams {\n contest_ids: number[];\n}\n\nexport interface IndexerServerLeaderboardRegistrationParams {\n subaccount: string;\n contest_id: number;\n update_registration: SignedTx<EIP712LeaderboardAuthenticationValues> | null;\n}\n\nexport interface IndexerServerFastWithdrawalSignatureParams {\n /**\n * The submission index of the WithdrawCollateral tx to be used for fast withdraw.\n */\n idx: number | string;\n}\n\nexport interface IndexerServerNlpSnapshotsParams {\n interval: IndexerServerSnapshotsInterval;\n}\n\nexport interface IndexerServerDDAQueryParams {\n subaccount: string;\n}\n\n// Request\nexport interface IndexerServerQueryRequestByType {\n account_snapshots: IndexerServerMultiSubaccountSnapshotsParams;\n backlog: Record<string, never>;\n candlesticks: IndexerServerCandlesticksParams;\n direct_deposit_address: IndexerServerDDAQueryParams;\n edge_candlesticks: IndexerEdgeServerCandlesticksParams;\n edge_market_snapshots: IndexerEdgeServerMarketSnapshotsParams;\n events: IndexerServerEventsParams;\n fast_withdrawal_signature: IndexerServerFastWithdrawalSignatureParams;\n funding_rate: IndexerServerFundingRateParams;\n funding_rates: IndexerServerFundingRatesParams;\n interest_and_funding: IndexerServerInterestFundingParams;\n leaderboard: IndexerServerLeaderboardParams;\n leaderboard_contests: IndexerServerLeaderboardContestsParams;\n leaderboard_rank: IndexerServerLeaderboardRankParams;\n leaderboard_registration: IndexerServerLeaderboardRegistrationParams;\n linked_signer_rate_limit: IndexerServerLinkedSignerParams;\n maker_statistics: IndexerServerMakerStatisticsParams;\n market_snapshots: IndexerServerMarketSnapshotsParams;\n matches: IndexerServerMatchEventsParams;\n oracle_price: IndexerServerOraclePricesParams;\n orders: IndexerServerOrdersParams;\n perp_prices: IndexerServerPerpPricesParams;\n price: IndexerServerPriceParams;\n product_snapshots: IndexerServerMultiProductsParams;\n products: IndexerServerProductsParams;\n referral_code: IndexerServerReferralCodeParams;\n subaccounts: IndexerServerListSubaccountsParams;\n quote_price: Record<string, never>;\n nlp_snapshots: IndexerServerNlpSnapshotsParams;\n}\n\nexport type IndexerServerQueryRequestType =\n keyof IndexerServerQueryRequestByType;\n\n/**\n * Responses\n */\n\nexport interface IndexerServerListSubaccountsResponse {\n subaccounts: {\n id: string;\n // Hex of subaccount bytes\n subaccount: string;\n }[];\n}\n\nexport interface IndexerServerMultiSubaccountSnapshotsResponse {\n // Map of subaccount hex -> timestamp requested -> latest events corresponding to each product\n snapshots: Record<string, Record<string, IndexerServerEvent[]>>;\n}\n\nexport interface IndexerServerReferralCodeResponse {\n referral_code: string | null;\n}\n\nexport interface IndexerServerFundingRate {\n product_id: number;\n funding_rate_x18: string;\n update_time: number;\n}\n\nexport type IndexerServerFundingRateResponse = IndexerServerFundingRate;\n\n// Map of productId -> IndexerServerFundingRate\nexport type IndexerServerFundingRatesResponse = Record<\n string,\n IndexerServerFundingRate\n>;\n\nexport interface IndexerServerPerpPrices {\n product_id: number;\n index_price_x18: string;\n mark_price_x18: string;\n update_time: number;\n}\n\nexport type IndexerServerPriceResponse = IndexerServerPerpPrices;\n\n// Map of productId -> IndexerServerPerpPrices\nexport type IndexerServerPerpPricesResponse = Record<\n string,\n IndexerServerPerpPrices\n>;\n\nexport interface IndexerServerOraclePricesResponse {\n prices: IndexerServerOraclePrice[];\n}\n\nexport interface IndexerServerCandlesticksResponse {\n candlesticks: IndexerServerCandlestick[];\n}\n\nexport type IndexerEdgeServerCandlesticksResponse =\n IndexerServerCandlesticksResponse;\n\nexport interface IndexerServerProductsResponse {\n products: IndexerServerProductSnapshot[];\n txs: IndexerServerTx[];\n}\n\n// Map of timestamp -> (productID -> IndexerServerProductSnapshot)\nexport type IndexerServerMultiProductsResponse = Record<\n string,\n Record<string, IndexerServerProductSnapshot>\n>;\n\nexport interface IndexerServerEventsResponse {\n events: IndexerServerEvent[];\n txs: IndexerServerTx[];\n}\n\nexport interface IndexerServerOrdersResponse {\n orders: IndexerServerOrder[];\n}\n\nexport interface IndexerServerMatchEventsResponse {\n matches: IndexerServerMatchEvent[];\n txs: IndexerServerTx[];\n}\n\nexport interface IndexerServerQuotePriceResponse {\n price_x18: string;\n}\n\nexport interface IndexerServerLinkedSignerResponse {\n total_tx_limit: string;\n remaining_tx: string;\n wait_time: string;\n signer: string;\n}\n\nexport interface IndexerServerMarketSnapshotsResponse {\n snapshots: IndexerServerMarketSnapshot[];\n}\n\nexport interface IndexerEdgeServerMarketSnapshotsResponse {\n snapshots: Record<number, IndexerServerMarketSnapshot[]>;\n}\n\nexport interface IndexerServerInterestFundingResponse {\n interest_payments: IndexerServerProductPayment[];\n funding_payments: IndexerServerProductPayment[];\n next_idx: string;\n}\n\nexport interface IndexerServerMakerStatisticsResponse {\n reward_coefficient: string;\n makers: IndexerServerMaker[];\n}\n\nexport interface IndexerServerLeaderboardResponse {\n positions: IndexerServerLeaderboardPosition[];\n}\n\nexport interface IndexerServerLeaderboardRegistrationResponse {\n // For non-tiered contests, null if the user is not registered for the provided contestId.\n // For tiered contests (i.e., related contests), null if the user is not registered for any of the contests in the tier group.\n registration: IndexerServerLeaderboardRegistration | null;\n}\n\nexport interface IndexerServerLeaderboardRankResponse {\n // If the subaccount is not eligible for a given contest, it would not be included in the response.\n // contestId -> IndexerServerLeaderboardPosition\n positions: Record<string, IndexerServerLeaderboardPosition>;\n}\n\nexport interface IndexerServerLeaderboardContestsResponse {\n contests: IndexerServerLeaderboardContest[];\n}\n\nexport interface IndexerServerFastWithdrawalSignatureResponse {\n idx: string;\n tx: NadoWithdrawCollateralTx['withdraw_collateral'];\n tx_bytes: string;\n signatures: string[];\n}\n\nexport interface IndexerServerNlpSnapshotsResponse {\n snapshots: IndexerServerNlpSnapshot[];\n}\n\nexport interface IndexerServerDDAResponse {\n v1_address: string;\n}\n\nexport interface IndexerServerBacklogResponse {\n // Total number of transactions stored in the indexer DB\n total_txs: string;\n // Current nSubmissions value from the chain (i.e., number of processed txs)\n total_submissions: string;\n // Number of unprocessed transactions (total_txs - total_submissions)\n backlog_size: string;\n // UNIX timestamp (in seconds) of when the data was last updated\n updated_at: string;\n // Estimated time in seconds (float) to clear the entire backlog (null if unavailable)\n backlog_eta_in_seconds: string | null;\n // Current submission rate in transactions per second (float) (null if unavailable)\n txs_per_second: string | null;\n}\n\n// Response\nexport interface IndexerServerQueryResponseByType {\n account_snapshots: IndexerServerMultiSubaccountSnapshotsResponse;\n backlog: IndexerServerBacklogResponse;\n candlesticks: IndexerServerCandlesticksResponse;\n direct_deposit_address: IndexerServerDDAResponse;\n edge_candlesticks: IndexerEdgeServerCandlesticksResponse;\n edge_market_snapshots: IndexerEdgeServerMarketSnapshotsResponse;\n events: IndexerServerEventsResponse;\n fast_withdrawal_signature: IndexerServerFastWithdrawalSignatureResponse;\n funding_rate: IndexerServerFundingRateResponse;\n funding_rates: IndexerServerFundingRatesResponse;\n interest_and_funding: IndexerServerInterestFundingResponse;\n leaderboard: IndexerServerLeaderboardResponse;\n leaderboard_contests: IndexerServerLeaderboardContestsResponse;\n leaderboard_rank: IndexerServerLeaderboardRankResponse;\n leaderboard_registration: IndexerServerLeaderboardRegistrationResponse;\n linked_signer_rate_limit: IndexerServerLinkedSignerResponse;\n maker_statistics: IndexerServerMakerStatisticsResponse;\n market_snapshots: IndexerServerMarketSnapshotsResponse;\n matches: IndexerServerMatchEventsResponse;\n oracle_price: IndexerServerOraclePricesResponse;\n orders: IndexerServerOrdersResponse;\n perp_prices: IndexerServerPerpPricesResponse;\n price: IndexerServerPriceResponse;\n product_snapshots: IndexerServerMultiProductsResponse;\n products: IndexerServerProductsResponse;\n referral_code: IndexerServerReferralCodeResponse;\n subaccounts: IndexerServerListSubaccountsResponse;\n quote_price: IndexerServerQuotePriceResponse;\n nlp_snapshots: IndexerServerNlpSnapshotsResponse;\n}\n\n/**\n * V2 API Types\n */\n\n/**\n * Individual ticker data from v2 indexer endpoint (server format)\n */\nexport interface IndexerServerV2TickerResponse {\n product_id: number;\n ticker_id: string;\n base_currency: string;\n quote_currency: string;\n last_price: number;\n base_volume: number;\n quote_volume: number;\n price_change_percent_24h: number;\n}\n\n/**\n * Response from v2 tickers endpoint (server format)\n * Maps ticker IDs to their respective ticker data\n */\nexport type IndexerServerV2TickersResponse = Record<\n string,\n IndexerServerV2TickerResponse\n>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -54,7 +54,7 @@ interface IndexerServerMultiProductsParams {
54
54
  max_time: number[];
55
55
  }
56
56
  interface IndexerServerEventsParams {
57
- subaccount?: string;
57
+ subaccounts?: string[];
58
58
  product_ids?: number[];
59
59
  isolated?: boolean;
60
60
  event_types?: IndexerEventType[];
@@ -69,7 +69,7 @@ interface IndexerServerEventsParams {
69
69
  }
70
70
  type IndexerServerTriggerTypeFilter = 'none' | 'price_trigger' | 'time_trigger';
71
71
  interface IndexerServerOrdersParams {
72
- subaccount?: string;
72
+ subaccounts?: string[];
73
73
  product_ids?: number[];
74
74
  trigger_types?: IndexerServerTriggerTypeFilter[];
75
75
  digests?: string[];
@@ -79,7 +79,7 @@ interface IndexerServerOrdersParams {
79
79
  idx?: string;
80
80
  }
81
81
  interface IndexerServerMatchEventsParams {
82
- subaccount?: string;
82
+ subaccounts?: string[];
83
83
  product_ids?: number[];
84
84
  isolated?: boolean;
85
85
  max_time?: number;
@@ -54,7 +54,7 @@ interface IndexerServerMultiProductsParams {
54
54
  max_time: number[];
55
55
  }
56
56
  interface IndexerServerEventsParams {
57
- subaccount?: string;
57
+ subaccounts?: string[];
58
58
  product_ids?: number[];
59
59
  isolated?: boolean;
60
60
  event_types?: IndexerEventType[];
@@ -69,7 +69,7 @@ interface IndexerServerEventsParams {
69
69
  }
70
70
  type IndexerServerTriggerTypeFilter = 'none' | 'price_trigger' | 'time_trigger';
71
71
  interface IndexerServerOrdersParams {
72
- subaccount?: string;
72
+ subaccounts?: string[];
73
73
  product_ids?: number[];
74
74
  trigger_types?: IndexerServerTriggerTypeFilter[];
75
75
  digests?: string[];
@@ -79,7 +79,7 @@ interface IndexerServerOrdersParams {
79
79
  idx?: string;
80
80
  }
81
81
  interface IndexerServerMatchEventsParams {
82
- subaccount?: string;
82
+ subaccounts?: string[];
83
83
  product_ids?: number[];
84
84
  isolated?: boolean;
85
85
  max_time?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nadohq/indexer-client",
3
- "version": "0.1.0-alpha.31",
3
+ "version": "0.1.0-alpha.32",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "> TODO: description",
@@ -36,9 +36,13 @@
36
36
  }
37
37
  }
38
38
  },
39
+ "react-native": "./dist/index.js",
40
+ "main": "./dist/index.cjs",
41
+ "module": "./dist/index.js",
42
+ "types": "./dist/index.d.ts",
39
43
  "dependencies": {
40
- "@nadohq/engine-client": "^0.1.0-alpha.31",
41
- "@nadohq/shared": "^0.1.0-alpha.31",
44
+ "@nadohq/engine-client": "^0.1.0-alpha.32",
45
+ "@nadohq/shared": "^0.1.0-alpha.32",
42
46
  "axios": "*",
43
47
  "ts-mixer": "*"
44
48
  },
@@ -48,5 +52,5 @@
48
52
  "devDependencies": {
49
53
  "viem": "*"
50
54
  },
51
- "gitHead": "5491b8de4e6422d04a5ef9cd5ef736afdba8fa66"
55
+ "gitHead": "af3e125a5791069b1af98481cd36397ffb405951"
52
56
  }