@nadohq/indexer-client 0.1.0-alpha.5 → 0.1.0-alpha.7

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.
@@ -571,7 +571,7 @@ var IndexerBaseClient = class {
571
571
  subaccount: (0, import_shared.subaccountToHex)(params.subaccount)
572
572
  });
573
573
  return {
574
- address: baseResponse.v1_address
574
+ address: (0, import_shared.getValidatedAddress)(baseResponse.v1_address)
575
575
  };
576
576
  }
577
577
  async getSequencerBacklog() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/IndexerBaseClient.ts"],"sourcesContent":["import {\n EIP712LeaderboardAuthenticationParams,\n EIP712LeaderboardAuthenticationValues,\n getDefaultRecvTime,\n getNadoEIP712Values,\n getSignedTransactionRequest,\n getValidatedHex,\n mapValues,\n nowInSeconds,\n removeDecimals,\n SignableRequestType,\n SignableRequestTypeToParams,\n SignedTx,\n subaccountFromHex,\n subaccountToHex,\n toBigDecimal,\n toBigInt,\n toIntegerString,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n mapIndexerCandlesticks,\n mapIndexerEvent,\n mapIndexerEventWithTx,\n mapIndexerFundingRate,\n mapIndexerLeaderboardContest,\n mapIndexerLeaderboardPosition,\n mapIndexerLeaderboardRegistration,\n mapIndexerMakerStatistics,\n mapIndexerMarketSnapshot,\n mapIndexerMatchEventBalances,\n mapIndexerNlpSnapshot,\n mapIndexerOrder,\n mapIndexerPerpPrices,\n mapIndexerProductPayment,\n mapIndexerServerProduct,\n mapSnapshotsIntervalToServerParams,\n} from './dataMappers';\nimport {\n GetIndexerBacklogResponse,\n GetIndexerCandlesticksParams,\n GetIndexerCandlesticksResponse,\n GetIndexerEdgeCandlesticksParams,\n GetIndexerEdgeCandlesticksResponse,\n GetIndexerEdgeMarketSnapshotResponse,\n GetIndexerEdgeMarketSnapshotsParams,\n GetIndexerEventsParams,\n GetIndexerEventsResponse,\n GetIndexerFastWithdrawalSignatureParams,\n GetIndexerFastWithdrawalSignatureResponse,\n GetIndexerFundingRateParams,\n GetIndexerFundingRateResponse,\n GetIndexerInterestFundingPaymentsParams,\n GetIndexerInterestFundingPaymentsResponse,\n GetIndexerLeaderboardContestsParams,\n GetIndexerLeaderboardContestsResponse,\n GetIndexerLeaderboardParams,\n GetIndexerLeaderboardParticipantParams,\n GetIndexerLeaderboardParticipantResponse,\n GetIndexerLeaderboardRegistrationParams,\n GetIndexerLeaderboardRegistrationResponse,\n GetIndexerLeaderboardResponse,\n GetIndexerLinkedSignerParams,\n GetIndexerLinkedSignerResponse,\n GetIndexerMakerStatisticsParams,\n GetIndexerMakerStatisticsResponse,\n GetIndexerMarketSnapshotsParams,\n GetIndexerMarketSnapshotsResponse,\n GetIndexerMatchEventsParams,\n GetIndexerMatchEventsResponse,\n GetIndexerMultiProductFundingRatesParams,\n GetIndexerMultiProductFundingRatesResponse,\n GetIndexerMultiProductPerpPricesParams,\n GetIndexerMultiProductPerpPricesResponse,\n GetIndexerMultiProductSnapshotsParams,\n GetIndexerMultiProductSnapshotsResponse,\n GetIndexerMultiSubaccountSnapshotsParams,\n GetIndexerMultiSubaccountSnapshotsResponse,\n GetIndexerNlpSnapshotsParams,\n GetIndexerNlpSnapshotsResponse,\n GetIndexerOraclePricesParams,\n GetIndexerOraclePricesResponse,\n GetIndexerOrdersParams,\n GetIndexerOrdersResponse,\n GetIndexerPerpPricesParams,\n GetIndexerPerpPricesResponse,\n GetIndexerProductSnapshotsParams,\n GetIndexerProductSnapshotsResponse,\n GetIndexerQuotePriceResponse,\n GetIndexerReferralCodeParams,\n GetIndexerReferralCodeResponse,\n GetIndexerSubaccountDDAParams,\n GetIndexerSubaccountDDAResponse,\n IndexerEventWithTx,\n IndexerMatchEvent,\n IndexerOraclePrice,\n IndexerServerEventsParams,\n IndexerServerQueryRequestByType,\n IndexerServerQueryRequestType,\n IndexerServerQueryResponseByType,\n IndexerSnapshotBalance,\n IndexerSubaccountSnapshot,\n ListIndexerSubaccountsParams,\n ListIndexerSubaccountsResponse,\n UpdateIndexerLeaderboardRegistrationParams,\n UpdateIndexerLeaderboardRegistrationResponse,\n} from './types';\n\nexport interface IndexerClientOpts {\n // Server URLs\n url: string;\n v2Url?: string;\n // Wallet Client for EIP712 signing\n walletClient?: WalletClientWithAccount;\n}\n\ntype IndexerQueryRequestBody = Partial<IndexerServerQueryRequestByType>;\n\n/**\n * Base client for all indexer requests\n */\nexport class IndexerBaseClient {\n readonly opts: IndexerClientOpts;\n readonly v2Url: string;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: IndexerClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n // We have custom logic to validate response status and create an appropriate error\n validateStatus: () => true,\n });\n this.v2Url = opts.v2Url ? opts.v2Url : opts.url.replace('v1', 'v2');\n }\n\n /**\n * List all subaccounts\n *\n * @param params\n */\n async listSubaccounts(\n params: ListIndexerSubaccountsParams,\n ): Promise<ListIndexerSubaccountsResponse> {\n const baseResponse = await this.query('subaccounts', params);\n\n return baseResponse.subaccounts.map((item) => {\n const subaccount = subaccountFromHex(item.subaccount);\n return {\n hexId: item.subaccount,\n ...subaccount,\n };\n });\n }\n\n /**\n * Retrieve snapshots of multiple subaccounts at multiple points in time.\n * Each snapshot is a view of the subaccount's balances at this point in time, with tracked variables for interest, funding, etc.\n *\n * @param params\n */\n async getMultiSubaccountSnapshots(\n params: GetIndexerMultiSubaccountSnapshotsParams,\n ): Promise<GetIndexerMultiSubaccountSnapshotsResponse> {\n const subaccountHexIds = params.subaccounts.map(\n ({ subaccountOwner, subaccountName }) =>\n subaccountToHex({\n subaccountOwner,\n subaccountName,\n }),\n );\n\n const baseResponse = await this.query('account_snapshots', {\n subaccounts: subaccountHexIds,\n timestamps: params.timestamps,\n isolated: params.isolated,\n });\n\n const snapshotsBySubaccount = mapValues(\n baseResponse.snapshots,\n (balanceSnapshots) => {\n const snapshotByTimestamp: Record<string, IndexerSubaccountSnapshot> =\n {};\n\n Object.entries(balanceSnapshots).forEach(([timestamp, events]) => {\n const balances: IndexerSnapshotBalance[] =\n events.map(mapIndexerEvent);\n\n snapshotByTimestamp[timestamp] = {\n timestamp: toBigDecimal(timestamp),\n balances,\n };\n });\n\n return snapshotByTimestamp;\n },\n );\n\n return {\n subaccountHexIds,\n snapshots: snapshotsBySubaccount,\n };\n }\n\n /**\n * Retrieves referral code for an address\n *\n * @param params\n */\n async getReferralCode(\n params: GetIndexerReferralCodeParams,\n ): Promise<GetIndexerReferralCodeResponse> {\n const baseResponse = await this.query('referral_code', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n }),\n });\n\n return {\n referralCode: baseResponse.referral_code,\n };\n }\n\n /**\n * Retrieves funding rate for a product, where 1 = 100%\n * @param params\n */\n async getFundingRate(\n params: GetIndexerFundingRateParams,\n ): Promise<GetIndexerFundingRateResponse> {\n const baseResponse = await this.query('funding_rate', {\n product_id: params.productId,\n });\n\n return mapIndexerFundingRate(baseResponse);\n }\n\n /**\n * Retrieves funding rate for multiple products, where 1 = 100%\n * @param params\n */\n async getMultiProductFundingRates(\n params: GetIndexerMultiProductFundingRatesParams,\n ): Promise<GetIndexerMultiProductFundingRatesResponse> {\n const baseResponse = await this.query('funding_rates', {\n product_ids: params.productIds,\n });\n\n return mapValues(baseResponse, mapIndexerFundingRate);\n }\n\n /**\n * Retrieves latest mark/index price for a perp product\n * @param params\n */\n async getPerpPrices(\n params: GetIndexerPerpPricesParams,\n ): Promise<GetIndexerPerpPricesResponse> {\n const baseResponse = await this.query('price', {\n product_id: params.productId,\n });\n\n return mapIndexerPerpPrices(baseResponse);\n }\n\n /**\n * Retrieves latest mark/index price for multiple perp products\n * @param params\n */\n async getMultiProductPerpPrices(\n params: GetIndexerMultiProductPerpPricesParams,\n ): Promise<GetIndexerMultiProductPerpPricesResponse> {\n const baseResponse = await this.query('perp_prices', {\n product_ids: params.productIds,\n });\n\n return mapValues(baseResponse, mapIndexerPerpPrices);\n }\n\n /**\n * Retrieves latest oracle prices for provided products\n * @param params\n */\n async getOraclePrices(\n params: GetIndexerOraclePricesParams,\n ): Promise<GetIndexerOraclePricesResponse> {\n const baseResponse = await this.query('oracle_price', {\n product_ids: params.productIds,\n });\n\n return baseResponse.prices.map((price): IndexerOraclePrice => {\n return {\n oraclePrice: removeDecimals(price.oracle_price_x18),\n updateTime: toBigDecimal(price.update_time),\n productId: price.product_id,\n };\n });\n }\n\n /**\n * Retrieves candlesticks for a product\n * @param params\n */\n async getCandlesticks(\n params: GetIndexerCandlesticksParams,\n ): Promise<GetIndexerCandlesticksResponse> {\n const baseResponse = await this.query('candlesticks', {\n product_id: params.productId,\n max_time: params.maxTimeInclusive,\n limit: params.limit,\n granularity: params.period,\n });\n\n return baseResponse.candlesticks.map(mapIndexerCandlesticks);\n }\n\n /**\n * Retrieves candlesticks for a product from Edge\n * @param params\n */\n async getEdgeCandlesticks(\n params: GetIndexerEdgeCandlesticksParams,\n ): Promise<GetIndexerEdgeCandlesticksResponse> {\n const baseResponse = await this.query('edge_candlesticks', {\n product_id: params.productId,\n max_time: params.maxTimeInclusive,\n limit: params.limit,\n granularity: params.period,\n });\n\n return baseResponse.candlesticks.map(mapIndexerCandlesticks);\n }\n\n /**\n * Retrieves historical snapshots for a product\n * @param params\n */\n async getProductSnapshots(\n params: GetIndexerProductSnapshotsParams,\n ): Promise<GetIndexerProductSnapshotsResponse> {\n const baseResponse = await this.query('products', {\n product_id: params.productId,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n return baseResponse.products.map((product) => {\n return {\n ...mapIndexerServerProduct(product.product),\n submissionIndex: product.submission_idx,\n };\n });\n }\n\n /**\n * Retrieves historical snapshots for multiple products\n * @param params\n */\n async getMultiProductSnapshots(\n params: GetIndexerMultiProductSnapshotsParams,\n ): Promise<GetIndexerMultiProductSnapshotsResponse> {\n const timestampToProductsMap = await this.query('product_snapshots', {\n product_ids: params.productIds,\n max_time: params.maxTimestampInclusive ?? [nowInSeconds()],\n });\n\n return mapValues(timestampToProductsMap, (productIdToProduct) => {\n return mapValues(productIdToProduct, (indexerProduct) => {\n return {\n ...mapIndexerServerProduct(indexerProduct.product),\n submissionIndex: indexerProduct.submission_idx,\n };\n });\n });\n }\n\n /**\n * Retrieves historical events\n *\n * @param params\n */\n async getEvents(\n params: GetIndexerEventsParams,\n ): Promise<GetIndexerEventsResponse> {\n const serverLimit = ((): IndexerServerEventsParams['limit'] | undefined => {\n if (!params.limit) {\n return;\n }\n\n if (params.limit.type === 'events') {\n return {\n raw: params.limit.value,\n };\n }\n return {\n txs: params.limit.value,\n };\n })();\n\n const baseResponse = await this.query('events', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n event_types: params.eventTypes,\n max_time: params.maxTimestampInclusive,\n desc: params.desc,\n limit: serverLimit,\n idx: params.startCursor,\n });\n\n // Keep track of the last tx index, and go to the next one if the submission_idx for the currently processed event does not match\n // txs are ordered the same as events, so this should be correct\n let lastTxIdx = 0;\n return baseResponse.events.map((event): IndexerEventWithTx => {\n if (baseResponse.txs[lastTxIdx].submission_idx !== event.submission_idx) {\n lastTxIdx += 1;\n }\n const tx = baseResponse.txs[lastTxIdx];\n return mapIndexerEventWithTx(event, tx);\n });\n }\n\n /**\n * Retrieves historical orders\n * @param params\n */\n async getOrders(\n params: GetIndexerOrdersParams,\n ): Promise<GetIndexerOrdersResponse> {\n const baseResponse = await this.query('orders', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n digests: params.digests,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n return baseResponse.orders.map(mapIndexerOrder);\n }\n\n /**\n * Gets match order events, this will return the same events as the events query, but with additional information\n * to identify the order that was matched\n *\n * @param params\n */\n async getMatchEvents(\n params: GetIndexerMatchEventsParams,\n ): Promise<GetIndexerMatchEventsResponse> {\n const baseResponse = await this.query('matches', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n // Same as logic in `getEvents`\n let lastTxIdx = 0;\n return baseResponse.matches.map((matchEvent): IndexerMatchEvent => {\n if (\n baseResponse.txs[lastTxIdx].submission_idx !== matchEvent.submission_idx\n ) {\n lastTxIdx += 1;\n }\n const { tx, timestamp } = baseResponse.txs[lastTxIdx];\n\n // We use this to derive the product ID for the match\n const postBalances = mapIndexerMatchEventBalances(\n matchEvent.post_balance,\n );\n\n return {\n productId: postBalances.base.productId,\n isolated: matchEvent.isolated,\n totalFee: toBigDecimal(matchEvent.fee),\n sequencerFee: toBigDecimal(matchEvent.sequencer_fee),\n baseFilled: toBigDecimal(matchEvent.base_filled),\n quoteFilled: toBigDecimal(matchEvent.quote_filled),\n cumulativeFee: toBigDecimal(matchEvent.cumulative_fee),\n cumulativeBaseFilled: toBigDecimal(matchEvent.cumulative_base_filled),\n cumulativeQuoteFilled: toBigDecimal(matchEvent.cumulative_quote_filled),\n digest: matchEvent.digest,\n order: matchEvent.order,\n submissionIndex: matchEvent.submission_idx,\n timestamp: toBigDecimal(timestamp),\n preEventTrackedVars: {\n netEntryUnrealized: toBigDecimal(matchEvent.net_entry_unrealized),\n netEntryCumulative: toBigDecimal(matchEvent.net_entry_cumulative),\n },\n preBalances: mapIndexerMatchEventBalances(matchEvent.pre_balance),\n postBalances,\n tx,\n ...subaccountFromHex(matchEvent.order.sender),\n };\n });\n }\n\n /**\n * Retrieves historical funding & interest payments.\n * NOTE: `limit` is an upperbound. If a user changes position size such that his position is 0 during each funding/interest tick,\n * then the indexer will return fewer than `limit` results per page. However, more events can be present. This means that\n * there isn't a reliable way to determine whether there is a next page. We just need to keep paginating until the next cursor is null.\n *\n * @param params\n */\n async getInterestFundingPayments(\n params: GetIndexerInterestFundingPaymentsParams,\n ): Promise<GetIndexerInterestFundingPaymentsResponse> {\n const baseResponse = await this.query('interest_and_funding', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n }),\n product_ids: params.productIds,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n max_idx: params.startCursor,\n });\n\n return {\n fundingPayments: baseResponse.funding_payments.map(\n mapIndexerProductPayment,\n ),\n interestPayments: baseResponse.interest_payments.map(\n mapIndexerProductPayment,\n ),\n nextCursor: baseResponse.next_idx,\n };\n }\n\n /**\n * Gets quote (USDC) price in terms of USD\n */\n async getQuotePrice(): Promise<GetIndexerQuotePriceResponse> {\n const baseResponse = await this.query('usdc_price', {});\n return {\n price: removeDecimals(baseResponse.price_x18),\n };\n }\n\n /**\n * Fetches currently registered linked signer with the remaining txs allowed for the subaccount\n */\n async getLinkedSignerWithRateLimit(\n params: GetIndexerLinkedSignerParams,\n ): Promise<GetIndexerLinkedSignerResponse> {\n const baseResponse = await this.query('linked_signer_rate_limit', {\n subaccount: subaccountToHex(params.subaccount),\n });\n return {\n totalTxLimit: toBigDecimal(baseResponse.total_tx_limit),\n remainingTxs: toBigDecimal(baseResponse.remaining_tx),\n signer: baseResponse.signer,\n waitTimeUntilNextTx: toBigDecimal(baseResponse.wait_time),\n };\n }\n\n /**\n * Retrieve historical market snapshots\n * @param params\n */\n async getMarketSnapshots(\n params: GetIndexerMarketSnapshotsParams,\n ): Promise<GetIndexerMarketSnapshotsResponse> {\n const baseResponse = await this.query('market_snapshots', {\n interval: mapSnapshotsIntervalToServerParams(params),\n product_ids: params.productIds,\n });\n\n return baseResponse.snapshots.map(mapIndexerMarketSnapshot);\n }\n\n /**\n * Retrieve historical market snapshots from Edge\n * @param params\n */\n async getEdgeMarketSnapshots(\n params: GetIndexerEdgeMarketSnapshotsParams,\n ): Promise<GetIndexerEdgeMarketSnapshotResponse> {\n const baseResponse = await this.query('edge_market_snapshots', {\n interval: mapSnapshotsIntervalToServerParams(params),\n });\n\n return mapValues(baseResponse.snapshots, (snapshots) =>\n snapshots.map(mapIndexerMarketSnapshot),\n );\n }\n\n /**\n * Retrieve maker statistics for a given epoch\n *\n * @param params\n */\n async getMakerStatistics(\n params: GetIndexerMakerStatisticsParams,\n ): Promise<GetIndexerMakerStatisticsResponse> {\n const baseResponse = await this.query('maker_statistics', {\n product_id: params.productId,\n epoch: params.epoch,\n interval: params.interval,\n });\n\n return {\n rewardCoefficient: toBigDecimal(baseResponse.reward_coefficient),\n makers: baseResponse.makers.map(mapIndexerMakerStatistics),\n };\n }\n\n /**\n * Retrieve leaderboard stats for a given contest\n *\n * @param params\n */\n async getLeaderboard(\n params: GetIndexerLeaderboardParams,\n ): Promise<GetIndexerLeaderboardResponse> {\n const baseResponse = await this.query('leaderboard', {\n contest_id: params.contestId,\n rank_type: params.rankType,\n start: params.startCursor,\n limit: params.limit,\n });\n\n return {\n participants: baseResponse.positions.map(mapIndexerLeaderboardPosition),\n };\n }\n\n /**\n * Retrieve leaderboard ranking of a subaccount on a given contest\n *\n * @param params\n */\n async getLeaderboardParticipant(\n params: GetIndexerLeaderboardParticipantParams,\n ): Promise<GetIndexerLeaderboardParticipantResponse> {\n const baseResponse = await this.query('leaderboard_rank', {\n subaccount: subaccountToHex(params.subaccount),\n contest_ids: params.contestIds,\n });\n\n return {\n participant: mapValues(baseResponse.positions, (position) =>\n mapIndexerLeaderboardPosition(position),\n ),\n };\n }\n\n /**\n * Attempts to update a user's registration to the provided `contestId`. This requires signing.\n * @param params\n */\n async updateLeaderboardRegistration(\n params: UpdateIndexerLeaderboardRegistrationParams,\n ): Promise<UpdateIndexerLeaderboardRegistrationResponse> {\n const signatureParams: EIP712LeaderboardAuthenticationParams = {\n // Default to 90 seconds from now if no recvTime is provided\n expiration: toIntegerString(params.recvTime ?? getDefaultRecvTime()),\n subaccountName: params.subaccountName,\n subaccountOwner: params.subaccountOwner,\n };\n\n const tx = getNadoEIP712Values(\n 'leaderboard_authentication',\n signatureParams,\n );\n const signature = await this.sign(\n 'leaderboard_authentication',\n params.updateRegistration.verifyingAddr,\n params.updateRegistration.chainId,\n signatureParams,\n );\n\n const updateRegistrationTx: SignedTx<EIP712LeaderboardAuthenticationValues> =\n {\n tx,\n signature,\n };\n\n const baseResponse = await this.query('leaderboard_registration', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n contest_id: params.contestId,\n update_registration: updateRegistrationTx,\n });\n return {\n registration: baseResponse.registration\n ? mapIndexerLeaderboardRegistration(baseResponse.registration)\n : null,\n };\n }\n\n /**\n * Retrieves the registration status for a leaderboard participant for provided `contestId`.\n * @param params\n */\n async getLeaderboardRegistration(\n params: GetIndexerLeaderboardRegistrationParams,\n ): Promise<GetIndexerLeaderboardRegistrationResponse> {\n const baseResponse = await this.query('leaderboard_registration', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n contest_id: params.contestId,\n update_registration: null,\n });\n return {\n registration: baseResponse.registration\n ? mapIndexerLeaderboardRegistration(baseResponse.registration)\n : null,\n };\n }\n\n /**\n * Retrieve metadata of provided leaderboard contests\n *\n * @param params\n */\n async getLeaderboardContests(\n params: GetIndexerLeaderboardContestsParams,\n ): Promise<GetIndexerLeaderboardContestsResponse> {\n const baseResponse = await this.query('leaderboard_contests', {\n contest_ids: params.contestIds,\n });\n\n return {\n contests: baseResponse.contests.map(mapIndexerLeaderboardContest),\n };\n }\n\n /**\n * Retrieve signature and tx to submit a fast withdrawal\n *\n * @param params\n */\n async getFastWithdrawalSignature(\n params: GetIndexerFastWithdrawalSignatureParams,\n ): Promise<GetIndexerFastWithdrawalSignatureResponse> {\n const baseResponse = await this.query('fast_withdrawal_signature', params);\n return {\n idx: toBigInt(baseResponse.idx),\n tx: baseResponse.tx,\n txBytes: getValidatedHex(baseResponse.tx_bytes),\n signatures: baseResponse.signatures.map(getValidatedHex),\n };\n }\n\n async getNlpSnapshots(\n params: GetIndexerNlpSnapshotsParams,\n ): Promise<GetIndexerNlpSnapshotsResponse> {\n const baseResponse = await this.query('nlp_snapshots', {\n interval: {\n count: params.limit,\n max_time: params.maxTimeInclusive\n ? toIntegerString(params.maxTimeInclusive)\n : undefined,\n granularity: params.granularity,\n },\n });\n\n return {\n snapshots: baseResponse.snapshots.map(mapIndexerNlpSnapshot),\n };\n }\n\n /**\n * Retrieves the subaccount's DDA (Direct Deposit Address)\n * @param params\n */\n async getSubaccountDDA(\n params: GetIndexerSubaccountDDAParams,\n ): Promise<GetIndexerSubaccountDDAResponse> {\n const baseResponse = await this.query('direct_deposit_address', {\n subaccount: subaccountToHex(params.subaccount),\n });\n\n return {\n address: baseResponse.v1_address,\n };\n }\n\n async getSequencerBacklog(): Promise<GetIndexerBacklogResponse> {\n const baseResponse = await this.query('backlog', {});\n\n return {\n totalTxs: toBigDecimal(baseResponse.total_txs),\n totalSubmissions: toBigDecimal(baseResponse.total_submissions),\n backlogSize: toBigDecimal(baseResponse.backlog_size),\n updatedAt: toBigDecimal(baseResponse.updated_at),\n backlogEtaInSeconds: baseResponse.backlog_eta_in_seconds\n ? toBigDecimal(baseResponse.backlog_eta_in_seconds)\n : null,\n txsPerSecond: baseResponse.txs_per_second\n ? toBigDecimal(baseResponse.txs_per_second)\n : null,\n };\n }\n\n protected async query<TRequestType extends IndexerServerQueryRequestType>(\n requestType: TRequestType,\n params: IndexerServerQueryRequestByType[TRequestType],\n ): Promise<IndexerServerQueryResponseByType[TRequestType]> {\n const reqBody: IndexerQueryRequestBody = {\n [requestType]: params,\n };\n const response = await this.axiosInstance.post<\n IndexerServerQueryResponseByType[TRequestType]\n >(this.opts.url, reqBody);\n\n this.checkResponseStatus(response);\n\n return response.data;\n }\n\n protected async sign<T extends SignableRequestType>(\n requestType: T,\n verifyingContract: string,\n chainId: number,\n params: SignableRequestTypeToParams[T],\n ) {\n const walletClient = this.opts.walletClient;\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n return getSignedTransactionRequest({\n chainId,\n requestParams: params,\n requestType,\n walletClient,\n verifyingContract,\n });\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}`,\n );\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAoBO;AACP,mBAAoD;AACpD,yBAiBO;AAoFA,IAAM,oBAAN,MAAwB;AAAA,EAK7B,YAAY,MAAyB;AACnC,SAAK,OAAO;AACZ,SAAK,gBAAgB,aAAAA,QAAM,OAAO;AAAA,MAChC,iBAAiB;AAAA;AAAA,MAEjB,gBAAgB,MAAM;AAAA,IACxB,CAAC;AACD,SAAK,QAAQ,KAAK,QAAQ,KAAK,QAAQ,KAAK,IAAI,QAAQ,MAAM,IAAI;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,gBACJ,QACyC;AACzC,UAAM,eAAe,MAAM,KAAK,MAAM,eAAe,MAAM;AAE3D,WAAO,aAAa,YAAY,IAAI,CAAC,SAAS;AAC5C,YAAM,iBAAa,iCAAkB,KAAK,UAAU;AACpD,aAAO;AAAA,QACL,OAAO,KAAK;AAAA,QACZ,GAAG;AAAA,MACL;AAAA,IACF,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,4BACJ,QACqD;AACrD,UAAM,mBAAmB,OAAO,YAAY;AAAA,MAC1C,CAAC,EAAE,iBAAiB,eAAe,UACjC,+B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ACA,SACA,QACA;AACA,UAAM,eAAe,KAAK,KAAK;AAE/B,QAAI,CAAC,cAAc;AACjB,YAAM,IAAI,qCAAuB;AAAA,IACnC;AAEA,eAAO,2CAA4B;AAAA,MACjC;AAAA,MACA,eAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,oBAAoB,UAAyB;AACnD,QAAI,SAAS,WAAW,OAAO,CAAC,SAAS,MAAM;AAC7C,YAAM;AAAA,QACJ,oCAAoC,SAAS,MAAM,IAAI,SAAS,UAAU;AAAA,MAC5E;AAAA,IACF;AAAA,EACF;AACF;","names":["axios"]}
1
+ {"version":3,"sources":["../src/IndexerBaseClient.ts"],"sourcesContent":["import {\n EIP712LeaderboardAuthenticationParams,\n EIP712LeaderboardAuthenticationValues,\n getDefaultRecvTime,\n getNadoEIP712Values,\n getSignedTransactionRequest,\n getValidatedAddress,\n getValidatedHex,\n mapValues,\n nowInSeconds,\n removeDecimals,\n SignableRequestType,\n SignableRequestTypeToParams,\n SignedTx,\n subaccountFromHex,\n subaccountToHex,\n toBigDecimal,\n toBigInt,\n toIntegerString,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n mapIndexerCandlesticks,\n mapIndexerEvent,\n mapIndexerEventWithTx,\n mapIndexerFundingRate,\n mapIndexerLeaderboardContest,\n mapIndexerLeaderboardPosition,\n mapIndexerLeaderboardRegistration,\n mapIndexerMakerStatistics,\n mapIndexerMarketSnapshot,\n mapIndexerMatchEventBalances,\n mapIndexerNlpSnapshot,\n mapIndexerOrder,\n mapIndexerPerpPrices,\n mapIndexerProductPayment,\n mapIndexerServerProduct,\n mapSnapshotsIntervalToServerParams,\n} from './dataMappers';\nimport {\n GetIndexerBacklogResponse,\n GetIndexerCandlesticksParams,\n GetIndexerCandlesticksResponse,\n GetIndexerEdgeCandlesticksParams,\n GetIndexerEdgeCandlesticksResponse,\n GetIndexerEdgeMarketSnapshotResponse,\n GetIndexerEdgeMarketSnapshotsParams,\n GetIndexerEventsParams,\n GetIndexerEventsResponse,\n GetIndexerFastWithdrawalSignatureParams,\n GetIndexerFastWithdrawalSignatureResponse,\n GetIndexerFundingRateParams,\n GetIndexerFundingRateResponse,\n GetIndexerInterestFundingPaymentsParams,\n GetIndexerInterestFundingPaymentsResponse,\n GetIndexerLeaderboardContestsParams,\n GetIndexerLeaderboardContestsResponse,\n GetIndexerLeaderboardParams,\n GetIndexerLeaderboardParticipantParams,\n GetIndexerLeaderboardParticipantResponse,\n GetIndexerLeaderboardRegistrationParams,\n GetIndexerLeaderboardRegistrationResponse,\n GetIndexerLeaderboardResponse,\n GetIndexerLinkedSignerParams,\n GetIndexerLinkedSignerResponse,\n GetIndexerMakerStatisticsParams,\n GetIndexerMakerStatisticsResponse,\n GetIndexerMarketSnapshotsParams,\n GetIndexerMarketSnapshotsResponse,\n GetIndexerMatchEventsParams,\n GetIndexerMatchEventsResponse,\n GetIndexerMultiProductFundingRatesParams,\n GetIndexerMultiProductFundingRatesResponse,\n GetIndexerMultiProductPerpPricesParams,\n GetIndexerMultiProductPerpPricesResponse,\n GetIndexerMultiProductSnapshotsParams,\n GetIndexerMultiProductSnapshotsResponse,\n GetIndexerMultiSubaccountSnapshotsParams,\n GetIndexerMultiSubaccountSnapshotsResponse,\n GetIndexerNlpSnapshotsParams,\n GetIndexerNlpSnapshotsResponse,\n GetIndexerOraclePricesParams,\n GetIndexerOraclePricesResponse,\n GetIndexerOrdersParams,\n GetIndexerOrdersResponse,\n GetIndexerPerpPricesParams,\n GetIndexerPerpPricesResponse,\n GetIndexerProductSnapshotsParams,\n GetIndexerProductSnapshotsResponse,\n GetIndexerQuotePriceResponse,\n GetIndexerReferralCodeParams,\n GetIndexerReferralCodeResponse,\n GetIndexerSubaccountDDAParams,\n GetIndexerSubaccountDDAResponse,\n IndexerEventWithTx,\n IndexerMatchEvent,\n IndexerOraclePrice,\n IndexerServerEventsParams,\n IndexerServerQueryRequestByType,\n IndexerServerQueryRequestType,\n IndexerServerQueryResponseByType,\n IndexerSnapshotBalance,\n IndexerSubaccountSnapshot,\n ListIndexerSubaccountsParams,\n ListIndexerSubaccountsResponse,\n UpdateIndexerLeaderboardRegistrationParams,\n UpdateIndexerLeaderboardRegistrationResponse,\n} from './types';\n\nexport interface IndexerClientOpts {\n // Server URLs\n url: string;\n v2Url?: string;\n // Wallet Client for EIP712 signing\n walletClient?: WalletClientWithAccount;\n}\n\ntype IndexerQueryRequestBody = Partial<IndexerServerQueryRequestByType>;\n\n/**\n * Base client for all indexer requests\n */\nexport class IndexerBaseClient {\n readonly opts: IndexerClientOpts;\n readonly v2Url: string;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: IndexerClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n // We have custom logic to validate response status and create an appropriate error\n validateStatus: () => true,\n });\n this.v2Url = opts.v2Url ? opts.v2Url : opts.url.replace('v1', 'v2');\n }\n\n /**\n * List all subaccounts\n *\n * @param params\n */\n async listSubaccounts(\n params: ListIndexerSubaccountsParams,\n ): Promise<ListIndexerSubaccountsResponse> {\n const baseResponse = await this.query('subaccounts', params);\n\n return baseResponse.subaccounts.map((item) => {\n const subaccount = subaccountFromHex(item.subaccount);\n return {\n hexId: item.subaccount,\n ...subaccount,\n };\n });\n }\n\n /**\n * Retrieve snapshots of multiple subaccounts at multiple points in time.\n * Each snapshot is a view of the subaccount's balances at this point in time, with tracked variables for interest, funding, etc.\n *\n * @param params\n */\n async getMultiSubaccountSnapshots(\n params: GetIndexerMultiSubaccountSnapshotsParams,\n ): Promise<GetIndexerMultiSubaccountSnapshotsResponse> {\n const subaccountHexIds = params.subaccounts.map(\n ({ subaccountOwner, subaccountName }) =>\n subaccountToHex({\n subaccountOwner,\n subaccountName,\n }),\n );\n\n const baseResponse = await this.query('account_snapshots', {\n subaccounts: subaccountHexIds,\n timestamps: params.timestamps,\n isolated: params.isolated,\n });\n\n const snapshotsBySubaccount = mapValues(\n baseResponse.snapshots,\n (balanceSnapshots) => {\n const snapshotByTimestamp: Record<string, IndexerSubaccountSnapshot> =\n {};\n\n Object.entries(balanceSnapshots).forEach(([timestamp, events]) => {\n const balances: IndexerSnapshotBalance[] =\n events.map(mapIndexerEvent);\n\n snapshotByTimestamp[timestamp] = {\n timestamp: toBigDecimal(timestamp),\n balances,\n };\n });\n\n return snapshotByTimestamp;\n },\n );\n\n return {\n subaccountHexIds,\n snapshots: snapshotsBySubaccount,\n };\n }\n\n /**\n * Retrieves referral code for an address\n *\n * @param params\n */\n async getReferralCode(\n params: GetIndexerReferralCodeParams,\n ): Promise<GetIndexerReferralCodeResponse> {\n const baseResponse = await this.query('referral_code', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n }),\n });\n\n return {\n referralCode: baseResponse.referral_code,\n };\n }\n\n /**\n * Retrieves funding rate for a product, where 1 = 100%\n * @param params\n */\n async getFundingRate(\n params: GetIndexerFundingRateParams,\n ): Promise<GetIndexerFundingRateResponse> {\n const baseResponse = await this.query('funding_rate', {\n product_id: params.productId,\n });\n\n return mapIndexerFundingRate(baseResponse);\n }\n\n /**\n * Retrieves funding rate for multiple products, where 1 = 100%\n * @param params\n */\n async getMultiProductFundingRates(\n params: GetIndexerMultiProductFundingRatesParams,\n ): Promise<GetIndexerMultiProductFundingRatesResponse> {\n const baseResponse = await this.query('funding_rates', {\n product_ids: params.productIds,\n });\n\n return mapValues(baseResponse, mapIndexerFundingRate);\n }\n\n /**\n * Retrieves latest mark/index price for a perp product\n * @param params\n */\n async getPerpPrices(\n params: GetIndexerPerpPricesParams,\n ): Promise<GetIndexerPerpPricesResponse> {\n const baseResponse = await this.query('price', {\n product_id: params.productId,\n });\n\n return mapIndexerPerpPrices(baseResponse);\n }\n\n /**\n * Retrieves latest mark/index price for multiple perp products\n * @param params\n */\n async getMultiProductPerpPrices(\n params: GetIndexerMultiProductPerpPricesParams,\n ): Promise<GetIndexerMultiProductPerpPricesResponse> {\n const baseResponse = await this.query('perp_prices', {\n product_ids: params.productIds,\n });\n\n return mapValues(baseResponse, mapIndexerPerpPrices);\n }\n\n /**\n * Retrieves latest oracle prices for provided products\n * @param params\n */\n async getOraclePrices(\n params: GetIndexerOraclePricesParams,\n ): Promise<GetIndexerOraclePricesResponse> {\n const baseResponse = await this.query('oracle_price', {\n product_ids: params.productIds,\n });\n\n return baseResponse.prices.map((price): IndexerOraclePrice => {\n return {\n oraclePrice: removeDecimals(price.oracle_price_x18),\n updateTime: toBigDecimal(price.update_time),\n productId: price.product_id,\n };\n });\n }\n\n /**\n * Retrieves candlesticks for a product\n * @param params\n */\n async getCandlesticks(\n params: GetIndexerCandlesticksParams,\n ): Promise<GetIndexerCandlesticksResponse> {\n const baseResponse = await this.query('candlesticks', {\n product_id: params.productId,\n max_time: params.maxTimeInclusive,\n limit: params.limit,\n granularity: params.period,\n });\n\n return baseResponse.candlesticks.map(mapIndexerCandlesticks);\n }\n\n /**\n * Retrieves candlesticks for a product from Edge\n * @param params\n */\n async getEdgeCandlesticks(\n params: GetIndexerEdgeCandlesticksParams,\n ): Promise<GetIndexerEdgeCandlesticksResponse> {\n const baseResponse = await this.query('edge_candlesticks', {\n product_id: params.productId,\n max_time: params.maxTimeInclusive,\n limit: params.limit,\n granularity: params.period,\n });\n\n return baseResponse.candlesticks.map(mapIndexerCandlesticks);\n }\n\n /**\n * Retrieves historical snapshots for a product\n * @param params\n */\n async getProductSnapshots(\n params: GetIndexerProductSnapshotsParams,\n ): Promise<GetIndexerProductSnapshotsResponse> {\n const baseResponse = await this.query('products', {\n product_id: params.productId,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n return baseResponse.products.map((product) => {\n return {\n ...mapIndexerServerProduct(product.product),\n submissionIndex: product.submission_idx,\n };\n });\n }\n\n /**\n * Retrieves historical snapshots for multiple products\n * @param params\n */\n async getMultiProductSnapshots(\n params: GetIndexerMultiProductSnapshotsParams,\n ): Promise<GetIndexerMultiProductSnapshotsResponse> {\n const timestampToProductsMap = await this.query('product_snapshots', {\n product_ids: params.productIds,\n max_time: params.maxTimestampInclusive ?? [nowInSeconds()],\n });\n\n return mapValues(timestampToProductsMap, (productIdToProduct) => {\n return mapValues(productIdToProduct, (indexerProduct) => {\n return {\n ...mapIndexerServerProduct(indexerProduct.product),\n submissionIndex: indexerProduct.submission_idx,\n };\n });\n });\n }\n\n /**\n * Retrieves historical events\n *\n * @param params\n */\n async getEvents(\n params: GetIndexerEventsParams,\n ): Promise<GetIndexerEventsResponse> {\n const serverLimit = ((): IndexerServerEventsParams['limit'] | undefined => {\n if (!params.limit) {\n return;\n }\n\n if (params.limit.type === 'events') {\n return {\n raw: params.limit.value,\n };\n }\n return {\n txs: params.limit.value,\n };\n })();\n\n const baseResponse = await this.query('events', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n event_types: params.eventTypes,\n max_time: params.maxTimestampInclusive,\n desc: params.desc,\n limit: serverLimit,\n idx: params.startCursor,\n });\n\n // Keep track of the last tx index, and go to the next one if the submission_idx for the currently processed event does not match\n // txs are ordered the same as events, so this should be correct\n let lastTxIdx = 0;\n return baseResponse.events.map((event): IndexerEventWithTx => {\n if (baseResponse.txs[lastTxIdx].submission_idx !== event.submission_idx) {\n lastTxIdx += 1;\n }\n const tx = baseResponse.txs[lastTxIdx];\n return mapIndexerEventWithTx(event, tx);\n });\n }\n\n /**\n * Retrieves historical orders\n * @param params\n */\n async getOrders(\n params: GetIndexerOrdersParams,\n ): Promise<GetIndexerOrdersResponse> {\n const baseResponse = await this.query('orders', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n digests: params.digests,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n return baseResponse.orders.map(mapIndexerOrder);\n }\n\n /**\n * Gets match order events, this will return the same events as the events query, but with additional information\n * to identify the order that was matched\n *\n * @param params\n */\n async getMatchEvents(\n params: GetIndexerMatchEventsParams,\n ): Promise<GetIndexerMatchEventsResponse> {\n const baseResponse = await this.query('matches', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n // Same as logic in `getEvents`\n let lastTxIdx = 0;\n return baseResponse.matches.map((matchEvent): IndexerMatchEvent => {\n if (\n baseResponse.txs[lastTxIdx].submission_idx !== matchEvent.submission_idx\n ) {\n lastTxIdx += 1;\n }\n const { tx, timestamp } = baseResponse.txs[lastTxIdx];\n\n // We use this to derive the product ID for the match\n const postBalances = mapIndexerMatchEventBalances(\n matchEvent.post_balance,\n );\n\n return {\n productId: postBalances.base.productId,\n isolated: matchEvent.isolated,\n totalFee: toBigDecimal(matchEvent.fee),\n sequencerFee: toBigDecimal(matchEvent.sequencer_fee),\n baseFilled: toBigDecimal(matchEvent.base_filled),\n quoteFilled: toBigDecimal(matchEvent.quote_filled),\n cumulativeFee: toBigDecimal(matchEvent.cumulative_fee),\n cumulativeBaseFilled: toBigDecimal(matchEvent.cumulative_base_filled),\n cumulativeQuoteFilled: toBigDecimal(matchEvent.cumulative_quote_filled),\n digest: matchEvent.digest,\n order: matchEvent.order,\n submissionIndex: matchEvent.submission_idx,\n timestamp: toBigDecimal(timestamp),\n preEventTrackedVars: {\n netEntryUnrealized: toBigDecimal(matchEvent.net_entry_unrealized),\n netEntryCumulative: toBigDecimal(matchEvent.net_entry_cumulative),\n },\n preBalances: mapIndexerMatchEventBalances(matchEvent.pre_balance),\n postBalances,\n tx,\n ...subaccountFromHex(matchEvent.order.sender),\n };\n });\n }\n\n /**\n * Retrieves historical funding & interest payments.\n * NOTE: `limit` is an upperbound. If a user changes position size such that his position is 0 during each funding/interest tick,\n * then the indexer will return fewer than `limit` results per page. However, more events can be present. This means that\n * there isn't a reliable way to determine whether there is a next page. We just need to keep paginating until the next cursor is null.\n *\n * @param params\n */\n async getInterestFundingPayments(\n params: GetIndexerInterestFundingPaymentsParams,\n ): Promise<GetIndexerInterestFundingPaymentsResponse> {\n const baseResponse = await this.query('interest_and_funding', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n }),\n product_ids: params.productIds,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n max_idx: params.startCursor,\n });\n\n return {\n fundingPayments: baseResponse.funding_payments.map(\n mapIndexerProductPayment,\n ),\n interestPayments: baseResponse.interest_payments.map(\n mapIndexerProductPayment,\n ),\n nextCursor: baseResponse.next_idx,\n };\n }\n\n /**\n * Gets quote (USDC) price in terms of USD\n */\n async getQuotePrice(): Promise<GetIndexerQuotePriceResponse> {\n const baseResponse = await this.query('usdc_price', {});\n return {\n price: removeDecimals(baseResponse.price_x18),\n };\n }\n\n /**\n * Fetches currently registered linked signer with the remaining txs allowed for the subaccount\n */\n async getLinkedSignerWithRateLimit(\n params: GetIndexerLinkedSignerParams,\n ): Promise<GetIndexerLinkedSignerResponse> {\n const baseResponse = await this.query('linked_signer_rate_limit', {\n subaccount: subaccountToHex(params.subaccount),\n });\n return {\n totalTxLimit: toBigDecimal(baseResponse.total_tx_limit),\n remainingTxs: toBigDecimal(baseResponse.remaining_tx),\n signer: baseResponse.signer,\n waitTimeUntilNextTx: toBigDecimal(baseResponse.wait_time),\n };\n }\n\n /**\n * Retrieve historical market snapshots\n * @param params\n */\n async getMarketSnapshots(\n params: GetIndexerMarketSnapshotsParams,\n ): Promise<GetIndexerMarketSnapshotsResponse> {\n const baseResponse = await this.query('market_snapshots', {\n interval: mapSnapshotsIntervalToServerParams(params),\n product_ids: params.productIds,\n });\n\n return baseResponse.snapshots.map(mapIndexerMarketSnapshot);\n }\n\n /**\n * Retrieve historical market snapshots from Edge\n * @param params\n */\n async getEdgeMarketSnapshots(\n params: GetIndexerEdgeMarketSnapshotsParams,\n ): Promise<GetIndexerEdgeMarketSnapshotResponse> {\n const baseResponse = await this.query('edge_market_snapshots', {\n interval: mapSnapshotsIntervalToServerParams(params),\n });\n\n return mapValues(baseResponse.snapshots, (snapshots) =>\n snapshots.map(mapIndexerMarketSnapshot),\n );\n }\n\n /**\n * Retrieve maker statistics for a given epoch\n *\n * @param params\n */\n async getMakerStatistics(\n params: GetIndexerMakerStatisticsParams,\n ): Promise<GetIndexerMakerStatisticsResponse> {\n const baseResponse = await this.query('maker_statistics', {\n product_id: params.productId,\n epoch: params.epoch,\n interval: params.interval,\n });\n\n return {\n rewardCoefficient: toBigDecimal(baseResponse.reward_coefficient),\n makers: baseResponse.makers.map(mapIndexerMakerStatistics),\n };\n }\n\n /**\n * Retrieve leaderboard stats for a given contest\n *\n * @param params\n */\n async getLeaderboard(\n params: GetIndexerLeaderboardParams,\n ): Promise<GetIndexerLeaderboardResponse> {\n const baseResponse = await this.query('leaderboard', {\n contest_id: params.contestId,\n rank_type: params.rankType,\n start: params.startCursor,\n limit: params.limit,\n });\n\n return {\n participants: baseResponse.positions.map(mapIndexerLeaderboardPosition),\n };\n }\n\n /**\n * Retrieve leaderboard ranking of a subaccount on a given contest\n *\n * @param params\n */\n async getLeaderboardParticipant(\n params: GetIndexerLeaderboardParticipantParams,\n ): Promise<GetIndexerLeaderboardParticipantResponse> {\n const baseResponse = await this.query('leaderboard_rank', {\n subaccount: subaccountToHex(params.subaccount),\n contest_ids: params.contestIds,\n });\n\n return {\n participant: mapValues(baseResponse.positions, (position) =>\n mapIndexerLeaderboardPosition(position),\n ),\n };\n }\n\n /**\n * Attempts to update a user's registration to the provided `contestId`. This requires signing.\n * @param params\n */\n async updateLeaderboardRegistration(\n params: UpdateIndexerLeaderboardRegistrationParams,\n ): Promise<UpdateIndexerLeaderboardRegistrationResponse> {\n const signatureParams: EIP712LeaderboardAuthenticationParams = {\n // Default to 90 seconds from now if no recvTime is provided\n expiration: toIntegerString(params.recvTime ?? getDefaultRecvTime()),\n subaccountName: params.subaccountName,\n subaccountOwner: params.subaccountOwner,\n };\n\n const tx = getNadoEIP712Values(\n 'leaderboard_authentication',\n signatureParams,\n );\n const signature = await this.sign(\n 'leaderboard_authentication',\n params.updateRegistration.verifyingAddr,\n params.updateRegistration.chainId,\n signatureParams,\n );\n\n const updateRegistrationTx: SignedTx<EIP712LeaderboardAuthenticationValues> =\n {\n tx,\n signature,\n };\n\n const baseResponse = await this.query('leaderboard_registration', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n contest_id: params.contestId,\n update_registration: updateRegistrationTx,\n });\n return {\n registration: baseResponse.registration\n ? mapIndexerLeaderboardRegistration(baseResponse.registration)\n : null,\n };\n }\n\n /**\n * Retrieves the registration status for a leaderboard participant for provided `contestId`.\n * @param params\n */\n async getLeaderboardRegistration(\n params: GetIndexerLeaderboardRegistrationParams,\n ): Promise<GetIndexerLeaderboardRegistrationResponse> {\n const baseResponse = await this.query('leaderboard_registration', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n contest_id: params.contestId,\n update_registration: null,\n });\n return {\n registration: baseResponse.registration\n ? mapIndexerLeaderboardRegistration(baseResponse.registration)\n : null,\n };\n }\n\n /**\n * Retrieve metadata of provided leaderboard contests\n *\n * @param params\n */\n async getLeaderboardContests(\n params: GetIndexerLeaderboardContestsParams,\n ): Promise<GetIndexerLeaderboardContestsResponse> {\n const baseResponse = await this.query('leaderboard_contests', {\n contest_ids: params.contestIds,\n });\n\n return {\n contests: baseResponse.contests.map(mapIndexerLeaderboardContest),\n };\n }\n\n /**\n * Retrieve signature and tx to submit a fast withdrawal\n *\n * @param params\n */\n async getFastWithdrawalSignature(\n params: GetIndexerFastWithdrawalSignatureParams,\n ): Promise<GetIndexerFastWithdrawalSignatureResponse> {\n const baseResponse = await this.query('fast_withdrawal_signature', params);\n return {\n idx: toBigInt(baseResponse.idx),\n tx: baseResponse.tx,\n txBytes: getValidatedHex(baseResponse.tx_bytes),\n signatures: baseResponse.signatures.map(getValidatedHex),\n };\n }\n\n async getNlpSnapshots(\n params: GetIndexerNlpSnapshotsParams,\n ): Promise<GetIndexerNlpSnapshotsResponse> {\n const baseResponse = await this.query('nlp_snapshots', {\n interval: {\n count: params.limit,\n max_time: params.maxTimeInclusive\n ? toIntegerString(params.maxTimeInclusive)\n : undefined,\n granularity: params.granularity,\n },\n });\n\n return {\n snapshots: baseResponse.snapshots.map(mapIndexerNlpSnapshot),\n };\n }\n\n /**\n * Retrieves the subaccount's DDA (Direct Deposit Address)\n * @param params\n */\n async getSubaccountDDA(\n params: GetIndexerSubaccountDDAParams,\n ): Promise<GetIndexerSubaccountDDAResponse> {\n const baseResponse = await this.query('direct_deposit_address', {\n subaccount: subaccountToHex(params.subaccount),\n });\n\n return {\n address: getValidatedAddress(baseResponse.v1_address),\n };\n }\n\n async getSequencerBacklog(): Promise<GetIndexerBacklogResponse> {\n const baseResponse = await this.query('backlog', {});\n\n return {\n totalTxs: toBigDecimal(baseResponse.total_txs),\n totalSubmissions: toBigDecimal(baseResponse.total_submissions),\n backlogSize: toBigDecimal(baseResponse.backlog_size),\n updatedAt: toBigDecimal(baseResponse.updated_at),\n backlogEtaInSeconds: baseResponse.backlog_eta_in_seconds\n ? toBigDecimal(baseResponse.backlog_eta_in_seconds)\n : null,\n txsPerSecond: baseResponse.txs_per_second\n ? toBigDecimal(baseResponse.txs_per_second)\n : null,\n };\n }\n\n protected async query<TRequestType extends IndexerServerQueryRequestType>(\n requestType: TRequestType,\n params: IndexerServerQueryRequestByType[TRequestType],\n ): Promise<IndexerServerQueryResponseByType[TRequestType]> {\n const reqBody: IndexerQueryRequestBody = {\n [requestType]: params,\n };\n const response = await this.axiosInstance.post<\n IndexerServerQueryResponseByType[TRequestType]\n >(this.opts.url, reqBody);\n\n this.checkResponseStatus(response);\n\n return response.data;\n }\n\n protected async sign<T extends SignableRequestType>(\n requestType: T,\n verifyingContract: string,\n chainId: number,\n params: SignableRequestTypeToParams[T],\n ) {\n const walletClient = this.opts.walletClient;\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n return getSignedTransactionRequest({\n chainId,\n requestParams: params,\n requestType,\n walletClient,\n verifyingContract,\n });\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}`,\n );\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAqBO;AACP,mBAAoD;AACpD,yBAiBO;AAoFA,IAAM,oBAAN,MAAwB;AAAA,EAK7B,YAAY,MAAyB;AACnC,SAAK,OAAO;AACZ,SAAK,gBAAgB,aAAAA,QAAM,OAAO;AAAA,MAChC,iBAAiB;AAAA;AAAA,MAEjB,gBAAgB,MAAM;AAAA,IACxB,CAAC;AACD,SAAK,QAAQ,KAAK,QAAQ,KAAK,QAAQ,KAAK,IAAI,QAAQ,MAAM,IAAI;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,gBACJ,QACyC;AACzC,UAAM,eAAe,MAAM,KAAK,MAAM,eAAe,MAAM;AAE3D,WAAO,aAAa,YAAY,IAAI,CAAC,SAAS;AAC5C,YAAM,iBAAa,iCAAkB,KAAK,UAAU;AACpD,aAAO;AAAA,QACL,OAAO,KAAK;AAAA,QACZ,GAAG;AAAA,MACL;AAAA,IACF,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,4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AAK,KAAK,OAAO;AAExB,SAAK,oBAAoB,QAAQ;AAEjC,WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,MAAgB,KACd,aACA,mBACA,SACA,QACA;AACA,UAAM,eAAe,KAAK,KAAK;AAE/B,QAAI,CAAC,cAAc;AACjB,YAAM,IAAI,qCAAuB;AAAA,IACnC;AAEA,eAAO,2CAA4B;AAAA,MACjC;AAAA,MACA,eAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,oBAAoB,UAAyB;AACnD,QAAI,SAAS,WAAW,OAAO,CAAC,SAAS,MAAM;AAC7C,YAAM;AAAA,QACJ,oCAAoC,SAAS,MAAM,IAAI,SAAS,UAAU;AAAA,MAC5E;AAAA,IACF;AAAA,EACF;AACF;","names":["axios"]}
@@ -3,6 +3,7 @@ import {
3
3
  getDefaultRecvTime,
4
4
  getNadoEIP712Values,
5
5
  getSignedTransactionRequest,
6
+ getValidatedAddress,
6
7
  getValidatedHex,
7
8
  mapValues,
8
9
  nowInSeconds,
@@ -568,7 +569,7 @@ var IndexerBaseClient = class {
568
569
  subaccount: subaccountToHex(params.subaccount)
569
570
  });
570
571
  return {
571
- address: baseResponse.v1_address
572
+ address: getValidatedAddress(baseResponse.v1_address)
572
573
  };
573
574
  }
574
575
  async getSequencerBacklog() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/IndexerBaseClient.ts"],"sourcesContent":["import {\n EIP712LeaderboardAuthenticationParams,\n EIP712LeaderboardAuthenticationValues,\n getDefaultRecvTime,\n getNadoEIP712Values,\n getSignedTransactionRequest,\n getValidatedHex,\n mapValues,\n nowInSeconds,\n removeDecimals,\n SignableRequestType,\n SignableRequestTypeToParams,\n SignedTx,\n subaccountFromHex,\n subaccountToHex,\n toBigDecimal,\n toBigInt,\n toIntegerString,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n mapIndexerCandlesticks,\n mapIndexerEvent,\n mapIndexerEventWithTx,\n mapIndexerFundingRate,\n mapIndexerLeaderboardContest,\n mapIndexerLeaderboardPosition,\n mapIndexerLeaderboardRegistration,\n mapIndexerMakerStatistics,\n mapIndexerMarketSnapshot,\n mapIndexerMatchEventBalances,\n mapIndexerNlpSnapshot,\n mapIndexerOrder,\n mapIndexerPerpPrices,\n mapIndexerProductPayment,\n mapIndexerServerProduct,\n mapSnapshotsIntervalToServerParams,\n} from './dataMappers';\nimport {\n GetIndexerBacklogResponse,\n GetIndexerCandlesticksParams,\n GetIndexerCandlesticksResponse,\n GetIndexerEdgeCandlesticksParams,\n GetIndexerEdgeCandlesticksResponse,\n GetIndexerEdgeMarketSnapshotResponse,\n GetIndexerEdgeMarketSnapshotsParams,\n GetIndexerEventsParams,\n GetIndexerEventsResponse,\n GetIndexerFastWithdrawalSignatureParams,\n GetIndexerFastWithdrawalSignatureResponse,\n GetIndexerFundingRateParams,\n GetIndexerFundingRateResponse,\n GetIndexerInterestFundingPaymentsParams,\n GetIndexerInterestFundingPaymentsResponse,\n GetIndexerLeaderboardContestsParams,\n GetIndexerLeaderboardContestsResponse,\n GetIndexerLeaderboardParams,\n GetIndexerLeaderboardParticipantParams,\n GetIndexerLeaderboardParticipantResponse,\n GetIndexerLeaderboardRegistrationParams,\n GetIndexerLeaderboardRegistrationResponse,\n GetIndexerLeaderboardResponse,\n GetIndexerLinkedSignerParams,\n GetIndexerLinkedSignerResponse,\n GetIndexerMakerStatisticsParams,\n GetIndexerMakerStatisticsResponse,\n GetIndexerMarketSnapshotsParams,\n GetIndexerMarketSnapshotsResponse,\n GetIndexerMatchEventsParams,\n GetIndexerMatchEventsResponse,\n GetIndexerMultiProductFundingRatesParams,\n GetIndexerMultiProductFundingRatesResponse,\n GetIndexerMultiProductPerpPricesParams,\n GetIndexerMultiProductPerpPricesResponse,\n GetIndexerMultiProductSnapshotsParams,\n GetIndexerMultiProductSnapshotsResponse,\n GetIndexerMultiSubaccountSnapshotsParams,\n GetIndexerMultiSubaccountSnapshotsResponse,\n GetIndexerNlpSnapshotsParams,\n GetIndexerNlpSnapshotsResponse,\n GetIndexerOraclePricesParams,\n GetIndexerOraclePricesResponse,\n GetIndexerOrdersParams,\n GetIndexerOrdersResponse,\n GetIndexerPerpPricesParams,\n GetIndexerPerpPricesResponse,\n GetIndexerProductSnapshotsParams,\n GetIndexerProductSnapshotsResponse,\n GetIndexerQuotePriceResponse,\n GetIndexerReferralCodeParams,\n GetIndexerReferralCodeResponse,\n GetIndexerSubaccountDDAParams,\n GetIndexerSubaccountDDAResponse,\n IndexerEventWithTx,\n IndexerMatchEvent,\n IndexerOraclePrice,\n IndexerServerEventsParams,\n IndexerServerQueryRequestByType,\n IndexerServerQueryRequestType,\n IndexerServerQueryResponseByType,\n IndexerSnapshotBalance,\n IndexerSubaccountSnapshot,\n ListIndexerSubaccountsParams,\n ListIndexerSubaccountsResponse,\n UpdateIndexerLeaderboardRegistrationParams,\n UpdateIndexerLeaderboardRegistrationResponse,\n} from './types';\n\nexport interface IndexerClientOpts {\n // Server URLs\n url: string;\n v2Url?: string;\n // Wallet Client for EIP712 signing\n walletClient?: WalletClientWithAccount;\n}\n\ntype IndexerQueryRequestBody = Partial<IndexerServerQueryRequestByType>;\n\n/**\n * Base client for all indexer requests\n */\nexport class IndexerBaseClient {\n readonly opts: IndexerClientOpts;\n readonly v2Url: string;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: IndexerClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n // We have custom logic to validate response status and create an appropriate error\n validateStatus: () => true,\n });\n this.v2Url = opts.v2Url ? opts.v2Url : opts.url.replace('v1', 'v2');\n }\n\n /**\n * List all subaccounts\n *\n * @param params\n */\n async listSubaccounts(\n params: ListIndexerSubaccountsParams,\n ): Promise<ListIndexerSubaccountsResponse> {\n const baseResponse = await this.query('subaccounts', params);\n\n return baseResponse.subaccounts.map((item) => {\n const subaccount = subaccountFromHex(item.subaccount);\n return {\n hexId: item.subaccount,\n ...subaccount,\n };\n });\n }\n\n /**\n * Retrieve snapshots of multiple subaccounts at multiple points in time.\n * Each snapshot is a view of the subaccount's balances at this point in time, with tracked variables for interest, funding, etc.\n *\n * @param params\n */\n async getMultiSubaccountSnapshots(\n params: GetIndexerMultiSubaccountSnapshotsParams,\n ): Promise<GetIndexerMultiSubaccountSnapshotsResponse> {\n const subaccountHexIds = params.subaccounts.map(\n ({ subaccountOwner, subaccountName }) =>\n subaccountToHex({\n subaccountOwner,\n subaccountName,\n }),\n );\n\n const baseResponse = await this.query('account_snapshots', {\n subaccounts: subaccountHexIds,\n timestamps: params.timestamps,\n isolated: params.isolated,\n });\n\n const snapshotsBySubaccount = mapValues(\n baseResponse.snapshots,\n (balanceSnapshots) => {\n const snapshotByTimestamp: Record<string, IndexerSubaccountSnapshot> =\n {};\n\n Object.entries(balanceSnapshots).forEach(([timestamp, events]) => {\n const balances: IndexerSnapshotBalance[] =\n events.map(mapIndexerEvent);\n\n snapshotByTimestamp[timestamp] = {\n timestamp: toBigDecimal(timestamp),\n balances,\n };\n });\n\n return snapshotByTimestamp;\n },\n );\n\n return {\n subaccountHexIds,\n snapshots: snapshotsBySubaccount,\n };\n }\n\n /**\n * Retrieves referral code for an address\n *\n * @param params\n */\n async getReferralCode(\n params: GetIndexerReferralCodeParams,\n ): Promise<GetIndexerReferralCodeResponse> {\n const baseResponse = await this.query('referral_code', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n }),\n });\n\n return {\n referralCode: baseResponse.referral_code,\n };\n }\n\n /**\n * Retrieves funding rate for a product, where 1 = 100%\n * @param params\n */\n async getFundingRate(\n params: GetIndexerFundingRateParams,\n ): Promise<GetIndexerFundingRateResponse> {\n const baseResponse = await this.query('funding_rate', {\n product_id: params.productId,\n });\n\n return mapIndexerFundingRate(baseResponse);\n }\n\n /**\n * Retrieves funding rate for multiple products, where 1 = 100%\n * @param params\n */\n async getMultiProductFundingRates(\n params: GetIndexerMultiProductFundingRatesParams,\n ): Promise<GetIndexerMultiProductFundingRatesResponse> {\n const baseResponse = await this.query('funding_rates', {\n product_ids: params.productIds,\n });\n\n return mapValues(baseResponse, mapIndexerFundingRate);\n }\n\n /**\n * Retrieves latest mark/index price for a perp product\n * @param params\n */\n async getPerpPrices(\n params: GetIndexerPerpPricesParams,\n ): Promise<GetIndexerPerpPricesResponse> {\n const baseResponse = await this.query('price', {\n product_id: params.productId,\n });\n\n return mapIndexerPerpPrices(baseResponse);\n }\n\n /**\n * Retrieves latest mark/index price for multiple perp products\n * @param params\n */\n async getMultiProductPerpPrices(\n params: GetIndexerMultiProductPerpPricesParams,\n ): Promise<GetIndexerMultiProductPerpPricesResponse> {\n const baseResponse = await this.query('perp_prices', {\n product_ids: params.productIds,\n });\n\n return mapValues(baseResponse, mapIndexerPerpPrices);\n }\n\n /**\n * Retrieves latest oracle prices for provided products\n * @param params\n */\n async getOraclePrices(\n params: GetIndexerOraclePricesParams,\n ): Promise<GetIndexerOraclePricesResponse> {\n const baseResponse = await this.query('oracle_price', {\n product_ids: params.productIds,\n });\n\n return baseResponse.prices.map((price): IndexerOraclePrice => {\n return {\n oraclePrice: removeDecimals(price.oracle_price_x18),\n updateTime: toBigDecimal(price.update_time),\n productId: price.product_id,\n };\n });\n }\n\n /**\n * Retrieves candlesticks for a product\n * @param params\n */\n async getCandlesticks(\n params: GetIndexerCandlesticksParams,\n ): Promise<GetIndexerCandlesticksResponse> {\n const baseResponse = await this.query('candlesticks', {\n product_id: params.productId,\n max_time: params.maxTimeInclusive,\n limit: params.limit,\n granularity: params.period,\n });\n\n return baseResponse.candlesticks.map(mapIndexerCandlesticks);\n }\n\n /**\n * Retrieves candlesticks for a product from Edge\n * @param params\n */\n async getEdgeCandlesticks(\n params: GetIndexerEdgeCandlesticksParams,\n ): Promise<GetIndexerEdgeCandlesticksResponse> {\n const baseResponse = await this.query('edge_candlesticks', {\n product_id: params.productId,\n max_time: params.maxTimeInclusive,\n limit: params.limit,\n granularity: params.period,\n });\n\n return baseResponse.candlesticks.map(mapIndexerCandlesticks);\n }\n\n /**\n * Retrieves historical snapshots for a product\n * @param params\n */\n async getProductSnapshots(\n params: GetIndexerProductSnapshotsParams,\n ): Promise<GetIndexerProductSnapshotsResponse> {\n const baseResponse = await this.query('products', {\n product_id: params.productId,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n return baseResponse.products.map((product) => {\n return {\n ...mapIndexerServerProduct(product.product),\n submissionIndex: product.submission_idx,\n };\n });\n }\n\n /**\n * Retrieves historical snapshots for multiple products\n * @param params\n */\n async getMultiProductSnapshots(\n params: GetIndexerMultiProductSnapshotsParams,\n ): Promise<GetIndexerMultiProductSnapshotsResponse> {\n const timestampToProductsMap = await this.query('product_snapshots', {\n product_ids: params.productIds,\n max_time: params.maxTimestampInclusive ?? [nowInSeconds()],\n });\n\n return mapValues(timestampToProductsMap, (productIdToProduct) => {\n return mapValues(productIdToProduct, (indexerProduct) => {\n return {\n ...mapIndexerServerProduct(indexerProduct.product),\n submissionIndex: indexerProduct.submission_idx,\n };\n });\n });\n }\n\n /**\n * Retrieves historical events\n *\n * @param params\n */\n async getEvents(\n params: GetIndexerEventsParams,\n ): Promise<GetIndexerEventsResponse> {\n const serverLimit = ((): IndexerServerEventsParams['limit'] | undefined => {\n if (!params.limit) {\n return;\n }\n\n if (params.limit.type === 'events') {\n return {\n raw: params.limit.value,\n };\n }\n return {\n txs: params.limit.value,\n };\n })();\n\n const baseResponse = await this.query('events', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n event_types: params.eventTypes,\n max_time: params.maxTimestampInclusive,\n desc: params.desc,\n limit: serverLimit,\n idx: params.startCursor,\n });\n\n // Keep track of the last tx index, and go to the next one if the submission_idx for the currently processed event does not match\n // txs are ordered the same as events, so this should be correct\n let lastTxIdx = 0;\n return baseResponse.events.map((event): IndexerEventWithTx => {\n if (baseResponse.txs[lastTxIdx].submission_idx !== event.submission_idx) {\n lastTxIdx += 1;\n }\n const tx = baseResponse.txs[lastTxIdx];\n return mapIndexerEventWithTx(event, tx);\n });\n }\n\n /**\n * Retrieves historical orders\n * @param params\n */\n async getOrders(\n params: GetIndexerOrdersParams,\n ): Promise<GetIndexerOrdersResponse> {\n const baseResponse = await this.query('orders', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n digests: params.digests,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n return baseResponse.orders.map(mapIndexerOrder);\n }\n\n /**\n * Gets match order events, this will return the same events as the events query, but with additional information\n * to identify the order that was matched\n *\n * @param params\n */\n async getMatchEvents(\n params: GetIndexerMatchEventsParams,\n ): Promise<GetIndexerMatchEventsResponse> {\n const baseResponse = await this.query('matches', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n // Same as logic in `getEvents`\n let lastTxIdx = 0;\n return baseResponse.matches.map((matchEvent): IndexerMatchEvent => {\n if (\n baseResponse.txs[lastTxIdx].submission_idx !== matchEvent.submission_idx\n ) {\n lastTxIdx += 1;\n }\n const { tx, timestamp } = baseResponse.txs[lastTxIdx];\n\n // We use this to derive the product ID for the match\n const postBalances = mapIndexerMatchEventBalances(\n matchEvent.post_balance,\n );\n\n return {\n productId: postBalances.base.productId,\n isolated: matchEvent.isolated,\n totalFee: toBigDecimal(matchEvent.fee),\n sequencerFee: toBigDecimal(matchEvent.sequencer_fee),\n baseFilled: toBigDecimal(matchEvent.base_filled),\n quoteFilled: toBigDecimal(matchEvent.quote_filled),\n cumulativeFee: toBigDecimal(matchEvent.cumulative_fee),\n cumulativeBaseFilled: toBigDecimal(matchEvent.cumulative_base_filled),\n cumulativeQuoteFilled: toBigDecimal(matchEvent.cumulative_quote_filled),\n digest: matchEvent.digest,\n order: matchEvent.order,\n submissionIndex: matchEvent.submission_idx,\n timestamp: toBigDecimal(timestamp),\n preEventTrackedVars: {\n netEntryUnrealized: toBigDecimal(matchEvent.net_entry_unrealized),\n netEntryCumulative: toBigDecimal(matchEvent.net_entry_cumulative),\n },\n preBalances: mapIndexerMatchEventBalances(matchEvent.pre_balance),\n postBalances,\n tx,\n ...subaccountFromHex(matchEvent.order.sender),\n };\n });\n }\n\n /**\n * Retrieves historical funding & interest payments.\n * NOTE: `limit` is an upperbound. If a user changes position size such that his position is 0 during each funding/interest tick,\n * then the indexer will return fewer than `limit` results per page. However, more events can be present. This means that\n * there isn't a reliable way to determine whether there is a next page. We just need to keep paginating until the next cursor is null.\n *\n * @param params\n */\n async getInterestFundingPayments(\n params: GetIndexerInterestFundingPaymentsParams,\n ): Promise<GetIndexerInterestFundingPaymentsResponse> {\n const baseResponse = await this.query('interest_and_funding', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n }),\n product_ids: params.productIds,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n max_idx: params.startCursor,\n });\n\n return {\n fundingPayments: baseResponse.funding_payments.map(\n mapIndexerProductPayment,\n ),\n interestPayments: baseResponse.interest_payments.map(\n mapIndexerProductPayment,\n ),\n nextCursor: baseResponse.next_idx,\n };\n }\n\n /**\n * Gets quote (USDC) price in terms of USD\n */\n async getQuotePrice(): Promise<GetIndexerQuotePriceResponse> {\n const baseResponse = await this.query('usdc_price', {});\n return {\n price: removeDecimals(baseResponse.price_x18),\n };\n }\n\n /**\n * Fetches currently registered linked signer with the remaining txs allowed for the subaccount\n */\n async getLinkedSignerWithRateLimit(\n params: GetIndexerLinkedSignerParams,\n ): Promise<GetIndexerLinkedSignerResponse> {\n const baseResponse = await this.query('linked_signer_rate_limit', {\n subaccount: subaccountToHex(params.subaccount),\n });\n return {\n totalTxLimit: toBigDecimal(baseResponse.total_tx_limit),\n remainingTxs: toBigDecimal(baseResponse.remaining_tx),\n signer: baseResponse.signer,\n waitTimeUntilNextTx: toBigDecimal(baseResponse.wait_time),\n };\n }\n\n /**\n * Retrieve historical market snapshots\n * @param params\n */\n async getMarketSnapshots(\n params: GetIndexerMarketSnapshotsParams,\n ): Promise<GetIndexerMarketSnapshotsResponse> {\n const baseResponse = await this.query('market_snapshots', {\n interval: mapSnapshotsIntervalToServerParams(params),\n product_ids: params.productIds,\n });\n\n return baseResponse.snapshots.map(mapIndexerMarketSnapshot);\n }\n\n /**\n * Retrieve historical market snapshots from Edge\n * @param params\n */\n async getEdgeMarketSnapshots(\n params: GetIndexerEdgeMarketSnapshotsParams,\n ): Promise<GetIndexerEdgeMarketSnapshotResponse> {\n const baseResponse = await this.query('edge_market_snapshots', {\n interval: mapSnapshotsIntervalToServerParams(params),\n });\n\n return mapValues(baseResponse.snapshots, (snapshots) =>\n snapshots.map(mapIndexerMarketSnapshot),\n );\n }\n\n /**\n * Retrieve maker statistics for a given epoch\n *\n * @param params\n */\n async getMakerStatistics(\n params: GetIndexerMakerStatisticsParams,\n ): Promise<GetIndexerMakerStatisticsResponse> {\n const baseResponse = await this.query('maker_statistics', {\n product_id: params.productId,\n epoch: params.epoch,\n interval: params.interval,\n });\n\n return {\n rewardCoefficient: toBigDecimal(baseResponse.reward_coefficient),\n makers: baseResponse.makers.map(mapIndexerMakerStatistics),\n };\n }\n\n /**\n * Retrieve leaderboard stats for a given contest\n *\n * @param params\n */\n async getLeaderboard(\n params: GetIndexerLeaderboardParams,\n ): Promise<GetIndexerLeaderboardResponse> {\n const baseResponse = await this.query('leaderboard', {\n contest_id: params.contestId,\n rank_type: params.rankType,\n start: params.startCursor,\n limit: params.limit,\n });\n\n return {\n participants: baseResponse.positions.map(mapIndexerLeaderboardPosition),\n };\n }\n\n /**\n * Retrieve leaderboard ranking of a subaccount on a given contest\n *\n * @param params\n */\n async getLeaderboardParticipant(\n params: GetIndexerLeaderboardParticipantParams,\n ): Promise<GetIndexerLeaderboardParticipantResponse> {\n const baseResponse = await this.query('leaderboard_rank', {\n subaccount: subaccountToHex(params.subaccount),\n contest_ids: params.contestIds,\n });\n\n return {\n participant: mapValues(baseResponse.positions, (position) =>\n mapIndexerLeaderboardPosition(position),\n ),\n };\n }\n\n /**\n * Attempts to update a user's registration to the provided `contestId`. This requires signing.\n * @param params\n */\n async updateLeaderboardRegistration(\n params: UpdateIndexerLeaderboardRegistrationParams,\n ): Promise<UpdateIndexerLeaderboardRegistrationResponse> {\n const signatureParams: EIP712LeaderboardAuthenticationParams = {\n // Default to 90 seconds from now if no recvTime is provided\n expiration: toIntegerString(params.recvTime ?? getDefaultRecvTime()),\n subaccountName: params.subaccountName,\n subaccountOwner: params.subaccountOwner,\n };\n\n const tx = getNadoEIP712Values(\n 'leaderboard_authentication',\n signatureParams,\n );\n const signature = await this.sign(\n 'leaderboard_authentication',\n params.updateRegistration.verifyingAddr,\n params.updateRegistration.chainId,\n signatureParams,\n );\n\n const updateRegistrationTx: SignedTx<EIP712LeaderboardAuthenticationValues> =\n {\n tx,\n signature,\n };\n\n const baseResponse = await this.query('leaderboard_registration', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n contest_id: params.contestId,\n update_registration: updateRegistrationTx,\n });\n return {\n registration: baseResponse.registration\n ? mapIndexerLeaderboardRegistration(baseResponse.registration)\n : null,\n };\n }\n\n /**\n * Retrieves the registration status for a leaderboard participant for provided `contestId`.\n * @param params\n */\n async getLeaderboardRegistration(\n params: GetIndexerLeaderboardRegistrationParams,\n ): Promise<GetIndexerLeaderboardRegistrationResponse> {\n const baseResponse = await this.query('leaderboard_registration', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n contest_id: params.contestId,\n update_registration: null,\n });\n return {\n registration: baseResponse.registration\n ? mapIndexerLeaderboardRegistration(baseResponse.registration)\n : null,\n };\n }\n\n /**\n * Retrieve metadata of provided leaderboard contests\n *\n * @param params\n */\n async getLeaderboardContests(\n params: GetIndexerLeaderboardContestsParams,\n ): Promise<GetIndexerLeaderboardContestsResponse> {\n const baseResponse = await this.query('leaderboard_contests', {\n contest_ids: params.contestIds,\n });\n\n return {\n contests: baseResponse.contests.map(mapIndexerLeaderboardContest),\n };\n }\n\n /**\n * Retrieve signature and tx to submit a fast withdrawal\n *\n * @param params\n */\n async getFastWithdrawalSignature(\n params: GetIndexerFastWithdrawalSignatureParams,\n ): Promise<GetIndexerFastWithdrawalSignatureResponse> {\n const baseResponse = await this.query('fast_withdrawal_signature', params);\n return {\n idx: toBigInt(baseResponse.idx),\n tx: baseResponse.tx,\n txBytes: getValidatedHex(baseResponse.tx_bytes),\n signatures: baseResponse.signatures.map(getValidatedHex),\n };\n }\n\n async getNlpSnapshots(\n params: GetIndexerNlpSnapshotsParams,\n ): Promise<GetIndexerNlpSnapshotsResponse> {\n const baseResponse = await this.query('nlp_snapshots', {\n interval: {\n count: params.limit,\n max_time: params.maxTimeInclusive\n ? toIntegerString(params.maxTimeInclusive)\n : undefined,\n granularity: params.granularity,\n },\n });\n\n return {\n snapshots: baseResponse.snapshots.map(mapIndexerNlpSnapshot),\n };\n }\n\n /**\n * Retrieves the subaccount's DDA (Direct Deposit Address)\n * @param params\n */\n async getSubaccountDDA(\n params: GetIndexerSubaccountDDAParams,\n ): Promise<GetIndexerSubaccountDDAResponse> {\n const baseResponse = await this.query('direct_deposit_address', {\n subaccount: subaccountToHex(params.subaccount),\n });\n\n return {\n address: baseResponse.v1_address,\n };\n }\n\n async getSequencerBacklog(): Promise<GetIndexerBacklogResponse> {\n const baseResponse = await this.query('backlog', {});\n\n return {\n totalTxs: toBigDecimal(baseResponse.total_txs),\n totalSubmissions: toBigDecimal(baseResponse.total_submissions),\n backlogSize: toBigDecimal(baseResponse.backlog_size),\n updatedAt: toBigDecimal(baseResponse.updated_at),\n backlogEtaInSeconds: baseResponse.backlog_eta_in_seconds\n ? toBigDecimal(baseResponse.backlog_eta_in_seconds)\n : null,\n txsPerSecond: baseResponse.txs_per_second\n ? toBigDecimal(baseResponse.txs_per_second)\n : null,\n };\n }\n\n protected async query<TRequestType extends IndexerServerQueryRequestType>(\n requestType: TRequestType,\n params: IndexerServerQueryRequestByType[TRequestType],\n ): Promise<IndexerServerQueryResponseByType[TRequestType]> {\n const reqBody: IndexerQueryRequestBody = {\n [requestType]: params,\n };\n const response = await this.axiosInstance.post<\n IndexerServerQueryResponseByType[TRequestType]\n >(this.opts.url, reqBody);\n\n this.checkResponseStatus(response);\n\n return response.data;\n }\n\n protected async sign<T extends SignableRequestType>(\n requestType: T,\n verifyingContract: string,\n chainId: number,\n params: SignableRequestTypeToParams[T],\n ) {\n const walletClient = this.opts.walletClient;\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n return getSignedTransactionRequest({\n chainId,\n requestParams: params,\n requestType,\n walletClient,\n verifyingContract,\n });\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}`,\n );\n }\n }\n}\n"],"mappings":";AAAA;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AACP,OAAO,WAA6C;AACpD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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AAED,WAAO;AAAA,MACL,SAAS,aAAa;AAAA,IACxB;AAAA,EACF;AAAA,EAEA,MAAM,sBAA0D;AAC9D,UAAM,eAAe,MAAM,KAAK,MAAM,WAAW,CAAC,CAAC;AAEnD,WAAO;AAAA,MACL,UAAU,aAAa,aAAa,SAAS;AAAA,MAC7C,kBAAkB,aAAa,aAAa,iBAAiB;AAAA,MAC7D,aAAa,aAAa,aAAa,YAAY;AAAA,MACnD,WAAW,aAAa,aAAa,UAAU;AAAA,MAC/C,qBAAqB,aAAa,yBAC9B,aAAa,aAAa,sBAAsB,IAChD;AAAA,MACJ,cAAc,aAAa,iBACvB,aAAa,aAAa,cAAc,IACxC;AAAA,IACN;AAAA,EACF;AAAA,EAEA,MAAgB,MACd,aACA,QACyD;AACzD,UAAM,UAAmC;AAAA,MACvC,CAAC,WAAW,GAAG;AAAA,IACjB;AACA,UAAM,WAAW,MAAM,KAAK,cAAc,KAExC,KAAK,KAAK,KAAK,OAAO;AAExB,SAAK,oBAAoB,QAAQ;AAEjC,WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,MAAgB,KACd,aACA,mBACA,SACA,QACA;AACA,UAAM,eAAe,KAAK,KAAK;AAE/B,QAAI,CAAC,cAAc;AACjB,YAAM,IAAI,uBAAuB;AAAA,IACnC;AAEA,WAAO,4BAA4B;AAAA,MACjC;AAAA,MACA,eAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,oBAAoB,UAAyB;AACnD,QAAI,SAAS,WAAW,OAAO,CAAC,SAAS,MAAM;AAC7C,YAAM;AAAA,QACJ,oCAAoC,SAAS,MAAM,IAAI,SAAS,UAAU;AAAA,MAC5E;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/IndexerBaseClient.ts"],"sourcesContent":["import {\n EIP712LeaderboardAuthenticationParams,\n EIP712LeaderboardAuthenticationValues,\n getDefaultRecvTime,\n getNadoEIP712Values,\n getSignedTransactionRequest,\n getValidatedAddress,\n getValidatedHex,\n mapValues,\n nowInSeconds,\n removeDecimals,\n SignableRequestType,\n SignableRequestTypeToParams,\n SignedTx,\n subaccountFromHex,\n subaccountToHex,\n toBigDecimal,\n toBigInt,\n toIntegerString,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n mapIndexerCandlesticks,\n mapIndexerEvent,\n mapIndexerEventWithTx,\n mapIndexerFundingRate,\n mapIndexerLeaderboardContest,\n mapIndexerLeaderboardPosition,\n mapIndexerLeaderboardRegistration,\n mapIndexerMakerStatistics,\n mapIndexerMarketSnapshot,\n mapIndexerMatchEventBalances,\n mapIndexerNlpSnapshot,\n mapIndexerOrder,\n mapIndexerPerpPrices,\n mapIndexerProductPayment,\n mapIndexerServerProduct,\n mapSnapshotsIntervalToServerParams,\n} from './dataMappers';\nimport {\n GetIndexerBacklogResponse,\n GetIndexerCandlesticksParams,\n GetIndexerCandlesticksResponse,\n GetIndexerEdgeCandlesticksParams,\n GetIndexerEdgeCandlesticksResponse,\n GetIndexerEdgeMarketSnapshotResponse,\n GetIndexerEdgeMarketSnapshotsParams,\n GetIndexerEventsParams,\n GetIndexerEventsResponse,\n GetIndexerFastWithdrawalSignatureParams,\n GetIndexerFastWithdrawalSignatureResponse,\n GetIndexerFundingRateParams,\n GetIndexerFundingRateResponse,\n GetIndexerInterestFundingPaymentsParams,\n GetIndexerInterestFundingPaymentsResponse,\n GetIndexerLeaderboardContestsParams,\n GetIndexerLeaderboardContestsResponse,\n GetIndexerLeaderboardParams,\n GetIndexerLeaderboardParticipantParams,\n GetIndexerLeaderboardParticipantResponse,\n GetIndexerLeaderboardRegistrationParams,\n GetIndexerLeaderboardRegistrationResponse,\n GetIndexerLeaderboardResponse,\n GetIndexerLinkedSignerParams,\n GetIndexerLinkedSignerResponse,\n GetIndexerMakerStatisticsParams,\n GetIndexerMakerStatisticsResponse,\n GetIndexerMarketSnapshotsParams,\n GetIndexerMarketSnapshotsResponse,\n GetIndexerMatchEventsParams,\n GetIndexerMatchEventsResponse,\n GetIndexerMultiProductFundingRatesParams,\n GetIndexerMultiProductFundingRatesResponse,\n GetIndexerMultiProductPerpPricesParams,\n GetIndexerMultiProductPerpPricesResponse,\n GetIndexerMultiProductSnapshotsParams,\n GetIndexerMultiProductSnapshotsResponse,\n GetIndexerMultiSubaccountSnapshotsParams,\n GetIndexerMultiSubaccountSnapshotsResponse,\n GetIndexerNlpSnapshotsParams,\n GetIndexerNlpSnapshotsResponse,\n GetIndexerOraclePricesParams,\n GetIndexerOraclePricesResponse,\n GetIndexerOrdersParams,\n GetIndexerOrdersResponse,\n GetIndexerPerpPricesParams,\n GetIndexerPerpPricesResponse,\n GetIndexerProductSnapshotsParams,\n GetIndexerProductSnapshotsResponse,\n GetIndexerQuotePriceResponse,\n GetIndexerReferralCodeParams,\n GetIndexerReferralCodeResponse,\n GetIndexerSubaccountDDAParams,\n GetIndexerSubaccountDDAResponse,\n IndexerEventWithTx,\n IndexerMatchEvent,\n IndexerOraclePrice,\n IndexerServerEventsParams,\n IndexerServerQueryRequestByType,\n IndexerServerQueryRequestType,\n IndexerServerQueryResponseByType,\n IndexerSnapshotBalance,\n IndexerSubaccountSnapshot,\n ListIndexerSubaccountsParams,\n ListIndexerSubaccountsResponse,\n UpdateIndexerLeaderboardRegistrationParams,\n UpdateIndexerLeaderboardRegistrationResponse,\n} from './types';\n\nexport interface IndexerClientOpts {\n // Server URLs\n url: string;\n v2Url?: string;\n // Wallet Client for EIP712 signing\n walletClient?: WalletClientWithAccount;\n}\n\ntype IndexerQueryRequestBody = Partial<IndexerServerQueryRequestByType>;\n\n/**\n * Base client for all indexer requests\n */\nexport class IndexerBaseClient {\n readonly opts: IndexerClientOpts;\n readonly v2Url: string;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: IndexerClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n // We have custom logic to validate response status and create an appropriate error\n validateStatus: () => true,\n });\n this.v2Url = opts.v2Url ? opts.v2Url : opts.url.replace('v1', 'v2');\n }\n\n /**\n * List all subaccounts\n *\n * @param params\n */\n async listSubaccounts(\n params: ListIndexerSubaccountsParams,\n ): Promise<ListIndexerSubaccountsResponse> {\n const baseResponse = await this.query('subaccounts', params);\n\n return baseResponse.subaccounts.map((item) => {\n const subaccount = subaccountFromHex(item.subaccount);\n return {\n hexId: item.subaccount,\n ...subaccount,\n };\n });\n }\n\n /**\n * Retrieve snapshots of multiple subaccounts at multiple points in time.\n * Each snapshot is a view of the subaccount's balances at this point in time, with tracked variables for interest, funding, etc.\n *\n * @param params\n */\n async getMultiSubaccountSnapshots(\n params: GetIndexerMultiSubaccountSnapshotsParams,\n ): Promise<GetIndexerMultiSubaccountSnapshotsResponse> {\n const subaccountHexIds = params.subaccounts.map(\n ({ subaccountOwner, subaccountName }) =>\n subaccountToHex({\n subaccountOwner,\n subaccountName,\n }),\n );\n\n const baseResponse = await this.query('account_snapshots', {\n subaccounts: subaccountHexIds,\n timestamps: params.timestamps,\n isolated: params.isolated,\n });\n\n const snapshotsBySubaccount = mapValues(\n baseResponse.snapshots,\n (balanceSnapshots) => {\n const snapshotByTimestamp: Record<string, IndexerSubaccountSnapshot> =\n {};\n\n Object.entries(balanceSnapshots).forEach(([timestamp, events]) => {\n const balances: IndexerSnapshotBalance[] =\n events.map(mapIndexerEvent);\n\n snapshotByTimestamp[timestamp] = {\n timestamp: toBigDecimal(timestamp),\n balances,\n };\n });\n\n return snapshotByTimestamp;\n },\n );\n\n return {\n subaccountHexIds,\n snapshots: snapshotsBySubaccount,\n };\n }\n\n /**\n * Retrieves referral code for an address\n *\n * @param params\n */\n async getReferralCode(\n params: GetIndexerReferralCodeParams,\n ): Promise<GetIndexerReferralCodeResponse> {\n const baseResponse = await this.query('referral_code', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n }),\n });\n\n return {\n referralCode: baseResponse.referral_code,\n };\n }\n\n /**\n * Retrieves funding rate for a product, where 1 = 100%\n * @param params\n */\n async getFundingRate(\n params: GetIndexerFundingRateParams,\n ): Promise<GetIndexerFundingRateResponse> {\n const baseResponse = await this.query('funding_rate', {\n product_id: params.productId,\n });\n\n return mapIndexerFundingRate(baseResponse);\n }\n\n /**\n * Retrieves funding rate for multiple products, where 1 = 100%\n * @param params\n */\n async getMultiProductFundingRates(\n params: GetIndexerMultiProductFundingRatesParams,\n ): Promise<GetIndexerMultiProductFundingRatesResponse> {\n const baseResponse = await this.query('funding_rates', {\n product_ids: params.productIds,\n });\n\n return mapValues(baseResponse, mapIndexerFundingRate);\n }\n\n /**\n * Retrieves latest mark/index price for a perp product\n * @param params\n */\n async getPerpPrices(\n params: GetIndexerPerpPricesParams,\n ): Promise<GetIndexerPerpPricesResponse> {\n const baseResponse = await this.query('price', {\n product_id: params.productId,\n });\n\n return mapIndexerPerpPrices(baseResponse);\n }\n\n /**\n * Retrieves latest mark/index price for multiple perp products\n * @param params\n */\n async getMultiProductPerpPrices(\n params: GetIndexerMultiProductPerpPricesParams,\n ): Promise<GetIndexerMultiProductPerpPricesResponse> {\n const baseResponse = await this.query('perp_prices', {\n product_ids: params.productIds,\n });\n\n return mapValues(baseResponse, mapIndexerPerpPrices);\n }\n\n /**\n * Retrieves latest oracle prices for provided products\n * @param params\n */\n async getOraclePrices(\n params: GetIndexerOraclePricesParams,\n ): Promise<GetIndexerOraclePricesResponse> {\n const baseResponse = await this.query('oracle_price', {\n product_ids: params.productIds,\n });\n\n return baseResponse.prices.map((price): IndexerOraclePrice => {\n return {\n oraclePrice: removeDecimals(price.oracle_price_x18),\n updateTime: toBigDecimal(price.update_time),\n productId: price.product_id,\n };\n });\n }\n\n /**\n * Retrieves candlesticks for a product\n * @param params\n */\n async getCandlesticks(\n params: GetIndexerCandlesticksParams,\n ): Promise<GetIndexerCandlesticksResponse> {\n const baseResponse = await this.query('candlesticks', {\n product_id: params.productId,\n max_time: params.maxTimeInclusive,\n limit: params.limit,\n granularity: params.period,\n });\n\n return baseResponse.candlesticks.map(mapIndexerCandlesticks);\n }\n\n /**\n * Retrieves candlesticks for a product from Edge\n * @param params\n */\n async getEdgeCandlesticks(\n params: GetIndexerEdgeCandlesticksParams,\n ): Promise<GetIndexerEdgeCandlesticksResponse> {\n const baseResponse = await this.query('edge_candlesticks', {\n product_id: params.productId,\n max_time: params.maxTimeInclusive,\n limit: params.limit,\n granularity: params.period,\n });\n\n return baseResponse.candlesticks.map(mapIndexerCandlesticks);\n }\n\n /**\n * Retrieves historical snapshots for a product\n * @param params\n */\n async getProductSnapshots(\n params: GetIndexerProductSnapshotsParams,\n ): Promise<GetIndexerProductSnapshotsResponse> {\n const baseResponse = await this.query('products', {\n product_id: params.productId,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n return baseResponse.products.map((product) => {\n return {\n ...mapIndexerServerProduct(product.product),\n submissionIndex: product.submission_idx,\n };\n });\n }\n\n /**\n * Retrieves historical snapshots for multiple products\n * @param params\n */\n async getMultiProductSnapshots(\n params: GetIndexerMultiProductSnapshotsParams,\n ): Promise<GetIndexerMultiProductSnapshotsResponse> {\n const timestampToProductsMap = await this.query('product_snapshots', {\n product_ids: params.productIds,\n max_time: params.maxTimestampInclusive ?? [nowInSeconds()],\n });\n\n return mapValues(timestampToProductsMap, (productIdToProduct) => {\n return mapValues(productIdToProduct, (indexerProduct) => {\n return {\n ...mapIndexerServerProduct(indexerProduct.product),\n submissionIndex: indexerProduct.submission_idx,\n };\n });\n });\n }\n\n /**\n * Retrieves historical events\n *\n * @param params\n */\n async getEvents(\n params: GetIndexerEventsParams,\n ): Promise<GetIndexerEventsResponse> {\n const serverLimit = ((): IndexerServerEventsParams['limit'] | undefined => {\n if (!params.limit) {\n return;\n }\n\n if (params.limit.type === 'events') {\n return {\n raw: params.limit.value,\n };\n }\n return {\n txs: params.limit.value,\n };\n })();\n\n const baseResponse = await this.query('events', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n event_types: params.eventTypes,\n max_time: params.maxTimestampInclusive,\n desc: params.desc,\n limit: serverLimit,\n idx: params.startCursor,\n });\n\n // Keep track of the last tx index, and go to the next one if the submission_idx for the currently processed event does not match\n // txs are ordered the same as events, so this should be correct\n let lastTxIdx = 0;\n return baseResponse.events.map((event): IndexerEventWithTx => {\n if (baseResponse.txs[lastTxIdx].submission_idx !== event.submission_idx) {\n lastTxIdx += 1;\n }\n const tx = baseResponse.txs[lastTxIdx];\n return mapIndexerEventWithTx(event, tx);\n });\n }\n\n /**\n * Retrieves historical orders\n * @param params\n */\n async getOrders(\n params: GetIndexerOrdersParams,\n ): Promise<GetIndexerOrdersResponse> {\n const baseResponse = await this.query('orders', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n digests: params.digests,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n return baseResponse.orders.map(mapIndexerOrder);\n }\n\n /**\n * Gets match order events, this will return the same events as the events query, but with additional information\n * to identify the order that was matched\n *\n * @param params\n */\n async getMatchEvents(\n params: GetIndexerMatchEventsParams,\n ): Promise<GetIndexerMatchEventsResponse> {\n const baseResponse = await this.query('matches', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n // Same as logic in `getEvents`\n let lastTxIdx = 0;\n return baseResponse.matches.map((matchEvent): IndexerMatchEvent => {\n if (\n baseResponse.txs[lastTxIdx].submission_idx !== matchEvent.submission_idx\n ) {\n lastTxIdx += 1;\n }\n const { tx, timestamp } = baseResponse.txs[lastTxIdx];\n\n // We use this to derive the product ID for the match\n const postBalances = mapIndexerMatchEventBalances(\n matchEvent.post_balance,\n );\n\n return {\n productId: postBalances.base.productId,\n isolated: matchEvent.isolated,\n totalFee: toBigDecimal(matchEvent.fee),\n sequencerFee: toBigDecimal(matchEvent.sequencer_fee),\n baseFilled: toBigDecimal(matchEvent.base_filled),\n quoteFilled: toBigDecimal(matchEvent.quote_filled),\n cumulativeFee: toBigDecimal(matchEvent.cumulative_fee),\n cumulativeBaseFilled: toBigDecimal(matchEvent.cumulative_base_filled),\n cumulativeQuoteFilled: toBigDecimal(matchEvent.cumulative_quote_filled),\n digest: matchEvent.digest,\n order: matchEvent.order,\n submissionIndex: matchEvent.submission_idx,\n timestamp: toBigDecimal(timestamp),\n preEventTrackedVars: {\n netEntryUnrealized: toBigDecimal(matchEvent.net_entry_unrealized),\n netEntryCumulative: toBigDecimal(matchEvent.net_entry_cumulative),\n },\n preBalances: mapIndexerMatchEventBalances(matchEvent.pre_balance),\n postBalances,\n tx,\n ...subaccountFromHex(matchEvent.order.sender),\n };\n });\n }\n\n /**\n * Retrieves historical funding & interest payments.\n * NOTE: `limit` is an upperbound. If a user changes position size such that his position is 0 during each funding/interest tick,\n * then the indexer will return fewer than `limit` results per page. However, more events can be present. This means that\n * there isn't a reliable way to determine whether there is a next page. We just need to keep paginating until the next cursor is null.\n *\n * @param params\n */\n async getInterestFundingPayments(\n params: GetIndexerInterestFundingPaymentsParams,\n ): Promise<GetIndexerInterestFundingPaymentsResponse> {\n const baseResponse = await this.query('interest_and_funding', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n }),\n product_ids: params.productIds,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n max_idx: params.startCursor,\n });\n\n return {\n fundingPayments: baseResponse.funding_payments.map(\n mapIndexerProductPayment,\n ),\n interestPayments: baseResponse.interest_payments.map(\n mapIndexerProductPayment,\n ),\n nextCursor: baseResponse.next_idx,\n };\n }\n\n /**\n * Gets quote (USDC) price in terms of USD\n */\n async getQuotePrice(): Promise<GetIndexerQuotePriceResponse> {\n const baseResponse = await this.query('usdc_price', {});\n return {\n price: removeDecimals(baseResponse.price_x18),\n };\n }\n\n /**\n * Fetches currently registered linked signer with the remaining txs allowed for the subaccount\n */\n async getLinkedSignerWithRateLimit(\n params: GetIndexerLinkedSignerParams,\n ): Promise<GetIndexerLinkedSignerResponse> {\n const baseResponse = await this.query('linked_signer_rate_limit', {\n subaccount: subaccountToHex(params.subaccount),\n });\n return {\n totalTxLimit: toBigDecimal(baseResponse.total_tx_limit),\n remainingTxs: toBigDecimal(baseResponse.remaining_tx),\n signer: baseResponse.signer,\n waitTimeUntilNextTx: toBigDecimal(baseResponse.wait_time),\n };\n }\n\n /**\n * Retrieve historical market snapshots\n * @param params\n */\n async getMarketSnapshots(\n params: GetIndexerMarketSnapshotsParams,\n ): Promise<GetIndexerMarketSnapshotsResponse> {\n const baseResponse = await this.query('market_snapshots', {\n interval: mapSnapshotsIntervalToServerParams(params),\n product_ids: params.productIds,\n });\n\n return baseResponse.snapshots.map(mapIndexerMarketSnapshot);\n }\n\n /**\n * Retrieve historical market snapshots from Edge\n * @param params\n */\n async getEdgeMarketSnapshots(\n params: GetIndexerEdgeMarketSnapshotsParams,\n ): Promise<GetIndexerEdgeMarketSnapshotResponse> {\n const baseResponse = await this.query('edge_market_snapshots', {\n interval: mapSnapshotsIntervalToServerParams(params),\n });\n\n return mapValues(baseResponse.snapshots, (snapshots) =>\n snapshots.map(mapIndexerMarketSnapshot),\n );\n }\n\n /**\n * Retrieve maker statistics for a given epoch\n *\n * @param params\n */\n async getMakerStatistics(\n params: GetIndexerMakerStatisticsParams,\n ): Promise<GetIndexerMakerStatisticsResponse> {\n const baseResponse = await this.query('maker_statistics', {\n product_id: params.productId,\n epoch: params.epoch,\n interval: params.interval,\n });\n\n return {\n rewardCoefficient: toBigDecimal(baseResponse.reward_coefficient),\n makers: baseResponse.makers.map(mapIndexerMakerStatistics),\n };\n }\n\n /**\n * Retrieve leaderboard stats for a given contest\n *\n * @param params\n */\n async getLeaderboard(\n params: GetIndexerLeaderboardParams,\n ): Promise<GetIndexerLeaderboardResponse> {\n const baseResponse = await this.query('leaderboard', {\n contest_id: params.contestId,\n rank_type: params.rankType,\n start: params.startCursor,\n limit: params.limit,\n });\n\n return {\n participants: baseResponse.positions.map(mapIndexerLeaderboardPosition),\n };\n }\n\n /**\n * Retrieve leaderboard ranking of a subaccount on a given contest\n *\n * @param params\n */\n async getLeaderboardParticipant(\n params: GetIndexerLeaderboardParticipantParams,\n ): Promise<GetIndexerLeaderboardParticipantResponse> {\n const baseResponse = await this.query('leaderboard_rank', {\n subaccount: subaccountToHex(params.subaccount),\n contest_ids: params.contestIds,\n });\n\n return {\n participant: mapValues(baseResponse.positions, (position) =>\n mapIndexerLeaderboardPosition(position),\n ),\n };\n }\n\n /**\n * Attempts to update a user's registration to the provided `contestId`. This requires signing.\n * @param params\n */\n async updateLeaderboardRegistration(\n params: UpdateIndexerLeaderboardRegistrationParams,\n ): Promise<UpdateIndexerLeaderboardRegistrationResponse> {\n const signatureParams: EIP712LeaderboardAuthenticationParams = {\n // Default to 90 seconds from now if no recvTime is provided\n expiration: toIntegerString(params.recvTime ?? getDefaultRecvTime()),\n subaccountName: params.subaccountName,\n subaccountOwner: params.subaccountOwner,\n };\n\n const tx = getNadoEIP712Values(\n 'leaderboard_authentication',\n signatureParams,\n );\n const signature = await this.sign(\n 'leaderboard_authentication',\n params.updateRegistration.verifyingAddr,\n params.updateRegistration.chainId,\n signatureParams,\n );\n\n const updateRegistrationTx: SignedTx<EIP712LeaderboardAuthenticationValues> =\n {\n tx,\n signature,\n };\n\n const baseResponse = await this.query('leaderboard_registration', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n contest_id: params.contestId,\n update_registration: updateRegistrationTx,\n });\n return {\n registration: baseResponse.registration\n ? mapIndexerLeaderboardRegistration(baseResponse.registration)\n : null,\n };\n }\n\n /**\n * Retrieves the registration status for a leaderboard participant for provided `contestId`.\n * @param params\n */\n async getLeaderboardRegistration(\n params: GetIndexerLeaderboardRegistrationParams,\n ): Promise<GetIndexerLeaderboardRegistrationResponse> {\n const baseResponse = await this.query('leaderboard_registration', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n contest_id: params.contestId,\n update_registration: null,\n });\n return {\n registration: baseResponse.registration\n ? mapIndexerLeaderboardRegistration(baseResponse.registration)\n : null,\n };\n }\n\n /**\n * Retrieve metadata of provided leaderboard contests\n *\n * @param params\n */\n async getLeaderboardContests(\n params: GetIndexerLeaderboardContestsParams,\n ): Promise<GetIndexerLeaderboardContestsResponse> {\n const baseResponse = await this.query('leaderboard_contests', {\n contest_ids: params.contestIds,\n });\n\n return {\n contests: baseResponse.contests.map(mapIndexerLeaderboardContest),\n };\n }\n\n /**\n * Retrieve signature and tx to submit a fast withdrawal\n *\n * @param params\n */\n async getFastWithdrawalSignature(\n params: GetIndexerFastWithdrawalSignatureParams,\n ): Promise<GetIndexerFastWithdrawalSignatureResponse> {\n const baseResponse = await this.query('fast_withdrawal_signature', params);\n return {\n idx: toBigInt(baseResponse.idx),\n tx: baseResponse.tx,\n txBytes: getValidatedHex(baseResponse.tx_bytes),\n signatures: baseResponse.signatures.map(getValidatedHex),\n };\n }\n\n async getNlpSnapshots(\n params: GetIndexerNlpSnapshotsParams,\n ): Promise<GetIndexerNlpSnapshotsResponse> {\n const baseResponse = await this.query('nlp_snapshots', {\n interval: {\n count: params.limit,\n max_time: params.maxTimeInclusive\n ? toIntegerString(params.maxTimeInclusive)\n : undefined,\n granularity: params.granularity,\n },\n });\n\n return {\n snapshots: baseResponse.snapshots.map(mapIndexerNlpSnapshot),\n };\n }\n\n /**\n * Retrieves the subaccount's DDA (Direct Deposit Address)\n * @param params\n */\n async getSubaccountDDA(\n params: GetIndexerSubaccountDDAParams,\n ): Promise<GetIndexerSubaccountDDAResponse> {\n const baseResponse = await this.query('direct_deposit_address', {\n subaccount: subaccountToHex(params.subaccount),\n });\n\n return {\n address: getValidatedAddress(baseResponse.v1_address),\n };\n }\n\n async getSequencerBacklog(): Promise<GetIndexerBacklogResponse> {\n const baseResponse = await this.query('backlog', {});\n\n return {\n totalTxs: toBigDecimal(baseResponse.total_txs),\n totalSubmissions: toBigDecimal(baseResponse.total_submissions),\n backlogSize: toBigDecimal(baseResponse.backlog_size),\n updatedAt: toBigDecimal(baseResponse.updated_at),\n backlogEtaInSeconds: baseResponse.backlog_eta_in_seconds\n ? toBigDecimal(baseResponse.backlog_eta_in_seconds)\n : null,\n txsPerSecond: baseResponse.txs_per_second\n ? toBigDecimal(baseResponse.txs_per_second)\n : null,\n };\n }\n\n protected async query<TRequestType extends IndexerServerQueryRequestType>(\n requestType: TRequestType,\n params: IndexerServerQueryRequestByType[TRequestType],\n ): Promise<IndexerServerQueryResponseByType[TRequestType]> {\n const reqBody: IndexerQueryRequestBody = {\n [requestType]: params,\n };\n const response = await this.axiosInstance.post<\n IndexerServerQueryResponseByType[TRequestType]\n >(this.opts.url, reqBody);\n\n this.checkResponseStatus(response);\n\n return response.data;\n }\n\n protected async sign<T extends SignableRequestType>(\n requestType: T,\n verifyingContract: string,\n chainId: number,\n params: SignableRequestTypeToParams[T],\n ) {\n const walletClient = this.opts.walletClient;\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n return getSignedTransactionRequest({\n chainId,\n requestParams: params,\n requestType,\n walletClient,\n verifyingContract,\n });\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}`,\n );\n }\n }\n}\n"],"mappings":";AAAA;AAAA,EAGE;AAAA,EACA;A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ACnD,QAAI,SAAS,WAAW,OAAO,CAAC,SAAS,MAAM;AAC7C,YAAM;AAAA,QACJ,oCAAoC,SAAS,MAAM,IAAI,SAAS,UAAU;AAAA,MAC5E;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -74,7 +74,6 @@ function mapIndexerOrder(order) {
74
74
  return {
75
75
  amount: (0, import_shared.toBigDecimal)(order.amount),
76
76
  digest: order.digest,
77
- isolated: order.isolated,
78
77
  expiration: Number(order.expiration),
79
78
  appendix,
80
79
  nonce: (0, import_shared.toBigDecimal)(order.nonce),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dataMappers.ts"],"sourcesContent":["import {\n mapEngineServerPerpProduct,\n mapEngineServerSpotProduct,\n} from '@nadohq/engine-client';\nimport {\n getRecvTimeFromOrderNonce,\n mapValues,\n Market,\n PerpMarket,\n ProductEngineType,\n removeDecimals,\n SpotMarket,\n subaccountFromHex,\n toBigDecimal,\n toIntegerString,\n unpackOrderAppendix,\n} from '@nadohq/shared';\nimport {\n Candlestick,\n IndexerEvent,\n IndexerEventWithTx,\n IndexerFundingRate,\n IndexerLeaderboardContest,\n IndexerLeaderboardParticipant,\n IndexerLeaderboardRegistration,\n IndexerMaker,\n IndexerMarketSnapshot,\n IndexerMatchEventBalances,\n IndexerNlpSnapshot,\n IndexerOrder,\n IndexerPerpBalance,\n IndexerPerpPrices,\n IndexerProductPayment,\n IndexerServerBalance,\n IndexerServerCandlestick,\n IndexerServerEvent,\n IndexerServerFundingRate,\n IndexerServerLeaderboardContest,\n IndexerServerLeaderboardPosition,\n IndexerServerLeaderboardRegistration,\n IndexerServerMaker,\n IndexerServerMarketSnapshot,\n IndexerServerMatchEventBalances,\n IndexerServerNlpSnapshot,\n IndexerServerOrder,\n IndexerServerPerpPrices,\n IndexerServerProduct,\n IndexerServerProductPayment,\n IndexerServerSnapshotsInterval,\n IndexerServerTx,\n IndexerSnapshotsIntervalParams,\n IndexerSpotBalance,\n} from './types';\n\nexport function mapSnapshotsIntervalToServerParams(\n params: IndexerSnapshotsIntervalParams,\n): IndexerServerSnapshotsInterval {\n return {\n count: params.limit,\n max_time: params.maxTimeInclusive\n ? toIntegerString(params.maxTimeInclusive)\n : undefined,\n granularity: params.granularity,\n };\n}\n\nexport function mapIndexerServerProduct(product: IndexerServerProduct): Market {\n if ('spot' in product) {\n return mapEngineServerSpotProduct(product.spot);\n }\n return mapEngineServerPerpProduct(product.perp);\n}\n\nexport function mapIndexerServerBalance(\n balance: IndexerServerBalance,\n): IndexerSpotBalance | IndexerPerpBalance {\n if ('spot' in balance) {\n return {\n amount: toBigDecimal(balance.spot.balance.amount),\n productId: balance.spot.product_id,\n type: ProductEngineType.SPOT,\n };\n }\n return {\n amount: toBigDecimal(balance.perp.balance.amount),\n productId: balance.perp.product_id,\n type: ProductEngineType.PERP,\n vQuoteBalance: toBigDecimal(balance.perp.balance.v_quote_balance),\n };\n}\n\nexport function mapIndexerOrder(order: IndexerServerOrder): IndexerOrder {\n const appendix = unpackOrderAppendix(order.appendix);\n return {\n amount: toBigDecimal(order.amount),\n digest: order.digest,\n isolated: order.isolated,\n expiration: Number(order.expiration),\n appendix,\n nonce: toBigDecimal(order.nonce),\n recvTimeSeconds: getRecvTimeFromOrderNonce(order.nonce) / 1000,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccount: order.subaccount,\n submissionIndex: order.submission_idx,\n baseFilled: toBigDecimal(order.base_filled),\n quoteFilled: toBigDecimal(order.quote_filled),\n totalFee: toBigDecimal(order.fee),\n };\n}\n\nexport function mapIndexerEvent(event: IndexerServerEvent): IndexerEvent {\n const eventState: IndexerEvent['state'] = (() => {\n // Assume backend data is consistent\n if ('spot' in event.pre_balance) {\n return {\n type: ProductEngineType.SPOT,\n market: mapIndexerServerProduct(event.product) as SpotMarket,\n preBalance: mapIndexerServerBalance(\n event.pre_balance,\n ) as IndexerSpotBalance,\n postBalance: mapIndexerServerBalance(\n event.post_balance,\n ) as IndexerSpotBalance,\n };\n }\n return {\n type: ProductEngineType.PERP,\n market: mapIndexerServerProduct(event.product) as PerpMarket,\n preBalance: mapIndexerServerBalance(\n event.pre_balance,\n ) as IndexerPerpBalance,\n postBalance: mapIndexerServerBalance(\n event.post_balance,\n ) as IndexerPerpBalance,\n };\n })();\n\n return {\n eventType: event.event_type,\n productId: event.product_id,\n isolated: event.isolated,\n isolatedProductId: event.isolated_product_id,\n state: eventState,\n subaccount: event.subaccount,\n submissionIndex: event.submission_idx,\n trackedVars: {\n netEntryCumulative: toBigDecimal(event.net_entry_cumulative),\n netEntryUnrealized: toBigDecimal(event.net_entry_unrealized),\n netFundingCumulative: toBigDecimal(event.net_funding_cumulative),\n netFundingUnrealized: toBigDecimal(event.net_funding_unrealized),\n netInterestCumulative: toBigDecimal(event.net_interest_cumulative),\n netInterestUnrealized: toBigDecimal(event.net_interest_unrealized),\n },\n };\n}\n\nexport function mapIndexerEventWithTx(\n event: IndexerServerEvent,\n tx: IndexerServerTx,\n): IndexerEventWithTx {\n return {\n timestamp: toBigDecimal(tx.timestamp),\n tx: tx.tx,\n ...mapIndexerEvent(event),\n };\n}\n\nexport function mapIndexerMatchEventBalances(\n eventBalances: IndexerServerMatchEventBalances,\n): IndexerMatchEventBalances {\n return {\n base: mapIndexerServerBalance(eventBalances.base),\n quote: eventBalances.quote\n ? (mapIndexerServerBalance(eventBalances.quote) as IndexerSpotBalance)\n : undefined,\n };\n}\n\nexport function mapIndexerProductPayment(\n payment: IndexerServerProductPayment,\n): IndexerProductPayment {\n return {\n submissionIndex: payment.idx,\n timestamp: toBigDecimal(payment.timestamp),\n paymentAmount: toBigDecimal(payment.amount),\n balanceAmount: toBigDecimal(payment.balance_amount),\n annualPaymentRate: removeDecimals(payment.rate_x18),\n oraclePrice: removeDecimals(payment.oracle_price_x18),\n isolated: payment.isolated,\n productId: payment.product_id,\n isolatedProductId: payment.isolated_product_id,\n };\n}\n\nexport function mapIndexerPerpPrices(\n perpPrices: IndexerServerPerpPrices,\n): IndexerPerpPrices {\n return {\n indexPrice: removeDecimals(perpPrices.index_price_x18),\n markPrice: removeDecimals(perpPrices.mark_price_x18),\n updateTime: toBigDecimal(perpPrices.update_time),\n productId: perpPrices.product_id,\n };\n}\n\nexport function mapIndexerFundingRate(\n fundingRate: IndexerServerFundingRate,\n): IndexerFundingRate {\n return {\n fundingRate: removeDecimals(fundingRate.funding_rate_x18),\n updateTime: toBigDecimal(fundingRate.update_time),\n productId: fundingRate.product_id,\n };\n}\n\nexport function mapIndexerMakerStatistics(\n maker: IndexerServerMaker,\n): IndexerMaker {\n return {\n address: maker.address,\n snapshots: maker.data.map((makerData) => {\n return {\n timestamp: toBigDecimal(makerData.timestamp),\n makerFee: toBigDecimal(makerData.maker_fee),\n uptime: toBigDecimal(makerData.uptime),\n sumQMin: toBigDecimal(makerData.sum_q_min),\n qScore: toBigDecimal(makerData.q_score),\n makerShare: toBigDecimal(makerData.maker_share),\n expectedMakerReward: toBigDecimal(makerData.expected_maker_reward),\n };\n }),\n };\n}\n\nexport function mapIndexerLeaderboardPosition(\n position: IndexerServerLeaderboardPosition,\n): IndexerLeaderboardParticipant {\n return {\n subaccount: subaccountFromHex(position.subaccount),\n contestId: position.contest_id,\n pnl: toBigDecimal(position.pnl),\n pnlRank: toBigDecimal(position.pnl_rank),\n percentRoi: toBigDecimal(position.roi),\n roiRank: toBigDecimal(position.roi_rank),\n accountValue: toBigDecimal(position.account_value),\n volume: position.volume ? toBigDecimal(position.volume) : undefined,\n updateTime: toBigDecimal(position.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardRegistration(\n registration: IndexerServerLeaderboardRegistration,\n): IndexerLeaderboardRegistration {\n return {\n subaccount: subaccountFromHex(registration.subaccount),\n contestId: registration.contest_id,\n updateTime: toBigDecimal(registration.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardContest(\n contest: IndexerServerLeaderboardContest,\n): IndexerLeaderboardContest {\n return {\n contestId: contest.contest_id,\n startTime: toBigDecimal(contest.start_time),\n endTime: toBigDecimal(contest.end_time),\n period: toBigDecimal(contest.threshold),\n totalParticipants: toBigDecimal(contest.count),\n minRequiredAccountValue: toBigDecimal(contest.threshold),\n minRequiredVolume: toBigDecimal(contest.volume_threshold),\n requiredProductIds: contest.product_ids,\n active: contest.active,\n lastUpdated: toBigDecimal(contest.last_updated),\n };\n}\n\nexport function mapIndexerCandlesticks(\n candlestick: IndexerServerCandlestick,\n): Candlestick {\n return {\n close: removeDecimals(candlestick.close_x18),\n high: removeDecimals(candlestick.high_x18),\n low: removeDecimals(candlestick.low_x18),\n open: removeDecimals(candlestick.open_x18),\n time: toBigDecimal(candlestick.timestamp),\n volume: toBigDecimal(candlestick.volume),\n };\n}\n\nexport function mapIndexerMarketSnapshot(\n snapshot: IndexerServerMarketSnapshot,\n): IndexerMarketSnapshot {\n return {\n timestamp: toBigDecimal(snapshot.timestamp),\n cumulativeUsers: toBigDecimal(snapshot.cumulative_users),\n dailyActiveUsers: toBigDecimal(snapshot.daily_active_users),\n tvl: toBigDecimal(snapshot.tvl),\n borrowRates: mapValues(snapshot.borrow_rates, (value) =>\n removeDecimals(value),\n ),\n cumulativeLiquidationAmounts: mapValues(\n snapshot.cumulative_liquidation_amounts,\n toBigDecimal,\n ),\n cumulativeMakerFees: mapValues(\n snapshot.cumulative_maker_fees,\n toBigDecimal,\n ),\n cumulativeSequencerFees: mapValues(\n snapshot.cumulative_sequencer_fees,\n toBigDecimal,\n ),\n cumulativeTakerFees: mapValues(\n snapshot.cumulative_taker_fees,\n toBigDecimal,\n ),\n cumulativeTrades: mapValues(snapshot.cumulative_trades, toBigDecimal),\n cumulativeVolumes: mapValues(snapshot.cumulative_volumes, toBigDecimal),\n depositRates: mapValues(snapshot.deposit_rates, (value) =>\n removeDecimals(value),\n ),\n fundingRates: mapValues(snapshot.funding_rates, (value) =>\n removeDecimals(value),\n ),\n openInterestsQuote: mapValues(snapshot.open_interests, toBigDecimal),\n totalBorrows: mapValues(snapshot.total_borrows, toBigDecimal),\n totalDeposits: mapValues(snapshot.total_deposits, toBigDecimal),\n cumulativeTradeSizes: mapValues(\n snapshot.cumulative_trade_sizes,\n toBigDecimal,\n ),\n cumulativeInflows: mapValues(snapshot.cumulative_inflows, toBigDecimal),\n cumulativeOutflows: mapValues(snapshot.cumulative_outflows, toBigDecimal),\n oraclePrices: mapValues(snapshot.oracle_prices, (value) =>\n removeDecimals(value),\n ),\n };\n}\n\nexport function mapIndexerNlpSnapshot(\n snapshot: IndexerServerNlpSnapshot,\n): IndexerNlpSnapshot {\n return {\n submissionIndex: snapshot.submission_idx,\n timestamp: toBigDecimal(snapshot.timestamp),\n cumulativeBurnAmountUsdc: toBigDecimal(snapshot.cumulative_burn_usdc),\n cumulativeMintAmountUsdc: toBigDecimal(snapshot.cumulative_mint_usdc),\n cumulativePnl: toBigDecimal(snapshot.cumulative_pnl),\n cumulativeTrades: toBigDecimal(snapshot.cumulative_trades),\n cumulativeVolume: toBigDecimal(snapshot.cumulative_volume),\n depositors: toBigDecimal(snapshot.depositors),\n oraclePrice: removeDecimals(snapshot.oracle_price_x18),\n tvl: toBigDecimal(snapshot.tvl),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAGO;AACP,oBAYO;AAsCA,SAAS,mCACd,QACgC;AAChC,SAAO;AAAA,IACL,OAAO,OAAO;AAAA,IACd,UAAU,OAAO,uBACb,+BAAgB,OAAO,gBAAgB,IACvC;AAAA,IACJ,aAAa,OAAO;AAAA,EACtB;AACF;AAEO,SAAS,wBAAwB,SAAuC;AAC7E,MAAI,UAAU,SAAS;AACrB,eAAO,iDAA2B,QAAQ,IAAI;AAAA,EAChD;AACA,aAAO,iDAA2B,QAAQ,IAAI;AAChD;AAEO,SAAS,wBACd,SACyC;AACzC,MAAI,UAAU,SAAS;AACrB,WAAO;AAAA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}
1
+ {"version":3,"sources":["../src/dataMappers.ts"],"sourcesContent":["import {\n mapEngineServerPerpProduct,\n mapEngineServerSpotProduct,\n} from '@nadohq/engine-client';\nimport {\n getRecvTimeFromOrderNonce,\n mapValues,\n Market,\n PerpMarket,\n ProductEngineType,\n removeDecimals,\n SpotMarket,\n subaccountFromHex,\n toBigDecimal,\n toIntegerString,\n unpackOrderAppendix,\n} from '@nadohq/shared';\nimport {\n Candlestick,\n IndexerEvent,\n IndexerEventWithTx,\n IndexerFundingRate,\n IndexerLeaderboardContest,\n IndexerLeaderboardParticipant,\n IndexerLeaderboardRegistration,\n IndexerMaker,\n IndexerMarketSnapshot,\n IndexerMatchEventBalances,\n IndexerNlpSnapshot,\n IndexerOrder,\n IndexerPerpBalance,\n IndexerPerpPrices,\n IndexerProductPayment,\n IndexerServerBalance,\n IndexerServerCandlestick,\n IndexerServerEvent,\n IndexerServerFundingRate,\n IndexerServerLeaderboardContest,\n IndexerServerLeaderboardPosition,\n IndexerServerLeaderboardRegistration,\n IndexerServerMaker,\n IndexerServerMarketSnapshot,\n IndexerServerMatchEventBalances,\n IndexerServerNlpSnapshot,\n IndexerServerOrder,\n IndexerServerPerpPrices,\n IndexerServerProduct,\n IndexerServerProductPayment,\n IndexerServerSnapshotsInterval,\n IndexerServerTx,\n IndexerSnapshotsIntervalParams,\n IndexerSpotBalance,\n} from './types';\n\nexport function mapSnapshotsIntervalToServerParams(\n params: IndexerSnapshotsIntervalParams,\n): IndexerServerSnapshotsInterval {\n return {\n count: params.limit,\n max_time: params.maxTimeInclusive\n ? toIntegerString(params.maxTimeInclusive)\n : undefined,\n granularity: params.granularity,\n };\n}\n\nexport function mapIndexerServerProduct(product: IndexerServerProduct): Market {\n if ('spot' in product) {\n return mapEngineServerSpotProduct(product.spot);\n }\n return mapEngineServerPerpProduct(product.perp);\n}\n\nexport function mapIndexerServerBalance(\n balance: IndexerServerBalance,\n): IndexerSpotBalance | IndexerPerpBalance {\n if ('spot' in balance) {\n return {\n amount: toBigDecimal(balance.spot.balance.amount),\n productId: balance.spot.product_id,\n type: ProductEngineType.SPOT,\n };\n }\n return {\n amount: toBigDecimal(balance.perp.balance.amount),\n productId: balance.perp.product_id,\n type: ProductEngineType.PERP,\n vQuoteBalance: toBigDecimal(balance.perp.balance.v_quote_balance),\n };\n}\n\nexport function mapIndexerOrder(order: IndexerServerOrder): IndexerOrder {\n const appendix = unpackOrderAppendix(order.appendix);\n return {\n amount: toBigDecimal(order.amount),\n digest: order.digest,\n expiration: Number(order.expiration),\n appendix,\n nonce: toBigDecimal(order.nonce),\n recvTimeSeconds: getRecvTimeFromOrderNonce(order.nonce) / 1000,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccount: order.subaccount,\n submissionIndex: order.submission_idx,\n baseFilled: toBigDecimal(order.base_filled),\n quoteFilled: toBigDecimal(order.quote_filled),\n totalFee: toBigDecimal(order.fee),\n };\n}\n\nexport function mapIndexerEvent(event: IndexerServerEvent): IndexerEvent {\n const eventState: IndexerEvent['state'] = (() => {\n // Assume backend data is consistent\n if ('spot' in event.pre_balance) {\n return {\n type: ProductEngineType.SPOT,\n market: mapIndexerServerProduct(event.product) as SpotMarket,\n preBalance: mapIndexerServerBalance(\n event.pre_balance,\n ) as IndexerSpotBalance,\n postBalance: mapIndexerServerBalance(\n event.post_balance,\n ) as IndexerSpotBalance,\n };\n }\n return {\n type: ProductEngineType.PERP,\n market: mapIndexerServerProduct(event.product) as PerpMarket,\n preBalance: mapIndexerServerBalance(\n event.pre_balance,\n ) as IndexerPerpBalance,\n postBalance: mapIndexerServerBalance(\n event.post_balance,\n ) as IndexerPerpBalance,\n };\n })();\n\n return {\n eventType: event.event_type,\n productId: event.product_id,\n isolated: event.isolated,\n isolatedProductId: event.isolated_product_id,\n state: eventState,\n subaccount: event.subaccount,\n submissionIndex: event.submission_idx,\n trackedVars: {\n netEntryCumulative: toBigDecimal(event.net_entry_cumulative),\n netEntryUnrealized: toBigDecimal(event.net_entry_unrealized),\n netFundingCumulative: toBigDecimal(event.net_funding_cumulative),\n netFundingUnrealized: toBigDecimal(event.net_funding_unrealized),\n netInterestCumulative: toBigDecimal(event.net_interest_cumulative),\n netInterestUnrealized: toBigDecimal(event.net_interest_unrealized),\n },\n };\n}\n\nexport function mapIndexerEventWithTx(\n event: IndexerServerEvent,\n tx: IndexerServerTx,\n): IndexerEventWithTx {\n return {\n timestamp: toBigDecimal(tx.timestamp),\n tx: tx.tx,\n ...mapIndexerEvent(event),\n };\n}\n\nexport function mapIndexerMatchEventBalances(\n eventBalances: IndexerServerMatchEventBalances,\n): IndexerMatchEventBalances {\n return {\n base: mapIndexerServerBalance(eventBalances.base),\n quote: eventBalances.quote\n ? (mapIndexerServerBalance(eventBalances.quote) as IndexerSpotBalance)\n : undefined,\n };\n}\n\nexport function mapIndexerProductPayment(\n payment: IndexerServerProductPayment,\n): IndexerProductPayment {\n return {\n submissionIndex: payment.idx,\n timestamp: toBigDecimal(payment.timestamp),\n paymentAmount: toBigDecimal(payment.amount),\n balanceAmount: toBigDecimal(payment.balance_amount),\n annualPaymentRate: removeDecimals(payment.rate_x18),\n oraclePrice: removeDecimals(payment.oracle_price_x18),\n isolated: payment.isolated,\n productId: payment.product_id,\n isolatedProductId: payment.isolated_product_id,\n };\n}\n\nexport function mapIndexerPerpPrices(\n perpPrices: IndexerServerPerpPrices,\n): IndexerPerpPrices {\n return {\n indexPrice: removeDecimals(perpPrices.index_price_x18),\n markPrice: removeDecimals(perpPrices.mark_price_x18),\n updateTime: toBigDecimal(perpPrices.update_time),\n productId: perpPrices.product_id,\n };\n}\n\nexport function mapIndexerFundingRate(\n fundingRate: IndexerServerFundingRate,\n): IndexerFundingRate {\n return {\n fundingRate: removeDecimals(fundingRate.funding_rate_x18),\n updateTime: toBigDecimal(fundingRate.update_time),\n productId: fundingRate.product_id,\n };\n}\n\nexport function mapIndexerMakerStatistics(\n maker: IndexerServerMaker,\n): IndexerMaker {\n return {\n address: maker.address,\n snapshots: maker.data.map((makerData) => {\n return {\n timestamp: toBigDecimal(makerData.timestamp),\n makerFee: toBigDecimal(makerData.maker_fee),\n uptime: toBigDecimal(makerData.uptime),\n sumQMin: toBigDecimal(makerData.sum_q_min),\n qScore: toBigDecimal(makerData.q_score),\n makerShare: toBigDecimal(makerData.maker_share),\n expectedMakerReward: toBigDecimal(makerData.expected_maker_reward),\n };\n }),\n };\n}\n\nexport function mapIndexerLeaderboardPosition(\n position: IndexerServerLeaderboardPosition,\n): IndexerLeaderboardParticipant {\n return {\n subaccount: subaccountFromHex(position.subaccount),\n contestId: position.contest_id,\n pnl: toBigDecimal(position.pnl),\n pnlRank: toBigDecimal(position.pnl_rank),\n percentRoi: toBigDecimal(position.roi),\n roiRank: toBigDecimal(position.roi_rank),\n accountValue: toBigDecimal(position.account_value),\n volume: position.volume ? toBigDecimal(position.volume) : undefined,\n updateTime: toBigDecimal(position.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardRegistration(\n registration: IndexerServerLeaderboardRegistration,\n): IndexerLeaderboardRegistration {\n return {\n subaccount: subaccountFromHex(registration.subaccount),\n contestId: registration.contest_id,\n updateTime: toBigDecimal(registration.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardContest(\n contest: IndexerServerLeaderboardContest,\n): IndexerLeaderboardContest {\n return {\n contestId: contest.contest_id,\n startTime: toBigDecimal(contest.start_time),\n endTime: toBigDecimal(contest.end_time),\n period: toBigDecimal(contest.threshold),\n totalParticipants: toBigDecimal(contest.count),\n minRequiredAccountValue: toBigDecimal(contest.threshold),\n minRequiredVolume: toBigDecimal(contest.volume_threshold),\n requiredProductIds: contest.product_ids,\n active: contest.active,\n lastUpdated: toBigDecimal(contest.last_updated),\n };\n}\n\nexport function mapIndexerCandlesticks(\n candlestick: IndexerServerCandlestick,\n): Candlestick {\n return {\n close: removeDecimals(candlestick.close_x18),\n high: removeDecimals(candlestick.high_x18),\n low: removeDecimals(candlestick.low_x18),\n open: removeDecimals(candlestick.open_x18),\n time: toBigDecimal(candlestick.timestamp),\n volume: toBigDecimal(candlestick.volume),\n };\n}\n\nexport function mapIndexerMarketSnapshot(\n snapshot: IndexerServerMarketSnapshot,\n): IndexerMarketSnapshot {\n return {\n timestamp: toBigDecimal(snapshot.timestamp),\n cumulativeUsers: toBigDecimal(snapshot.cumulative_users),\n dailyActiveUsers: toBigDecimal(snapshot.daily_active_users),\n tvl: toBigDecimal(snapshot.tvl),\n borrowRates: mapValues(snapshot.borrow_rates, (value) =>\n removeDecimals(value),\n ),\n cumulativeLiquidationAmounts: mapValues(\n snapshot.cumulative_liquidation_amounts,\n toBigDecimal,\n ),\n cumulativeMakerFees: mapValues(\n snapshot.cumulative_maker_fees,\n toBigDecimal,\n ),\n cumulativeSequencerFees: mapValues(\n snapshot.cumulative_sequencer_fees,\n toBigDecimal,\n ),\n cumulativeTakerFees: mapValues(\n snapshot.cumulative_taker_fees,\n toBigDecimal,\n ),\n cumulativeTrades: mapValues(snapshot.cumulative_trades, toBigDecimal),\n cumulativeVolumes: mapValues(snapshot.cumulative_volumes, toBigDecimal),\n depositRates: mapValues(snapshot.deposit_rates, (value) =>\n removeDecimals(value),\n ),\n fundingRates: mapValues(snapshot.funding_rates, (value) =>\n removeDecimals(value),\n ),\n openInterestsQuote: mapValues(snapshot.open_interests, toBigDecimal),\n totalBorrows: mapValues(snapshot.total_borrows, toBigDecimal),\n totalDeposits: mapValues(snapshot.total_deposits, toBigDecimal),\n cumulativeTradeSizes: mapValues(\n snapshot.cumulative_trade_sizes,\n toBigDecimal,\n ),\n cumulativeInflows: mapValues(snapshot.cumulative_inflows, toBigDecimal),\n cumulativeOutflows: mapValues(snapshot.cumulative_outflows, toBigDecimal),\n oraclePrices: mapValues(snapshot.oracle_prices, (value) =>\n removeDecimals(value),\n ),\n };\n}\n\nexport function mapIndexerNlpSnapshot(\n snapshot: IndexerServerNlpSnapshot,\n): IndexerNlpSnapshot {\n return {\n submissionIndex: snapshot.submission_idx,\n timestamp: toBigDecimal(snapshot.timestamp),\n cumulativeBurnAmountUsdc: toBigDecimal(snapshot.cumulative_burn_usdc),\n cumulativeMintAmountUsdc: toBigDecimal(snapshot.cumulative_mint_usdc),\n cumulativePnl: toBigDecimal(snapshot.cumulative_pnl),\n cumulativeTrades: toBigDecimal(snapshot.cumulative_trades),\n cumulativeVolume: toBigDecimal(snapshot.cumulative_volume),\n depositors: toBigDecimal(snapshot.depositors),\n oraclePrice: removeDecimals(snapshot.oracle_price_x18),\n tvl: toBigDecimal(snapshot.tvl),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAGO;AACP,oBAYO;AAsCA,SAAS,mCACd,QACgC;AAChC,SAAO;AAAA,IACL,OAAO,OAAO;AAAA,IACd,UAAU,OAAO,uBACb,+BAAgB,OAAO,gBAAgB,IACvC;AAAA,IACJ,aAAa,OAAO;AAAA,EACtB;AACF;AAEO,SAAS,wBAAwB,SAAuC;AAC7E,MAAI,UAAU,SAAS;AACrB,eAAO,iDAA2B,QAAQ,IAAI;AAAA,EAChD;AACA,aAAO,iDAA2B,QAAQ,IAAI;AAChD;AAEO,SAAS,wBACd,SACyC;AACzC,MAAI,UAAU,SAAS;AACrB,WAAO;AAAA,MACL,YAAQ,4BAAa,QAAQ,KAAK,QAAQ,MAAM;AAAA,MAChD,WAAW,QAAQ,KAAK;AAAA,MACxB,MAAM,gCAAkB;AAAA,IAC1B;AAAA,EACF;AACA,SAAO;AAAA,IACL,YAAQ,4BAAa,QAAQ,KAAK,QAAQ,MAAM;AAAA,IAChD,WAAW,QAAQ,KAAK;AAAA,IACxB,MAAM,gCAAkB;AAAA,IACxB,mBAAe,4BAAa,QAAQ,KAAK,QAAQ,eAAe;AAAA,EAClE;AACF;AAEO,SAAS,gBAAgB,OAAyC;AACvE,QAAM,eAAW,mCAAoB,MAA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AU,SAAS,gBAAgB,0BAAY;AAAA,IACnE,kBAAc,yBAAU,SAAS,eAAe,0BAAY;AAAA,IAC5D,mBAAe,yBAAU,SAAS,gBAAgB,0BAAY;AAAA,IAC9D,0BAAsB;AAAA,MACpB,SAAS;AAAA,MACT;AAAA,IACF;AAAA,IACA,uBAAmB,yBAAU,SAAS,oBAAoB,0BAAY;AAAA,IACtE,wBAAoB,yBAAU,SAAS,qBAAqB,0BAAY;AAAA,IACxE,kBAAc;AAAA,MAAU,SAAS;AAAA,MAAe,CAAC,cAC/C,8BAAe,KAAK;AAAA,IACtB;AAAA,EACF;AACF;AAEO,SAAS,sBACd,UACoB;AACpB,SAAO;AAAA,IACL,iBAAiB,SAAS;AAAA,IAC1B,eAAW,4BAAa,SAAS,SAAS;AAAA,IAC1C,8BAA0B,4BAAa,SAAS,oBAAoB;AAAA,IACpE,8BAA0B,4BAAa,SAAS,oBAAoB;AAAA,IACpE,mBAAe,4BAAa,SAAS,cAAc;AAAA,IACnD,sBAAkB,4BAAa,SAAS,iBAAiB;AAAA,IACzD,sBAAkB,4BAAa,SAAS,iBAAiB;AAAA,IACzD,gBAAY,4BAAa,SAAS,UAAU;AAAA,IAC5C,iBAAa,8BAAe,SAAS,gBAAgB;AAAA,IACrD,SAAK,4BAAa,SAAS,GAAG;AAAA,EAChC;AACF;","names":[]}
@@ -46,7 +46,6 @@ function mapIndexerOrder(order) {
46
46
  return {
47
47
  amount: toBigDecimal(order.amount),
48
48
  digest: order.digest,
49
- isolated: order.isolated,
50
49
  expiration: Number(order.expiration),
51
50
  appendix,
52
51
  nonce: toBigDecimal(order.nonce),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dataMappers.ts"],"sourcesContent":["import {\n mapEngineServerPerpProduct,\n mapEngineServerSpotProduct,\n} from '@nadohq/engine-client';\nimport {\n getRecvTimeFromOrderNonce,\n mapValues,\n Market,\n PerpMarket,\n ProductEngineType,\n removeDecimals,\n SpotMarket,\n subaccountFromHex,\n toBigDecimal,\n toIntegerString,\n unpackOrderAppendix,\n} from '@nadohq/shared';\nimport {\n Candlestick,\n IndexerEvent,\n IndexerEventWithTx,\n IndexerFundingRate,\n IndexerLeaderboardContest,\n IndexerLeaderboardParticipant,\n IndexerLeaderboardRegistration,\n IndexerMaker,\n IndexerMarketSnapshot,\n IndexerMatchEventBalances,\n IndexerNlpSnapshot,\n IndexerOrder,\n IndexerPerpBalance,\n IndexerPerpPrices,\n IndexerProductPayment,\n IndexerServerBalance,\n IndexerServerCandlestick,\n IndexerServerEvent,\n IndexerServerFundingRate,\n IndexerServerLeaderboardContest,\n IndexerServerLeaderboardPosition,\n IndexerServerLeaderboardRegistration,\n IndexerServerMaker,\n IndexerServerMarketSnapshot,\n IndexerServerMatchEventBalances,\n IndexerServerNlpSnapshot,\n IndexerServerOrder,\n IndexerServerPerpPrices,\n IndexerServerProduct,\n IndexerServerProductPayment,\n IndexerServerSnapshotsInterval,\n IndexerServerTx,\n IndexerSnapshotsIntervalParams,\n IndexerSpotBalance,\n} from './types';\n\nexport function mapSnapshotsIntervalToServerParams(\n params: IndexerSnapshotsIntervalParams,\n): IndexerServerSnapshotsInterval {\n return {\n count: params.limit,\n max_time: params.maxTimeInclusive\n ? toIntegerString(params.maxTimeInclusive)\n : undefined,\n granularity: params.granularity,\n };\n}\n\nexport function mapIndexerServerProduct(product: IndexerServerProduct): Market {\n if ('spot' in product) {\n return mapEngineServerSpotProduct(product.spot);\n }\n return mapEngineServerPerpProduct(product.perp);\n}\n\nexport function mapIndexerServerBalance(\n balance: IndexerServerBalance,\n): IndexerSpotBalance | IndexerPerpBalance {\n if ('spot' in balance) {\n return {\n amount: toBigDecimal(balance.spot.balance.amount),\n productId: balance.spot.product_id,\n type: ProductEngineType.SPOT,\n };\n }\n return {\n amount: toBigDecimal(balance.perp.balance.amount),\n productId: balance.perp.product_id,\n type: ProductEngineType.PERP,\n vQuoteBalance: toBigDecimal(balance.perp.balance.v_quote_balance),\n };\n}\n\nexport function mapIndexerOrder(order: IndexerServerOrder): IndexerOrder {\n const appendix = unpackOrderAppendix(order.appendix);\n return {\n amount: toBigDecimal(order.amount),\n digest: order.digest,\n isolated: order.isolated,\n expiration: Number(order.expiration),\n appendix,\n nonce: toBigDecimal(order.nonce),\n recvTimeSeconds: getRecvTimeFromOrderNonce(order.nonce) / 1000,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccount: order.subaccount,\n submissionIndex: order.submission_idx,\n baseFilled: toBigDecimal(order.base_filled),\n quoteFilled: toBigDecimal(order.quote_filled),\n totalFee: toBigDecimal(order.fee),\n };\n}\n\nexport function mapIndexerEvent(event: IndexerServerEvent): IndexerEvent {\n const eventState: IndexerEvent['state'] = (() => {\n // Assume backend data is consistent\n if ('spot' in event.pre_balance) {\n return {\n type: ProductEngineType.SPOT,\n market: mapIndexerServerProduct(event.product) as SpotMarket,\n preBalance: mapIndexerServerBalance(\n event.pre_balance,\n ) as IndexerSpotBalance,\n postBalance: mapIndexerServerBalance(\n event.post_balance,\n ) as IndexerSpotBalance,\n };\n }\n return {\n type: ProductEngineType.PERP,\n market: mapIndexerServerProduct(event.product) as PerpMarket,\n preBalance: mapIndexerServerBalance(\n event.pre_balance,\n ) as IndexerPerpBalance,\n postBalance: mapIndexerServerBalance(\n event.post_balance,\n ) as IndexerPerpBalance,\n };\n })();\n\n return {\n eventType: event.event_type,\n productId: event.product_id,\n isolated: event.isolated,\n isolatedProductId: event.isolated_product_id,\n state: eventState,\n subaccount: event.subaccount,\n submissionIndex: event.submission_idx,\n trackedVars: {\n netEntryCumulative: toBigDecimal(event.net_entry_cumulative),\n netEntryUnrealized: toBigDecimal(event.net_entry_unrealized),\n netFundingCumulative: toBigDecimal(event.net_funding_cumulative),\n netFundingUnrealized: toBigDecimal(event.net_funding_unrealized),\n netInterestCumulative: toBigDecimal(event.net_interest_cumulative),\n netInterestUnrealized: toBigDecimal(event.net_interest_unrealized),\n },\n };\n}\n\nexport function mapIndexerEventWithTx(\n event: IndexerServerEvent,\n tx: IndexerServerTx,\n): IndexerEventWithTx {\n return {\n timestamp: toBigDecimal(tx.timestamp),\n tx: tx.tx,\n ...mapIndexerEvent(event),\n };\n}\n\nexport function mapIndexerMatchEventBalances(\n eventBalances: IndexerServerMatchEventBalances,\n): IndexerMatchEventBalances {\n return {\n base: mapIndexerServerBalance(eventBalances.base),\n quote: eventBalances.quote\n ? (mapIndexerServerBalance(eventBalances.quote) as IndexerSpotBalance)\n : undefined,\n };\n}\n\nexport function mapIndexerProductPayment(\n payment: IndexerServerProductPayment,\n): IndexerProductPayment {\n return {\n submissionIndex: payment.idx,\n timestamp: toBigDecimal(payment.timestamp),\n paymentAmount: toBigDecimal(payment.amount),\n balanceAmount: toBigDecimal(payment.balance_amount),\n annualPaymentRate: removeDecimals(payment.rate_x18),\n oraclePrice: removeDecimals(payment.oracle_price_x18),\n isolated: payment.isolated,\n productId: payment.product_id,\n isolatedProductId: payment.isolated_product_id,\n };\n}\n\nexport function mapIndexerPerpPrices(\n perpPrices: IndexerServerPerpPrices,\n): IndexerPerpPrices {\n return {\n indexPrice: removeDecimals(perpPrices.index_price_x18),\n markPrice: removeDecimals(perpPrices.mark_price_x18),\n updateTime: toBigDecimal(perpPrices.update_time),\n productId: perpPrices.product_id,\n };\n}\n\nexport function mapIndexerFundingRate(\n fundingRate: IndexerServerFundingRate,\n): IndexerFundingRate {\n return {\n fundingRate: removeDecimals(fundingRate.funding_rate_x18),\n updateTime: toBigDecimal(fundingRate.update_time),\n productId: fundingRate.product_id,\n };\n}\n\nexport function mapIndexerMakerStatistics(\n maker: IndexerServerMaker,\n): IndexerMaker {\n return {\n address: maker.address,\n snapshots: maker.data.map((makerData) => {\n return {\n timestamp: toBigDecimal(makerData.timestamp),\n makerFee: toBigDecimal(makerData.maker_fee),\n uptime: toBigDecimal(makerData.uptime),\n sumQMin: toBigDecimal(makerData.sum_q_min),\n qScore: toBigDecimal(makerData.q_score),\n makerShare: toBigDecimal(makerData.maker_share),\n expectedMakerReward: toBigDecimal(makerData.expected_maker_reward),\n };\n }),\n };\n}\n\nexport function mapIndexerLeaderboardPosition(\n position: IndexerServerLeaderboardPosition,\n): IndexerLeaderboardParticipant {\n return {\n subaccount: subaccountFromHex(position.subaccount),\n contestId: position.contest_id,\n pnl: toBigDecimal(position.pnl),\n pnlRank: toBigDecimal(position.pnl_rank),\n percentRoi: toBigDecimal(position.roi),\n roiRank: toBigDecimal(position.roi_rank),\n accountValue: toBigDecimal(position.account_value),\n volume: position.volume ? toBigDecimal(position.volume) : undefined,\n updateTime: toBigDecimal(position.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardRegistration(\n registration: IndexerServerLeaderboardRegistration,\n): IndexerLeaderboardRegistration {\n return {\n subaccount: subaccountFromHex(registration.subaccount),\n contestId: registration.contest_id,\n updateTime: toBigDecimal(registration.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardContest(\n contest: IndexerServerLeaderboardContest,\n): IndexerLeaderboardContest {\n return {\n contestId: contest.contest_id,\n startTime: toBigDecimal(contest.start_time),\n endTime: toBigDecimal(contest.end_time),\n period: toBigDecimal(contest.threshold),\n totalParticipants: toBigDecimal(contest.count),\n minRequiredAccountValue: toBigDecimal(contest.threshold),\n minRequiredVolume: toBigDecimal(contest.volume_threshold),\n requiredProductIds: contest.product_ids,\n active: contest.active,\n lastUpdated: toBigDecimal(contest.last_updated),\n };\n}\n\nexport function mapIndexerCandlesticks(\n candlestick: IndexerServerCandlestick,\n): Candlestick {\n return {\n close: removeDecimals(candlestick.close_x18),\n high: removeDecimals(candlestick.high_x18),\n low: removeDecimals(candlestick.low_x18),\n open: removeDecimals(candlestick.open_x18),\n time: toBigDecimal(candlestick.timestamp),\n volume: toBigDecimal(candlestick.volume),\n };\n}\n\nexport function mapIndexerMarketSnapshot(\n snapshot: IndexerServerMarketSnapshot,\n): IndexerMarketSnapshot {\n return {\n timestamp: toBigDecimal(snapshot.timestamp),\n cumulativeUsers: toBigDecimal(snapshot.cumulative_users),\n dailyActiveUsers: toBigDecimal(snapshot.daily_active_users),\n tvl: toBigDecimal(snapshot.tvl),\n borrowRates: mapValues(snapshot.borrow_rates, (value) =>\n removeDecimals(value),\n ),\n cumulativeLiquidationAmounts: mapValues(\n snapshot.cumulative_liquidation_amounts,\n toBigDecimal,\n ),\n cumulativeMakerFees: mapValues(\n snapshot.cumulative_maker_fees,\n toBigDecimal,\n ),\n cumulativeSequencerFees: mapValues(\n snapshot.cumulative_sequencer_fees,\n toBigDecimal,\n ),\n cumulativeTakerFees: mapValues(\n snapshot.cumulative_taker_fees,\n toBigDecimal,\n ),\n cumulativeTrades: mapValues(snapshot.cumulative_trades, toBigDecimal),\n cumulativeVolumes: mapValues(snapshot.cumulative_volumes, toBigDecimal),\n depositRates: mapValues(snapshot.deposit_rates, (value) =>\n removeDecimals(value),\n ),\n fundingRates: mapValues(snapshot.funding_rates, (value) =>\n removeDecimals(value),\n ),\n openInterestsQuote: mapValues(snapshot.open_interests, toBigDecimal),\n totalBorrows: mapValues(snapshot.total_borrows, toBigDecimal),\n totalDeposits: mapValues(snapshot.total_deposits, toBigDecimal),\n cumulativeTradeSizes: mapValues(\n snapshot.cumulative_trade_sizes,\n toBigDecimal,\n ),\n cumulativeInflows: mapValues(snapshot.cumulative_inflows, toBigDecimal),\n cumulativeOutflows: mapValues(snapshot.cumulative_outflows, toBigDecimal),\n oraclePrices: mapValues(snapshot.oracle_prices, (value) =>\n removeDecimals(value),\n ),\n };\n}\n\nexport function mapIndexerNlpSnapshot(\n snapshot: IndexerServerNlpSnapshot,\n): IndexerNlpSnapshot {\n return {\n submissionIndex: snapshot.submission_idx,\n timestamp: toBigDecimal(snapshot.timestamp),\n cumulativeBurnAmountUsdc: toBigDecimal(snapshot.cumulative_burn_usdc),\n cumulativeMintAmountUsdc: toBigDecimal(snapshot.cumulative_mint_usdc),\n cumulativePnl: toBigDecimal(snapshot.cumulative_pnl),\n cumulativeTrades: toBigDecimal(snapshot.cumulative_trades),\n cumulativeVolume: toBigDecimal(snapshot.cumulative_volume),\n depositors: toBigDecimal(snapshot.depositors),\n oraclePrice: removeDecimals(snapshot.oracle_price_x18),\n tvl: toBigDecimal(snapshot.tvl),\n };\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAsCA,SAAS,mCACd,QACgC;AAChC,SAAO;AAAA,IACL,OAAO,OAAO;AAAA,IACd,UAAU,OAAO,mBACb,gBAAgB,OAAO,gBAAgB,IACvC;AAAA,IACJ,aAAa,OAAO;AAAA,EACtB;AACF;AAEO,SAAS,wBAAwB,SAAuC;AAC7E,MAAI,UAAU,SAAS;AACrB,WAAO,2BAA2B,QAAQ,IAAI;AAAA,EAChD;AACA,SAAO,2BAA2B,QAAQ,IAAI;AAChD;AAEO,SAAS,wBACd,SACyC;AACzC,MAAI,UAAU,SAAS;AACrB,WAAO;AAAA,MACL,QAAQ,aAAa,QAAQ,KAAK,QAAQ,MAAM;AAAA,MAChD,WAAW,QAAQ,KAAK;AAAA,MACxB,MAAM,kBAAkB;AAAA,IAC1B;AAAA,EACF;AACA,SAAO;AAAA,IACL,QAAQ,aAAa,QAAQ,KAAK,QAAQ,MAAM;AAAA,IAChD,WAAW,QAAQ,KAAK;AAAA,IACxB,MAAM,kBAAkB;AAAA,IACxB,eAAe,aAAa,QAAQ,KAAK,QAAQ,eAAe;AAAA,EAClE;AACF;AAEO,SAAS,gBAAgB,OAAyC;AACvE,QAAM,WAAW,oBAAoB,MAAM,QAAQ;AACnD,SAAO;AAAA,IACL,QAAQ,aAAa,MAAM,MAAM;AAAA,IACjC,QAAQ,MAAM;AAAA,IACd,UAAU,MAAM;AAAA,IAChB,YAAY,OAAO,MAAM,UAAU;AAAA,IACnC;AAAA,IACA,OAAO,aAAa,MAAM,KAAK;AAAA,IAC/B,iBAAiB,0BAA0B,MAAM,KAAK,IAAI;A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CAAC,UAC/C,eAAe,KAAK;AAAA,IACtB;AAAA,EACF;AACF;AAEO,SAAS,sBACd,UACoB;AACpB,SAAO;AAAA,IACL,iBAAiB,SAAS;AAAA,IAC1B,WAAW,aAAa,SAAS,SAAS;AAAA,IAC1C,0BAA0B,aAAa,SAAS,oBAAoB;AAAA,IACpE,0BAA0B,aAAa,SAAS,oBAAoB;AAAA,IACpE,eAAe,aAAa,SAAS,cAAc;AAAA,IACnD,kBAAkB,aAAa,SAAS,iBAAiB;AAAA,IACzD,kBAAkB,aAAa,SAAS,iBAAiB;AAAA,IACzD,YAAY,aAAa,SAAS,UAAU;AAAA,IAC5C,aAAa,eAAe,SAAS,gBAAgB;AAAA,IACrD,KAAK,aAAa,SAAS,GAAG;AAAA,EAChC;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/dataMappers.ts"],"sourcesContent":["import {\n mapEngineServerPerpProduct,\n mapEngineServerSpotProduct,\n} from '@nadohq/engine-client';\nimport {\n getRecvTimeFromOrderNonce,\n mapValues,\n Market,\n PerpMarket,\n ProductEngineType,\n removeDecimals,\n SpotMarket,\n subaccountFromHex,\n toBigDecimal,\n toIntegerString,\n unpackOrderAppendix,\n} from '@nadohq/shared';\nimport {\n Candlestick,\n IndexerEvent,\n IndexerEventWithTx,\n IndexerFundingRate,\n IndexerLeaderboardContest,\n IndexerLeaderboardParticipant,\n IndexerLeaderboardRegistration,\n IndexerMaker,\n IndexerMarketSnapshot,\n IndexerMatchEventBalances,\n IndexerNlpSnapshot,\n IndexerOrder,\n IndexerPerpBalance,\n IndexerPerpPrices,\n IndexerProductPayment,\n IndexerServerBalance,\n IndexerServerCandlestick,\n IndexerServerEvent,\n IndexerServerFundingRate,\n IndexerServerLeaderboardContest,\n IndexerServerLeaderboardPosition,\n IndexerServerLeaderboardRegistration,\n IndexerServerMaker,\n IndexerServerMarketSnapshot,\n IndexerServerMatchEventBalances,\n IndexerServerNlpSnapshot,\n IndexerServerOrder,\n IndexerServerPerpPrices,\n IndexerServerProduct,\n IndexerServerProductPayment,\n IndexerServerSnapshotsInterval,\n IndexerServerTx,\n IndexerSnapshotsIntervalParams,\n IndexerSpotBalance,\n} from './types';\n\nexport function mapSnapshotsIntervalToServerParams(\n params: IndexerSnapshotsIntervalParams,\n): IndexerServerSnapshotsInterval {\n return {\n count: params.limit,\n max_time: params.maxTimeInclusive\n ? toIntegerString(params.maxTimeInclusive)\n : undefined,\n granularity: params.granularity,\n };\n}\n\nexport function mapIndexerServerProduct(product: IndexerServerProduct): Market {\n if ('spot' in product) {\n return mapEngineServerSpotProduct(product.spot);\n }\n return mapEngineServerPerpProduct(product.perp);\n}\n\nexport function mapIndexerServerBalance(\n balance: IndexerServerBalance,\n): IndexerSpotBalance | IndexerPerpBalance {\n if ('spot' in balance) {\n return {\n amount: toBigDecimal(balance.spot.balance.amount),\n productId: balance.spot.product_id,\n type: ProductEngineType.SPOT,\n };\n }\n return {\n amount: toBigDecimal(balance.perp.balance.amount),\n productId: balance.perp.product_id,\n type: ProductEngineType.PERP,\n vQuoteBalance: toBigDecimal(balance.perp.balance.v_quote_balance),\n };\n}\n\nexport function mapIndexerOrder(order: IndexerServerOrder): IndexerOrder {\n const appendix = unpackOrderAppendix(order.appendix);\n return {\n amount: toBigDecimal(order.amount),\n digest: order.digest,\n expiration: Number(order.expiration),\n appendix,\n nonce: toBigDecimal(order.nonce),\n recvTimeSeconds: getRecvTimeFromOrderNonce(order.nonce) / 1000,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccount: order.subaccount,\n submissionIndex: order.submission_idx,\n baseFilled: toBigDecimal(order.base_filled),\n quoteFilled: toBigDecimal(order.quote_filled),\n totalFee: toBigDecimal(order.fee),\n };\n}\n\nexport function mapIndexerEvent(event: IndexerServerEvent): IndexerEvent {\n const eventState: IndexerEvent['state'] = (() => {\n // Assume backend data is consistent\n if ('spot' in event.pre_balance) {\n return {\n type: ProductEngineType.SPOT,\n market: mapIndexerServerProduct(event.product) as SpotMarket,\n preBalance: mapIndexerServerBalance(\n event.pre_balance,\n ) as IndexerSpotBalance,\n postBalance: mapIndexerServerBalance(\n event.post_balance,\n ) as IndexerSpotBalance,\n };\n }\n return {\n type: ProductEngineType.PERP,\n market: mapIndexerServerProduct(event.product) as PerpMarket,\n preBalance: mapIndexerServerBalance(\n event.pre_balance,\n ) as IndexerPerpBalance,\n postBalance: mapIndexerServerBalance(\n event.post_balance,\n ) as IndexerPerpBalance,\n };\n })();\n\n return {\n eventType: event.event_type,\n productId: event.product_id,\n isolated: event.isolated,\n isolatedProductId: event.isolated_product_id,\n state: eventState,\n subaccount: event.subaccount,\n submissionIndex: event.submission_idx,\n trackedVars: {\n netEntryCumulative: toBigDecimal(event.net_entry_cumulative),\n netEntryUnrealized: toBigDecimal(event.net_entry_unrealized),\n netFundingCumulative: toBigDecimal(event.net_funding_cumulative),\n netFundingUnrealized: toBigDecimal(event.net_funding_unrealized),\n netInterestCumulative: toBigDecimal(event.net_interest_cumulative),\n netInterestUnrealized: toBigDecimal(event.net_interest_unrealized),\n },\n };\n}\n\nexport function mapIndexerEventWithTx(\n event: IndexerServerEvent,\n tx: IndexerServerTx,\n): IndexerEventWithTx {\n return {\n timestamp: toBigDecimal(tx.timestamp),\n tx: tx.tx,\n ...mapIndexerEvent(event),\n };\n}\n\nexport function mapIndexerMatchEventBalances(\n eventBalances: IndexerServerMatchEventBalances,\n): IndexerMatchEventBalances {\n return {\n base: mapIndexerServerBalance(eventBalances.base),\n quote: eventBalances.quote\n ? (mapIndexerServerBalance(eventBalances.quote) as IndexerSpotBalance)\n : undefined,\n };\n}\n\nexport function mapIndexerProductPayment(\n payment: IndexerServerProductPayment,\n): IndexerProductPayment {\n return {\n submissionIndex: payment.idx,\n timestamp: toBigDecimal(payment.timestamp),\n paymentAmount: toBigDecimal(payment.amount),\n balanceAmount: toBigDecimal(payment.balance_amount),\n annualPaymentRate: removeDecimals(payment.rate_x18),\n oraclePrice: removeDecimals(payment.oracle_price_x18),\n isolated: payment.isolated,\n productId: payment.product_id,\n isolatedProductId: payment.isolated_product_id,\n };\n}\n\nexport function mapIndexerPerpPrices(\n perpPrices: IndexerServerPerpPrices,\n): IndexerPerpPrices {\n return {\n indexPrice: removeDecimals(perpPrices.index_price_x18),\n markPrice: removeDecimals(perpPrices.mark_price_x18),\n updateTime: toBigDecimal(perpPrices.update_time),\n productId: perpPrices.product_id,\n };\n}\n\nexport function mapIndexerFundingRate(\n fundingRate: IndexerServerFundingRate,\n): IndexerFundingRate {\n return {\n fundingRate: removeDecimals(fundingRate.funding_rate_x18),\n updateTime: toBigDecimal(fundingRate.update_time),\n productId: fundingRate.product_id,\n };\n}\n\nexport function mapIndexerMakerStatistics(\n maker: IndexerServerMaker,\n): IndexerMaker {\n return {\n address: maker.address,\n snapshots: maker.data.map((makerData) => {\n return {\n timestamp: toBigDecimal(makerData.timestamp),\n makerFee: toBigDecimal(makerData.maker_fee),\n uptime: toBigDecimal(makerData.uptime),\n sumQMin: toBigDecimal(makerData.sum_q_min),\n qScore: toBigDecimal(makerData.q_score),\n makerShare: toBigDecimal(makerData.maker_share),\n expectedMakerReward: toBigDecimal(makerData.expected_maker_reward),\n };\n }),\n };\n}\n\nexport function mapIndexerLeaderboardPosition(\n position: IndexerServerLeaderboardPosition,\n): IndexerLeaderboardParticipant {\n return {\n subaccount: subaccountFromHex(position.subaccount),\n contestId: position.contest_id,\n pnl: toBigDecimal(position.pnl),\n pnlRank: toBigDecimal(position.pnl_rank),\n percentRoi: toBigDecimal(position.roi),\n roiRank: toBigDecimal(position.roi_rank),\n accountValue: toBigDecimal(position.account_value),\n volume: position.volume ? toBigDecimal(position.volume) : undefined,\n updateTime: toBigDecimal(position.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardRegistration(\n registration: IndexerServerLeaderboardRegistration,\n): IndexerLeaderboardRegistration {\n return {\n subaccount: subaccountFromHex(registration.subaccount),\n contestId: registration.contest_id,\n updateTime: toBigDecimal(registration.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardContest(\n contest: IndexerServerLeaderboardContest,\n): IndexerLeaderboardContest {\n return {\n contestId: contest.contest_id,\n startTime: toBigDecimal(contest.start_time),\n endTime: toBigDecimal(contest.end_time),\n period: toBigDecimal(contest.threshold),\n totalParticipants: toBigDecimal(contest.count),\n minRequiredAccountValue: toBigDecimal(contest.threshold),\n minRequiredVolume: toBigDecimal(contest.volume_threshold),\n requiredProductIds: contest.product_ids,\n active: contest.active,\n lastUpdated: toBigDecimal(contest.last_updated),\n };\n}\n\nexport function mapIndexerCandlesticks(\n candlestick: IndexerServerCandlestick,\n): Candlestick {\n return {\n close: removeDecimals(candlestick.close_x18),\n high: removeDecimals(candlestick.high_x18),\n low: removeDecimals(candlestick.low_x18),\n open: removeDecimals(candlestick.open_x18),\n time: toBigDecimal(candlestick.timestamp),\n volume: toBigDecimal(candlestick.volume),\n };\n}\n\nexport function mapIndexerMarketSnapshot(\n snapshot: IndexerServerMarketSnapshot,\n): IndexerMarketSnapshot {\n return {\n timestamp: toBigDecimal(snapshot.timestamp),\n cumulativeUsers: toBigDecimal(snapshot.cumulative_users),\n dailyActiveUsers: toBigDecimal(snapshot.daily_active_users),\n tvl: toBigDecimal(snapshot.tvl),\n borrowRates: mapValues(snapshot.borrow_rates, (value) =>\n removeDecimals(value),\n ),\n cumulativeLiquidationAmounts: mapValues(\n snapshot.cumulative_liquidation_amounts,\n toBigDecimal,\n ),\n cumulativeMakerFees: mapValues(\n snapshot.cumulative_maker_fees,\n toBigDecimal,\n ),\n cumulativeSequencerFees: mapValues(\n snapshot.cumulative_sequencer_fees,\n toBigDecimal,\n ),\n cumulativeTakerFees: mapValues(\n snapshot.cumulative_taker_fees,\n toBigDecimal,\n ),\n cumulativeTrades: mapValues(snapshot.cumulative_trades, toBigDecimal),\n cumulativeVolumes: mapValues(snapshot.cumulative_volumes, toBigDecimal),\n depositRates: mapValues(snapshot.deposit_rates, (value) =>\n removeDecimals(value),\n ),\n fundingRates: mapValues(snapshot.funding_rates, (value) =>\n removeDecimals(value),\n ),\n openInterestsQuote: mapValues(snapshot.open_interests, toBigDecimal),\n totalBorrows: mapValues(snapshot.total_borrows, toBigDecimal),\n totalDeposits: mapValues(snapshot.total_deposits, toBigDecimal),\n cumulativeTradeSizes: mapValues(\n snapshot.cumulative_trade_sizes,\n toBigDecimal,\n ),\n cumulativeInflows: mapValues(snapshot.cumulative_inflows, toBigDecimal),\n cumulativeOutflows: mapValues(snapshot.cumulative_outflows, toBigDecimal),\n oraclePrices: mapValues(snapshot.oracle_prices, (value) =>\n removeDecimals(value),\n ),\n };\n}\n\nexport function mapIndexerNlpSnapshot(\n snapshot: IndexerServerNlpSnapshot,\n): IndexerNlpSnapshot {\n return {\n submissionIndex: snapshot.submission_idx,\n timestamp: toBigDecimal(snapshot.timestamp),\n cumulativeBurnAmountUsdc: toBigDecimal(snapshot.cumulative_burn_usdc),\n cumulativeMintAmountUsdc: toBigDecimal(snapshot.cumulative_mint_usdc),\n cumulativePnl: toBigDecimal(snapshot.cumulative_pnl),\n cumulativeTrades: toBigDecimal(snapshot.cumulative_trades),\n cumulativeVolume: toBigDecimal(snapshot.cumulative_volume),\n depositors: toBigDecimal(snapshot.depositors),\n oraclePrice: removeDecimals(snapshot.oracle_price_x18),\n tvl: toBigDecimal(snapshot.tvl),\n };\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAsCA,SAAS,mCACd,QACgC;AAChC,SAAO;AAAA,IACL,OAAO,OAAO;AAAA,IACd,UAAU,OAAO,mBACb,gBAAgB,OAAO,gBAAgB,IACvC;AAAA,IACJ,aAAa,OAAO;AAAA,EACtB;AACF;AAEO,SAAS,wBAAwB,SAAuC;AAC7E,MAAI,UAAU,SAAS;AACrB,WAAO,2BAA2B,QAAQ,IAAI;AAAA,EAChD;AACA,SAAO,2BAA2B,QAAQ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EIP712OrderValues,\n Market,\n OrderAppendix,\n PerpBalance,\n PerpMarket,\n ProductEngineType,\n SpotBalance,\n SpotMarket,\n Subaccount,\n} from '@nadohq/shared';\nimport { 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} 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}\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 // 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 isolated: boolean;\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 cumulativeMintAmountUsdc: BigDecimal;\n cumulativeBurnAmountUsdc: 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: string;\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} 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}\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 // 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 cumulativeMintAmountUsdc: BigDecimal;\n cumulativeBurnAmountUsdc: 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"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import { Subaccount, BigDecimal, ProductEngineType, SpotBalance, SpotMarket, PerpBalance, PerpMarket, Market, OrderAppendix, EIP712OrderValues } from '@nadohq/shared';
2
- import { Hex } from 'viem';
2
+ import { Hex, Address } from 'viem';
3
3
  import { CandlestickPeriod } from './CandlestickPeriod.cjs';
4
4
  import { IndexerEventType } from './IndexerEventType.cjs';
5
5
  import { IndexerLeaderboardRankType } from './IndexerLeaderboardType.cjs';
@@ -231,7 +231,6 @@ interface GetIndexerOrdersParams {
231
231
  interface IndexerOrder {
232
232
  digest: string;
233
233
  subaccount: string;
234
- isolated: boolean;
235
234
  productId: number;
236
235
  submissionIndex: string;
237
236
  amount: BigDecimal;
@@ -464,7 +463,7 @@ interface GetIndexerSubaccountDDAParams {
464
463
  subaccount: Subaccount;
465
464
  }
466
465
  interface GetIndexerSubaccountDDAResponse {
467
- address: string;
466
+ address: Address;
468
467
  }
469
468
 
470
469
  export type { Candlestick, GetIndexerBacklogResponse, GetIndexerCandlesticksParams, GetIndexerCandlesticksResponse, GetIndexerEdgeCandlesticksParams, GetIndexerEdgeCandlesticksResponse, GetIndexerEdgeMarketSnapshotResponse, GetIndexerEdgeMarketSnapshotsParams, GetIndexerEventsLimitType, GetIndexerEventsParams, GetIndexerEventsResponse, GetIndexerFastWithdrawalSignatureParams, GetIndexerFastWithdrawalSignatureResponse, GetIndexerFundingRateParams, GetIndexerFundingRateResponse, GetIndexerInterestFundingPaymentsParams, GetIndexerInterestFundingPaymentsResponse, GetIndexerLeaderboardContestsParams, GetIndexerLeaderboardContestsResponse, GetIndexerLeaderboardParams, GetIndexerLeaderboardParticipantParams, GetIndexerLeaderboardParticipantResponse, GetIndexerLeaderboardRegistrationParams, GetIndexerLeaderboardRegistrationResponse, GetIndexerLeaderboardResponse, GetIndexerLinkedSignerParams, GetIndexerLinkedSignerResponse, GetIndexerMakerStatisticsParams, GetIndexerMakerStatisticsResponse, GetIndexerMarketSnapshotsParams, GetIndexerMarketSnapshotsResponse, GetIndexerMatchEventsParams, GetIndexerMatchEventsResponse, GetIndexerMultiProductFundingRatesParams, GetIndexerMultiProductFundingRatesResponse, GetIndexerMultiProductPerpPricesParams, GetIndexerMultiProductPerpPricesResponse, GetIndexerMultiProductSnapshotsParams, GetIndexerMultiProductSnapshotsResponse, GetIndexerMultiSubaccountSnapshotsParams, GetIndexerMultiSubaccountSnapshotsResponse, GetIndexerNlpSnapshotsParams, GetIndexerNlpSnapshotsResponse, GetIndexerOraclePricesParams, GetIndexerOraclePricesResponse, GetIndexerOrdersParams, GetIndexerOrdersResponse, GetIndexerPerpPricesParams, GetIndexerPerpPricesResponse, GetIndexerProductSnapshotsParams, GetIndexerProductSnapshotsResponse, GetIndexerQuotePriceResponse, GetIndexerReferralCodeParams, GetIndexerReferralCodeResponse, GetIndexerSubaccountDDAParams, GetIndexerSubaccountDDAResponse, IndexerBalanceTrackedVars, IndexerEvent, IndexerEventBalanceStateSnapshot, IndexerEventPerpStateSnapshot, IndexerEventSpotStateSnapshot, IndexerEventWithTx, IndexerFundingRate, IndexerLeaderboardContest, IndexerLeaderboardParticipant, IndexerLeaderboardRegistration, IndexerMaker, IndexerMakerSnapshot, IndexerMarketSnapshot, IndexerMatchEvent, IndexerMatchEventBalances, IndexerNlpSnapshot, IndexerOraclePrice, IndexerOrder, IndexerPerpBalance, IndexerPerpPrices, IndexerProductPayment, IndexerProductSnapshot, IndexerSnapshotBalance, IndexerSnapshotsIntervalParams, IndexerSpotBalance, IndexerSubaccountSnapshot, ListIndexerSubaccountsParams, ListIndexerSubaccountsResponse, UpdateIndexerLeaderboardRegistrationParams, UpdateIndexerLeaderboardRegistrationResponse };
@@ -1,5 +1,5 @@
1
1
  import { Subaccount, BigDecimal, ProductEngineType, SpotBalance, SpotMarket, PerpBalance, PerpMarket, Market, OrderAppendix, EIP712OrderValues } from '@nadohq/shared';
2
- import { Hex } from 'viem';
2
+ import { Hex, Address } from 'viem';
3
3
  import { CandlestickPeriod } from './CandlestickPeriod.js';
4
4
  import { IndexerEventType } from './IndexerEventType.js';
5
5
  import { IndexerLeaderboardRankType } from './IndexerLeaderboardType.js';
@@ -231,7 +231,6 @@ interface GetIndexerOrdersParams {
231
231
  interface IndexerOrder {
232
232
  digest: string;
233
233
  subaccount: string;
234
- isolated: boolean;
235
234
  productId: number;
236
235
  submissionIndex: string;
237
236
  amount: BigDecimal;
@@ -464,7 +463,7 @@ interface GetIndexerSubaccountDDAParams {
464
463
  subaccount: Subaccount;
465
464
  }
466
465
  interface GetIndexerSubaccountDDAResponse {
467
- address: string;
466
+ address: Address;
468
467
  }
469
468
 
470
469
  export type { Candlestick, GetIndexerBacklogResponse, GetIndexerCandlesticksParams, GetIndexerCandlesticksResponse, GetIndexerEdgeCandlesticksParams, GetIndexerEdgeCandlesticksResponse, GetIndexerEdgeMarketSnapshotResponse, GetIndexerEdgeMarketSnapshotsParams, GetIndexerEventsLimitType, GetIndexerEventsParams, GetIndexerEventsResponse, GetIndexerFastWithdrawalSignatureParams, GetIndexerFastWithdrawalSignatureResponse, GetIndexerFundingRateParams, GetIndexerFundingRateResponse, GetIndexerInterestFundingPaymentsParams, GetIndexerInterestFundingPaymentsResponse, GetIndexerLeaderboardContestsParams, GetIndexerLeaderboardContestsResponse, GetIndexerLeaderboardParams, GetIndexerLeaderboardParticipantParams, GetIndexerLeaderboardParticipantResponse, GetIndexerLeaderboardRegistrationParams, GetIndexerLeaderboardRegistrationResponse, GetIndexerLeaderboardResponse, GetIndexerLinkedSignerParams, GetIndexerLinkedSignerResponse, GetIndexerMakerStatisticsParams, GetIndexerMakerStatisticsResponse, GetIndexerMarketSnapshotsParams, GetIndexerMarketSnapshotsResponse, GetIndexerMatchEventsParams, GetIndexerMatchEventsResponse, GetIndexerMultiProductFundingRatesParams, GetIndexerMultiProductFundingRatesResponse, GetIndexerMultiProductPerpPricesParams, GetIndexerMultiProductPerpPricesResponse, GetIndexerMultiProductSnapshotsParams, GetIndexerMultiProductSnapshotsResponse, GetIndexerMultiSubaccountSnapshotsParams, GetIndexerMultiSubaccountSnapshotsResponse, GetIndexerNlpSnapshotsParams, GetIndexerNlpSnapshotsResponse, GetIndexerOraclePricesParams, GetIndexerOraclePricesResponse, GetIndexerOrdersParams, GetIndexerOrdersResponse, GetIndexerPerpPricesParams, GetIndexerPerpPricesResponse, GetIndexerProductSnapshotsParams, GetIndexerProductSnapshotsResponse, GetIndexerQuotePriceResponse, GetIndexerReferralCodeParams, GetIndexerReferralCodeResponse, GetIndexerSubaccountDDAParams, GetIndexerSubaccountDDAResponse, IndexerBalanceTrackedVars, IndexerEvent, IndexerEventBalanceStateSnapshot, IndexerEventPerpStateSnapshot, IndexerEventSpotStateSnapshot, IndexerEventWithTx, IndexerFundingRate, IndexerLeaderboardContest, IndexerLeaderboardParticipant, IndexerLeaderboardRegistration, IndexerMaker, IndexerMakerSnapshot, IndexerMarketSnapshot, IndexerMatchEvent, IndexerMatchEventBalances, IndexerNlpSnapshot, IndexerOraclePrice, IndexerOrder, IndexerPerpBalance, IndexerPerpPrices, IndexerProductPayment, IndexerProductSnapshot, IndexerSnapshotBalance, IndexerSnapshotsIntervalParams, IndexerSpotBalance, IndexerSubaccountSnapshot, ListIndexerSubaccountsParams, ListIndexerSubaccountsResponse, UpdateIndexerLeaderboardRegistrationParams, UpdateIndexerLeaderboardRegistrationResponse };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/serverModelTypes.ts"],"sourcesContent":["import { EIP712OrderValues } from '@nadohq/shared';\nimport {\n EngineServerPerpBalance,\n EngineServerPerpProduct,\n EngineServerSpotBalance,\n EngineServerSpotProduct,\n} from '@nadohq/engine-client';\nimport { IndexerEventType } from './IndexerEventType';\nimport { NadoTx } from './NadoTx';\n\nexport interface IndexerServerSnapshotsInterval {\n count: number;\n // Currently accepts any granularity, time distance (in seconds) between data points\n granularity: number;\n max_time?: string;\n}\n\nexport type IndexerServerProduct =\n | {\n spot: EngineServerSpotProduct;\n }\n | {\n perp: EngineServerPerpProduct;\n };\n\nexport type IndexerServerBalance =\n | {\n spot: EngineServerSpotBalance;\n }\n | {\n perp: EngineServerPerpBalance;\n };\n\n/**\n * Candlesticks\n */\n\nexport interface IndexerServerCandlestick {\n product_id: number;\n granularity: string;\n submission_idx: string;\n timestamp: string;\n open_x18: string;\n high_x18: string;\n low_x18: string;\n close_x18: string;\n volume: string;\n}\n\n/**\n * Product snapshots\n */\n\nexport interface IndexerServerProductSnapshot {\n product_id: number;\n submission_idx: string;\n product: IndexerServerProduct;\n}\n\n/**\n * Base Events\n */\n\nexport interface IndexerServerEvent {\n subaccount: string;\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 isolated_product_id: number | null;\n product_id: number;\n submission_idx: string;\n event_type: IndexerEventType;\n pre_balance: IndexerServerBalance;\n post_balance: IndexerServerBalance;\n product: IndexerServerProduct;\n net_interest_unrealized: string;\n net_interest_cumulative: string;\n net_funding_unrealized: string;\n net_funding_cumulative: string;\n net_entry_unrealized: string;\n net_entry_cumulative: string;\n}\n\nexport interface IndexerServerTx {\n submission_idx: string;\n timestamp: string;\n tx: NadoTx;\n}\n\n/**\n * Orders\n */\n\nexport interface IndexerServerOrder {\n digest: string;\n isolated: boolean;\n subaccount: string;\n product_id: number;\n submission_idx: string;\n amount: string;\n price_x18: string;\n expiration: string;\n appendix: string;\n nonce: string;\n base_filled: string;\n // Includes fee\n quote_filled: string;\n // Includes sequencer fee\n fee: string;\n}\n\n/**\n * Match events\n */\n\nexport interface IndexerServerMatchEvent {\n digest: string;\n isolated: boolean;\n order: EIP712OrderValues;\n base_filled: string;\n // Includes fee\n quote_filled: string;\n // Includes sequencer fee\n fee: string;\n sequencer_fee: string;\n cumulative_fee: string;\n cumulative_base_filled: string;\n cumulative_quote_filled: string;\n submission_idx: string;\n net_entry_unrealized: string;\n net_entry_cumulative: string;\n pre_balance: IndexerServerMatchEventBalances;\n post_balance: IndexerServerMatchEventBalances;\n}\n\nexport interface IndexerServerMatchEventBalances {\n base: IndexerServerBalance;\n // Quote is defined if 0 is included in `product_ids` and the match event is a spot event\n quote?: IndexerServerBalance;\n}\n\n/**\n * Oracle price\n */\n\nexport interface IndexerServerOraclePrice {\n product_id: number;\n oracle_price_x18: string;\n update_time: number;\n}\n\n/**\n * Market snapshots\n */\n\nexport interface IndexerServerMarketSnapshotInterval {\n count: number;\n // Currently accepts any granularity, time distance (in seconds) between data points\n granularity: number;\n max_time?: string;\n}\n\nexport interface IndexerServerMarketSnapshot {\n timestamp: string;\n cumulative_users: string;\n daily_active_users: string;\n tvl: string;\n // Keyed by product ID -> decimal value in string (i.e. no decimal adjustment) necessary\n // Backend serializes hashmaps with string keys\n cumulative_volumes: Record<string, string>;\n cumulative_taker_fees: Record<string, string>;\n cumulative_sequencer_fees: Record<string, string>;\n cumulative_maker_fees: Record<string, string>;\n cumulative_trades: Record<string, string>;\n cumulative_liquidation_amounts: Record<string, string>;\n open_interests: Record<string, string>;\n total_deposits: Record<string, string>;\n total_borrows: Record<string, string>;\n funding_rates: Record<string, string>;\n deposit_rates: Record<string, string>;\n borrow_rates: Record<string, string>;\n cumulative_trade_sizes: Record<string, string>;\n cumulative_inflows: Record<string, string>;\n cumulative_outflows: Record<string, string>;\n oracle_prices: Record<string, string>;\n}\n\n/**\n * Interest / funding\n */\n\nexport interface IndexerServerProductPayment {\n product_id: number;\n idx: string;\n timestamp: string;\n amount: string;\n balance_amount: string;\n rate_x18: string;\n oracle_price_x18: string;\n isolated: boolean;\n isolated_product_id: number | null;\n}\n\n/**\n * Maker stats\n */\n\nexport interface IndexerServerMakerData {\n timestamp: string;\n maker_fee: string;\n uptime: string;\n sum_q_min: string;\n q_score: string;\n maker_share: string;\n expected_maker_reward: string;\n}\n\nexport interface IndexerServerMaker {\n address: string;\n data: IndexerServerMakerData[];\n}\n\n/**\n * Leaderboard\n */\n\nexport interface IndexerServerLeaderboardPosition {\n subaccount: string;\n contest_id: number;\n pnl: string;\n pnl_rank: string;\n roi: string;\n roi_rank: string;\n account_value: string;\n volume?: string;\n update_time: string;\n}\n\nexport interface IndexerServerLeaderboardContest {\n contest_id: number;\n start_time: string;\n end_time: string;\n timeframe: string;\n count: string;\n threshold: string;\n volume_threshold: string;\n product_ids: number[];\n last_updated: string;\n active: boolean;\n}\n\nexport interface IndexerServerLeaderboardRegistration {\n subaccount: string;\n contest_id: number;\n update_time: string;\n}\n\n/**\n * NLP\n */\n\nexport interface IndexerServerNlpSnapshot {\n cumulative_burn_usdc: string;\n cumulative_mint_usdc: string;\n cumulative_pnl: string;\n cumulative_trades: string;\n cumulative_volume: string;\n depositors: string;\n oracle_price_x18: string;\n submission_idx: string;\n timestamp: string;\n tvl: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/serverModelTypes.ts"],"sourcesContent":["import {\n EngineServerPerpBalance,\n EngineServerPerpProduct,\n EngineServerSpotBalance,\n EngineServerSpotProduct,\n} from '@nadohq/engine-client';\nimport { EIP712OrderValues } from '@nadohq/shared';\nimport { IndexerEventType } from './IndexerEventType';\nimport { NadoTx } from './NadoTx';\n\nexport interface IndexerServerSnapshotsInterval {\n count: number;\n // Currently accepts any granularity, time distance (in seconds) between data points\n granularity: number;\n max_time?: string;\n}\n\nexport type IndexerServerProduct =\n | {\n spot: EngineServerSpotProduct;\n }\n | {\n perp: EngineServerPerpProduct;\n };\n\nexport type IndexerServerBalance =\n | {\n spot: EngineServerSpotBalance;\n }\n | {\n perp: EngineServerPerpBalance;\n };\n\n/**\n * Candlesticks\n */\n\nexport interface IndexerServerCandlestick {\n product_id: number;\n granularity: string;\n submission_idx: string;\n timestamp: string;\n open_x18: string;\n high_x18: string;\n low_x18: string;\n close_x18: string;\n volume: string;\n}\n\n/**\n * Product snapshots\n */\n\nexport interface IndexerServerProductSnapshot {\n product_id: number;\n submission_idx: string;\n product: IndexerServerProduct;\n}\n\n/**\n * Base Events\n */\n\nexport interface IndexerServerEvent {\n subaccount: string;\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 isolated_product_id: number | null;\n product_id: number;\n submission_idx: string;\n event_type: IndexerEventType;\n pre_balance: IndexerServerBalance;\n post_balance: IndexerServerBalance;\n product: IndexerServerProduct;\n net_interest_unrealized: string;\n net_interest_cumulative: string;\n net_funding_unrealized: string;\n net_funding_cumulative: string;\n net_entry_unrealized: string;\n net_entry_cumulative: string;\n}\n\nexport interface IndexerServerTx {\n submission_idx: string;\n timestamp: string;\n tx: NadoTx;\n}\n\n/**\n * Orders\n */\n\nexport interface IndexerServerOrder {\n digest: string;\n subaccount: string;\n product_id: number;\n submission_idx: string;\n amount: string;\n price_x18: string;\n expiration: string;\n appendix: string;\n nonce: string;\n base_filled: string;\n // Includes fee\n quote_filled: string;\n // Includes sequencer fee\n fee: string;\n}\n\n/**\n * Match events\n */\n\nexport interface IndexerServerMatchEvent {\n digest: string;\n isolated: boolean;\n order: EIP712OrderValues;\n base_filled: string;\n // Includes fee\n quote_filled: string;\n // Includes sequencer fee\n fee: string;\n sequencer_fee: string;\n cumulative_fee: string;\n cumulative_base_filled: string;\n cumulative_quote_filled: string;\n submission_idx: string;\n net_entry_unrealized: string;\n net_entry_cumulative: string;\n pre_balance: IndexerServerMatchEventBalances;\n post_balance: IndexerServerMatchEventBalances;\n}\n\nexport interface IndexerServerMatchEventBalances {\n base: IndexerServerBalance;\n // Quote is defined if 0 is included in `product_ids` and the match event is a spot event\n quote?: IndexerServerBalance;\n}\n\n/**\n * Oracle price\n */\n\nexport interface IndexerServerOraclePrice {\n product_id: number;\n oracle_price_x18: string;\n update_time: number;\n}\n\n/**\n * Market snapshots\n */\n\nexport interface IndexerServerMarketSnapshotInterval {\n count: number;\n // Currently accepts any granularity, time distance (in seconds) between data points\n granularity: number;\n max_time?: string;\n}\n\nexport interface IndexerServerMarketSnapshot {\n timestamp: string;\n cumulative_users: string;\n daily_active_users: string;\n tvl: string;\n // Keyed by product ID -> decimal value in string (i.e. no decimal adjustment) necessary\n // Backend serializes hashmaps with string keys\n cumulative_volumes: Record<string, string>;\n cumulative_taker_fees: Record<string, string>;\n cumulative_sequencer_fees: Record<string, string>;\n cumulative_maker_fees: Record<string, string>;\n cumulative_trades: Record<string, string>;\n cumulative_liquidation_amounts: Record<string, string>;\n open_interests: Record<string, string>;\n total_deposits: Record<string, string>;\n total_borrows: Record<string, string>;\n funding_rates: Record<string, string>;\n deposit_rates: Record<string, string>;\n borrow_rates: Record<string, string>;\n cumulative_trade_sizes: Record<string, string>;\n cumulative_inflows: Record<string, string>;\n cumulative_outflows: Record<string, string>;\n oracle_prices: Record<string, string>;\n}\n\n/**\n * Interest / funding\n */\n\nexport interface IndexerServerProductPayment {\n product_id: number;\n idx: string;\n timestamp: string;\n amount: string;\n balance_amount: string;\n rate_x18: string;\n oracle_price_x18: string;\n isolated: boolean;\n isolated_product_id: number | null;\n}\n\n/**\n * Maker stats\n */\n\nexport interface IndexerServerMakerData {\n timestamp: string;\n maker_fee: string;\n uptime: string;\n sum_q_min: string;\n q_score: string;\n maker_share: string;\n expected_maker_reward: string;\n}\n\nexport interface IndexerServerMaker {\n address: string;\n data: IndexerServerMakerData[];\n}\n\n/**\n * Leaderboard\n */\n\nexport interface IndexerServerLeaderboardPosition {\n subaccount: string;\n contest_id: number;\n pnl: string;\n pnl_rank: string;\n roi: string;\n roi_rank: string;\n account_value: string;\n volume?: string;\n update_time: string;\n}\n\nexport interface IndexerServerLeaderboardContest {\n contest_id: number;\n start_time: string;\n end_time: string;\n timeframe: string;\n count: string;\n threshold: string;\n volume_threshold: string;\n product_ids: number[];\n last_updated: string;\n active: boolean;\n}\n\nexport interface IndexerServerLeaderboardRegistration {\n subaccount: string;\n contest_id: number;\n update_time: string;\n}\n\n/**\n * NLP\n */\n\nexport interface IndexerServerNlpSnapshot {\n cumulative_burn_usdc: string;\n cumulative_mint_usdc: string;\n cumulative_pnl: string;\n cumulative_trades: string;\n cumulative_volume: string;\n depositors: string;\n oracle_price_x18: string;\n submission_idx: string;\n timestamp: string;\n tvl: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,5 +1,5 @@
1
- import { EIP712OrderValues } from '@nadohq/shared';
2
1
  import { EngineServerSpotBalance, EngineServerPerpBalance, EngineServerSpotProduct, EngineServerPerpProduct } from '@nadohq/engine-client';
2
+ import { EIP712OrderValues } from '@nadohq/shared';
3
3
  import { IndexerEventType } from './IndexerEventType.cjs';
4
4
  import { NadoTx } from './NadoTx.cjs';
5
5
 
@@ -70,7 +70,6 @@ interface IndexerServerTx {
70
70
  */
71
71
  interface IndexerServerOrder {
72
72
  digest: string;
73
- isolated: boolean;
74
73
  subaccount: string;
75
74
  product_id: number;
76
75
  submission_idx: string;
@@ -1,5 +1,5 @@
1
- import { EIP712OrderValues } from '@nadohq/shared';
2
1
  import { EngineServerSpotBalance, EngineServerPerpBalance, EngineServerSpotProduct, EngineServerPerpProduct } from '@nadohq/engine-client';
2
+ import { EIP712OrderValues } from '@nadohq/shared';
3
3
  import { IndexerEventType } from './IndexerEventType.js';
4
4
  import { NadoTx } from './NadoTx.js';
5
5
 
@@ -70,7 +70,6 @@ interface IndexerServerTx {
70
70
  */
71
71
  interface IndexerServerOrder {
72
72
  digest: string;
73
- isolated: boolean;
74
73
  subaccount: string;
75
74
  product_id: number;
76
75
  submission_idx: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nadohq/indexer-client",
3
- "version": "0.1.0-alpha.5",
3
+ "version": "0.1.0-alpha.7",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "> TODO: description",
@@ -37,8 +37,8 @@
37
37
  }
38
38
  },
39
39
  "dependencies": {
40
- "@nadohq/engine-client": "^0.1.0-alpha.5",
41
- "@nadohq/shared": "^0.1.0-alpha.5",
40
+ "@nadohq/engine-client": "^0.1.0-alpha.7",
41
+ "@nadohq/shared": "^0.1.0-alpha.7",
42
42
  "axios": "*",
43
43
  "ts-mixer": "*"
44
44
  },
@@ -48,5 +48,5 @@
48
48
  "devDependencies": {
49
49
  "viem": "*"
50
50
  },
51
- "gitHead": "de119d61db2be44b2cab79b8d373b66eb0f8ffe6"
51
+ "gitHead": "c6f20e82e8d20e2c7a427b54a1728b6ab8adf058"
52
52
  }
@@ -4,6 +4,7 @@ import {
4
4
  getDefaultRecvTime,
5
5
  getNadoEIP712Values,
6
6
  getSignedTransactionRequest,
7
+ getValidatedAddress,
7
8
  getValidatedHex,
8
9
  mapValues,
9
10
  nowInSeconds,
@@ -801,7 +802,7 @@ export class IndexerBaseClient {
801
802
  });
802
803
 
803
804
  return {
804
- address: baseResponse.v1_address,
805
+ address: getValidatedAddress(baseResponse.v1_address),
805
806
  };
806
807
  }
807
808
 
@@ -94,7 +94,6 @@ export function mapIndexerOrder(order: IndexerServerOrder): IndexerOrder {
94
94
  return {
95
95
  amount: toBigDecimal(order.amount),
96
96
  digest: order.digest,
97
- isolated: order.isolated,
98
97
  expiration: Number(order.expiration),
99
98
  appendix,
100
99
  nonce: toBigDecimal(order.nonce),
@@ -10,7 +10,7 @@ import {
10
10
  SpotMarket,
11
11
  Subaccount,
12
12
  } from '@nadohq/shared';
13
- import { Hex } from 'viem';
13
+ import { Address, Hex } from 'viem';
14
14
  import { CandlestickPeriod } from './CandlestickPeriod';
15
15
  import { IndexerEventType } from './IndexerEventType';
16
16
  import { IndexerLeaderboardRankType } from './IndexerLeaderboardType';
@@ -349,7 +349,6 @@ export interface GetIndexerOrdersParams {
349
349
  export interface IndexerOrder {
350
350
  digest: string;
351
351
  subaccount: string;
352
- isolated: boolean;
353
352
  productId: number;
354
353
  submissionIndex: string;
355
354
  amount: BigDecimal;
@@ -681,5 +680,5 @@ export interface GetIndexerSubaccountDDAParams {
681
680
  }
682
681
 
683
682
  export interface GetIndexerSubaccountDDAResponse {
684
- address: string;
683
+ address: Address;
685
684
  }
@@ -1,10 +1,10 @@
1
- import { EIP712OrderValues } from '@nadohq/shared';
2
1
  import {
3
2
  EngineServerPerpBalance,
4
3
  EngineServerPerpProduct,
5
4
  EngineServerSpotBalance,
6
5
  EngineServerSpotProduct,
7
6
  } from '@nadohq/engine-client';
7
+ import { EIP712OrderValues } from '@nadohq/shared';
8
8
  import { IndexerEventType } from './IndexerEventType';
9
9
  import { NadoTx } from './NadoTx';
10
10
 
@@ -92,7 +92,6 @@ export interface IndexerServerTx {
92
92
 
93
93
  export interface IndexerServerOrder {
94
94
  digest: string;
95
- isolated: boolean;
96
95
  subaccount: string;
97
96
  product_id: number;
98
97
  submission_idx: string;