@nadohq/indexer-client 0.41.0 → 0.42.0

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.
Files changed (115) hide show
  1. package/dist/{IndexerBaseClient-jaeUYv71.cjs → IndexerBaseClient-CSn4twzz.cjs} +36 -1
  2. package/dist/IndexerBaseClient-CSn4twzz.cjs.map +1 -0
  3. package/dist/IndexerBaseClient.cjs +1 -1
  4. package/dist/IndexerBaseClient.d.cts +16 -2
  5. package/dist/IndexerBaseClient.d.cts.map +1 -1
  6. package/dist/IndexerBaseClient.d.ts +16 -2
  7. package/dist/IndexerBaseClient.d.ts.map +1 -1
  8. package/dist/IndexerBaseClient.js +36 -1
  9. package/dist/IndexerBaseClient.js.map +1 -1
  10. package/dist/IndexerClient.cjs +1 -1
  11. package/dist/IndexerClient.d.cts +1 -1
  12. package/dist/IndexerClient.d.ts +1 -1
  13. package/dist/IndexerEventType-BFvrhslw.d.ts +10 -0
  14. package/dist/IndexerEventType-BFvrhslw.d.ts.map +1 -0
  15. package/dist/IndexerEventType-BpH10mEW.d.cts +10 -0
  16. package/dist/IndexerEventType-BpH10mEW.d.cts.map +1 -0
  17. package/dist/{IndexerServerFailureError-ClC8vkmR.d.ts → IndexerServerFailureError-BoGd4gih.d.ts} +2 -2
  18. package/dist/{IndexerServerFailureError-ClC8vkmR.d.ts.map → IndexerServerFailureError-BoGd4gih.d.ts.map} +1 -1
  19. package/dist/{IndexerServerFailureError-BMmMPfFJ.d.cts → IndexerServerFailureError-D-KNqVt3.d.cts} +2 -2
  20. package/dist/{IndexerServerFailureError-BMmMPfFJ.d.cts.map → IndexerServerFailureError-D-KNqVt3.d.cts.map} +1 -1
  21. package/dist/{NadoTx-Bd4U-zDu.d.ts → NadoTx-4BQkGyHz.d.cts} +3 -8
  22. package/dist/NadoTx-4BQkGyHz.d.cts.map +1 -0
  23. package/dist/{NadoTx-C3_f0YvI.d.cts → NadoTx-DPrcN9Eo.d.ts} +3 -8
  24. package/dist/NadoTx-DPrcN9Eo.d.ts.map +1 -0
  25. package/dist/{clientTypes-BLKeWmIr.d.ts → clientTypes-CnswaLwH.d.ts} +107 -5
  26. package/dist/clientTypes-CnswaLwH.d.ts.map +1 -0
  27. package/dist/{clientTypes-QBgifUeV.d.cts → clientTypes-DS2w6Osq.d.cts} +107 -5
  28. package/dist/clientTypes-DS2w6Osq.d.cts.map +1 -0
  29. package/dist/{collateralEventType-s-WbBniE.d.ts → collateralEventType-AJY6oQt6.d.ts} +2 -2
  30. package/dist/collateralEventType-AJY6oQt6.d.ts.map +1 -0
  31. package/dist/{collateralEventType-CNrryEno.d.cts → collateralEventType-f2RJiAwy.d.cts} +2 -2
  32. package/dist/collateralEventType-f2RJiAwy.d.cts.map +1 -0
  33. package/dist/dataMappers.cjs +38 -1
  34. package/dist/dataMappers.cjs.map +1 -1
  35. package/dist/dataMappers.d.cts +10 -4
  36. package/dist/dataMappers.d.cts.map +1 -1
  37. package/dist/dataMappers.d.ts +10 -4
  38. package/dist/dataMappers.d.ts.map +1 -1
  39. package/dist/dataMappers.js +37 -1
  40. package/dist/dataMappers.js.map +1 -1
  41. package/dist/index.cjs +3 -1
  42. package/dist/index.d.cts +10 -10
  43. package/dist/index.d.ts +10 -10
  44. package/dist/index.js +2 -1
  45. package/dist/{indexerBalanceValue-ZJec8hfI.d.ts → indexerBalanceValue-DV3dtvyV.d.ts} +2 -2
  46. package/dist/{indexerBalanceValue-ZJec8hfI.d.ts.map → indexerBalanceValue-DV3dtvyV.d.ts.map} +1 -1
  47. package/dist/{indexerBalanceValue-DqMAvUsj.d.cts → indexerBalanceValue-yMyf537D.d.cts} +2 -2
  48. package/dist/{indexerBalanceValue-DqMAvUsj.d.cts.map → indexerBalanceValue-yMyf537D.d.cts.map} +1 -1
  49. package/dist/{paginatedEventsTypes-D668Hgzl.d.ts → paginatedEventsTypes-BT--OHd5.d.ts} +4 -4
  50. package/dist/{paginatedEventsTypes-D668Hgzl.d.ts.map → paginatedEventsTypes-BT--OHd5.d.ts.map} +1 -1
  51. package/dist/{paginatedEventsTypes-4I9Ibp9q.d.cts → paginatedEventsTypes-DZllHmqY.d.cts} +4 -4
  52. package/dist/{paginatedEventsTypes-4I9Ibp9q.d.cts.map → paginatedEventsTypes-DZllHmqY.d.cts.map} +1 -1
  53. package/dist/{serverModelTypes-BAZNgoLE.d.ts → serverModelTypes-B78obnnd.d.ts} +40 -4
  54. package/dist/serverModelTypes-B78obnnd.d.ts.map +1 -0
  55. package/dist/{serverModelTypes-DC4dsX9i.d.cts → serverModelTypes-vhALknbV.d.cts} +40 -4
  56. package/dist/serverModelTypes-vhALknbV.d.cts.map +1 -0
  57. package/dist/{serverTypes-DeUDMCog.d.cts → serverTypes-CyqBF-nt.d.cts} +29 -5
  58. package/dist/serverTypes-CyqBF-nt.d.cts.map +1 -0
  59. package/dist/{serverTypes-BQafrknp.d.ts → serverTypes-Dod9cCEW.d.ts} +29 -5
  60. package/dist/serverTypes-Dod9cCEW.d.ts.map +1 -0
  61. package/dist/types/IndexerEventType.cjs +23 -0
  62. package/dist/types/IndexerEventType.cjs.map +1 -0
  63. package/dist/types/IndexerEventType.d.cts +2 -2
  64. package/dist/types/IndexerEventType.d.ts +2 -2
  65. package/dist/types/IndexerEventType.js +22 -1
  66. package/dist/types/IndexerEventType.js.map +1 -0
  67. package/dist/types/IndexerServerFailureError.cjs +1 -1
  68. package/dist/types/IndexerServerFailureError.d.cts +1 -1
  69. package/dist/types/IndexerServerFailureError.d.ts +1 -1
  70. package/dist/types/NadoTx.d.cts +2 -2
  71. package/dist/types/NadoTx.d.ts +2 -2
  72. package/dist/types/clientTypes.d.cts +2 -2
  73. package/dist/types/clientTypes.d.ts +2 -2
  74. package/dist/types/collateralEventType.d.cts +1 -1
  75. package/dist/types/collateralEventType.d.ts +1 -1
  76. package/dist/types/index.cjs +2 -0
  77. package/dist/types/index.d.cts +9 -9
  78. package/dist/types/index.d.ts +9 -9
  79. package/dist/types/index.js +2 -1
  80. package/dist/types/indexerErrorCodes.cjs +1 -1
  81. package/dist/types/paginatedEventsTypes.d.cts +1 -1
  82. package/dist/types/paginatedEventsTypes.d.ts +1 -1
  83. package/dist/types/serverModelTypes.d.cts +2 -2
  84. package/dist/types/serverModelTypes.d.ts +2 -2
  85. package/dist/types/serverTypes.cjs.map +1 -1
  86. package/dist/types/serverTypes.d.cts +2 -2
  87. package/dist/types/serverTypes.d.ts +2 -2
  88. package/dist/types/serverTypes.js.map +1 -1
  89. package/dist/utils/index.d.cts +1 -1
  90. package/dist/utils/index.d.ts +1 -1
  91. package/dist/utils/indexerBalanceValue.d.cts +1 -1
  92. package/dist/utils/indexerBalanceValue.d.ts +1 -1
  93. package/package.json +4 -4
  94. package/src/IndexerBaseClient.ts +50 -0
  95. package/src/dataMappers.ts +41 -0
  96. package/src/types/IndexerEventType.ts +19 -11
  97. package/src/types/NadoTx.ts +0 -7
  98. package/src/types/clientTypes.ts +106 -0
  99. package/src/types/serverModelTypes.ts +59 -0
  100. package/src/types/serverTypes.ts +33 -0
  101. package/dist/IndexerBaseClient-jaeUYv71.cjs.map +0 -1
  102. package/dist/IndexerEventType-9GB2zRoN.d.cts +0 -5
  103. package/dist/IndexerEventType-9GB2zRoN.d.cts.map +0 -1
  104. package/dist/IndexerEventType-Brm9aX8w.d.ts +0 -5
  105. package/dist/IndexerEventType-Brm9aX8w.d.ts.map +0 -1
  106. package/dist/NadoTx-Bd4U-zDu.d.ts.map +0 -1
  107. package/dist/NadoTx-C3_f0YvI.d.cts.map +0 -1
  108. package/dist/clientTypes-BLKeWmIr.d.ts.map +0 -1
  109. package/dist/clientTypes-QBgifUeV.d.cts.map +0 -1
  110. package/dist/collateralEventType-CNrryEno.d.cts.map +0 -1
  111. package/dist/collateralEventType-s-WbBniE.d.ts.map +0 -1
  112. package/dist/serverModelTypes-BAZNgoLE.d.ts.map +0 -1
  113. package/dist/serverModelTypes-DC4dsX9i.d.cts.map +0 -1
  114. package/dist/serverTypes-BQafrknp.d.ts.map +0 -1
  115. package/dist/serverTypes-DeUDMCog.d.cts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"serverTypes.js","names":[],"sources":["../../src/types/serverTypes.ts"],"sourcesContent":["import {\n EIP712LeaderboardAuthenticationValues,\n EIP712SocialAuthenticationValues,\n SignedTx,\n} from '@nadohq/shared';\nimport { IndexerEventType } from './IndexerEventType';\nimport { IndexerLeaderboardRankType } from './IndexerLeaderboardType';\nimport { NadoWithdrawCollateralTx, NadoWithdrawCollateralV2Tx } from './NadoTx';\nimport {\n IndexerServerCandlestick,\n IndexerServerEvent,\n IndexerServerLeaderboardContest,\n IndexerServerLeaderboardPosition,\n IndexerServerLeaderboardRegistration,\n IndexerServerMaker,\n IndexerServerMarketSnapshot,\n IndexerServerMarketSnapshotInterval,\n IndexerServerMatchEvent,\n IndexerServerNlpSnapshot,\n IndexerServerOraclePrice,\n IndexerServerOrder,\n IndexerServerProductPayment,\n IndexerServerProductSnapshot,\n IndexerServerSnapshotsInterval,\n IndexerServerSocialAccount,\n IndexerServerTx,\n} from './serverModelTypes';\n\n/**\n * Params\n */\n\nexport interface IndexerServerListSubaccountsParams {\n // Inclusive, defaults to 0\n start?: number;\n // Defaults to 100\n limit?: number;\n address?: string;\n}\n\nexport interface IndexerServerMultiSubaccountSnapshotsParams {\n // Subaccount hex identifiers\n subaccounts: string[];\n timestamps: number[];\n // If not given, will return both isolated & non-iso balances\n isolated?: boolean;\n}\n\nexport interface IndexerServerReferralCodeParams {\n subaccount: string;\n}\n\nexport interface IndexerServerFundingRateParams {\n product_id: number;\n}\n\nexport interface IndexerServerFundingRatesParams {\n product_ids: number[];\n}\n\nexport interface IndexerServerFundingRateHistoryParams {\n product_id: number;\n start_time?: number | string;\n end_time?: number | string;\n // Max number of rates to return. Defaults to 100, max 1000.\n limit?: number;\n}\n\nexport interface IndexerServerPriceParams {\n product_id: number;\n}\n\nexport interface IndexerServerPerpPricesParams {\n product_ids: number[];\n}\n\nexport interface IndexerServerPortfolioParams {\n subaccount: string;\n}\n\nexport interface IndexerServerOraclePricesParams {\n product_ids: number[];\n}\n\nexport interface IndexerServerCandlesticksParams {\n product_id: number;\n granularity: number;\n // Seconds\n max_time?: number;\n limit: number;\n}\n\nexport type IndexerEdgeServerCandlesticksParams =\n IndexerServerCandlesticksParams;\n\nexport interface IndexerServerProductsParams {\n product_id: number;\n max_time?: number;\n limit: number;\n // submission_idx for pagination, inclusive\n idx?: string;\n}\n\nexport interface IndexerServerMultiProductsParams {\n product_ids: number[];\n max_time: number[];\n}\n\nexport interface IndexerServerEventsParams {\n subaccounts?: string[];\n product_ids?: number[];\n // If not given, will return both isolated & non-iso events\n isolated?: boolean;\n event_types?: IndexerEventType[];\n // Descending order for idx (time), defaults to true\n desc?: boolean;\n // submission_idx for pagination, inclusive\n idx?: string;\n max_time?: number;\n limit?:\n | {\n raw: number;\n }\n | {\n txs: number;\n };\n}\n\nexport type IndexerServerTriggerTypeFilter =\n | 'none'\n | 'price_trigger'\n | 'time_trigger';\n\nexport interface IndexerServerOrdersParams {\n subaccounts?: string[];\n product_ids?: number[];\n trigger_types?: IndexerServerTriggerTypeFilter[];\n digests?: string[];\n max_time?: number;\n limit?: number;\n // If not given, will return both isolated & non-iso orders\n isolated?: boolean;\n // submission_idx for pagination, inclusive\n idx?: string;\n}\n\nexport interface IndexerServerMatchEventsParams {\n subaccounts?: string[];\n product_ids?: number[];\n // If not given, will return both isolated & non-iso events\n isolated?: boolean;\n max_time?: number;\n limit: number;\n // submission_idx for pagination, inclusive\n idx?: string;\n}\n\nexport interface IndexerServerLinkedSignerParams {\n subaccount: string;\n}\n\nexport interface IndexerServerMarketSnapshotsParams {\n interval: IndexerServerMarketSnapshotInterval;\n // Defaults to all\n product_ids?: number[];\n}\n\nexport interface IndexerEdgeServerMarketSnapshotsParams {\n interval: IndexerServerMarketSnapshotInterval;\n}\n\nexport interface IndexerServerInterestFundingParams {\n subaccount: string;\n product_ids: number[];\n // If not given, defaults to latest\n max_idx?: string;\n max_time?: number;\n limit: number;\n}\n\nexport interface IndexerServerMakerStatisticsParams {\n product_id: number;\n epoch: number;\n interval: number;\n}\n\nexport interface IndexerServerLeaderboardParams {\n contest_id: number;\n rank_type?: IndexerLeaderboardRankType;\n start?: number | string;\n limit?: number | string;\n order?: 'ASC' | 'DESC';\n}\n\nexport interface IndexerServerLeaderboardRankParams {\n subaccount: string;\n contest_ids: number[];\n}\n\nexport interface IndexerServerLeaderboardContestsParams {\n contest_ids?: number[];\n active?: boolean;\n}\n\nexport interface IndexerServerLeaderboardRegistrationsParams {\n subaccount: string;\n contest_ids?: number[];\n active?: boolean;\n}\n\nexport interface IndexerServerLeaderboardRegisterParams {\n update_registration: SignedTx<EIP712LeaderboardAuthenticationValues>;\n}\n\nexport interface IndexerServerSocialConnectParams {\n update_social_account: SignedTx<EIP712SocialAuthenticationValues>;\n}\n\nexport interface IndexerServerListSocialAccountsParams {\n address: string;\n}\n\nexport type IndexerServerRevokeSocialAccountParams =\n IndexerServerSocialConnectParams;\n\nexport interface IndexerServerFastWithdrawalSignatureParams {\n /**\n * The submission index of the WithdrawCollateral tx to be used for fast withdraw.\n */\n idx: number | string;\n}\n\nexport interface IndexerServerNlpSnapshotsParams {\n interval: IndexerServerSnapshotsInterval;\n}\n\nexport interface IndexerServerDDAQueryParams {\n subaccount: string;\n}\n\nexport interface IndexerServerPrivateAlphaChoiceParams {\n address: string;\n}\n\nexport interface IndexerServerPointsParams {\n address: string;\n}\n\nexport interface IndexerServerXPointsParams {\n address: string;\n}\n\nexport interface IndexerServerCashIncentivesParams {\n wallet_address: string;\n}\n\n// Request\nexport interface IndexerServerQueryRequestByType {\n account_snapshots: IndexerServerMultiSubaccountSnapshotsParams;\n backlog: Record<string, never>;\n candlesticks: IndexerServerCandlesticksParams;\n direct_deposit_address: IndexerServerDDAQueryParams;\n edge_candlesticks: IndexerEdgeServerCandlesticksParams;\n edge_market_snapshots: IndexerEdgeServerMarketSnapshotsParams;\n events: IndexerServerEventsParams;\n fast_withdrawal_signature: IndexerServerFastWithdrawalSignatureParams;\n funding_rate: IndexerServerFundingRateParams;\n funding_rate_history: IndexerServerFundingRateHistoryParams;\n funding_rates: IndexerServerFundingRatesParams;\n interest_and_funding: IndexerServerInterestFundingParams;\n leaderboard: IndexerServerLeaderboardParams;\n leaderboard_contests: IndexerServerLeaderboardContestsParams;\n leaderboard_rank: IndexerServerLeaderboardRankParams;\n leaderboard_register: IndexerServerLeaderboardRegisterParams;\n leaderboard_registrations: IndexerServerLeaderboardRegistrationsParams;\n linked_signer_rate_limit: IndexerServerLinkedSignerParams;\n maker_statistics: IndexerServerMakerStatisticsParams;\n market_snapshots: IndexerServerMarketSnapshotsParams;\n matches: IndexerServerMatchEventsParams;\n oracle_price: IndexerServerOraclePricesParams;\n orders: IndexerServerOrdersParams;\n perp_prices: IndexerServerPerpPricesParams;\n portfolio: IndexerServerPortfolioParams;\n price: IndexerServerPriceParams;\n product_snapshots: IndexerServerMultiProductsParams;\n products: IndexerServerProductsParams;\n referral_code: IndexerServerReferralCodeParams;\n subaccounts: IndexerServerListSubaccountsParams;\n quote_price: Record<string, never>;\n nlp_snapshots: IndexerServerNlpSnapshotsParams;\n private_alpha_choice: IndexerServerPrivateAlphaChoiceParams;\n nado_points: IndexerServerPointsParams;\n nado_xpoints: IndexerServerXPointsParams;\n cash_incentives: IndexerServerCashIncentivesParams;\n social_connect: IndexerServerSocialConnectParams;\n list_social_accounts: IndexerServerListSocialAccountsParams;\n revoke_social_account: IndexerServerRevokeSocialAccountParams;\n}\n\nexport type IndexerServerQueryRequestType =\n keyof IndexerServerQueryRequestByType;\n\n/**\n * Responses\n */\n\nexport interface IndexerServerListSubaccountsResponse {\n subaccounts: {\n id: string;\n // Hex of subaccount bytes\n subaccount: string;\n // UNIX timestamp in seconds\n created_at: string;\n isolated: boolean;\n }[];\n}\n\nexport interface IndexerServerMultiSubaccountSnapshotsResponse {\n // Map of subaccount hex -> timestamp requested -> latest events corresponding to each product\n snapshots: Record<string, Record<string, IndexerServerEvent[]>>;\n}\n\nexport interface IndexerServerReferralCodeResponse {\n referral_code: string | null;\n}\n\nexport interface IndexerServerFundingRate {\n product_id: number;\n funding_rate_x18: string;\n update_time: number;\n}\n\nexport type IndexerServerFundingRateResponse = IndexerServerFundingRate;\n\n// Map of productId -> IndexerServerFundingRate\nexport type IndexerServerFundingRatesResponse = Record<\n string,\n IndexerServerFundingRate\n>;\n\nexport interface IndexerServerFundingRateHistoryEntry {\n product_id: number;\n // Epoch time in seconds of the settlement tick this funding rate was recorded at.\n timestamp: string;\n // Realized hourly funding rate at this tick, multiplied by 10^18 (% = rate * 100).\n funding_rate_x18: string;\n}\n\nexport interface IndexerServerFundingRateHistoryResponse {\n // Always ascending by timestamp.\n funding_rates: IndexerServerFundingRateHistoryEntry[];\n}\n\nexport type IndexerServerPortfolioPeriod =\n | 'day'\n | 'week'\n | 'month'\n | 'allTime'\n | 'perpDay'\n | 'perpWeek'\n | 'perpMonth'\n | 'perpAllTime';\n\n/**\n * [timestamp (unix seconds), value] — both x18-free decimal strings. Values are\n * USDT0-denominated, except `marketCountHistory` points, which are integer counts.\n */\nexport type IndexerServerPortfolioPoint = [string, string];\n\n// All five series are aligned: same timestamps, same length.\nexport interface IndexerServerPortfolioHistory {\n accountValueHistory: IndexerServerPortfolioPoint[];\n pnlHistory: IndexerServerPortfolioPoint[];\n volumeHistory: IndexerServerPortfolioPoint[];\n tradeSizeHistory: IndexerServerPortfolioPoint[];\n marketCountHistory: IndexerServerPortfolioPoint[];\n}\n\nexport type IndexerServerPortfolioResponse = [\n IndexerServerPortfolioPeriod,\n IndexerServerPortfolioHistory,\n][];\n\nexport interface IndexerServerPerpPrices {\n product_id: number;\n index_price_x18: string;\n mark_price_x18: string;\n update_time: number;\n}\n\nexport type IndexerServerPriceResponse = IndexerServerPerpPrices;\n\n// Map of productId -> IndexerServerPerpPrices\nexport type IndexerServerPerpPricesResponse = Record<\n string,\n IndexerServerPerpPrices\n>;\n\nexport interface IndexerServerOraclePricesResponse {\n prices: IndexerServerOraclePrice[];\n}\n\nexport interface IndexerServerCandlesticksResponse {\n candlesticks: IndexerServerCandlestick[];\n}\n\nexport type IndexerEdgeServerCandlesticksResponse =\n IndexerServerCandlesticksResponse;\n\nexport interface IndexerServerProductsResponse {\n products: IndexerServerProductSnapshot[];\n txs: IndexerServerTx[];\n}\n\n// Map of timestamp -> (productID -> IndexerServerProductSnapshot)\nexport type IndexerServerMultiProductsResponse = Record<\n string,\n Record<string, IndexerServerProductSnapshot>\n>;\n\nexport interface IndexerServerEventsResponse {\n events: IndexerServerEvent[];\n txs: IndexerServerTx[];\n}\n\nexport interface IndexerServerOrdersResponse {\n orders: IndexerServerOrder[];\n}\n\nexport interface IndexerServerMatchEventsResponse {\n matches: IndexerServerMatchEvent[];\n txs: IndexerServerTx[];\n}\n\nexport interface IndexerServerQuotePriceResponse {\n price_x18: string;\n}\n\nexport interface IndexerServerLinkedSignerResponse {\n total_tx_limit: string;\n remaining_tx: string;\n wait_time: string;\n signer: string;\n}\n\nexport interface IndexerServerMarketSnapshotsResponse {\n snapshots: IndexerServerMarketSnapshot[];\n}\n\nexport interface IndexerEdgeServerMarketSnapshotsResponse {\n snapshots: Record<number, IndexerServerMarketSnapshot[]>;\n}\n\nexport interface IndexerServerInterestFundingResponse {\n interest_payments: IndexerServerProductPayment[];\n funding_payments: IndexerServerProductPayment[];\n next_idx: string;\n}\n\nexport interface IndexerServerMakerStatisticsResponse {\n reward_coefficient: string;\n makers: IndexerServerMaker[];\n}\n\nexport interface IndexerServerLeaderboardResponse {\n positions: IndexerServerLeaderboardPosition[];\n}\n\nexport interface IndexerServerLeaderboardRegistrationsResponse {\n registrations: IndexerServerLeaderboardRegistration[];\n}\n\nexport type IndexerServerLeaderboardRegisterResponse =\n IndexerServerLeaderboardRegistrationsResponse;\n\nexport interface IndexerServerLeaderboardRankResponse {\n // If the subaccount is not eligible for a given contest, it would not be included in the response.\n // contestId -> IndexerServerLeaderboardPosition\n positions: Record<string, IndexerServerLeaderboardPosition>;\n}\n\nexport interface IndexerServerLeaderboardContestsResponse {\n contests: IndexerServerLeaderboardContest[];\n}\n\nexport interface IndexerServerFastWithdrawalSignatureResponse {\n idx: string;\n tx: NadoWithdrawCollateralTx['withdraw_collateral'];\n // Present only for `WithdrawCollateralV2` withdrawals.\n tx_v2?: NadoWithdrawCollateralV2Tx['withdraw_collateral_v2'];\n tx_bytes: string;\n signatures: string[];\n}\n\nexport interface IndexerServerNlpSnapshotsResponse {\n snapshots: IndexerServerNlpSnapshot[];\n}\n\nexport interface IndexerServerDDAResponse {\n v1_address: string;\n}\n\nexport interface IndexerServerBacklogResponse {\n // Total number of transactions stored in the indexer DB\n total_txs: string;\n // Current nSubmissions value from the chain (i.e., number of processed txs)\n total_submissions: string;\n // Number of unprocessed transactions (total_txs - total_submissions)\n backlog_size: string;\n // UNIX timestamp (in seconds) of when the data was last updated\n updated_at: string;\n // Estimated time in seconds (float) to clear the entire backlog (null if unavailable)\n backlog_eta_in_seconds: string | null;\n // Current submission rate in transactions per second (float) (null if unavailable)\n txs_per_second: string | null;\n}\n\nexport interface IndexerServerPrivateAlphaChoiceResponse {\n points: string;\n fee_refund: string;\n nft_eligibility: boolean;\n}\n\nexport interface IndexerServerPointsEpoch {\n epoch: number;\n description: string;\n start_time: string;\n end_time: string;\n total_points: string;\n points: string;\n rank: number;\n tier: number;\n}\n\nexport interface IndexerServerAllTimePoints {\n points: string;\n rank: number;\n tier: number;\n}\n\nexport interface IndexerServerPointsResponse {\n points_per_epoch: IndexerServerPointsEpoch[];\n all_time_points: IndexerServerAllTimePoints;\n}\n\nexport interface IndexerServerXPointsQuest {\n quest_type: string;\n points: string;\n}\n\nexport interface IndexerServerXPointsEpoch {\n epoch: number;\n description: string;\n start_time: string;\n end_time: string;\n total_points: string;\n rank: number;\n quests: IndexerServerXPointsQuest[];\n}\n\nexport interface IndexerServerXPointsAllTime {\n total_points: string;\n rank: number;\n quests: IndexerServerXPointsQuest[];\n}\n\nexport interface IndexerServerXPointsResponse {\n points_per_epoch: IndexerServerXPointsEpoch[];\n all_time_points: IndexerServerXPointsAllTime;\n}\n\nexport interface IndexerServerCashIncentivesEventMetadata {\n event_id: number;\n description: string;\n // UNIX timestamp in seconds\n epoch_start: string;\n // UNIX timestamp in seconds\n epoch_end: string;\n // x18 string\n max_volume: string;\n // x18 string\n max_reward: string;\n // x18 string\n min_volume: string;\n // x18 string\n min_reward: string;\n}\n\nexport interface IndexerServerCashIncentivesEventPlatform {\n // x18 string\n platform_volume: string;\n // x18 string\n unlocked_reward: string;\n}\n\n/**\n * Claim status of a wallet for a single Cash Incentives event.\n *\n * - `in_progress`: the event is still active.\n * - `pending`: the event has ended, but its settlement has not been published.\n * - `no_reward`: the settlement exists, but the wallet has no reward.\n * - `claimable`: the settlement grants this wallet a reward, and the proof to claim it is included.\n *\n * There is deliberately no `claimed` status. The airdrop contract's `getClaimed` is the source of\n * truth for whether a reward has already been taken, so a reward stays `claimable` here even after\n * it has been claimed onchain.\n */\nexport const INDEXER_SERVER_CASH_INCENTIVES_WALLET_STATUSES = [\n 'in_progress',\n 'pending',\n 'no_reward',\n 'claimable',\n] as const;\n\nexport type IndexerServerCashIncentivesWalletStatus =\n (typeof INDEXER_SERVER_CASH_INCENTIVES_WALLET_STATUSES)[number];\n\n/**\n * `wallet.claim` variant carrying everything needed to claim onchain.\n */\nexport interface IndexerServerCashIncentivesClaimableClaim {\n status: 'claimable';\n airdrop_address: string;\n // Reward event id within the airdrop contract, distinct from `metadata.event_id`\n week: number;\n // Integer string in raw token units, as committed to by the merkle root\n total_amount: string;\n // Merkle proof hashes\n proof: string[];\n}\n\n/**\n * `wallet.claim` variant for events with nothing to claim, which carries only the status.\n */\nexport interface IndexerServerCashIncentivesUnclaimableClaim {\n status: Exclude<IndexerServerCashIncentivesWalletStatus, 'claimable'>;\n}\n\n/**\n * Always present, tagged on `status`. Only the `claimable` variant carries proof data.\n */\nexport type IndexerServerCashIncentivesWalletClaim =\n | IndexerServerCashIncentivesClaimableClaim\n | IndexerServerCashIncentivesUnclaimableClaim;\n\nexport interface IndexerServerCashIncentivesEventWallet {\n // x18 string\n reward: string;\n claim: IndexerServerCashIncentivesWalletClaim;\n}\n\nexport interface IndexerServerCashIncentivesEvent {\n metadata: IndexerServerCashIncentivesEventMetadata;\n platform: IndexerServerCashIncentivesEventPlatform;\n wallet: IndexerServerCashIncentivesEventWallet;\n}\n\nexport interface IndexerServerCashIncentivesWalletSummary {\n // x18 string\n total_reward: string;\n // x18 string\n claimable_reward: string;\n}\n\nexport interface IndexerServerCashIncentivesResponse {\n events: IndexerServerCashIncentivesEvent[];\n wallet_summary: IndexerServerCashIncentivesWalletSummary;\n}\n\nexport interface IndexerServerSocialConnectResponse {\n url: string;\n}\n\nexport interface IndexerServerSocialAccountsResponse {\n accounts: IndexerServerSocialAccount[];\n}\n\n// Response\nexport interface IndexerServerQueryResponseByType {\n account_snapshots: IndexerServerMultiSubaccountSnapshotsResponse;\n backlog: IndexerServerBacklogResponse;\n candlesticks: IndexerServerCandlesticksResponse;\n direct_deposit_address: IndexerServerDDAResponse;\n edge_candlesticks: IndexerEdgeServerCandlesticksResponse;\n edge_market_snapshots: IndexerEdgeServerMarketSnapshotsResponse;\n events: IndexerServerEventsResponse;\n fast_withdrawal_signature: IndexerServerFastWithdrawalSignatureResponse;\n funding_rate: IndexerServerFundingRateResponse;\n funding_rate_history: IndexerServerFundingRateHistoryResponse;\n funding_rates: IndexerServerFundingRatesResponse;\n interest_and_funding: IndexerServerInterestFundingResponse;\n leaderboard: IndexerServerLeaderboardResponse;\n leaderboard_contests: IndexerServerLeaderboardContestsResponse;\n leaderboard_rank: IndexerServerLeaderboardRankResponse;\n leaderboard_register: IndexerServerLeaderboardRegisterResponse;\n leaderboard_registrations: IndexerServerLeaderboardRegistrationsResponse;\n linked_signer_rate_limit: IndexerServerLinkedSignerResponse;\n maker_statistics: IndexerServerMakerStatisticsResponse;\n market_snapshots: IndexerServerMarketSnapshotsResponse;\n matches: IndexerServerMatchEventsResponse;\n oracle_price: IndexerServerOraclePricesResponse;\n orders: IndexerServerOrdersResponse;\n perp_prices: IndexerServerPerpPricesResponse;\n portfolio: IndexerServerPortfolioResponse;\n price: IndexerServerPriceResponse;\n product_snapshots: IndexerServerMultiProductsResponse;\n products: IndexerServerProductsResponse;\n referral_code: IndexerServerReferralCodeResponse;\n subaccounts: IndexerServerListSubaccountsResponse;\n quote_price: IndexerServerQuotePriceResponse;\n nlp_snapshots: IndexerServerNlpSnapshotsResponse;\n private_alpha_choice: IndexerServerPrivateAlphaChoiceResponse;\n nado_points: IndexerServerPointsResponse;\n nado_xpoints: IndexerServerXPointsResponse;\n cash_incentives: IndexerServerCashIncentivesResponse;\n social_connect: IndexerServerSocialConnectResponse;\n list_social_accounts: IndexerServerSocialAccountsResponse;\n revoke_social_account: IndexerServerSocialAccountsResponse;\n}\n\n/**\n * V2 API Types\n */\n\n/**\n * Individual ticker data from v2 indexer endpoint (server format)\n */\nexport interface IndexerServerV2TickerResponse {\n product_id: number;\n ticker_id: string;\n base_currency: string;\n quote_currency: string;\n last_price: number;\n base_volume: number;\n quote_volume: number;\n price_change_percent_24h: number;\n}\n\n/**\n * Response from v2 tickers endpoint (server format)\n * Maps ticker IDs to their respective ticker data\n */\nexport type IndexerServerV2TickersResponse = Record<\n string,\n IndexerServerV2TickerResponse\n>;\n\n/**\n * Market hours data from v2 symbols endpoint (server format)\n */\nexport interface IndexerServerV2MarketHours {\n is_open: boolean;\n reason: string | null;\n next_close: string | null;\n next_open: string | null;\n}\n\n/**\n * Individual symbol data from v2 indexer endpoint (server format)\n */\nexport interface IndexerServerV2Symbol {\n type: string;\n product_id: number;\n symbol: string;\n price_increment_x18: string;\n size_increment: string;\n min_size: string;\n maker_fee_rate_x18: string;\n taker_fee_rate_x18: string;\n long_weight_initial_x18: string;\n long_weight_maintenance_x18: string;\n /**\n * Defined only for perp markets with a max OI cap\n */\n max_open_interest_x18: string | null;\n /**\n * Defined only for xStocks spot markets\n */\n exchange_rate_x18: string | null;\n trading_status: string;\n isolated_only: boolean;\n market_hours: IndexerServerV2MarketHours | null;\n /**\n * Boost tier for products with rewards boosts. Null for non-boosted products.\n * 0 = none, 1 = taker 4x / maker 4x, 2 = taker 3x / maker 4x\n */\n boost_type: number | null;\n /**\n * Taker rewards multiplier. Null for non-boosted products.\n */\n taker_multiplier: number | null;\n /**\n * Maker rewards multiplier. Null for non-boosted products.\n */\n maker_multiplier: number | null;\n}\n\n/**\n * Response from v2 symbols endpoint (server format)\n * Maps symbols to their respective data\n */\nexport type IndexerServerV2SymbolsResponse = Record<\n string,\n IndexerServerV2Symbol\n>;\n\n/**\n * Wire `request_type` the indexer echoes on failure envelopes. The indexer's failure envelope is\n * keyed by route (`<verb>_<query_type>`), mirroring the engine and trigger services. Kept as a\n * `${string}_${string}` template to avoid enumerating the full set of v1 query types declared\n * above.\n */\nexport type IndexerServerRequestType = `${string}_${string}`;\n\n/**\n * Failure envelope returned by the indexer service API. Mirrors the failure shape used by the\n * engine and trigger services: a `status: 'failure'` discriminant plus an `error`/`error_code`\n * pair and the originating `request_type`. A response missing this envelope shape (e.g. a\n * malformed body, or a non-JSON response) is a transport-level error, not a domain error.\n *\n * The v2 REST endpoints do not return this envelope — they use plain HTTP error responses\n * without an `error_code` field.\n */\nexport interface IndexerServerFailureResponse {\n status: 'failure';\n error: string;\n error_code: number;\n request_type: IndexerServerRequestType;\n}\n\n/**\n * Narrows an unknown response body to the indexer service API failure envelope.\n */\nexport function isIndexerServerFailureResponse(\n data: unknown,\n): data is IndexerServerFailureResponse {\n return (\n typeof data === 'object' &&\n data !== null &&\n (data as Record<string, unknown>).status === 'failure'\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA+lBA,MAAa,iDAAiD;CAC5D;CACA;CACA;CACA;AACF;;;;AA6NA,SAAgB,+BACd,MACsC;CACtC,OACE,OAAO,SAAS,YAChB,SAAS,QACR,KAAiC,WAAW;AAEjD"}
