@nadohq/indexer-client 0.2.1 → 0.3.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.
- package/dist/dataMappers.cjs +1 -0
- package/dist/dataMappers.cjs.map +1 -1
- package/dist/dataMappers.js +1 -0
- package/dist/dataMappers.js.map +1 -1
- package/dist/types/clientTypes.cjs.map +1 -1
- package/dist/types/clientTypes.d.cts +1 -0
- package/dist/types/clientTypes.d.ts +1 -0
- package/dist/types/serverModelTypes.cjs.map +1 -1
- package/dist/types/serverModelTypes.d.cts +1 -0
- package/dist/types/serverModelTypes.d.ts +1 -0
- package/package.json +4 -4
- package/src/dataMappers.ts +1 -0
- package/src/types/clientTypes.ts +2 -0
- package/src/types/serverModelTypes.ts +2 -0
package/dist/dataMappers.cjs
CHANGED
|
@@ -93,6 +93,7 @@ function mapIndexerOrder(order) {
|
|
|
93
93
|
closedSize: (0, import_shared.toBigNumber)(order.closed_amount),
|
|
94
94
|
closedNetEntry: (0, import_shared.toBigNumber)(order.closed_net_entry),
|
|
95
95
|
closedMargin: order.closed_margin ? (0, import_shared.toBigNumber)(order.closed_margin) : null,
|
|
96
|
+
preOrderAmount: (0, import_shared.toBigNumber)(order.prev_position),
|
|
96
97
|
firstFillTimestamp: (0, import_shared.toBigNumber)(order.first_fill_timestamp),
|
|
97
98
|
lastFillTimestamp: (0, import_shared.toBigNumber)(order.last_fill_timestamp)
|
|
98
99
|
};
|
package/dist/dataMappers.cjs.map
CHANGED
|
@@ -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 toBigNumber,\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 IndexerServerV2MarketHours,\n IndexerServerV2Symbol,\n IndexerServerV2TickerResponse,\n IndexerSnapshotsIntervalParams,\n IndexerSpotBalance,\n IndexerV2MarketHours,\n IndexerV2Symbol,\n IndexerV2TickerResponse,\n IndexerV2TradingStatus,\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: toBigNumber(balance.spot.balance.amount),\n productId: balance.spot.product_id,\n type: ProductEngineType.SPOT,\n };\n }\n return {\n amount: toBigNumber(balance.perp.balance.amount),\n productId: balance.perp.product_id,\n type: ProductEngineType.PERP,\n vQuoteBalance: toBigNumber(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: toBigNumber(order.amount),\n digest: order.digest,\n expiration: Number(order.expiration),\n appendix,\n nonce: toBigNumber(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: toBigNumber(order.base_filled),\n quoteFilled: toBigNumber(order.quote_filled),\n totalFee: toBigNumber(order.fee),\n builderFee: toBigNumber(order.builder_fee),\n realizedPnl: toBigNumber(order.realized_pnl),\n closedSize: toBigNumber(order.closed_amount),\n closedNetEntry: toBigNumber(order.closed_net_entry),\n closedMargin: order.closed_margin ? toBigNumber(order.closed_margin) : null,\n firstFillTimestamp: toBigNumber(order.first_fill_timestamp),\n lastFillTimestamp: toBigNumber(order.last_fill_timestamp),\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: toBigNumber(event.net_entry_cumulative),\n netEntryUnrealized: toBigNumber(event.net_entry_unrealized),\n netFundingCumulative: toBigNumber(event.net_funding_cumulative),\n netFundingUnrealized: toBigNumber(event.net_funding_unrealized),\n netInterestCumulative: toBigNumber(event.net_interest_cumulative),\n netInterestUnrealized: toBigNumber(event.net_interest_unrealized),\n quoteVolumeCumulative: toBigNumber(event.quote_volume_cumulative),\n },\n };\n}\n\nexport function mapIndexerEventWithTx(\n event: IndexerServerEvent,\n tx: IndexerServerTx,\n): IndexerEventWithTx {\n return {\n timestamp: toBigNumber(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: toBigNumber(payment.timestamp),\n paymentAmount: toBigNumber(payment.amount),\n balanceAmount: toBigNumber(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: toBigNumber(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: toBigNumber(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: toBigNumber(makerData.timestamp),\n makerFee: toBigNumber(makerData.maker_fee),\n uptime: toBigNumber(makerData.uptime),\n sumQMin: toBigNumber(makerData.sum_q_min),\n qScore: toBigNumber(makerData.q_score),\n makerShare: toBigNumber(makerData.maker_share),\n expectedMakerReward: toBigNumber(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: toBigNumber(position.pnl),\n pnlRank: toBigNumber(position.pnl_rank),\n percentRoi: toBigNumber(position.roi),\n roiRank: toBigNumber(position.roi_rank),\n accountValue: toBigNumber(position.account_value),\n volume: position.volume ? toBigNumber(position.volume) : undefined,\n updateTime: toBigNumber(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: toBigNumber(registration.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardContest(\n contest: IndexerServerLeaderboardContest,\n): IndexerLeaderboardContest {\n return {\n contestId: contest.contest_id,\n startTime: toBigNumber(contest.start_time),\n endTime: toBigNumber(contest.end_time),\n period: toBigNumber(contest.threshold),\n totalParticipants: toBigNumber(contest.count),\n minRequiredAccountValue: toBigNumber(contest.threshold),\n minRequiredVolume: toBigNumber(contest.volume_threshold),\n requiredProductIds: contest.product_ids,\n active: contest.active,\n lastUpdated: toBigNumber(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: toBigNumber(candlestick.timestamp),\n volume: toBigNumber(candlestick.volume),\n };\n}\n\nexport function mapIndexerMarketSnapshot(\n snapshot: IndexerServerMarketSnapshot,\n): IndexerMarketSnapshot {\n return {\n timestamp: toBigNumber(snapshot.timestamp),\n cumulativeUsers: toBigNumber(snapshot.cumulative_users),\n dailyActiveUsers: toBigNumber(snapshot.daily_active_users),\n tvl: toBigNumber(snapshot.tvl),\n borrowRates: mapValues(snapshot.borrow_rates, (value) =>\n removeDecimals(value),\n ),\n cumulativeLiquidationAmounts: mapValues(\n snapshot.cumulative_liquidation_amounts,\n toBigNumber,\n ),\n cumulativeMakerFees: mapValues(snapshot.cumulative_maker_fees, toBigNumber),\n cumulativeSequencerFees: mapValues(\n snapshot.cumulative_sequencer_fees,\n toBigNumber,\n ),\n cumulativeTakerFees: mapValues(snapshot.cumulative_taker_fees, toBigNumber),\n cumulativeTrades: mapValues(snapshot.cumulative_trades, toBigNumber),\n cumulativeVolumes: mapValues(snapshot.cumulative_volumes, toBigNumber),\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, toBigNumber),\n totalBorrows: mapValues(snapshot.total_borrows, toBigNumber),\n totalDeposits: mapValues(snapshot.total_deposits, toBigNumber),\n cumulativeTradeSizes: mapValues(\n snapshot.cumulative_trade_sizes,\n toBigNumber,\n ),\n cumulativeInflows: mapValues(snapshot.cumulative_inflows, toBigNumber),\n cumulativeOutflows: mapValues(snapshot.cumulative_outflows, toBigNumber),\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: toBigNumber(snapshot.timestamp),\n cumulativeBurnAmountQuote: toBigNumber(snapshot.cumulative_burn_quote),\n cumulativeMintAmountQuote: toBigNumber(snapshot.cumulative_mint_quote),\n cumulativePnl: toBigNumber(snapshot.cumulative_pnl),\n cumulativeTrades: toBigNumber(snapshot.cumulative_trades),\n cumulativeVolume: toBigNumber(snapshot.cumulative_volume),\n depositors: toBigNumber(snapshot.depositors),\n oraclePrice: removeDecimals(snapshot.oracle_price_x18),\n tvl: toBigNumber(snapshot.tvl),\n };\n}\n\nexport function mapIndexerV2Ticker(\n ticker: IndexerServerV2TickerResponse,\n): IndexerV2TickerResponse {\n return {\n productId: ticker.product_id,\n tickerId: ticker.ticker_id,\n baseCurrency: ticker.base_currency,\n quoteCurrency: ticker.quote_currency,\n lastPrice: ticker.last_price,\n baseVolume: ticker.base_volume,\n quoteVolume: ticker.quote_volume,\n priceChangePercent24h: ticker.price_change_percent_24h,\n };\n}\n\nexport function mapIndexerV2MarketHours(\n hours: IndexerServerV2MarketHours,\n): IndexerV2MarketHours {\n return {\n isOpen: hours.is_open,\n reason: hours.reason,\n nextClose: hours.next_close,\n nextOpen: hours.next_open,\n };\n}\n\nexport function mapIndexerV2Symbols(\n symbol: IndexerServerV2Symbol,\n): IndexerV2Symbol {\n return {\n type: symbol.type,\n productId: symbol.product_id,\n symbol: symbol.symbol,\n priceIncrement: removeDecimals(symbol.price_increment_x18),\n sizeIncrement: symbol.size_increment,\n minSize: symbol.min_size,\n makerFeeRate: removeDecimals(symbol.maker_fee_rate_x18),\n takerFeeRate: removeDecimals(symbol.taker_fee_rate_x18),\n longWeightInitial: removeDecimals(symbol.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(symbol.long_weight_maintenance_x18),\n maxOpenInterest: symbol.max_open_interest_x18\n ? removeDecimals(symbol.max_open_interest_x18)\n : null,\n tradingStatus: symbol.trading_status as IndexerV2TradingStatus,\n isolatedOnly: symbol.isolated_only,\n marketHours: symbol.market_hours\n ? mapIndexerV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IACd,WAAW,MAAM;AAAA,IACjB,UAAU,MAAM;AAAA,EAClB;AACF;AAEO,SAAS,oBACd,QACiB;AACjB,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb,WAAW,OAAO;AAAA,IAClB,QAAQ,OAAO;AAAA,IACf,oBAAgB,8BAAe,OAAO,mBAAmB;AAAA,IACzD,eAAe,OAAO;AAAA,IACtB,SAAS,OAAO;AAAA,IAChB,kBAAc,8BAAe,OAAO,kBAAkB;AAAA,IACtD,kBAAc,8BAAe,OAAO,kBAAkB;AAAA,IACtD,uBAAmB,8BAAe,OAAO,uBAAuB;AAAA,IAChE,2BAAuB,8BAAe,OAAO,2BAA2B;AAAA,IACxE,iBAAiB,OAAO,4BACpB,8BAAe,OAAO,qBAAqB,IAC3C;AAAA,IACJ,eAAe,OAAO;AAAA,IACtB,cAAc,OAAO;AAAA,IACrB,aAAa,OAAO,eAChB,wBAAwB,OAAO,YAAY,IAC3C;AAAA,EACN;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 toBigNumber,\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 IndexerServerV2MarketHours,\n IndexerServerV2Symbol,\n IndexerServerV2TickerResponse,\n IndexerSnapshotsIntervalParams,\n IndexerSpotBalance,\n IndexerV2MarketHours,\n IndexerV2Symbol,\n IndexerV2TickerResponse,\n IndexerV2TradingStatus,\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: toBigNumber(balance.spot.balance.amount),\n productId: balance.spot.product_id,\n type: ProductEngineType.SPOT,\n };\n }\n return {\n amount: toBigNumber(balance.perp.balance.amount),\n productId: balance.perp.product_id,\n type: ProductEngineType.PERP,\n vQuoteBalance: toBigNumber(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: toBigNumber(order.amount),\n digest: order.digest,\n expiration: Number(order.expiration),\n appendix,\n nonce: toBigNumber(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: toBigNumber(order.base_filled),\n quoteFilled: toBigNumber(order.quote_filled),\n totalFee: toBigNumber(order.fee),\n builderFee: toBigNumber(order.builder_fee),\n realizedPnl: toBigNumber(order.realized_pnl),\n closedSize: toBigNumber(order.closed_amount),\n closedNetEntry: toBigNumber(order.closed_net_entry),\n closedMargin: order.closed_margin ? toBigNumber(order.closed_margin) : null,\n preOrderAmount: toBigNumber(order.prev_position),\n firstFillTimestamp: toBigNumber(order.first_fill_timestamp),\n lastFillTimestamp: toBigNumber(order.last_fill_timestamp),\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: toBigNumber(event.net_entry_cumulative),\n netEntryUnrealized: toBigNumber(event.net_entry_unrealized),\n netFundingCumulative: toBigNumber(event.net_funding_cumulative),\n netFundingUnrealized: toBigNumber(event.net_funding_unrealized),\n netInterestCumulative: toBigNumber(event.net_interest_cumulative),\n netInterestUnrealized: toBigNumber(event.net_interest_unrealized),\n quoteVolumeCumulative: toBigNumber(event.quote_volume_cumulative),\n },\n };\n}\n\nexport function mapIndexerEventWithTx(\n event: IndexerServerEvent,\n tx: IndexerServerTx,\n): IndexerEventWithTx {\n return {\n timestamp: toBigNumber(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: toBigNumber(payment.timestamp),\n paymentAmount: toBigNumber(payment.amount),\n balanceAmount: toBigNumber(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: toBigNumber(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: toBigNumber(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: toBigNumber(makerData.timestamp),\n makerFee: toBigNumber(makerData.maker_fee),\n uptime: toBigNumber(makerData.uptime),\n sumQMin: toBigNumber(makerData.sum_q_min),\n qScore: toBigNumber(makerData.q_score),\n makerShare: toBigNumber(makerData.maker_share),\n expectedMakerReward: toBigNumber(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: toBigNumber(position.pnl),\n pnlRank: toBigNumber(position.pnl_rank),\n percentRoi: toBigNumber(position.roi),\n roiRank: toBigNumber(position.roi_rank),\n accountValue: toBigNumber(position.account_value),\n volume: position.volume ? toBigNumber(position.volume) : undefined,\n updateTime: toBigNumber(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: toBigNumber(registration.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardContest(\n contest: IndexerServerLeaderboardContest,\n): IndexerLeaderboardContest {\n return {\n contestId: contest.contest_id,\n startTime: toBigNumber(contest.start_time),\n endTime: toBigNumber(contest.end_time),\n period: toBigNumber(contest.threshold),\n totalParticipants: toBigNumber(contest.count),\n minRequiredAccountValue: toBigNumber(contest.threshold),\n minRequiredVolume: toBigNumber(contest.volume_threshold),\n requiredProductIds: contest.product_ids,\n active: contest.active,\n lastUpdated: toBigNumber(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: toBigNumber(candlestick.timestamp),\n volume: toBigNumber(candlestick.volume),\n };\n}\n\nexport function mapIndexerMarketSnapshot(\n snapshot: IndexerServerMarketSnapshot,\n): IndexerMarketSnapshot {\n return {\n timestamp: toBigNumber(snapshot.timestamp),\n cumulativeUsers: toBigNumber(snapshot.cumulative_users),\n dailyActiveUsers: toBigNumber(snapshot.daily_active_users),\n tvl: toBigNumber(snapshot.tvl),\n borrowRates: mapValues(snapshot.borrow_rates, (value) =>\n removeDecimals(value),\n ),\n cumulativeLiquidationAmounts: mapValues(\n snapshot.cumulative_liquidation_amounts,\n toBigNumber,\n ),\n cumulativeMakerFees: mapValues(snapshot.cumulative_maker_fees, toBigNumber),\n cumulativeSequencerFees: mapValues(\n snapshot.cumulative_sequencer_fees,\n toBigNumber,\n ),\n cumulativeTakerFees: mapValues(snapshot.cumulative_taker_fees, toBigNumber),\n cumulativeTrades: mapValues(snapshot.cumulative_trades, toBigNumber),\n cumulativeVolumes: mapValues(snapshot.cumulative_volumes, toBigNumber),\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, toBigNumber),\n totalBorrows: mapValues(snapshot.total_borrows, toBigNumber),\n totalDeposits: mapValues(snapshot.total_deposits, toBigNumber),\n cumulativeTradeSizes: mapValues(\n snapshot.cumulative_trade_sizes,\n toBigNumber,\n ),\n cumulativeInflows: mapValues(snapshot.cumulative_inflows, toBigNumber),\n cumulativeOutflows: mapValues(snapshot.cumulative_outflows, toBigNumber),\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: toBigNumber(snapshot.timestamp),\n cumulativeBurnAmountQuote: toBigNumber(snapshot.cumulative_burn_quote),\n cumulativeMintAmountQuote: toBigNumber(snapshot.cumulative_mint_quote),\n cumulativePnl: toBigNumber(snapshot.cumulative_pnl),\n cumulativeTrades: toBigNumber(snapshot.cumulative_trades),\n cumulativeVolume: toBigNumber(snapshot.cumulative_volume),\n depositors: toBigNumber(snapshot.depositors),\n oraclePrice: removeDecimals(snapshot.oracle_price_x18),\n tvl: toBigNumber(snapshot.tvl),\n };\n}\n\nexport function mapIndexerV2Ticker(\n ticker: IndexerServerV2TickerResponse,\n): IndexerV2TickerResponse {\n return {\n productId: ticker.product_id,\n tickerId: ticker.ticker_id,\n baseCurrency: ticker.base_currency,\n quoteCurrency: ticker.quote_currency,\n lastPrice: ticker.last_price,\n baseVolume: ticker.base_volume,\n quoteVolume: ticker.quote_volume,\n priceChangePercent24h: ticker.price_change_percent_24h,\n };\n}\n\nexport function mapIndexerV2MarketHours(\n hours: IndexerServerV2MarketHours,\n): IndexerV2MarketHours {\n return {\n isOpen: hours.is_open,\n reason: hours.reason,\n nextClose: hours.next_close,\n nextOpen: hours.next_open,\n };\n}\n\nexport function mapIndexerV2Symbols(\n symbol: IndexerServerV2Symbol,\n): IndexerV2Symbol {\n return {\n type: symbol.type,\n productId: symbol.product_id,\n symbol: symbol.symbol,\n priceIncrement: removeDecimals(symbol.price_increment_x18),\n sizeIncrement: symbol.size_increment,\n minSize: symbol.min_size,\n makerFeeRate: removeDecimals(symbol.maker_fee_rate_x18),\n takerFeeRate: removeDecimals(symbol.taker_fee_rate_x18),\n longWeightInitial: removeDecimals(symbol.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(symbol.long_weight_maintenance_x18),\n maxOpenInterest: symbol.max_open_interest_x18\n ? removeDecimals(symbol.max_open_interest_x18)\n : null,\n tradingStatus: symbol.trading_status as IndexerV2TradingStatus,\n isolatedOnly: symbol.isolated_only,\n marketHours: symbol.market_hours\n ? mapIndexerV2MarketHours(symbol.market_hours)\n : null,\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;AAAA;AAAA;AAAA,2BAGO;AACP,oBAYO;AA6CA,SAAS,mCACd,QACgC;AAChC,SAAO;AAAA,IACL,OAAO,OAAO;AAAA,IACd,UAAU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,8BAAe,OAAO,kBAAkB;AAAA,IACtD,kBAAc,8BAAe,OAAO,kBAAkB;AAAA,IACtD,uBAAmB,8BAAe,OAAO,uBAAuB;AAAA,IAChE,2BAAuB,8BAAe,OAAO,2BAA2B;AAAA,IACxE,iBAAiB,OAAO,4BACpB,8BAAe,OAAO,qBAAqB,IAC3C;AAAA,IACJ,eAAe,OAAO;AAAA,IACtB,cAAc,OAAO;AAAA,IACrB,aAAa,OAAO,eAChB,wBAAwB,OAAO,YAAY,IAC3C;AAAA,EACN;AACF;","names":[]}
|
package/dist/dataMappers.js
CHANGED
|
@@ -62,6 +62,7 @@ function mapIndexerOrder(order) {
|
|
|
62
62
|
closedSize: toBigNumber(order.closed_amount),
|
|
63
63
|
closedNetEntry: toBigNumber(order.closed_net_entry),
|
|
64
64
|
closedMargin: order.closed_margin ? toBigNumber(order.closed_margin) : null,
|
|
65
|
+
preOrderAmount: toBigNumber(order.prev_position),
|
|
65
66
|
firstFillTimestamp: toBigNumber(order.first_fill_timestamp),
|
|
66
67
|
lastFillTimestamp: toBigNumber(order.last_fill_timestamp)
|
|
67
68
|
};
|
package/dist/dataMappers.js.map
CHANGED
|
@@ -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 toBigNumber,\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 IndexerServerV2MarketHours,\n IndexerServerV2Symbol,\n IndexerServerV2TickerResponse,\n IndexerSnapshotsIntervalParams,\n IndexerSpotBalance,\n IndexerV2MarketHours,\n IndexerV2Symbol,\n IndexerV2TickerResponse,\n IndexerV2TradingStatus,\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: toBigNumber(balance.spot.balance.amount),\n productId: balance.spot.product_id,\n type: ProductEngineType.SPOT,\n };\n }\n return {\n amount: toBigNumber(balance.perp.balance.amount),\n productId: balance.perp.product_id,\n type: ProductEngineType.PERP,\n vQuoteBalance: toBigNumber(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: toBigNumber(order.amount),\n digest: order.digest,\n expiration: Number(order.expiration),\n appendix,\n nonce: toBigNumber(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: toBigNumber(order.base_filled),\n quoteFilled: toBigNumber(order.quote_filled),\n totalFee: toBigNumber(order.fee),\n builderFee: toBigNumber(order.builder_fee),\n realizedPnl: toBigNumber(order.realized_pnl),\n closedSize: toBigNumber(order.closed_amount),\n closedNetEntry: toBigNumber(order.closed_net_entry),\n closedMargin: order.closed_margin ? toBigNumber(order.closed_margin) : null,\n firstFillTimestamp: toBigNumber(order.first_fill_timestamp),\n lastFillTimestamp: toBigNumber(order.last_fill_timestamp),\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: toBigNumber(event.net_entry_cumulative),\n netEntryUnrealized: toBigNumber(event.net_entry_unrealized),\n netFundingCumulative: toBigNumber(event.net_funding_cumulative),\n netFundingUnrealized: toBigNumber(event.net_funding_unrealized),\n netInterestCumulative: toBigNumber(event.net_interest_cumulative),\n netInterestUnrealized: toBigNumber(event.net_interest_unrealized),\n quoteVolumeCumulative: toBigNumber(event.quote_volume_cumulative),\n },\n };\n}\n\nexport function mapIndexerEventWithTx(\n event: IndexerServerEvent,\n tx: IndexerServerTx,\n): IndexerEventWithTx {\n return {\n timestamp: toBigNumber(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: toBigNumber(payment.timestamp),\n paymentAmount: toBigNumber(payment.amount),\n balanceAmount: toBigNumber(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: toBigNumber(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: toBigNumber(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: toBigNumber(makerData.timestamp),\n makerFee: toBigNumber(makerData.maker_fee),\n uptime: toBigNumber(makerData.uptime),\n sumQMin: toBigNumber(makerData.sum_q_min),\n qScore: toBigNumber(makerData.q_score),\n makerShare: toBigNumber(makerData.maker_share),\n expectedMakerReward: toBigNumber(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: toBigNumber(position.pnl),\n pnlRank: toBigNumber(position.pnl_rank),\n percentRoi: toBigNumber(position.roi),\n roiRank: toBigNumber(position.roi_rank),\n accountValue: toBigNumber(position.account_value),\n volume: position.volume ? toBigNumber(position.volume) : undefined,\n updateTime: toBigNumber(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: toBigNumber(registration.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardContest(\n contest: IndexerServerLeaderboardContest,\n): IndexerLeaderboardContest {\n return {\n contestId: contest.contest_id,\n startTime: toBigNumber(contest.start_time),\n endTime: toBigNumber(contest.end_time),\n period: toBigNumber(contest.threshold),\n totalParticipants: toBigNumber(contest.count),\n minRequiredAccountValue: toBigNumber(contest.threshold),\n minRequiredVolume: toBigNumber(contest.volume_threshold),\n requiredProductIds: contest.product_ids,\n active: contest.active,\n lastUpdated: toBigNumber(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: toBigNumber(candlestick.timestamp),\n volume: toBigNumber(candlestick.volume),\n };\n}\n\nexport function mapIndexerMarketSnapshot(\n snapshot: IndexerServerMarketSnapshot,\n): IndexerMarketSnapshot {\n return {\n timestamp: toBigNumber(snapshot.timestamp),\n cumulativeUsers: toBigNumber(snapshot.cumulative_users),\n dailyActiveUsers: toBigNumber(snapshot.daily_active_users),\n tvl: toBigNumber(snapshot.tvl),\n borrowRates: mapValues(snapshot.borrow_rates, (value) =>\n removeDecimals(value),\n ),\n cumulativeLiquidationAmounts: mapValues(\n snapshot.cumulative_liquidation_amounts,\n toBigNumber,\n ),\n cumulativeMakerFees: mapValues(snapshot.cumulative_maker_fees, toBigNumber),\n cumulativeSequencerFees: mapValues(\n snapshot.cumulative_sequencer_fees,\n toBigNumber,\n ),\n cumulativeTakerFees: mapValues(snapshot.cumulative_taker_fees, toBigNumber),\n cumulativeTrades: mapValues(snapshot.cumulative_trades, toBigNumber),\n cumulativeVolumes: mapValues(snapshot.cumulative_volumes, toBigNumber),\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, toBigNumber),\n totalBorrows: mapValues(snapshot.total_borrows, toBigNumber),\n totalDeposits: mapValues(snapshot.total_deposits, toBigNumber),\n cumulativeTradeSizes: mapValues(\n snapshot.cumulative_trade_sizes,\n toBigNumber,\n ),\n cumulativeInflows: mapValues(snapshot.cumulative_inflows, toBigNumber),\n cumulativeOutflows: mapValues(snapshot.cumulative_outflows, toBigNumber),\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: toBigNumber(snapshot.timestamp),\n cumulativeBurnAmountQuote: toBigNumber(snapshot.cumulative_burn_quote),\n cumulativeMintAmountQuote: toBigNumber(snapshot.cumulative_mint_quote),\n cumulativePnl: toBigNumber(snapshot.cumulative_pnl),\n cumulativeTrades: toBigNumber(snapshot.cumulative_trades),\n cumulativeVolume: toBigNumber(snapshot.cumulative_volume),\n depositors: toBigNumber(snapshot.depositors),\n oraclePrice: removeDecimals(snapshot.oracle_price_x18),\n tvl: toBigNumber(snapshot.tvl),\n };\n}\n\nexport function mapIndexerV2Ticker(\n ticker: IndexerServerV2TickerResponse,\n): IndexerV2TickerResponse {\n return {\n productId: ticker.product_id,\n tickerId: ticker.ticker_id,\n baseCurrency: ticker.base_currency,\n quoteCurrency: ticker.quote_currency,\n lastPrice: ticker.last_price,\n baseVolume: ticker.base_volume,\n quoteVolume: ticker.quote_volume,\n priceChangePercent24h: ticker.price_change_percent_24h,\n };\n}\n\nexport function mapIndexerV2MarketHours(\n hours: IndexerServerV2MarketHours,\n): IndexerV2MarketHours {\n return {\n isOpen: hours.is_open,\n reason: hours.reason,\n nextClose: hours.next_close,\n nextOpen: hours.next_open,\n };\n}\n\nexport function mapIndexerV2Symbols(\n symbol: IndexerServerV2Symbol,\n): IndexerV2Symbol {\n return {\n type: symbol.type,\n productId: symbol.product_id,\n symbol: symbol.symbol,\n priceIncrement: removeDecimals(symbol.price_increment_x18),\n sizeIncrement: symbol.size_increment,\n minSize: symbol.min_size,\n makerFeeRate: removeDecimals(symbol.maker_fee_rate_x18),\n takerFeeRate: removeDecimals(symbol.taker_fee_rate_x18),\n longWeightInitial: removeDecimals(symbol.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(symbol.long_weight_maintenance_x18),\n maxOpenInterest: symbol.max_open_interest_x18\n ? removeDecimals(symbol.max_open_interest_x18)\n : null,\n tradingStatus: symbol.trading_status as IndexerV2TradingStatus,\n isolatedOnly: symbol.isolated_only,\n marketHours: symbol.market_hours\n ? mapIndexerV2MarketHours(symbol.market_hours)\n : null,\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;AA6CA,SAAS,mCACd,QACgC;AA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IACxE,iBAAiB,OAAO,wBACpB,eAAe,OAAO,qBAAqB,IAC3C;AAAA,IACJ,eAAe,OAAO;AAAA,IACtB,cAAc,OAAO;AAAA,IACrB,aAAa,OAAO,eAChB,wBAAwB,OAAO,YAAY,IAC3C;AAAA,EACN;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 toBigNumber,\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 IndexerServerV2MarketHours,\n IndexerServerV2Symbol,\n IndexerServerV2TickerResponse,\n IndexerSnapshotsIntervalParams,\n IndexerSpotBalance,\n IndexerV2MarketHours,\n IndexerV2Symbol,\n IndexerV2TickerResponse,\n IndexerV2TradingStatus,\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: toBigNumber(balance.spot.balance.amount),\n productId: balance.spot.product_id,\n type: ProductEngineType.SPOT,\n };\n }\n return {\n amount: toBigNumber(balance.perp.balance.amount),\n productId: balance.perp.product_id,\n type: ProductEngineType.PERP,\n vQuoteBalance: toBigNumber(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: toBigNumber(order.amount),\n digest: order.digest,\n expiration: Number(order.expiration),\n appendix,\n nonce: toBigNumber(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: toBigNumber(order.base_filled),\n quoteFilled: toBigNumber(order.quote_filled),\n totalFee: toBigNumber(order.fee),\n builderFee: toBigNumber(order.builder_fee),\n realizedPnl: toBigNumber(order.realized_pnl),\n closedSize: toBigNumber(order.closed_amount),\n closedNetEntry: toBigNumber(order.closed_net_entry),\n closedMargin: order.closed_margin ? toBigNumber(order.closed_margin) : null,\n preOrderAmount: toBigNumber(order.prev_position),\n firstFillTimestamp: toBigNumber(order.first_fill_timestamp),\n lastFillTimestamp: toBigNumber(order.last_fill_timestamp),\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: toBigNumber(event.net_entry_cumulative),\n netEntryUnrealized: toBigNumber(event.net_entry_unrealized),\n netFundingCumulative: toBigNumber(event.net_funding_cumulative),\n netFundingUnrealized: toBigNumber(event.net_funding_unrealized),\n netInterestCumulative: toBigNumber(event.net_interest_cumulative),\n netInterestUnrealized: toBigNumber(event.net_interest_unrealized),\n quoteVolumeCumulative: toBigNumber(event.quote_volume_cumulative),\n },\n };\n}\n\nexport function mapIndexerEventWithTx(\n event: IndexerServerEvent,\n tx: IndexerServerTx,\n): IndexerEventWithTx {\n return {\n timestamp: toBigNumber(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: toBigNumber(payment.timestamp),\n paymentAmount: toBigNumber(payment.amount),\n balanceAmount: toBigNumber(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: toBigNumber(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: toBigNumber(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: toBigNumber(makerData.timestamp),\n makerFee: toBigNumber(makerData.maker_fee),\n uptime: toBigNumber(makerData.uptime),\n sumQMin: toBigNumber(makerData.sum_q_min),\n qScore: toBigNumber(makerData.q_score),\n makerShare: toBigNumber(makerData.maker_share),\n expectedMakerReward: toBigNumber(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: toBigNumber(position.pnl),\n pnlRank: toBigNumber(position.pnl_rank),\n percentRoi: toBigNumber(position.roi),\n roiRank: toBigNumber(position.roi_rank),\n accountValue: toBigNumber(position.account_value),\n volume: position.volume ? toBigNumber(position.volume) : undefined,\n updateTime: toBigNumber(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: toBigNumber(registration.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardContest(\n contest: IndexerServerLeaderboardContest,\n): IndexerLeaderboardContest {\n return {\n contestId: contest.contest_id,\n startTime: toBigNumber(contest.start_time),\n endTime: toBigNumber(contest.end_time),\n period: toBigNumber(contest.threshold),\n totalParticipants: toBigNumber(contest.count),\n minRequiredAccountValue: toBigNumber(contest.threshold),\n minRequiredVolume: toBigNumber(contest.volume_threshold),\n requiredProductIds: contest.product_ids,\n active: contest.active,\n lastUpdated: toBigNumber(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: toBigNumber(candlestick.timestamp),\n volume: toBigNumber(candlestick.volume),\n };\n}\n\nexport function mapIndexerMarketSnapshot(\n snapshot: IndexerServerMarketSnapshot,\n): IndexerMarketSnapshot {\n return {\n timestamp: toBigNumber(snapshot.timestamp),\n cumulativeUsers: toBigNumber(snapshot.cumulative_users),\n dailyActiveUsers: toBigNumber(snapshot.daily_active_users),\n tvl: toBigNumber(snapshot.tvl),\n borrowRates: mapValues(snapshot.borrow_rates, (value) =>\n removeDecimals(value),\n ),\n cumulativeLiquidationAmounts: mapValues(\n snapshot.cumulative_liquidation_amounts,\n toBigNumber,\n ),\n cumulativeMakerFees: mapValues(snapshot.cumulative_maker_fees, toBigNumber),\n cumulativeSequencerFees: mapValues(\n snapshot.cumulative_sequencer_fees,\n toBigNumber,\n ),\n cumulativeTakerFees: mapValues(snapshot.cumulative_taker_fees, toBigNumber),\n cumulativeTrades: mapValues(snapshot.cumulative_trades, toBigNumber),\n cumulativeVolumes: mapValues(snapshot.cumulative_volumes, toBigNumber),\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, toBigNumber),\n totalBorrows: mapValues(snapshot.total_borrows, toBigNumber),\n totalDeposits: mapValues(snapshot.total_deposits, toBigNumber),\n cumulativeTradeSizes: mapValues(\n snapshot.cumulative_trade_sizes,\n toBigNumber,\n ),\n cumulativeInflows: mapValues(snapshot.cumulative_inflows, toBigNumber),\n cumulativeOutflows: mapValues(snapshot.cumulative_outflows, toBigNumber),\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: toBigNumber(snapshot.timestamp),\n cumulativeBurnAmountQuote: toBigNumber(snapshot.cumulative_burn_quote),\n cumulativeMintAmountQuote: toBigNumber(snapshot.cumulative_mint_quote),\n cumulativePnl: toBigNumber(snapshot.cumulative_pnl),\n cumulativeTrades: toBigNumber(snapshot.cumulative_trades),\n cumulativeVolume: toBigNumber(snapshot.cumulative_volume),\n depositors: toBigNumber(snapshot.depositors),\n oraclePrice: removeDecimals(snapshot.oracle_price_x18),\n tvl: toBigNumber(snapshot.tvl),\n };\n}\n\nexport function mapIndexerV2Ticker(\n ticker: IndexerServerV2TickerResponse,\n): IndexerV2TickerResponse {\n return {\n productId: ticker.product_id,\n tickerId: ticker.ticker_id,\n baseCurrency: ticker.base_currency,\n quoteCurrency: ticker.quote_currency,\n lastPrice: ticker.last_price,\n baseVolume: ticker.base_volume,\n quoteVolume: ticker.quote_volume,\n priceChangePercent24h: ticker.price_change_percent_24h,\n };\n}\n\nexport function mapIndexerV2MarketHours(\n hours: IndexerServerV2MarketHours,\n): IndexerV2MarketHours {\n return {\n isOpen: hours.is_open,\n reason: hours.reason,\n nextClose: hours.next_close,\n nextOpen: hours.next_open,\n };\n}\n\nexport function mapIndexerV2Symbols(\n symbol: IndexerServerV2Symbol,\n): IndexerV2Symbol {\n return {\n type: symbol.type,\n productId: symbol.product_id,\n symbol: symbol.symbol,\n priceIncrement: removeDecimals(symbol.price_increment_x18),\n sizeIncrement: symbol.size_increment,\n minSize: symbol.min_size,\n makerFeeRate: removeDecimals(symbol.maker_fee_rate_x18),\n takerFeeRate: removeDecimals(symbol.taker_fee_rate_x18),\n longWeightInitial: removeDecimals(symbol.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(symbol.long_weight_maintenance_x18),\n maxOpenInterest: symbol.max_open_interest_x18\n ? removeDecimals(symbol.max_open_interest_x18)\n : null,\n tradingStatus: symbol.trading_status as IndexerV2TradingStatus,\n isolatedOnly: symbol.isolated_only,\n marketHours: symbol.market_hours\n ? mapIndexerV2MarketHours(symbol.market_hours)\n : null,\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;AA6CA,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,YAAY,QAAQ,KAAK,QAAQ,MAAM;AAAA,MAC/C,WAAW,QAAQ,KAAK;AAAA,MACxB,MAAM,kBAAkB;AAAA,IAC1B;AAAA,EACF;AACA,SAAO;AAAA,IACL,QAAQ,YAAY,QAAQ,KAAK,QAAQ,MAAM;A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AAS,mBACd,QACyB;AACzB,SAAO;AAAA,IACL,WAAW,OAAO;AAAA,IAClB,UAAU,OAAO;AAAA,IACjB,cAAc,OAAO;AAAA,IACrB,eAAe,OAAO;AAAA,IACtB,WAAW,OAAO;AAAA,IAClB,YAAY,OAAO;AAAA,IACnB,aAAa,OAAO;AAAA,IACpB,uBAAuB,OAAO;AAAA,EAChC;AACF;AAEO,SAAS,wBACd,OACsB;AACtB,SAAO;AAAA,IACL,QAAQ,MAAM;AAAA,IACd,QAAQ,MAAM;AAAA,IACd,WAAW,MAAM;AAAA,IACjB,UAAU,MAAM;AAAA,EAClB;AACF;AAEO,SAAS,oBACd,QACiB;AACjB,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb,WAAW,OAAO;AAAA,IAClB,QAAQ,OAAO;AAAA,IACf,gBAAgB,eAAe,OAAO,mBAAmB;AAAA,IACzD,eAAe,OAAO;AAAA,IACtB,SAAS,OAAO;AAAA,IAChB,cAAc,eAAe,OAAO,kBAAkB;AAAA,IACtD,cAAc,eAAe,OAAO,kBAAkB;AAAA,IACtD,mBAAmB,eAAe,OAAO,uBAAuB;AAAA,IAChE,uBAAuB,eAAe,OAAO,2BAA2B;AAAA,IACxE,iBAAiB,OAAO,wBACpB,eAAe,OAAO,qBAAqB,IAC3C;AAAA,IACJ,eAAe,OAAO;AAAA,IACtB,cAAc,OAAO;AAAA,IACrB,aAAa,OAAO,eAChB,wBAAwB,OAAO,YAAY,IAC3C;AAAA,EACN;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/clientTypes.ts"],"sourcesContent":["import {\n EIP712OrderValues,\n Market,\n OrderAppendix,\n PerpBalance,\n PerpMarket,\n ProductEngineType,\n SpotBalance,\n SpotMarket,\n Subaccount,\n} from '@nadohq/shared';\nimport BigNumber from 'bignumber.js';\nimport { Address, Hex } from 'viem';\nimport { CandlestickPeriod } from './CandlestickPeriod';\nimport { IndexerEventType } from './IndexerEventType';\nimport { IndexerLeaderboardRankType } from './IndexerLeaderboardType';\nimport { NadoTx, NadoWithdrawCollateralTx } from './NadoTx';\nimport {\n IndexerServerFastWithdrawalSignatureParams,\n IndexerServerListSubaccountsParams,\n IndexerServerTriggerTypeFilter,\n} from './serverTypes';\n\n/**\n * Base types\n */\n\nexport type IndexerSpotBalance = Omit<SpotBalance, 'healthContributions'>;\n\nexport type IndexerPerpBalance = Omit<PerpBalance, 'healthContributions'>;\n\nexport interface IndexerEventSpotStateSnapshot {\n type: ProductEngineType.SPOT;\n preBalance: IndexerSpotBalance;\n postBalance: IndexerSpotBalance;\n market: SpotMarket;\n}\n\nexport interface IndexerEventPerpStateSnapshot {\n type: ProductEngineType.PERP;\n preBalance: IndexerPerpBalance;\n postBalance: IndexerPerpBalance;\n market: PerpMarket;\n}\n\nexport type IndexerEventBalanceStateSnapshot =\n | IndexerEventSpotStateSnapshot\n | IndexerEventPerpStateSnapshot;\n\nexport interface IndexerBalanceTrackedVars {\n netInterestUnrealized: BigNumber;\n netInterestCumulative: BigNumber;\n netFundingUnrealized: BigNumber;\n netFundingCumulative: BigNumber;\n netEntryUnrealized: BigNumber;\n netEntryCumulative: BigNumber;\n quoteVolumeCumulative: BigNumber;\n}\n\nexport interface IndexerEvent<\n TStateType extends IndexerEventBalanceStateSnapshot =\n 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 IndexerEventBalanceStateSnapshot =\n IndexerEventBalanceStateSnapshot,\n> extends IndexerEvent<TStateType> {\n timestamp: BigNumber;\n tx: NadoTx;\n}\n\n/**\n * List subaccounts\n */\n\nexport type ListIndexerSubaccountsParams = IndexerServerListSubaccountsParams;\n\nexport type ListIndexerSubaccountsResponse = ({\n hexId: string;\n // Unix timestamp in seconds\n createdAt: number;\n isolated: boolean;\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 IndexerEventBalanceStateSnapshot =\n IndexerEventBalanceStateSnapshot,\n> = IndexerEvent<TStateType>;\n\nexport interface IndexerSubaccountSnapshot {\n timestamp: BigNumber;\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: BigNumber;\n markPrice: BigNumber;\n // Seconds\n updateTime: BigNumber;\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: BigNumber;\n // Seconds\n updateTime: BigNumber;\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: BigNumber;\n // Seconds\n updateTime: BigNumber;\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: BigNumber;\n open: BigNumber;\n high: BigNumber;\n low: BigNumber;\n close: BigNumber;\n volume: BigNumber;\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 extends IndexerSnapshotsIntervalParams {\n // Defaults to all\n productIds?: number[];\n}\n\nexport interface IndexerMarketSnapshot {\n timestamp: BigNumber;\n cumulativeUsers: BigNumber;\n dailyActiveUsers: BigNumber;\n tvl: BigNumber;\n cumulativeVolumes: Record<number, BigNumber>;\n cumulativeTakerFees: Record<number, BigNumber>;\n cumulativeSequencerFees: Record<number, BigNumber>;\n cumulativeMakerFees: Record<number, BigNumber>;\n cumulativeTrades: Record<number, BigNumber>;\n cumulativeLiquidationAmounts: Record<number, BigNumber>;\n openInterestsQuote: Record<number, BigNumber>;\n totalDeposits: Record<number, BigNumber>;\n totalBorrows: Record<number, BigNumber>;\n fundingRates: Record<number, BigNumber>;\n depositRates: Record<number, BigNumber>;\n borrowRates: Record<number, BigNumber>;\n cumulativeTradeSizes: Record<number, BigNumber>;\n cumulativeInflows: Record<number, BigNumber>;\n cumulativeOutflows: Record<number, BigNumber>;\n oraclePrices: Record<number, BigNumber>;\n}\n\nexport type GetIndexerMarketSnapshotsResponse = IndexerMarketSnapshot[];\n\nexport type GetIndexerEdgeMarketSnapshotsParams =\n IndexerSnapshotsIntervalParams;\n\n// Map of chain id -> IndexerMarketSnapshot[]\nexport type GetIndexerEdgeMarketSnapshotResponse = Record<\n number,\n IndexerMarketSnapshot[]\n>;\n\n/**\n * Events\n */\n\n// There can be multiple events per tx, this allows a limit depending on usecase\nexport type GetIndexerEventsLimitType = 'events' | 'txs';\n\nexport interface GetIndexerEventsParams {\n // Max submission index, inclusive\n startCursor?: string;\n subaccounts?: Subaccount[];\n productIds?: number[];\n // If not given, will return both isolated & non-iso events\n isolated?: boolean;\n eventTypes?: IndexerEventType[];\n maxTimestampInclusive?: number;\n // Descending order for idx (time), defaults to true\n desc?: boolean;\n limit?: {\n type: GetIndexerEventsLimitType;\n value: number;\n };\n}\n\nexport type GetIndexerEventsResponse = IndexerEventWithTx[];\n\n/**\n * Historical orders\n */\n\nexport interface GetIndexerOrdersParams {\n // Max submission index, inclusive\n startCursor?: string;\n subaccounts?: Subaccount[];\n minTimestampInclusive?: number;\n maxTimestampInclusive?: number;\n limit?: number;\n productIds?: number[];\n triggerTypes?: IndexerServerTriggerTypeFilter[];\n // If not given, will return both isolated & non-iso orders\n isolated?: boolean;\n digests?: string[];\n}\n\nexport interface IndexerOrder {\n digest: string;\n subaccount: string;\n productId: number;\n submissionIndex: string;\n amount: BigNumber;\n price: BigNumber;\n expiration: number;\n // Order metadata from appendix\n appendix: OrderAppendix;\n nonce: BigNumber;\n // Derived from the nonce\n recvTimeSeconds: number;\n // Fill amounts\n baseFilled: BigNumber;\n // Includes fee\n quoteFilled: BigNumber;\n // Includes sequencer fee\n totalFee: BigNumber;\n builderFee: BigNumber;\n realizedPnl: BigNumber;\n // Always positive\n closedSize: BigNumber;\n // Cumulative realized entry price for the closed amount on an order\n closedNetEntry: BigNumber;\n // Weighted average margin allocated to the closed amount. Only present for isolated margin orders; null for cross-margin orders\n closedMargin: BigNumber | null;\n // Unix timestamp (seconds) of the first fill on the order\n firstFillTimestamp: BigNumber;\n // Unix timestamp (seconds) of the last fill on the order\n lastFillTimestamp: BigNumber;\n}\n\nexport type GetIndexerOrdersResponse = IndexerOrder[];\n\n/**\n * Match events\n */\n\nexport interface GetIndexerMatchEventsParams {\n // When not given, will return all maker events\n subaccounts?: Subaccount[];\n productIds?: number[];\n // If not given, will return both isolated & non-iso events\n isolated?: boolean;\n maxTimestampInclusive?: number;\n limit: number;\n // Max submission index, inclusive\n startCursor?: string;\n}\n\n// There are 2 balance states per match event if the match is in a spot market, but only one if the match is in a perp market\nexport interface IndexerMatchEventBalances {\n base: IndexerSpotBalance | IndexerPerpBalance;\n quote?: IndexerSpotBalance;\n}\n\nexport interface IndexerMatchEvent extends Subaccount {\n productId: number;\n digest: string;\n isolated: boolean;\n order: EIP712OrderValues;\n baseFilled: BigNumber;\n quoteFilled: BigNumber;\n // Includes sequencer fee\n totalFee: BigNumber;\n sequencerFee: BigNumber;\n builderFee: BigNumber;\n cumulativeBaseFilled: BigNumber;\n cumulativeQuoteFilled: BigNumber;\n cumulativeFee: BigNumber;\n submissionIndex: string;\n timestamp: BigNumber;\n isTaker: boolean;\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 realizedPnl: BigNumber;\n // Always positive\n closedSize: BigNumber;\n // Realized entry price for the closed amount on this match (x18). Represents the total quote value at which the closed portion of the position was originally entered.\n closedNetEntry: BigNumber;\n // Margin allocated to the closed amount on this match (x18). Only present for isolated margin orders; null for cross-margin orders.\n margin: BigNumber | null;\n}\n\nexport type GetIndexerMatchEventsResponse = IndexerMatchEvent[];\n\n/**\n * Quote price\n */\n\nexport interface GetIndexerQuotePriceResponse {\n price: BigNumber;\n}\n\n/**\n * Linked Signer\n */\n\nexport interface GetIndexerLinkedSignerParams {\n subaccount: Subaccount;\n}\n\nexport interface GetIndexerLinkedSignerResponse {\n totalTxLimit: BigNumber;\n remainingTxs: BigNumber;\n // If remainingTxs is 0, this is the time until the next link signer tx can be sent\n waitTimeUntilNextTx: BigNumber;\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: BigNumber;\n paymentAmount: BigNumber;\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: BigNumber;\n // Represents the annually interest rate for spots and annually funding rate for perps.\n annualPaymentRate: BigNumber;\n oraclePrice: BigNumber;\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: BigNumber;\n makerFee: BigNumber;\n uptime: BigNumber;\n sumQMin: BigNumber;\n qScore: BigNumber;\n makerShare: BigNumber;\n expectedMakerReward: BigNumber;\n}\n\nexport interface IndexerMaker {\n address: string;\n snapshots: IndexerMakerSnapshot[];\n}\n\nexport interface GetIndexerMakerStatisticsResponse {\n rewardCoefficient: BigNumber;\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: BigNumber;\n pnlRank: BigNumber;\n percentRoi: BigNumber;\n roiRank: BigNumber;\n // Float indicating the ending account value at the time the snapshot was taken i.e: at updateTime\n accountValue: BigNumber;\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?: BigNumber;\n // Seconds\n updateTime: BigNumber;\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 extends GetIndexerLeaderboardRegistrationParams {\n updateRegistration: LeaderboardSignatureParams;\n // In millis, defaults to 90s in the future\n recvTime?: BigNumber;\n}\n\nexport interface IndexerLeaderboardRegistration {\n subaccount: Subaccount;\n contestId: number;\n // Seconds\n updateTime: BigNumber;\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: BigNumber;\n // End time in seconds\n endTime: BigNumber;\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: BigNumber;\n // Last updated time in Seconds\n lastUpdated: BigNumber;\n totalParticipants: BigNumber;\n // Float indicating the min account value required to be eligible for this contest e.g: 250.0\n minRequiredAccountValue: BigNumber;\n // Float indicating the min trading volume required to be eligible for this contest e.g: 1000.0\n minRequiredVolume: BigNumber;\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: BigNumber;\n // Total volume traded by the NLP, in terms of the primary quote\n cumulativeVolume: BigNumber;\n cumulativeTrades: BigNumber;\n cumulativeMintAmountQuote: BigNumber;\n cumulativeBurnAmountQuote: BigNumber;\n cumulativePnl: BigNumber;\n tvl: BigNumber;\n oraclePrice: BigNumber;\n depositors: BigNumber;\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: BigNumber;\n // Current nSubmissions value from the chain (i.e., number of processed txs)\n totalSubmissions: BigNumber;\n // Number of unprocessed transactions (totalTxs - totalSubmissions)\n backlogSize: BigNumber;\n // UNIX timestamp (in seconds) of when the data was last updated\n updatedAt: BigNumber;\n // Estimated time in seconds (float) to clear the entire backlog (null if unavailable)\n backlogEtaInSeconds: BigNumber | null;\n // Current submission rate in transactions per second (float) (null if unavailable)\n txsPerSecond: BigNumber | null;\n}\n\nexport interface GetIndexerSubaccountDDAParams {\n subaccount: Subaccount;\n}\n\nexport interface GetIndexerSubaccountDDAResponse {\n address: Address;\n}\n\n/**\n * Private Alpha Choice\n */\n\nexport interface GetIndexerPrivateAlphaChoiceParams {\n address: Address;\n}\n\nexport interface GetIndexerPrivateAlphaChoiceResponse {\n points: BigNumber;\n feeRefund: BigNumber;\n nftEligibility: boolean;\n}\n\n/**\n * Nado Points\n */\n\nexport interface GetIndexerPointsParams {\n address: Address;\n}\n\nexport interface IndexerPointsEpoch {\n epoch: number;\n description: string;\n /** Unix timestamp in seconds */\n startTime: BigNumber;\n /** Unix timestamp in seconds */\n endTime: BigNumber;\n totalPoints: BigNumber;\n points: BigNumber;\n rank: number;\n tier: number;\n}\n\nexport interface IndexerAllTimePoints {\n points: BigNumber;\n rank: number;\n tier: number;\n}\n\nexport interface GetIndexerPointsResponse {\n pointsPerEpoch: IndexerPointsEpoch[];\n allTimePoints: IndexerAllTimePoints;\n}\n\n/**\n * V2 Tickers\n */\n\n/**\n * Market type for ticker filtering\n */\nexport type TickerMarketType = 'spot' | 'perp';\n\n/**\n * Parameters for querying v2 tickers endpoint\n */\nexport interface GetIndexerV2TickersParams {\n /**\n * Filter tickers by market type (spot or perp)\n * @example 'spot'\n * @example 'perp'\n */\n market?: TickerMarketType;\n /**\n * Whether to include edge products\n * @default false\n */\n edge?: boolean;\n}\n\n/**\n * Individual ticker data from v2 endpoint\n */\nexport interface IndexerV2TickerResponse {\n /** Unique product identifier */\n productId: number;\n /** Unique ticker identifier */\n tickerId: string;\n /** Base currency symbol */\n baseCurrency: string;\n /** Quote currency symbol */\n quoteCurrency: string;\n /** Last traded price */\n lastPrice: number;\n /** 24h trading volume in base currency */\n baseVolume: number;\n /** 24h trading volume in quote currency */\n quoteVolume: number;\n /** 24h price change percentage */\n priceChangePercent24h: number;\n}\n\n/**\n * Response from v2 tickers endpoint\n * Maps ticker IDs to their respective ticker data\n */\nexport type GetIndexerV2TickersResponse = Record<\n string,\n IndexerV2TickerResponse\n>;\n\n/**\n * Parameters for querying v2 symbols endpoint\n */\nexport interface GetIndexerV2SymbolsParams {\n /**\n * Filter by product type\n * @example 'spot'\n * @example 'perp'\n */\n productType?: 'spot' | 'perp';\n /**\n * Comma-separated list of product IDs to filter by\n * @example '2,4,42'\n */\n productIds?: string;\n}\n\n/**\n * Market hours information for a product\n */\nexport interface IndexerV2MarketHours {\n /** Whether the market is currently in its regular trading session */\n isOpen: boolean;\n /** Why the market is closed: \"weekend\" or \"holiday\". Null when open. */\n reason: string | null;\n /** ISO 8601 UTC timestamp of the next session close. Null when closed. */\n nextClose: string | null;\n /** ISO 8601 UTC timestamp of the next session open. Null when no upcoming open. */\n nextOpen: string | null;\n}\n\nexport type IndexerV2TradingStatus =\n // Normal trading, all order types accepted\n | 'live'\n // Only post-only orders accepted (taker orders rejected)\n | 'post_only'\n // Only reduce-only orders accepted; used when a market is being delisted\n | 'reduce_only'\n // No new positions can be opened; only orders that reduce existing positions are accepted. Used during periods of low activity (e.g. weekends, holidays)\n | 'soft_reduce_only'\n // No orders accepted\n | 'not_tradable';\n\n/**\n * Individual symbol data from v2 endpoint\n */\nexport interface IndexerV2Symbol {\n /** Product type: \"spot\" or \"perp\" */\n type: string;\n /** Unique product identifier */\n productId: number;\n /** Trading symbol (e.g., \"BTC-PERP\", \"WETH\") */\n symbol: string;\n /** Minimum price increment */\n priceIncrement: BigNumber;\n /** Minimum order size increment (base denominated) */\n sizeIncrement: string;\n /** Minimum order size (USDT0 denominated) */\n minSize: string;\n /** Default maker fee rate (negative = rebate) */\n makerFeeRate: BigNumber;\n /** Default taker fee rate */\n takerFeeRate: BigNumber;\n /** Initial margin weight for long positions */\n longWeightInitial: BigNumber;\n /** Maintenance margin weight for long positions */\n longWeightMaintenance: BigNumber;\n /** Maximum open interest cap. Null if uncapped. */\n maxOpenInterest: BigNumber | null;\n /** Current trading status */\n tradingStatus: IndexerV2TradingStatus;\n /** Whether the market only accepts isolated margin orders */\n isolatedOnly: boolean;\n /** Market hours information. Null for 24/7 markets. */\n marketHours: IndexerV2MarketHours | null;\n}\n\n/**\n * Response from v2 symbols endpoint\n * Maps symbols to their respective data\n */\nexport type GetIndexerV2SymbolsResponse = Record<string, IndexerV2Symbol>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/clientTypes.ts"],"sourcesContent":["import {\n EIP712OrderValues,\n Market,\n OrderAppendix,\n PerpBalance,\n PerpMarket,\n ProductEngineType,\n SpotBalance,\n SpotMarket,\n Subaccount,\n} from '@nadohq/shared';\nimport BigNumber from 'bignumber.js';\nimport { Address, Hex } from 'viem';\nimport { CandlestickPeriod } from './CandlestickPeriod';\nimport { IndexerEventType } from './IndexerEventType';\nimport { IndexerLeaderboardRankType } from './IndexerLeaderboardType';\nimport { NadoTx, NadoWithdrawCollateralTx } from './NadoTx';\nimport {\n IndexerServerFastWithdrawalSignatureParams,\n IndexerServerListSubaccountsParams,\n IndexerServerTriggerTypeFilter,\n} from './serverTypes';\n\n/**\n * Base types\n */\n\nexport type IndexerSpotBalance = Omit<SpotBalance, 'healthContributions'>;\n\nexport type IndexerPerpBalance = Omit<PerpBalance, 'healthContributions'>;\n\nexport interface IndexerEventSpotStateSnapshot {\n type: ProductEngineType.SPOT;\n preBalance: IndexerSpotBalance;\n postBalance: IndexerSpotBalance;\n market: SpotMarket;\n}\n\nexport interface IndexerEventPerpStateSnapshot {\n type: ProductEngineType.PERP;\n preBalance: IndexerPerpBalance;\n postBalance: IndexerPerpBalance;\n market: PerpMarket;\n}\n\nexport type IndexerEventBalanceStateSnapshot =\n | IndexerEventSpotStateSnapshot\n | IndexerEventPerpStateSnapshot;\n\nexport interface IndexerBalanceTrackedVars {\n netInterestUnrealized: BigNumber;\n netInterestCumulative: BigNumber;\n netFundingUnrealized: BigNumber;\n netFundingCumulative: BigNumber;\n netEntryUnrealized: BigNumber;\n netEntryCumulative: BigNumber;\n quoteVolumeCumulative: BigNumber;\n}\n\nexport interface IndexerEvent<\n TStateType extends IndexerEventBalanceStateSnapshot =\n 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 IndexerEventBalanceStateSnapshot =\n IndexerEventBalanceStateSnapshot,\n> extends IndexerEvent<TStateType> {\n timestamp: BigNumber;\n tx: NadoTx;\n}\n\n/**\n * List subaccounts\n */\n\nexport type ListIndexerSubaccountsParams = IndexerServerListSubaccountsParams;\n\nexport type ListIndexerSubaccountsResponse = ({\n hexId: string;\n // Unix timestamp in seconds\n createdAt: number;\n isolated: boolean;\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 IndexerEventBalanceStateSnapshot =\n IndexerEventBalanceStateSnapshot,\n> = IndexerEvent<TStateType>;\n\nexport interface IndexerSubaccountSnapshot {\n timestamp: BigNumber;\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: BigNumber;\n markPrice: BigNumber;\n // Seconds\n updateTime: BigNumber;\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: BigNumber;\n // Seconds\n updateTime: BigNumber;\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: BigNumber;\n // Seconds\n updateTime: BigNumber;\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: BigNumber;\n open: BigNumber;\n high: BigNumber;\n low: BigNumber;\n close: BigNumber;\n volume: BigNumber;\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 extends IndexerSnapshotsIntervalParams {\n // Defaults to all\n productIds?: number[];\n}\n\nexport interface IndexerMarketSnapshot {\n timestamp: BigNumber;\n cumulativeUsers: BigNumber;\n dailyActiveUsers: BigNumber;\n tvl: BigNumber;\n cumulativeVolumes: Record<number, BigNumber>;\n cumulativeTakerFees: Record<number, BigNumber>;\n cumulativeSequencerFees: Record<number, BigNumber>;\n cumulativeMakerFees: Record<number, BigNumber>;\n cumulativeTrades: Record<number, BigNumber>;\n cumulativeLiquidationAmounts: Record<number, BigNumber>;\n openInterestsQuote: Record<number, BigNumber>;\n totalDeposits: Record<number, BigNumber>;\n totalBorrows: Record<number, BigNumber>;\n fundingRates: Record<number, BigNumber>;\n depositRates: Record<number, BigNumber>;\n borrowRates: Record<number, BigNumber>;\n cumulativeTradeSizes: Record<number, BigNumber>;\n cumulativeInflows: Record<number, BigNumber>;\n cumulativeOutflows: Record<number, BigNumber>;\n oraclePrices: Record<number, BigNumber>;\n}\n\nexport type GetIndexerMarketSnapshotsResponse = IndexerMarketSnapshot[];\n\nexport type GetIndexerEdgeMarketSnapshotsParams =\n IndexerSnapshotsIntervalParams;\n\n// Map of chain id -> IndexerMarketSnapshot[]\nexport type GetIndexerEdgeMarketSnapshotResponse = Record<\n number,\n IndexerMarketSnapshot[]\n>;\n\n/**\n * Events\n */\n\n// There can be multiple events per tx, this allows a limit depending on usecase\nexport type GetIndexerEventsLimitType = 'events' | 'txs';\n\nexport interface GetIndexerEventsParams {\n // Max submission index, inclusive\n startCursor?: string;\n subaccounts?: Subaccount[];\n productIds?: number[];\n // If not given, will return both isolated & non-iso events\n isolated?: boolean;\n eventTypes?: IndexerEventType[];\n maxTimestampInclusive?: number;\n // Descending order for idx (time), defaults to true\n desc?: boolean;\n limit?: {\n type: GetIndexerEventsLimitType;\n value: number;\n };\n}\n\nexport type GetIndexerEventsResponse = IndexerEventWithTx[];\n\n/**\n * Historical orders\n */\n\nexport interface GetIndexerOrdersParams {\n // Max submission index, inclusive\n startCursor?: string;\n subaccounts?: Subaccount[];\n minTimestampInclusive?: number;\n maxTimestampInclusive?: number;\n limit?: number;\n productIds?: number[];\n triggerTypes?: IndexerServerTriggerTypeFilter[];\n // If not given, will return both isolated & non-iso orders\n isolated?: boolean;\n digests?: string[];\n}\n\nexport interface IndexerOrder {\n digest: string;\n subaccount: string;\n productId: number;\n submissionIndex: string;\n amount: BigNumber;\n price: BigNumber;\n expiration: number;\n // Order metadata from appendix\n appendix: OrderAppendix;\n nonce: BigNumber;\n // Derived from the nonce\n recvTimeSeconds: number;\n // Fill amounts\n baseFilled: BigNumber;\n // Includes fee\n quoteFilled: BigNumber;\n // Includes sequencer fee\n totalFee: BigNumber;\n builderFee: BigNumber;\n realizedPnl: BigNumber;\n // Always positive\n closedSize: BigNumber;\n // Cumulative realized entry price for the closed amount on an order\n closedNetEntry: BigNumber;\n // Weighted average margin allocated to the closed amount. Only present for isolated margin orders; null for cross-margin orders\n closedMargin: BigNumber | null;\n // Position amount right before the order\n preOrderAmount: BigNumber;\n // Unix timestamp (seconds) of the first fill on the order\n firstFillTimestamp: BigNumber;\n // Unix timestamp (seconds) of the last fill on the order\n lastFillTimestamp: BigNumber;\n}\n\nexport type GetIndexerOrdersResponse = IndexerOrder[];\n\n/**\n * Match events\n */\n\nexport interface GetIndexerMatchEventsParams {\n // When not given, will return all maker events\n subaccounts?: Subaccount[];\n productIds?: number[];\n // If not given, will return both isolated & non-iso events\n isolated?: boolean;\n maxTimestampInclusive?: number;\n limit: number;\n // Max submission index, inclusive\n startCursor?: string;\n}\n\n// There are 2 balance states per match event if the match is in a spot market, but only one if the match is in a perp market\nexport interface IndexerMatchEventBalances {\n base: IndexerSpotBalance | IndexerPerpBalance;\n quote?: IndexerSpotBalance;\n}\n\nexport interface IndexerMatchEvent extends Subaccount {\n productId: number;\n digest: string;\n isolated: boolean;\n order: EIP712OrderValues;\n baseFilled: BigNumber;\n quoteFilled: BigNumber;\n // Includes sequencer fee\n totalFee: BigNumber;\n sequencerFee: BigNumber;\n builderFee: BigNumber;\n cumulativeBaseFilled: BigNumber;\n cumulativeQuoteFilled: BigNumber;\n cumulativeFee: BigNumber;\n submissionIndex: string;\n timestamp: BigNumber;\n isTaker: boolean;\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 realizedPnl: BigNumber;\n // Always positive\n closedSize: BigNumber;\n // Realized entry price for the closed amount on this match (x18). Represents the total quote value at which the closed portion of the position was originally entered.\n closedNetEntry: BigNumber;\n // Margin allocated to the closed amount on this match (x18). Only present for isolated margin orders; null for cross-margin orders.\n margin: BigNumber | null;\n}\n\nexport type GetIndexerMatchEventsResponse = IndexerMatchEvent[];\n\n/**\n * Quote price\n */\n\nexport interface GetIndexerQuotePriceResponse {\n price: BigNumber;\n}\n\n/**\n * Linked Signer\n */\n\nexport interface GetIndexerLinkedSignerParams {\n subaccount: Subaccount;\n}\n\nexport interface GetIndexerLinkedSignerResponse {\n totalTxLimit: BigNumber;\n remainingTxs: BigNumber;\n // If remainingTxs is 0, this is the time until the next link signer tx can be sent\n waitTimeUntilNextTx: BigNumber;\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: BigNumber;\n paymentAmount: BigNumber;\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: BigNumber;\n // Represents the annually interest rate for spots and annually funding rate for perps.\n annualPaymentRate: BigNumber;\n oraclePrice: BigNumber;\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: BigNumber;\n makerFee: BigNumber;\n uptime: BigNumber;\n sumQMin: BigNumber;\n qScore: BigNumber;\n makerShare: BigNumber;\n expectedMakerReward: BigNumber;\n}\n\nexport interface IndexerMaker {\n address: string;\n snapshots: IndexerMakerSnapshot[];\n}\n\nexport interface GetIndexerMakerStatisticsResponse {\n rewardCoefficient: BigNumber;\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: BigNumber;\n pnlRank: BigNumber;\n percentRoi: BigNumber;\n roiRank: BigNumber;\n // Float indicating the ending account value at the time the snapshot was taken i.e: at updateTime\n accountValue: BigNumber;\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?: BigNumber;\n // Seconds\n updateTime: BigNumber;\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 extends GetIndexerLeaderboardRegistrationParams {\n updateRegistration: LeaderboardSignatureParams;\n // In millis, defaults to 90s in the future\n recvTime?: BigNumber;\n}\n\nexport interface IndexerLeaderboardRegistration {\n subaccount: Subaccount;\n contestId: number;\n // Seconds\n updateTime: BigNumber;\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: BigNumber;\n // End time in seconds\n endTime: BigNumber;\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: BigNumber;\n // Last updated time in Seconds\n lastUpdated: BigNumber;\n totalParticipants: BigNumber;\n // Float indicating the min account value required to be eligible for this contest e.g: 250.0\n minRequiredAccountValue: BigNumber;\n // Float indicating the min trading volume required to be eligible for this contest e.g: 1000.0\n minRequiredVolume: BigNumber;\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: BigNumber;\n // Total volume traded by the NLP, in terms of the primary quote\n cumulativeVolume: BigNumber;\n cumulativeTrades: BigNumber;\n cumulativeMintAmountQuote: BigNumber;\n cumulativeBurnAmountQuote: BigNumber;\n cumulativePnl: BigNumber;\n tvl: BigNumber;\n oraclePrice: BigNumber;\n depositors: BigNumber;\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: BigNumber;\n // Current nSubmissions value from the chain (i.e., number of processed txs)\n totalSubmissions: BigNumber;\n // Number of unprocessed transactions (totalTxs - totalSubmissions)\n backlogSize: BigNumber;\n // UNIX timestamp (in seconds) of when the data was last updated\n updatedAt: BigNumber;\n // Estimated time in seconds (float) to clear the entire backlog (null if unavailable)\n backlogEtaInSeconds: BigNumber | null;\n // Current submission rate in transactions per second (float) (null if unavailable)\n txsPerSecond: BigNumber | null;\n}\n\nexport interface GetIndexerSubaccountDDAParams {\n subaccount: Subaccount;\n}\n\nexport interface GetIndexerSubaccountDDAResponse {\n address: Address;\n}\n\n/**\n * Private Alpha Choice\n */\n\nexport interface GetIndexerPrivateAlphaChoiceParams {\n address: Address;\n}\n\nexport interface GetIndexerPrivateAlphaChoiceResponse {\n points: BigNumber;\n feeRefund: BigNumber;\n nftEligibility: boolean;\n}\n\n/**\n * Nado Points\n */\n\nexport interface GetIndexerPointsParams {\n address: Address;\n}\n\nexport interface IndexerPointsEpoch {\n epoch: number;\n description: string;\n /** Unix timestamp in seconds */\n startTime: BigNumber;\n /** Unix timestamp in seconds */\n endTime: BigNumber;\n totalPoints: BigNumber;\n points: BigNumber;\n rank: number;\n tier: number;\n}\n\nexport interface IndexerAllTimePoints {\n points: BigNumber;\n rank: number;\n tier: number;\n}\n\nexport interface GetIndexerPointsResponse {\n pointsPerEpoch: IndexerPointsEpoch[];\n allTimePoints: IndexerAllTimePoints;\n}\n\n/**\n * V2 Tickers\n */\n\n/**\n * Market type for ticker filtering\n */\nexport type TickerMarketType = 'spot' | 'perp';\n\n/**\n * Parameters for querying v2 tickers endpoint\n */\nexport interface GetIndexerV2TickersParams {\n /**\n * Filter tickers by market type (spot or perp)\n * @example 'spot'\n * @example 'perp'\n */\n market?: TickerMarketType;\n /**\n * Whether to include edge products\n * @default false\n */\n edge?: boolean;\n}\n\n/**\n * Individual ticker data from v2 endpoint\n */\nexport interface IndexerV2TickerResponse {\n /** Unique product identifier */\n productId: number;\n /** Unique ticker identifier */\n tickerId: string;\n /** Base currency symbol */\n baseCurrency: string;\n /** Quote currency symbol */\n quoteCurrency: string;\n /** Last traded price */\n lastPrice: number;\n /** 24h trading volume in base currency */\n baseVolume: number;\n /** 24h trading volume in quote currency */\n quoteVolume: number;\n /** 24h price change percentage */\n priceChangePercent24h: number;\n}\n\n/**\n * Response from v2 tickers endpoint\n * Maps ticker IDs to their respective ticker data\n */\nexport type GetIndexerV2TickersResponse = Record<\n string,\n IndexerV2TickerResponse\n>;\n\n/**\n * Parameters for querying v2 symbols endpoint\n */\nexport interface GetIndexerV2SymbolsParams {\n /**\n * Filter by product type\n * @example 'spot'\n * @example 'perp'\n */\n productType?: 'spot' | 'perp';\n /**\n * Comma-separated list of product IDs to filter by\n * @example '2,4,42'\n */\n productIds?: string;\n}\n\n/**\n * Market hours information for a product\n */\nexport interface IndexerV2MarketHours {\n /** Whether the market is currently in its regular trading session */\n isOpen: boolean;\n /** Why the market is closed: \"weekend\" or \"holiday\". Null when open. */\n reason: string | null;\n /** ISO 8601 UTC timestamp of the next session close. Null when closed. */\n nextClose: string | null;\n /** ISO 8601 UTC timestamp of the next session open. Null when no upcoming open. */\n nextOpen: string | null;\n}\n\nexport type IndexerV2TradingStatus =\n // Normal trading, all order types accepted\n | 'live'\n // Only post-only orders accepted (taker orders rejected)\n | 'post_only'\n // Only reduce-only orders accepted; used when a market is being delisted\n | 'reduce_only'\n // No new positions can be opened; only orders that reduce existing positions are accepted. Used during periods of low activity (e.g. weekends, holidays)\n | 'soft_reduce_only'\n // No orders accepted\n | 'not_tradable';\n\n/**\n * Individual symbol data from v2 endpoint\n */\nexport interface IndexerV2Symbol {\n /** Product type: \"spot\" or \"perp\" */\n type: string;\n /** Unique product identifier */\n productId: number;\n /** Trading symbol (e.g., \"BTC-PERP\", \"WETH\") */\n symbol: string;\n /** Minimum price increment */\n priceIncrement: BigNumber;\n /** Minimum order size increment (base denominated) */\n sizeIncrement: string;\n /** Minimum order size (USDT0 denominated) */\n minSize: string;\n /** Default maker fee rate (negative = rebate) */\n makerFeeRate: BigNumber;\n /** Default taker fee rate */\n takerFeeRate: BigNumber;\n /** Initial margin weight for long positions */\n longWeightInitial: BigNumber;\n /** Maintenance margin weight for long positions */\n longWeightMaintenance: BigNumber;\n /** Maximum open interest cap. Null if uncapped. */\n maxOpenInterest: BigNumber | null;\n /** Current trading status */\n tradingStatus: IndexerV2TradingStatus;\n /** Whether the market only accepts isolated margin orders */\n isolatedOnly: boolean;\n /** Market hours information. Null for 24/7 markets. */\n marketHours: IndexerV2MarketHours | null;\n}\n\n/**\n * Response from v2 symbols endpoint\n * Maps symbols to their respective data\n */\nexport type GetIndexerV2SymbolsResponse = Record<string, IndexerV2Symbol>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
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 * Total traded volume in terms of the primary quote (i.e in terms of USDT) for this product\n */\n quote_volume_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 builder_fee: string;\n realized_pnl: string;\n closed_amount: string;\n // Cumulative realized entry price for the closed amount (x18)\n closed_net_entry: string;\n // Weighted average margin for the closed amount (x18). Only present for isolated margin orders; null for cross-margin orders\n closed_margin: string | null;\n // Unix timestamp (seconds) of the first fill on the order\n first_fill_timestamp: string;\n // Unix timestamp (seconds) of the last fill on the order\n last_fill_timestamp: 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 builder_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 is_taker: boolean;\n realized_pnl: string;\n closed_amount: string;\n // Realized entry price for the closed amount on this match (x18). Represents the total quote value at which the closed portion of the position was originally entered.\n closed_net_entry: string;\n // Margin allocated to the closed amount on this match (x18). Only present for isolated margin orders; null for cross-margin orders.\n margin: string | null;\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_quote: string;\n cumulative_mint_quote: 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 * Total traded volume in terms of the primary quote (i.e in terms of USDT) for this product\n */\n quote_volume_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 builder_fee: string;\n realized_pnl: string;\n closed_amount: string;\n // Cumulative realized entry price for the closed amount (x18)\n closed_net_entry: string;\n // Weighted average margin for the closed amount (x18). Only present for isolated margin orders; null for cross-margin orders\n closed_margin: string | null;\n // Position amount right before the order\n prev_position: string;\n // Unix timestamp (seconds) of the first fill on the order\n first_fill_timestamp: string;\n // Unix timestamp (seconds) of the last fill on the order\n last_fill_timestamp: 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 builder_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 is_taker: boolean;\n realized_pnl: string;\n closed_amount: string;\n // Realized entry price for the closed amount on this match (x18). Represents the total quote value at which the closed portion of the position was originally entered.\n closed_net_entry: string;\n // Margin allocated to the closed amount on this match (x18). Only present for isolated margin orders; null for cross-margin orders.\n margin: string | null;\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_quote: string;\n cumulative_mint_quote: 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":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nadohq/indexer-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "> TODO: description",
|
|
@@ -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.
|
|
45
|
-
"@nadohq/shared": "0.
|
|
44
|
+
"@nadohq/engine-client": "0.3.0",
|
|
45
|
+
"@nadohq/shared": "0.3.0",
|
|
46
46
|
"axios": "*",
|
|
47
47
|
"ts-mixer": "*"
|
|
48
48
|
},
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"bignumber.js": "workspace:*",
|
|
55
55
|
"viem": "workspace:*"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "64dbad6c4c0b7e0a32ccff6b95c241422332fc3e"
|
|
58
58
|
}
|
package/src/dataMappers.ts
CHANGED
|
@@ -117,6 +117,7 @@ export function mapIndexerOrder(order: IndexerServerOrder): IndexerOrder {
|
|
|
117
117
|
closedSize: toBigNumber(order.closed_amount),
|
|
118
118
|
closedNetEntry: toBigNumber(order.closed_net_entry),
|
|
119
119
|
closedMargin: order.closed_margin ? toBigNumber(order.closed_margin) : null,
|
|
120
|
+
preOrderAmount: toBigNumber(order.prev_position),
|
|
120
121
|
firstFillTimestamp: toBigNumber(order.first_fill_timestamp),
|
|
121
122
|
lastFillTimestamp: toBigNumber(order.last_fill_timestamp),
|
|
122
123
|
};
|
package/src/types/clientTypes.ts
CHANGED
|
@@ -378,6 +378,8 @@ export interface IndexerOrder {
|
|
|
378
378
|
closedNetEntry: BigNumber;
|
|
379
379
|
// Weighted average margin allocated to the closed amount. Only present for isolated margin orders; null for cross-margin orders
|
|
380
380
|
closedMargin: BigNumber | null;
|
|
381
|
+
// Position amount right before the order
|
|
382
|
+
preOrderAmount: BigNumber;
|
|
381
383
|
// Unix timestamp (seconds) of the first fill on the order
|
|
382
384
|
firstFillTimestamp: BigNumber;
|
|
383
385
|
// Unix timestamp (seconds) of the last fill on the order
|
|
@@ -116,6 +116,8 @@ export interface IndexerServerOrder {
|
|
|
116
116
|
closed_net_entry: string;
|
|
117
117
|
// Weighted average margin for the closed amount (x18). Only present for isolated margin orders; null for cross-margin orders
|
|
118
118
|
closed_margin: string | null;
|
|
119
|
+
// Position amount right before the order
|
|
120
|
+
prev_position: string;
|
|
119
121
|
// Unix timestamp (seconds) of the first fill on the order
|
|
120
122
|
first_fill_timestamp: string;
|
|
121
123
|
// Unix timestamp (seconds) of the last fill on the order
|