1
+ {"version":3,"file":"serverTypes.js","names":[],"sources":["../../src/types/serverTypes.ts"],"sourcesContent":["import {\n EIP712LeaderboardAuthenticationValues,\n EIP712SocialAuthenticationValues,\n SignedTx,\n} from '@nadohq/shared';\nimport { IndexerEventType } from './IndexerEventType';\nimport { IndexerLeaderboardRankType } from './IndexerLeaderboardType';\nimport { NadoWithdrawCollateralTx, NadoWithdrawCollateralV2Tx } from './NadoTx';\nimport {\n IndexerServerCandlestick,\n IndexerServerEvent,\n IndexerServerLeaderboardContest,\n IndexerServerLeaderboardPosition,\n IndexerServerLeaderboardRegistration,\n IndexerServerMaker,\n IndexerServerMarketSnapshot,\n IndexerServerMarketSnapshotInterval,\n IndexerServerMatchEvent,\n IndexerServerNlpSnapshot,\n IndexerServerOraclePrice,\n IndexerServerOrder,\n IndexerServerPosition,\n IndexerServerProductPayment,\n IndexerServerProductSnapshot,\n IndexerServerSnapshotsInterval,\n IndexerServerSocialAccount,\n IndexerServerTx,\n} from './serverModelTypes';\n\n/**\n * Params\n */\n\nexport interface IndexerServerListSubaccountsParams {\n // Inclusive, defaults to 0\n start?: number;\n // Defaults to 100\n limit?: number;\n address?: string;\n}\n\nexport interface IndexerServerMultiSubaccountSnapshotsParams {\n // Subaccount hex identifiers\n subaccounts: string[];\n timestamps: number[];\n // If not given, will return both isolated & non-iso balances\n isolated?: boolean;\n}\n\nexport interface IndexerServerReferralCodeParams {\n subaccount: string;\n}\n\nexport interface IndexerServerFundingRateParams {\n product_id: number;\n}\n\nexport interface IndexerServerFundingRatesParams {\n product_ids: number[];\n}\n\nexport interface IndexerServerFundingRateHistoryParams {\n product_id: number;\n start_time?: number | string;\n end_time?: number | string;\n // Max number of rates to return. Defaults to 100, max 1000.\n limit?: number;\n}\n\nexport interface IndexerServerPriceParams {\n product_id: number;\n}\n\nexport interface IndexerServerPerpPricesParams {\n product_ids: number[];\n}\n\nexport interface IndexerServerPortfolioParams {\n subaccount: string;\n}\n\nexport interface IndexerServerOraclePricesParams {\n product_ids: number[];\n}\n\nexport interface IndexerServerCandlesticksParams {\n product_id: number;\n granularity: number;\n // Seconds\n max_time?: number;\n limit: number;\n}\n\nexport type IndexerEdgeServerCandlesticksParams =\n IndexerServerCandlesticksParams;\n\nexport interface IndexerServerProductsParams {\n product_id: number;\n max_time?: number;\n limit: number;\n // submission_idx for pagination, inclusive\n idx?: string;\n}\n\nexport interface IndexerServerMultiProductsParams {\n product_ids: number[];\n max_time: number[];\n}\n\nexport interface IndexerServerEventsParams {\n subaccounts?: string[];\n product_ids?: number[];\n // If not given, will return both isolated & non-iso events\n isolated?: boolean;\n event_types?: IndexerEventType[];\n // Descending order for idx (time), defaults to true\n desc?: boolean;\n // submission_idx for pagination, inclusive\n idx?: string;\n max_time?: number;\n limit?:\n | {\n raw: number;\n }\n | {\n txs: number;\n };\n}\n\nexport type IndexerServerTriggerTypeFilter =\n | 'none'\n | 'price_trigger'\n | 'time_trigger';\n\nexport interface IndexerServerOrdersParams {\n subaccounts?: string[];\n product_ids?: number[];\n trigger_types?: IndexerServerTriggerTypeFilter[];\n digests?: string[];\n max_time?: number;\n limit?: number;\n // If not given, will return both isolated & non-iso orders\n isolated?: boolean;\n // submission_idx for pagination, inclusive\n idx?: string;\n}\n\nexport interface IndexerServerMatchEventsParams {\n subaccounts?: string[];\n product_ids?: number[];\n // If not given, will return both isolated & non-iso events\n isolated?: boolean;\n max_time?: number;\n limit: number;\n // submission_idx for pagination, inclusive\n idx?: string;\n}\n\n/**\n * Params for the positions query. All parameters except `subaccount` are optional filters.\n */\nexport interface IndexerServerPositionsParams {\n // Subaccount hex identifier. Isolated positions are also returned under the parent subaccount\n subaccount: string;\n // When provided, only return positions of the specified product\n product_id?: number;\n // If not given, will return both isolated & cross positions\n isolated?: boolean;\n // If not given, will return both open & closed positions\n open?: boolean;\n // open_id for pagination, inclusive (only positions with open_id <= idx are returned)\n idx?: number | string;\n // Max number of positions to return. Defaults to 100, max 500\n limit?: number;\n}\n\nexport interface IndexerServerLinkedSignerParams {\n subaccount: string;\n}\n\nexport interface IndexerServerMarketSnapshotsParams {\n interval: IndexerServerMarketSnapshotInterval;\n // Defaults to all\n product_ids?: number[];\n}\n\nexport interface IndexerEdgeServerMarketSnapshotsParams {\n interval: IndexerServerMarketSnapshotInterval;\n}\n\nexport interface IndexerServerInterestFundingParams {\n subaccount: string;\n product_ids: number[];\n // If not given, defaults to latest\n max_idx?: string;\n max_time?: number;\n limit: number;\n}\n\nexport interface IndexerServerMakerStatisticsParams {\n product_id: number;\n epoch: number;\n interval: number;\n}\n\nexport interface IndexerServerLeaderboardParams {\n contest_id: number;\n rank_type?: IndexerLeaderboardRankType;\n start?: number | string;\n limit?: number | string;\n order?: 'ASC' | 'DESC';\n}\n\nexport interface IndexerServerLeaderboardRankParams {\n subaccount: string;\n contest_ids: number[];\n}\n\nexport interface IndexerServerLeaderboardContestsParams {\n contest_ids?: number[];\n active?: boolean;\n}\n\nexport interface IndexerServerLeaderboardRegistrationsParams {\n subaccount: string;\n contest_ids?: number[];\n active?: boolean;\n}\n\nexport interface IndexerServerLeaderboardRegisterParams {\n update_registration: SignedTx<EIP712LeaderboardAuthenticationValues>;\n}\n\nexport interface IndexerServerSocialConnectParams {\n update_social_account: SignedTx<EIP712SocialAuthenticationValues>;\n}\n\nexport interface IndexerServerListSocialAccountsParams {\n address: string;\n}\n\nexport type IndexerServerRevokeSocialAccountParams =\n IndexerServerSocialConnectParams;\n\nexport interface IndexerServerFastWithdrawalSignatureParams {\n /**\n * The submission index of the WithdrawCollateral tx to be used for fast withdraw.\n */\n idx: number | string;\n}\n\nexport interface IndexerServerNlpSnapshotsParams {\n interval: IndexerServerSnapshotsInterval;\n}\n\nexport interface IndexerServerDDAQueryParams {\n subaccount: string;\n}\n\nexport interface IndexerServerPrivateAlphaChoiceParams {\n address: string;\n}\n\nexport interface IndexerServerPointsParams {\n address: string;\n}\n\nexport interface IndexerServerXPointsParams {\n address: string;\n}\n\nexport interface IndexerServerCashIncentivesParams {\n wallet_address: string;\n}\n\n// Request\nexport interface IndexerServerQueryRequestByType {\n account_snapshots: IndexerServerMultiSubaccountSnapshotsParams;\n backlog: Record<string, never>;\n candlesticks: IndexerServerCandlesticksParams;\n direct_deposit_address: IndexerServerDDAQueryParams;\n edge_candlesticks: IndexerEdgeServerCandlesticksParams;\n edge_market_snapshots: IndexerEdgeServerMarketSnapshotsParams;\n events: IndexerServerEventsParams;\n fast_withdrawal_signature: IndexerServerFastWithdrawalSignatureParams;\n funding_rate: IndexerServerFundingRateParams;\n funding_rate_history: IndexerServerFundingRateHistoryParams;\n funding_rates: IndexerServerFundingRatesParams;\n interest_and_funding: IndexerServerInterestFundingParams;\n leaderboard: IndexerServerLeaderboardParams;\n leaderboard_contests: IndexerServerLeaderboardContestsParams;\n leaderboard_rank: IndexerServerLeaderboardRankParams;\n leaderboard_register: IndexerServerLeaderboardRegisterParams;\n leaderboard_registrations: IndexerServerLeaderboardRegistrationsParams;\n linked_signer_rate_limit: IndexerServerLinkedSignerParams;\n maker_statistics: IndexerServerMakerStatisticsParams;\n market_snapshots: IndexerServerMarketSnapshotsParams;\n matches: IndexerServerMatchEventsParams;\n oracle_price: IndexerServerOraclePricesParams;\n orders: IndexerServerOrdersParams;\n perp_prices: IndexerServerPerpPricesParams;\n portfolio: IndexerServerPortfolioParams;\n positions: IndexerServerPositionsParams;\n price: IndexerServerPriceParams;\n product_snapshots: IndexerServerMultiProductsParams;\n products: IndexerServerProductsParams;\n referral_code: IndexerServerReferralCodeParams;\n subaccounts: IndexerServerListSubaccountsParams;\n quote_price: Record<string, never>;\n nlp_snapshots: IndexerServerNlpSnapshotsParams;\n private_alpha_choice: IndexerServerPrivateAlphaChoiceParams;\n nado_points: IndexerServerPointsParams;\n nado_xpoints: IndexerServerXPointsParams;\n cash_incentives: IndexerServerCashIncentivesParams;\n social_connect: IndexerServerSocialConnectParams;\n list_social_accounts: IndexerServerListSocialAccountsParams;\n revoke_social_account: IndexerServerRevokeSocialAccountParams;\n}\n\nexport type IndexerServerQueryRequestType =\n keyof IndexerServerQueryRequestByType;\n\n/**\n * Responses\n */\n\nexport interface IndexerServerListSubaccountsResponse {\n subaccounts: {\n id: string;\n // Hex of subaccount bytes\n subaccount: string;\n // UNIX timestamp in seconds\n created_at: string;\n isolated: boolean;\n }[];\n}\n\nexport interface IndexerServerMultiSubaccountSnapshotsResponse {\n // Map of subaccount hex -> timestamp requested -> latest events corresponding to each product\n snapshots: Record<string, Record<string, IndexerServerEvent[]>>;\n}\n\nexport interface IndexerServerReferralCodeResponse {\n referral_code: string | null;\n}\n\nexport interface IndexerServerFundingRate {\n product_id: number;\n funding_rate_x18: string;\n update_time: number;\n}\n\nexport type IndexerServerFundingRateResponse = IndexerServerFundingRate;\n\n// Map of productId -> IndexerServerFundingRate\nexport type IndexerServerFundingRatesResponse = Record<\n string,\n IndexerServerFundingRate\n>;\n\nexport interface IndexerServerFundingRateHistoryEntry {\n product_id: number;\n // Epoch time in seconds of the settlement tick this funding rate was recorded at.\n timestamp: string;\n // Realized hourly funding rate at this tick, multiplied by 10^18 (% = rate * 100).\n funding_rate_x18: string;\n}\n\nexport interface IndexerServerFundingRateHistoryResponse {\n // Always ascending by timestamp.\n funding_rates: IndexerServerFundingRateHistoryEntry[];\n}\n\nexport type IndexerServerPortfolioPeriod =\n | 'day'\n | 'week'\n | 'month'\n | 'allTime'\n | 'perpDay'\n | 'perpWeek'\n | 'perpMonth'\n | 'perpAllTime';\n\n/**\n * [timestamp (unix seconds), value] — both x18-free decimal strings. Values are\n * USDT0-denominated, except `marketCountHistory` points, which are integer counts.\n */\nexport type IndexerServerPortfolioPoint = [string, string];\n\n// All five series are aligned: same timestamps, same length.\nexport interface IndexerServerPortfolioHistory {\n accountValueHistory: IndexerServerPortfolioPoint[];\n pnlHistory: IndexerServerPortfolioPoint[];\n volumeHistory: IndexerServerPortfolioPoint[];\n tradeSizeHistory: IndexerServerPortfolioPoint[];\n marketCountHistory: IndexerServerPortfolioPoint[];\n}\n\nexport type IndexerServerPortfolioResponse = [\n IndexerServerPortfolioPeriod,\n IndexerServerPortfolioHistory,\n][];\n\nexport interface IndexerServerPerpPrices {\n product_id: number;\n index_price_x18: string;\n mark_price_x18: string;\n update_time: number;\n}\n\nexport type IndexerServerPriceResponse = IndexerServerPerpPrices;\n\n// Map of productId -> IndexerServerPerpPrices\nexport type IndexerServerPerpPricesResponse = Record<\n string,\n IndexerServerPerpPrices\n>;\n\nexport interface IndexerServerOraclePricesResponse {\n prices: IndexerServerOraclePrice[];\n}\n\nexport interface IndexerServerCandlesticksResponse {\n candlesticks: IndexerServerCandlestick[];\n}\n\nexport type IndexerEdgeServerCandlesticksResponse =\n IndexerServerCandlesticksResponse;\n\nexport interface IndexerServerProductsResponse {\n products: IndexerServerProductSnapshot[];\n txs: IndexerServerTx[];\n}\n\n// Map of timestamp -> (productID -> IndexerServerProductSnapshot)\nexport type IndexerServerMultiProductsResponse = Record<\n string,\n Record<string, IndexerServerProductSnapshot>\n>;\n\nexport interface IndexerServerEventsResponse {\n events: IndexerServerEvent[];\n txs: IndexerServerTx[];\n}\n\nexport interface IndexerServerOrdersResponse {\n orders: IndexerServerOrder[];\n}\n\nexport interface IndexerServerMatchEventsResponse {\n matches: IndexerServerMatchEvent[];\n txs: IndexerServerTx[];\n}\n\n/**\n * Response for the positions query. Positions are in descending order by `open_id`.\n * `events` / `txs` are the events and transactions at each position's boundaries\n * (open and close, or open and latest update while still open), joined to positions\n * via `open_id` / `close_id` / `submission_idx`.\n */\nexport interface IndexerServerPositionsResponse {\n positions: IndexerServerPosition[];\n events: IndexerServerEvent[];\n txs: IndexerServerTx[];\n}\n\nexport interface IndexerServerQuotePriceResponse {\n price_x18: string;\n}\n\nexport interface IndexerServerLinkedSignerResponse {\n total_tx_limit: string;\n remaining_tx: string;\n wait_time: string;\n signer: string;\n}\n\nexport interface IndexerServerMarketSnapshotsResponse {\n snapshots: IndexerServerMarketSnapshot[];\n}\n\nexport interface IndexerEdgeServerMarketSnapshotsResponse {\n snapshots: Record<number, IndexerServerMarketSnapshot[]>;\n}\n\nexport interface IndexerServerInterestFundingResponse {\n interest_payments: IndexerServerProductPayment[];\n funding_payments: IndexerServerProductPayment[];\n next_idx: string;\n}\n\nexport interface IndexerServerMakerStatisticsResponse {\n reward_coefficient: string;\n makers: IndexerServerMaker[];\n}\n\nexport interface IndexerServerLeaderboardResponse {\n positions: IndexerServerLeaderboardPosition[];\n}\n\nexport interface IndexerServerLeaderboardRegistrationsResponse {\n registrations: IndexerServerLeaderboardRegistration[];\n}\n\nexport type IndexerServerLeaderboardRegisterResponse =\n IndexerServerLeaderboardRegistrationsResponse;\n\nexport interface IndexerServerLeaderboardRankResponse {\n // If the subaccount is not eligible for a given contest, it would not be included in the response.\n // contestId -> IndexerServerLeaderboardPosition\n positions: Record<string, IndexerServerLeaderboardPosition>;\n}\n\nexport interface IndexerServerLeaderboardContestsResponse {\n contests: IndexerServerLeaderboardContest[];\n}\n\nexport interface IndexerServerFastWithdrawalSignatureResponse {\n idx: string;\n tx: NadoWithdrawCollateralTx['withdraw_collateral'];\n // Present only for `WithdrawCollateralV2` withdrawals.\n tx_v2?: NadoWithdrawCollateralV2Tx['withdraw_collateral_v2'];\n tx_bytes: string;\n signatures: string[];\n}\n\nexport interface IndexerServerNlpSnapshotsResponse {\n snapshots: IndexerServerNlpSnapshot[];\n}\n\nexport interface IndexerServerDDAResponse {\n v1_address: string;\n}\n\nexport interface IndexerServerBacklogResponse {\n // Total number of transactions stored in the indexer DB\n total_txs: string;\n // Current nSubmissions value from the chain (i.e., number of processed txs)\n total_submissions: string;\n // Number of unprocessed transactions (total_txs - total_submissions)\n backlog_size: string;\n // UNIX timestamp (in seconds) of when the data was last updated\n updated_at: string;\n // Estimated time in seconds (float) to clear the entire backlog (null if unavailable)\n backlog_eta_in_seconds: string | null;\n // Current submission rate in transactions per second (float) (null if unavailable)\n txs_per_second: string | null;\n}\n\nexport interface IndexerServerPrivateAlphaChoiceResponse {\n points: string;\n fee_refund: string;\n nft_eligibility: boolean;\n}\n\nexport interface IndexerServerPointsEpoch {\n epoch: number;\n description: string;\n start_time: string;\n end_time: string;\n total_points: string;\n points: string;\n rank: number;\n tier: number;\n}\n\nexport interface IndexerServerAllTimePoints {\n points: string;\n rank: number;\n tier: number;\n}\n\nexport interface IndexerServerPointsResponse {\n points_per_epoch: IndexerServerPointsEpoch[];\n all_time_points: IndexerServerAllTimePoints;\n}\n\nexport interface IndexerServerXPointsQuest {\n quest_type: string;\n points: string;\n}\n\nexport interface IndexerServerXPointsEpoch {\n epoch: number;\n description: string;\n start_time: string;\n end_time: string;\n total_points: string;\n rank: number;\n quests: IndexerServerXPointsQuest[];\n}\n\nexport interface IndexerServerXPointsAllTime {\n total_points: string;\n rank: number;\n quests: IndexerServerXPointsQuest[];\n}\n\nexport interface IndexerServerXPointsResponse {\n points_per_epoch: IndexerServerXPointsEpoch[];\n all_time_points: IndexerServerXPointsAllTime;\n}\n\nexport interface IndexerServerCashIncentivesEventMetadata {\n event_id: number;\n description: string;\n // UNIX timestamp in seconds\n epoch_start: string;\n // UNIX timestamp in seconds\n epoch_end: string;\n // x18 string\n max_volume: string;\n // x18 string\n max_reward: string;\n // x18 string\n min_volume: string;\n // x18 string\n min_reward: string;\n}\n\nexport interface IndexerServerCashIncentivesEventPlatform {\n // x18 string\n platform_volume: string;\n // x18 string\n unlocked_reward: string;\n}\n\n/**\n * Claim status of a wallet for a single Cash Incentives event.\n *\n * - `in_progress`: the event is still active.\n * - `pending`: the event has ended, but its settlement has not been published.\n * - `no_reward`: the settlement exists, but the wallet has no reward.\n * - `claimable`: the settlement grants this wallet a reward, and the proof to claim it is included.\n *\n * There is deliberately no `claimed` status. The airdrop contract's `getClaimed` is the source of\n * truth for whether a reward has already been taken, so a reward stays `claimable` here even after\n * it has been claimed onchain.\n */\nexport const INDEXER_SERVER_CASH_INCENTIVES_WALLET_STATUSES = [\n 'in_progress',\n 'pending',\n 'no_reward',\n 'claimable',\n] as const;\n\nexport type IndexerServerCashIncentivesWalletStatus =\n (typeof INDEXER_SERVER_CASH_INCENTIVES_WALLET_STATUSES)[number];\n\n/**\n * `wallet.claim` variant carrying everything needed to claim onchain.\n */\nexport interface IndexerServerCashIncentivesClaimableClaim {\n status: 'claimable';\n airdrop_address: string;\n // Reward event id within the airdrop contract, distinct from `metadata.event_id`\n week: number;\n // Integer string in raw token units, as committed to by the merkle root\n total_amount: string;\n // Merkle proof hashes\n proof: string[];\n}\n\n/**\n * `wallet.claim` variant for events with nothing to claim, which carries only the status.\n */\nexport interface IndexerServerCashIncentivesUnclaimableClaim {\n status: Exclude<IndexerServerCashIncentivesWalletStatus, 'claimable'>;\n}\n\n/**\n * Always present, tagged on `status`. Only the `claimable` variant carries proof data.\n */\nexport type IndexerServerCashIncentivesWalletClaim =\n | IndexerServerCashIncentivesClaimableClaim\n | IndexerServerCashIncentivesUnclaimableClaim;\n\nexport interface IndexerServerCashIncentivesEventWallet {\n // x18 string\n reward: string;\n claim: IndexerServerCashIncentivesWalletClaim;\n}\n\nexport interface IndexerServerCashIncentivesEvent {\n metadata: IndexerServerCashIncentivesEventMetadata;\n platform: IndexerServerCashIncentivesEventPlatform;\n wallet: IndexerServerCashIncentivesEventWallet;\n}\n\nexport interface IndexerServerCashIncentivesWalletSummary {\n // x18 string\n total_reward: string;\n // x18 string\n claimable_reward: string;\n}\n\nexport interface IndexerServerCashIncentivesResponse {\n events: IndexerServerCashIncentivesEvent[];\n wallet_summary: IndexerServerCashIncentivesWalletSummary;\n}\n\nexport interface IndexerServerSocialConnectResponse {\n url: string;\n}\n\nexport interface IndexerServerSocialAccountsResponse {\n accounts: IndexerServerSocialAccount[];\n}\n\n// Response\nexport interface IndexerServerQueryResponseByType {\n account_snapshots: IndexerServerMultiSubaccountSnapshotsResponse;\n backlog: IndexerServerBacklogResponse;\n candlesticks: IndexerServerCandlesticksResponse;\n direct_deposit_address: IndexerServerDDAResponse;\n edge_candlesticks: IndexerEdgeServerCandlesticksResponse;\n edge_market_snapshots: IndexerEdgeServerMarketSnapshotsResponse;\n events: IndexerServerEventsResponse;\n fast_withdrawal_signature: IndexerServerFastWithdrawalSignatureResponse;\n funding_rate: IndexerServerFundingRateResponse;\n funding_rate_history: IndexerServerFundingRateHistoryResponse;\n funding_rates: IndexerServerFundingRatesResponse;\n interest_and_funding: IndexerServerInterestFundingResponse;\n leaderboard: IndexerServerLeaderboardResponse;\n leaderboard_contests: IndexerServerLeaderboardContestsResponse;\n leaderboard_rank: IndexerServerLeaderboardRankResponse;\n leaderboard_register: IndexerServerLeaderboardRegisterResponse;\n leaderboard_registrations: IndexerServerLeaderboardRegistrationsResponse;\n linked_signer_rate_limit: IndexerServerLinkedSignerResponse;\n maker_statistics: IndexerServerMakerStatisticsResponse;\n market_snapshots: IndexerServerMarketSnapshotsResponse;\n matches: IndexerServerMatchEventsResponse;\n oracle_price: IndexerServerOraclePricesResponse;\n orders: IndexerServerOrdersResponse;\n perp_prices: IndexerServerPerpPricesResponse;\n portfolio: IndexerServerPortfolioResponse;\n positions: IndexerServerPositionsResponse;\n price: IndexerServerPriceResponse;\n product_snapshots: IndexerServerMultiProductsResponse;\n products: IndexerServerProductsResponse;\n referral_code: IndexerServerReferralCodeResponse;\n subaccounts: IndexerServerListSubaccountsResponse;\n quote_price: IndexerServerQuotePriceResponse;\n nlp_snapshots: IndexerServerNlpSnapshotsResponse;\n private_alpha_choice: IndexerServerPrivateAlphaChoiceResponse;\n nado_points: IndexerServerPointsResponse;\n nado_xpoints: IndexerServerXPointsResponse;\n cash_incentives: IndexerServerCashIncentivesResponse;\n social_connect: IndexerServerSocialConnectResponse;\n list_social_accounts: IndexerServerSocialAccountsResponse;\n revoke_social_account: IndexerServerSocialAccountsResponse;\n}\n\n/**\n * V2 API Types\n */\n\n/**\n * Individual ticker data from v2 indexer endpoint (server format)\n */\nexport interface IndexerServerV2TickerResponse {\n product_id: number;\n ticker_id: string;\n base_currency: string;\n quote_currency: string;\n last_price: number;\n base_volume: number;\n quote_volume: number;\n price_change_percent_24h: number;\n}\n\n/**\n * Response from v2 tickers endpoint (server format)\n * Maps ticker IDs to their respective ticker data\n */\nexport type IndexerServerV2TickersResponse = Record<\n string,\n IndexerServerV2TickerResponse\n>;\n\n/**\n * Market hours data from v2 symbols endpoint (server format)\n */\nexport interface IndexerServerV2MarketHours {\n is_open: boolean;\n reason: string | null;\n next_close: string | null;\n next_open: string | null;\n}\n\n/**\n * Individual symbol data from v2 indexer endpoint (server format)\n */\nexport interface IndexerServerV2Symbol {\n type: string;\n product_id: number;\n symbol: string;\n price_increment_x18: string;\n size_increment: string;\n min_size: string;\n maker_fee_rate_x18: string;\n taker_fee_rate_x18: string;\n long_weight_initial_x18: string;\n long_weight_maintenance_x18: string;\n /**\n * Defined only for perp markets with a max OI cap\n */\n max_open_interest_x18: string | null;\n /**\n * Defined only for xStocks spot markets\n */\n exchange_rate_x18: string | null;\n trading_status: string;\n isolated_only: boolean;\n market_hours: IndexerServerV2MarketHours | null;\n /**\n * Boost tier for products with rewards boosts. Null for non-boosted products.\n * 0 = none, 1 = taker 4x / maker 4x, 2 = taker 3x / maker 4x\n */\n boost_type: number | null;\n /**\n * Taker rewards multiplier. Null for non-boosted products.\n */\n taker_multiplier: number | null;\n /**\n * Maker rewards multiplier. Null for non-boosted products.\n */\n maker_multiplier: number | null;\n}\n\n/**\n * Response from v2 symbols endpoint (server format)\n * Maps symbols to their respective data\n */\nexport type IndexerServerV2SymbolsResponse = Record<\n string,\n IndexerServerV2Symbol\n>;\n\n/**\n * Wire `request_type` the indexer echoes on failure envelopes. The indexer's failure envelope is\n * keyed by route (`<verb>_<query_type>`), mirroring the engine and trigger services. Kept as a\n * `${string}_${string}` template to avoid enumerating the full set of v1 query types declared\n * above.\n */\nexport type IndexerServerRequestType = `${string}_${string}`;\n\n/**\n * Failure envelope returned by the indexer service API. Mirrors the failure shape used by the\n * engine and trigger services: a `status: 'failure'` discriminant plus an `error`/`error_code`\n * pair and the originating `request_type`. A response missing this envelope shape (e.g. a\n * malformed body, or a non-JSON response) is a transport-level error, not a domain error.\n *\n * The v2 REST endpoints do not return this envelope — they use plain HTTP error responses\n * without an `error_code` field.\n */\nexport interface IndexerServerFailureResponse {\n status: 'failure';\n error: string;\n error_code: number;\n request_type: IndexerServerRequestType;\n}\n\n/**\n * Narrows an unknown response body to the indexer service API failure envelope.\n */\nexport function isIndexerServerFailureResponse(\n data: unknown,\n): data is IndexerServerFailureResponse {\n return (\n typeof data === 'object' &&\n data !== null &&\n (data as Record<string, unknown>).status === 'failure'\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA+nBA,MAAa,iDAAiD;CAC5D;CACA;CACA;CACA;AACF;;;;AA8NA,SAAgB,+BACd,MACsC;CACtC,OACE,OAAO,SAAS,YAChB,SAAS,QACR,KAAiC,WAAW;AAEjD"}
@@ -1,2 +1,2 @@
1
- import { n as calcIndexerPerpBalanceValue, r as calcIndexerSpotBalanceValue, t as calcIndexerPerpBalanceNotionalValue } from "../indexerBalanceValue-DqMAvUsj.cjs";
1
+ import { n as calcIndexerPerpBalanceValue, r as calcIndexerSpotBalanceValue, t as calcIndexerPerpBalanceNotionalValue } from "../indexerBalanceValue-yMyf537D.cjs";
2
2
  export { calcIndexerPerpBalanceNotionalValue, calcIndexerPerpBalanceValue, calcIndexerSpotBalanceValue };
@@ -1,2 +1,2 @@
1
- import { n as calcIndexerPerpBalanceValue, r as calcIndexerSpotBalanceValue, t as calcIndexerPerpBalanceNotionalValue } from "../indexerBalanceValue-ZJec8hfI.js";
1
+ import { n as calcIndexerPerpBalanceValue, r as calcIndexerSpotBalanceValue, t as calcIndexerPerpBalanceNotionalValue } from "../indexerBalanceValue-DV3dtvyV.js";
2
2
  export { calcIndexerPerpBalanceNotionalValue, calcIndexerPerpBalanceValue, calcIndexerSpotBalanceValue };
@@ -1,2 +1,2 @@
1
- import { n as calcIndexerPerpBalanceValue, r as calcIndexerSpotBalanceValue, t as calcIndexerPerpBalanceNotionalValue } from "../indexerBalanceValue-DqMAvUsj.cjs";
1
+ import { n as calcIndexerPerpBalanceValue, r as calcIndexerSpotBalanceValue, t as calcIndexerPerpBalanceNotionalValue } from "../indexerBalanceValue-yMyf537D.cjs";
2
2
  export { calcIndexerPerpBalanceNotionalValue, calcIndexerPerpBalanceValue, calcIndexerSpotBalanceValue };
@@ -1,2 +1,2 @@
1
- import { n as calcIndexerPerpBalanceValue, r as calcIndexerSpotBalanceValue, t as calcIndexerPerpBalanceNotionalValue } from "../indexerBalanceValue-ZJec8hfI.js";
1
+ import { n as calcIndexerPerpBalanceValue, r as calcIndexerSpotBalanceValue, t as calcIndexerPerpBalanceNotionalValue } from "../indexerBalanceValue-DV3dtvyV.js";
2
2
  export { calcIndexerPerpBalanceNotionalValue, calcIndexerPerpBalanceValue, calcIndexerSpotBalanceValue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nadohq/indexer-client",
3
- "version": "0.41.0",
3
+ "version": "0.42.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "HTTP client for the Nado indexer — historical data, events, and analytics queries",
@@ -41,8 +41,8 @@
41
41
  "module": "./dist/index.js",
42
42
  "types": "./dist/index.d.ts",
43
43
  "dependencies": {
44
- "@nadohq/engine-client": "^0.41.0",
45
- "@nadohq/shared": "^0.41.0",
44
+ "@nadohq/engine-client": "^0.42.0",
45
+ "@nadohq/shared": "^0.42.0",
46
46
  "axios": "1.16.1",
47
47
  "ts-mixer": "6.0.4"
48
48
  },
@@ -54,5 +54,5 @@
54
54
  "bignumber.js": "11.1.1",
55
55
  "viem": "2.52.0"
56
56
  },
57
- "gitHead": "bd534f98c5e429aafc861e1fcc4a639ffd2850a6"
57
+ "gitHead": "f9db267e3f3a3068f2197faee9b1b827157f33b1"
58
58
  }
@@ -39,6 +39,7 @@ import {
39
39
  mapIndexerOrder,
40
40
  mapIndexerPerpPrices,
41
41
  mapIndexerPortfolio,
42
+ mapIndexerPosition,
42
43
  mapIndexerProductPayment,
43
44
  mapIndexerServerProduct,
44
45
  mapIndexerV2Symbols,
@@ -103,6 +104,8 @@ import {
103
104
  GetIndexerPointsResponse,
104
105
  GetIndexerPortfolioParams,
105
106
  GetIndexerPortfolioResponse,
107
+ GetIndexerPositionsParams,
108
+ GetIndexerPositionsResponse,
106
109
  GetIndexerPrivateAlphaChoiceParams,
107
110
  GetIndexerPrivateAlphaChoiceResponse,
108
111
  GetIndexerProductSnapshotsParams,
@@ -626,6 +629,53 @@ export class IndexerBaseClient {
626
629
  });
627
630
  }
628
631
 
632
+ /**
633
+ * Retrieves a subaccount's historical positions, ordered descending by `openId`.
634
+ * Positions are tracked for every product except the quote product.
635
+ *
636
+ * The response also includes the boundary events (with their transactions) at each
637
+ * position's open and close, or open and latest update while still open; join them
638
+ * to positions via `openId` / `closeId` / `submissionIndex`.
639
+ *
640
+ * To paginate, pass the last returned position's `openId - 1` as the next request's
641
+ * `startCursor`.
642
+ *
643
+ * @param params
644
+ */
645
+ async getPositions(
646
+ params: GetIndexerPositionsParams,
647
+ ): Promise<GetIndexerPositionsResponse> {
648
+ const baseResponse = await this.query('positions', {
649
+ subaccount: subaccountToHex({
650
+ subaccountOwner: params.subaccount.subaccountOwner,
651
+ subaccountName: params.subaccount.subaccountName,
652
+ }),
653
+ product_id: params.productId,
654
+ isolated: params.isolated,
655
+ open: params.open,
656
+ idx: params.startCursor,
657
+ limit: params.limit,
658
+ });
659
+
660
+ // Unlike `getEvents`, boundary events aren't strictly ordered against txs, so join by submission index
661
+ const txsBySubmissionIdx = new Map(
662
+ baseResponse.txs.map((tx) => [tx.submission_idx, tx]),
663
+ );
664
+
665
+ return {
666
+ positions: baseResponse.positions.map(mapIndexerPosition),
667
+ events: baseResponse.events.map((event) => {
668
+ const tx = txsBySubmissionIdx.get(event.submission_idx);
669
+ if (!tx) {
670
+ throw Error(
671
+ `No tx found for position boundary event with submission_idx ${event.submission_idx}`,
672
+ );
673
+ }
674
+ return mapIndexerEventWithTx(event, tx);
675
+ }),
676
+ };
677
+ }
678
+
629
679
  /**
630
680
  * Retrieves historical funding & interest payments.
631
681
  * NOTE: `limit` is an upperbound. If a user changes position size such that his position is 0 during each funding/interest tick,
@@ -33,6 +33,7 @@ import {
33
33
  IndexerPerpBalance,
34
34
  IndexerPerpPrices,
35
35
  IndexerPortfolioPoint,
36
+ IndexerPosition,
36
37
  IndexerProductPayment,
37
38
  IndexerServerBalance,
38
39
  IndexerServerCandlestick,
@@ -50,6 +51,7 @@ import {
50
51
  IndexerServerPerpPrices,
51
52
  IndexerServerPortfolioPoint,
52
53
  IndexerServerPortfolioResponse,
54
+ IndexerServerPosition,
53
55
  IndexerServerProduct,
54
56
  IndexerServerProductPayment,
55
57
  IndexerServerSnapshotsInterval,
@@ -204,6 +206,45 @@ export function mapIndexerMatchEventBalances(
204
206
  };
205
207
  }
206
208
 
209
+ /**
210
+ * Maps a position returned by the indexer positions query to its client representation.
211
+ * @param position - The position in server (snake_case, x18 prices) format.
212
+ * @returns The position with camelCase fields and BigNumber values.
213
+ */
214
+ export function mapIndexerPosition(
215
+ position: IndexerServerPosition,
216
+ ): IndexerPosition {
217
+ return {
218
+ subaccount: position.subaccount,
219
+ productId: position.product_id,
220
+ isolated: position.isolated,
221
+ direction: position.direction,
222
+ openId: position.open_id,
223
+ closeId: position.close_id,
224
+ submissionIndex: position.submission_idx,
225
+ amount: toBigNumber(position.amount),
226
+ maxAmount: toBigNumber(position.max_amount),
227
+ totalOpenAmount: toBigNumber(position.total_open_amount),
228
+ totalCloseAmount: toBigNumber(position.total_close_amount),
229
+ averageEntryPrice: removeDecimals(position.average_entry_price),
230
+ averageExitPrice: removeDecimals(position.average_exit_price),
231
+ liquidatedAmount: toBigNumber(position.liquidated_amount),
232
+ maxIsolatedLeverage: removeDecimals(position.max_isolated_leverage_x18),
233
+ openFee: toBigNumber(position.open_fee),
234
+ closeFee: toBigNumber(position.close_fee),
235
+ realizedPnl: toBigNumber(position.realized_pnl),
236
+ openTimestamp: toBigNumber(position.open_timestamp),
237
+ updateTimestamp: toBigNumber(position.update_timestamp),
238
+ openReason: position.open_reason,
239
+ closeReason: position.close_reason,
240
+ netFundingPayment: toBigNumber(position.net_funding_payment),
241
+ netInterestPayment: toBigNumber(position.net_interest_payment),
242
+ openDigest: position.open_digest,
243
+ closeDigest: position.close_digest,
244
+ netEntryUnrealized: toBigNumber(position.net_entry_unrealized),
245
+ };
246
+ }
247
+
207
248
  export function mapIndexerProductPayment(
208
249
  payment: IndexerServerProductPayment,
209
250
  ): IndexerProductPayment {
@@ -1,11 +1,19 @@
1
- export type IndexerEventType =
2
- | 'liquidate_subaccount'
3
- | 'deposit_collateral'
4
- | 'withdraw_collateral'
5
- | 'withdraw_collateral_v2'
6
- | 'settle_pnl'
7
- | 'match_orders'
8
- | 'transfer_quote'
9
- | 'mint_nlp'
10
- | 'burn_nlp'
11
- | 'claim_builder_fee';
1
+ /**
2
+ * All balance-change event types emitted by the indexer. This is also the set of
3
+ * transaction types that can open/close a position (`openReason` / `closeReason`).
4
+ */
5
+ export const INDEXER_EVENT_TYPES = [
6
+ 'liquidate_subaccount',
7
+ 'deposit_collateral',
8
+ 'withdraw_collateral',
9
+ 'withdraw_collateral_v2',
10
+ 'settle_pnl',
11
+ 'match_orders',
12
+ 'transfer_quote',
13
+ 'mint_nlp',
14
+ 'burn_nlp',
15
+ 'claim_builder_fee',
16
+ 'delist_product',
17
+ ] as const;
18
+
19
+ export type IndexerEventType = (typeof INDEXER_EVENT_TYPES)[number];
@@ -4,12 +4,6 @@ export interface NadoMatchOrdersTx {
4
4
  };
5
5
  }
6
6
 
7
- export interface NadoMatchOrdersRfqTx {
8
- match_orders_r_f_q: {
9
- product_id: number;
10
- };
11
- }
12
-
13
7
  export interface NadoLiquidateSubaccountTx {
14
8
  liquidate_subaccount: {
15
9
  sender: string;
@@ -63,7 +57,6 @@ export interface NadoTransferQuoteTx {
63
57
 
64
58
  export type NadoTx =
65
59
  | NadoMatchOrdersTx
66
- | NadoMatchOrdersRfqTx
67
60
  | NadoLiquidateSubaccountTx
68
61
  | NadoDepositCollateralTx
69
62
  | NadoTransferQuoteTx
@@ -561,6 +561,112 @@ export interface IndexerMatchEvent extends Subaccount {
561
561
 
562
562
  export type GetIndexerMatchEventsResponse = IndexerMatchEvent[];
563
563
 
564
+ /**
565
+ * Position history
566
+ */
567
+
568
+ /**
569
+ * Params for querying a subaccount's historical positions. All parameters except
570
+ * `subaccount` are optional filters.
571
+ */
572
+ export interface GetIndexerPositionsParams {
573
+ /**
574
+ * Subaccount to query. Isolated positions are also returned under the parent
575
+ * subaccount, so always query with the parent.
576
+ */
577
+ subaccount: Subaccount;
578
+ /** When provided, only return positions of the specified product. */
579
+ productId?: number;
580
+ /** `true`: only isolated positions, `false`: only cross positions. Omit for both. */
581
+ isolated?: boolean;
582
+ /** `true`: only positions that are still open, `false`: only closed positions. Omit for both. */
583
+ open?: boolean;
584
+ /**
585
+ * Max `openId`, inclusive. To paginate, pass the last returned position's
586
+ * `openId - 1` as the next request's `startCursor`.
587
+ */
588
+ startCursor?: string;
589
+ /** Max number of positions to return. Defaults to 100, max 500. */
590
+ limit?: number;
591
+ }
592
+
593
+ /**
594
+ * A historical position for a subaccount in a product. A position opens when the balance
595
+ * goes from zero to non-zero or flips direction, and closes when the balance returns to
596
+ * zero or flips again. All amount fields are absolute values; the side of the position is
597
+ * given by `direction`.
598
+ */
599
+ export interface IndexerPosition {
600
+ /** Subaccount hex ID associated with the position. */
601
+ subaccount: string;
602
+ productId: number;
603
+ isolated: boolean;
604
+ /** Direction of the position. `true` for long, `false` for short. */
605
+ direction: boolean;
606
+ /** `submissionIndex` of the transaction that opened the position. */
607
+ openId: string;
608
+ /** `submissionIndex` of the transaction that closed the position; `-1` if still open. */
609
+ closeId: string;
610
+ /** `submissionIndex` of the last transaction that updated the position. */
611
+ submissionIndex: string;
612
+ /** Current size of the position; `0` once the position is closed. */
613
+ amount: BigNumber;
614
+ /** Peak size reached by the position. */
615
+ maxAmount: BigNumber;
616
+ /** Total amount opened on this position. */
617
+ totalOpenAmount: BigNumber;
618
+ /** Total amount closed on this position. */
619
+ totalCloseAmount: BigNumber;
620
+ /** Volume-weighted average entry price of the position. */
621
+ averageEntryPrice: BigNumber;
622
+ /** Volume-weighted average exit price of the position. */
623
+ averageExitPrice: BigNumber;
624
+ /** Total amount closed by liquidations on this position. */
625
+ liquidatedAmount: BigNumber;
626
+ /**
627
+ * Peak leverage reached by the isolated position; `0` for cross positions.
628
+ * Set to `i128::MAX` (decimal adjusted) when the position's equity is below zero.
629
+ */
630
+ maxIsolatedLeverage: BigNumber;
631
+ /** Total fees paid on fills that increased the position. */
632
+ openFee: BigNumber;
633
+ /** Total fees paid on fills that decreased the position. */
634
+ closeFee: BigNumber;
635
+ /** Realized PnL for this position. */
636
+ realizedPnl: BigNumber;
637
+ /** Unix epoch in seconds of when the position was opened. */
638
+ openTimestamp: BigNumber;
639
+ /** Unix epoch in seconds of when the position was last updated. */
640
+ updateTimestamp: BigNumber;
641
+ /** The transaction type that opened the position, e.g. `match_orders`. */
642
+ openReason: IndexerEventType;
643
+ /** The transaction type that closed the position; `null` if still open. */
644
+ closeReason: IndexerEventType | null;
645
+ /** Net funding payment on this position. Only for perp positions. */
646
+ netFundingPayment: BigNumber;
647
+ /** Net interest payment on this position. Only for spot positions. */
648
+ netInterestPayment: BigNumber;
649
+ /** Digest of the order that opened the position; `null` if not opened by a match. */
650
+ openDigest: string | null;
651
+ /** Digest of the order that closed the position; `null` if not closed by a match or still open. */
652
+ closeDigest: string | null;
653
+ netEntryUnrealized: BigNumber;
654
+ }
655
+
656
+ /**
657
+ * Response for the positions query.
658
+ */
659
+ export interface GetIndexerPositionsResponse {
660
+ /** Positions in descending order by `openId`. */
661
+ positions: IndexerPosition[];
662
+ /**
663
+ * Events (with their transactions) at each position's boundaries: open and close, or
664
+ * open and latest update while still open. Join them to positions via
665
+ * `openId` / `closeId` / `submissionIndex`.
666
+ */
667
+ events: IndexerEventWithTx[];
668
+ }
669
+
564
670
  /**
565
671
  * Quote price
566
672
  */
@@ -170,6 +170,65 @@ export interface IndexerServerMatchEventBalances {
170
170
  quote?: IndexerServerBalance;
171
171
  }
172
172
 
173
+ /**
174
+ * Positions
175
+ */
176
+
177
+ /**
178
+ * A single historical position. All amount fields are absolute values; the side of the
179
+ * position is given by `direction`.
180
+ */
181
+ export interface IndexerServerPosition {
182
+ subaccount: string;
183
+ product_id: number;
184
+ isolated: boolean;
185
+ // true for long, false for short
186
+ direction: boolean;
187
+ // submission_idx of the transaction that opened the position
188
+ open_id: string;
189
+ // submission_idx of the transaction that closed the position; -1 if still open
190
+ close_id: string;
191
+ // submission_idx of the last transaction that updated the position
192
+ submission_idx: string;
193
+ // Current size of the position; 0 once the position is closed
194
+ amount: string;
195
+ // Peak size reached by the position
196
+ max_amount: string;
197
+ total_open_amount: string;
198
+ total_close_amount: string;
199
+ // Volume-weighted average entry price (x18)
200
+ average_entry_price: string;
201
+ // Volume-weighted average exit price (x18)
202
+ average_exit_price: string;
203
+ // Total amount closed by liquidations on this position
204
+ liquidated_amount: string;
205
+ // Peak leverage reached by the isolated position; 0 for cross positions.
206
+ // Set to i128::MAX when the position's equity is below zero
207
+ max_isolated_leverage_x18: string;
208
+ // Total fees paid on fills that increased the position
209
+ open_fee: string;
210
+ // Total fees paid on fills that decreased the position
211
+ close_fee: string;
212
+ realized_pnl: string;
213
+ // Unix epoch in seconds of when the position was opened
214
+ open_timestamp: string;
215
+ // Unix epoch in seconds of when the position was last updated
216
+ update_timestamp: string;
217
+ // The transaction type that opened the position, e.g. `match_orders`
218
+ open_reason: IndexerEventType;
219
+ // The transaction type that closed the position; null if still open
220
+ close_reason: IndexerEventType | null;
221
+ // Net funding payment on this position. Only for perp positions
222
+ net_funding_payment: string;
223
+ // Net interest payment on this position. Only for spot positions
224
+ net_interest_payment: string;
225
+ // Digest of the order that opened the position; null if not opened by a match
226
+ open_digest: string | null;
227
+ // Digest of the order that closed the position; null if not closed by a match or still open
228
+ close_digest: string | null;
229
+ net_entry_unrealized: string;
230
+ }
231
+
173
232
  /**
174
233
  * Oracle price
175
234
  */
@@ -19,6 +19,7 @@ import {
19
19
  IndexerServerNlpSnapshot,
20
20
  IndexerServerOraclePrice,
21
21
  IndexerServerOrder,
22
+ IndexerServerPosition,
22
23
  IndexerServerProductPayment,
23
24
  IndexerServerProductSnapshot,
24
25
  IndexerServerSnapshotsInterval,
@@ -155,6 +156,24 @@ export interface IndexerServerMatchEventsParams {
155
156
  idx?: string;
156
157
  }
157
158
 
159
+ /**
160
+ * Params for the positions query. All parameters except `subaccount` are optional filters.
161
+ */
162
+ export interface IndexerServerPositionsParams {
163
+ // Subaccount hex identifier. Isolated positions are also returned under the parent subaccount
164
+ subaccount: string;
165
+ // When provided, only return positions of the specified product
166
+ product_id?: number;
167
+ // If not given, will return both isolated & cross positions
168
+ isolated?: boolean;
169
+ // If not given, will return both open & closed positions
170
+ open?: boolean;
171
+ // open_id for pagination, inclusive (only positions with open_id <= idx are returned)
172
+ idx?: number | string;
173
+ // Max number of positions to return. Defaults to 100, max 500
174
+ limit?: number;
175
+ }
176
+
158
177
  export interface IndexerServerLinkedSignerParams {
159
178
  subaccount: string;
160
179
  }
@@ -281,6 +300,7 @@ export interface IndexerServerQueryRequestByType {
281
300
  orders: IndexerServerOrdersParams;
282
301
  perp_prices: IndexerServerPerpPricesParams;
283
302
  portfolio: IndexerServerPortfolioParams;
303
+ positions: IndexerServerPositionsParams;
284
304
  price: IndexerServerPriceParams;
285
305
  product_snapshots: IndexerServerMultiProductsParams;
286
306
  products: IndexerServerProductsParams;
@@ -432,6 +452,18 @@ export interface IndexerServerMatchEventsResponse {
432
452
  txs: IndexerServerTx[];
433
453
  }
434
454
 
455
+ /**
456
+ * Response for the positions query. Positions are in descending order by `open_id`.
457
+ * `events` / `txs` are the events and transactions at each position's boundaries
458
+ * (open and close, or open and latest update while still open), joined to positions
459
+ * via `open_id` / `close_id` / `submission_idx`.
460
+ */
461
+ export interface IndexerServerPositionsResponse {
462
+ positions: IndexerServerPosition[];
463
+ events: IndexerServerEvent[];
464
+ txs: IndexerServerTx[];
465
+ }
466
+
435
467
  export interface IndexerServerQuotePriceResponse {
436
468
  price_x18: string;
437
469
  }
@@ -702,6 +734,7 @@ export interface IndexerServerQueryResponseByType {
702
734
  orders: IndexerServerOrdersResponse;
703
735
  perp_prices: IndexerServerPerpPricesResponse;
704
736
  portfolio: IndexerServerPortfolioResponse;
737
+ positions: IndexerServerPositionsResponse;
705
738
  price: IndexerServerPriceResponse;
706
739
  product_snapshots: IndexerServerMultiProductsResponse;
707
740
  products: IndexerServerProductsResponse;