@nadohq/indexer-client 0.1.0-alpha.2 → 0.1.0-alpha.4
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/IndexerBaseClient.cjs +71 -55
- package/dist/IndexerBaseClient.cjs.map +1 -1
- package/dist/IndexerBaseClient.d.cts +7 -3
- package/dist/IndexerBaseClient.d.ts +7 -3
- package/dist/IndexerBaseClient.js +22 -7
- package/dist/IndexerBaseClient.js.map +1 -1
- package/dist/IndexerClient.cjs +16 -16
- package/dist/IndexerClient.cjs.map +1 -1
- package/dist/IndexerClient.d.cts +2 -3
- package/dist/IndexerClient.d.ts +2 -3
- package/dist/IndexerClient.js +2 -2
- package/dist/IndexerClient.js.map +1 -1
- package/dist/dataMappers.cjs +105 -108
- package/dist/dataMappers.cjs.map +1 -1
- package/dist/dataMappers.d.cts +1 -2
- package/dist/dataMappers.d.ts +1 -2
- package/dist/dataMappers.js +7 -10
- package/dist/dataMappers.js.map +1 -1
- package/dist/endpoints.cjs +2 -2
- package/dist/endpoints.cjs.map +1 -1
- package/dist/endpoints.d.cts +1 -1
- package/dist/endpoints.d.ts +1 -1
- package/dist/endpoints.js +2 -2
- package/dist/endpoints.js.map +1 -1
- package/dist/index.d.cts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/types/clientTypes.cjs.map +1 -1
- package/dist/types/clientTypes.d.cts +8 -7
- package/dist/types/clientTypes.d.ts +8 -7
- package/dist/types/index.d.cts +3 -4
- package/dist/types/index.d.ts +3 -4
- package/dist/types/paginatedEventsTypes.cjs.map +1 -1
- package/dist/types/paginatedEventsTypes.d.cts +1 -2
- package/dist/types/paginatedEventsTypes.d.ts +1 -2
- package/dist/types/serverModelTypes.cjs.map +1 -1
- package/dist/types/serverModelTypes.d.cts +2 -1
- package/dist/types/serverModelTypes.d.ts +2 -1
- package/dist/types/serverTypes.cjs.map +1 -1
- package/dist/types/serverTypes.d.cts +10 -2
- package/dist/types/serverTypes.d.ts +10 -2
- package/dist/utils/index.d.cts +2 -3
- package/dist/utils/index.d.ts +2 -3
- package/dist/utils/indexerBalanceValue.cjs.map +1 -1
- package/dist/utils/indexerBalanceValue.d.cts +2 -3
- package/dist/utils/indexerBalanceValue.d.ts +2 -3
- package/dist/utils/indexerBalanceValue.js.map +1 -1
- package/package.json +4 -5
- package/src/IndexerBaseClient.ts +32 -11
- package/src/IndexerClient.ts +2 -2
- package/src/dataMappers.ts +8 -11
- package/src/endpoints.ts +2 -2
- package/src/types/clientTypes.ts +12 -8
- package/src/types/paginatedEventsTypes.ts +1 -2
- package/src/types/serverModelTypes.ts +2 -1
- package/src/types/serverTypes.ts +11 -1
- package/src/utils/indexerBalanceValue.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SignedTx, EIP712LeaderboardAuthenticationValues } from '@nadohq/
|
|
1
|
+
import { SignedTx, EIP712LeaderboardAuthenticationValues } from '@nadohq/shared';
|
|
2
2
|
import { IndexerEventType } from './IndexerEventType.cjs';
|
|
3
3
|
import { IndexerLeaderboardRankType } from './IndexerLeaderboardType.cjs';
|
|
4
4
|
import { NadoWithdrawCollateralTx } from './NadoTx.cjs';
|
|
@@ -133,10 +133,14 @@ interface IndexerServerFastWithdrawalSignatureParams {
|
|
|
133
133
|
interface IndexerServerNlpSnapshotsParams {
|
|
134
134
|
interval: IndexerServerSnapshotsInterval;
|
|
135
135
|
}
|
|
136
|
+
interface IndexerServerDDAQueryParams {
|
|
137
|
+
subaccount: string;
|
|
138
|
+
}
|
|
136
139
|
interface IndexerServerQueryRequestByType {
|
|
137
140
|
account_snapshots: IndexerServerMultiSubaccountSnapshotsParams;
|
|
138
141
|
backlog: Record<string, never>;
|
|
139
142
|
candlesticks: IndexerServerCandlesticksParams;
|
|
143
|
+
direct_deposit_address: IndexerServerDDAQueryParams;
|
|
140
144
|
edge_candlesticks: IndexerEdgeServerCandlesticksParams;
|
|
141
145
|
edge_market_snapshots: IndexerEdgeServerMarketSnapshotsParams;
|
|
142
146
|
events: IndexerServerEventsParams;
|
|
@@ -262,6 +266,9 @@ interface IndexerServerFastWithdrawalSignatureResponse {
|
|
|
262
266
|
interface IndexerServerNlpSnapshotsResponse {
|
|
263
267
|
snapshots: IndexerServerNlpSnapshot[];
|
|
264
268
|
}
|
|
269
|
+
interface IndexerServerDDAResponse {
|
|
270
|
+
v1_address: string;
|
|
271
|
+
}
|
|
265
272
|
interface IndexerServerBacklogResponse {
|
|
266
273
|
total_txs: string;
|
|
267
274
|
total_submissions: string;
|
|
@@ -274,6 +281,7 @@ interface IndexerServerQueryResponseByType {
|
|
|
274
281
|
account_snapshots: IndexerServerMultiSubaccountSnapshotsResponse;
|
|
275
282
|
backlog: IndexerServerBacklogResponse;
|
|
276
283
|
candlesticks: IndexerServerCandlesticksResponse;
|
|
284
|
+
direct_deposit_address: IndexerServerDDAResponse;
|
|
277
285
|
edge_candlesticks: IndexerEdgeServerCandlesticksResponse;
|
|
278
286
|
edge_market_snapshots: IndexerEdgeServerMarketSnapshotsResponse;
|
|
279
287
|
events: IndexerServerEventsResponse;
|
|
@@ -301,4 +309,4 @@ interface IndexerServerQueryResponseByType {
|
|
|
301
309
|
nlp_snapshots: IndexerServerNlpSnapshotsResponse;
|
|
302
310
|
}
|
|
303
311
|
|
|
304
|
-
export type { IndexerEdgeServerCandlesticksParams, IndexerEdgeServerCandlesticksResponse, IndexerEdgeServerMarketSnapshotsParams, IndexerEdgeServerMarketSnapshotsResponse, IndexerServerBacklogResponse, IndexerServerCandlesticksParams, IndexerServerCandlesticksResponse, IndexerServerEventsParams, IndexerServerEventsResponse, IndexerServerFastWithdrawalSignatureParams, IndexerServerFastWithdrawalSignatureResponse, IndexerServerFundingRate, IndexerServerFundingRateParams, IndexerServerFundingRateResponse, IndexerServerFundingRatesParams, IndexerServerFundingRatesResponse, IndexerServerInterestFundingParams, IndexerServerInterestFundingResponse, IndexerServerLeaderboardContestsParams, IndexerServerLeaderboardContestsResponse, IndexerServerLeaderboardParams, IndexerServerLeaderboardRankParams, IndexerServerLeaderboardRankResponse, IndexerServerLeaderboardRegistrationParams, IndexerServerLeaderboardRegistrationResponse, IndexerServerLeaderboardResponse, IndexerServerLinkedSignerParams, IndexerServerLinkedSignerResponse, IndexerServerListSubaccountsParams, IndexerServerListSubaccountsResponse, IndexerServerMakerStatisticsParams, IndexerServerMakerStatisticsResponse, IndexerServerMarketSnapshotsParams, IndexerServerMarketSnapshotsResponse, IndexerServerMatchEventsParams, IndexerServerMatchEventsResponse, IndexerServerMultiProductsParams, IndexerServerMultiProductsResponse, IndexerServerMultiSubaccountSnapshotsParams, IndexerServerMultiSubaccountSnapshotsResponse, IndexerServerNlpSnapshotsParams, IndexerServerNlpSnapshotsResponse, IndexerServerOraclePricesParams, IndexerServerOraclePricesResponse, IndexerServerOrdersParams, IndexerServerOrdersResponse, IndexerServerPerpPrices, IndexerServerPerpPricesParams, IndexerServerPerpPricesResponse, IndexerServerPriceParams, IndexerServerPriceResponse, IndexerServerProductsParams, IndexerServerProductsResponse, IndexerServerQueryRequestByType, IndexerServerQueryRequestType, IndexerServerQueryResponseByType, IndexerServerReferralCodeParams, IndexerServerReferralCodeResponse, IndexerServerUsdcPriceResponse };
|
|
312
|
+
export type { IndexerEdgeServerCandlesticksParams, IndexerEdgeServerCandlesticksResponse, IndexerEdgeServerMarketSnapshotsParams, IndexerEdgeServerMarketSnapshotsResponse, IndexerServerBacklogResponse, IndexerServerCandlesticksParams, IndexerServerCandlesticksResponse, IndexerServerDDAQueryParams, IndexerServerDDAResponse, IndexerServerEventsParams, IndexerServerEventsResponse, IndexerServerFastWithdrawalSignatureParams, IndexerServerFastWithdrawalSignatureResponse, IndexerServerFundingRate, IndexerServerFundingRateParams, IndexerServerFundingRateResponse, IndexerServerFundingRatesParams, IndexerServerFundingRatesResponse, IndexerServerInterestFundingParams, IndexerServerInterestFundingResponse, IndexerServerLeaderboardContestsParams, IndexerServerLeaderboardContestsResponse, IndexerServerLeaderboardParams, IndexerServerLeaderboardRankParams, IndexerServerLeaderboardRankResponse, IndexerServerLeaderboardRegistrationParams, IndexerServerLeaderboardRegistrationResponse, IndexerServerLeaderboardResponse, IndexerServerLinkedSignerParams, IndexerServerLinkedSignerResponse, IndexerServerListSubaccountsParams, IndexerServerListSubaccountsResponse, IndexerServerMakerStatisticsParams, IndexerServerMakerStatisticsResponse, IndexerServerMarketSnapshotsParams, IndexerServerMarketSnapshotsResponse, IndexerServerMatchEventsParams, IndexerServerMatchEventsResponse, IndexerServerMultiProductsParams, IndexerServerMultiProductsResponse, IndexerServerMultiSubaccountSnapshotsParams, IndexerServerMultiSubaccountSnapshotsResponse, IndexerServerNlpSnapshotsParams, IndexerServerNlpSnapshotsResponse, IndexerServerOraclePricesParams, IndexerServerOraclePricesResponse, IndexerServerOrdersParams, IndexerServerOrdersResponse, IndexerServerPerpPrices, IndexerServerPerpPricesParams, IndexerServerPerpPricesResponse, IndexerServerPriceParams, IndexerServerPriceResponse, IndexerServerProductsParams, IndexerServerProductsResponse, IndexerServerQueryRequestByType, IndexerServerQueryRequestType, IndexerServerQueryResponseByType, IndexerServerReferralCodeParams, IndexerServerReferralCodeResponse, IndexerServerUsdcPriceResponse };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SignedTx, EIP712LeaderboardAuthenticationValues } from '@nadohq/
|
|
1
|
+
import { SignedTx, EIP712LeaderboardAuthenticationValues } from '@nadohq/shared';
|
|
2
2
|
import { IndexerEventType } from './IndexerEventType.js';
|
|
3
3
|
import { IndexerLeaderboardRankType } from './IndexerLeaderboardType.js';
|
|
4
4
|
import { NadoWithdrawCollateralTx } from './NadoTx.js';
|
|
@@ -133,10 +133,14 @@ interface IndexerServerFastWithdrawalSignatureParams {
|
|
|
133
133
|
interface IndexerServerNlpSnapshotsParams {
|
|
134
134
|
interval: IndexerServerSnapshotsInterval;
|
|
135
135
|
}
|
|
136
|
+
interface IndexerServerDDAQueryParams {
|
|
137
|
+
subaccount: string;
|
|
138
|
+
}
|
|
136
139
|
interface IndexerServerQueryRequestByType {
|
|
137
140
|
account_snapshots: IndexerServerMultiSubaccountSnapshotsParams;
|
|
138
141
|
backlog: Record<string, never>;
|
|
139
142
|
candlesticks: IndexerServerCandlesticksParams;
|
|
143
|
+
direct_deposit_address: IndexerServerDDAQueryParams;
|
|
140
144
|
edge_candlesticks: IndexerEdgeServerCandlesticksParams;
|
|
141
145
|
edge_market_snapshots: IndexerEdgeServerMarketSnapshotsParams;
|
|
142
146
|
events: IndexerServerEventsParams;
|
|
@@ -262,6 +266,9 @@ interface IndexerServerFastWithdrawalSignatureResponse {
|
|
|
262
266
|
interface IndexerServerNlpSnapshotsResponse {
|
|
263
267
|
snapshots: IndexerServerNlpSnapshot[];
|
|
264
268
|
}
|
|
269
|
+
interface IndexerServerDDAResponse {
|
|
270
|
+
v1_address: string;
|
|
271
|
+
}
|
|
265
272
|
interface IndexerServerBacklogResponse {
|
|
266
273
|
total_txs: string;
|
|
267
274
|
total_submissions: string;
|
|
@@ -274,6 +281,7 @@ interface IndexerServerQueryResponseByType {
|
|
|
274
281
|
account_snapshots: IndexerServerMultiSubaccountSnapshotsResponse;
|
|
275
282
|
backlog: IndexerServerBacklogResponse;
|
|
276
283
|
candlesticks: IndexerServerCandlesticksResponse;
|
|
284
|
+
direct_deposit_address: IndexerServerDDAResponse;
|
|
277
285
|
edge_candlesticks: IndexerEdgeServerCandlesticksResponse;
|
|
278
286
|
edge_market_snapshots: IndexerEdgeServerMarketSnapshotsResponse;
|
|
279
287
|
events: IndexerServerEventsResponse;
|
|
@@ -301,4 +309,4 @@ interface IndexerServerQueryResponseByType {
|
|
|
301
309
|
nlp_snapshots: IndexerServerNlpSnapshotsResponse;
|
|
302
310
|
}
|
|
303
311
|
|
|
304
|
-
export type { IndexerEdgeServerCandlesticksParams, IndexerEdgeServerCandlesticksResponse, IndexerEdgeServerMarketSnapshotsParams, IndexerEdgeServerMarketSnapshotsResponse, IndexerServerBacklogResponse, IndexerServerCandlesticksParams, IndexerServerCandlesticksResponse, IndexerServerEventsParams, IndexerServerEventsResponse, IndexerServerFastWithdrawalSignatureParams, IndexerServerFastWithdrawalSignatureResponse, IndexerServerFundingRate, IndexerServerFundingRateParams, IndexerServerFundingRateResponse, IndexerServerFundingRatesParams, IndexerServerFundingRatesResponse, IndexerServerInterestFundingParams, IndexerServerInterestFundingResponse, IndexerServerLeaderboardContestsParams, IndexerServerLeaderboardContestsResponse, IndexerServerLeaderboardParams, IndexerServerLeaderboardRankParams, IndexerServerLeaderboardRankResponse, IndexerServerLeaderboardRegistrationParams, IndexerServerLeaderboardRegistrationResponse, IndexerServerLeaderboardResponse, IndexerServerLinkedSignerParams, IndexerServerLinkedSignerResponse, IndexerServerListSubaccountsParams, IndexerServerListSubaccountsResponse, IndexerServerMakerStatisticsParams, IndexerServerMakerStatisticsResponse, IndexerServerMarketSnapshotsParams, IndexerServerMarketSnapshotsResponse, IndexerServerMatchEventsParams, IndexerServerMatchEventsResponse, IndexerServerMultiProductsParams, IndexerServerMultiProductsResponse, IndexerServerMultiSubaccountSnapshotsParams, IndexerServerMultiSubaccountSnapshotsResponse, IndexerServerNlpSnapshotsParams, IndexerServerNlpSnapshotsResponse, IndexerServerOraclePricesParams, IndexerServerOraclePricesResponse, IndexerServerOrdersParams, IndexerServerOrdersResponse, IndexerServerPerpPrices, IndexerServerPerpPricesParams, IndexerServerPerpPricesResponse, IndexerServerPriceParams, IndexerServerPriceResponse, IndexerServerProductsParams, IndexerServerProductsResponse, IndexerServerQueryRequestByType, IndexerServerQueryRequestType, IndexerServerQueryResponseByType, IndexerServerReferralCodeParams, IndexerServerReferralCodeResponse, IndexerServerUsdcPriceResponse };
|
|
312
|
+
export type { IndexerEdgeServerCandlesticksParams, IndexerEdgeServerCandlesticksResponse, IndexerEdgeServerMarketSnapshotsParams, IndexerEdgeServerMarketSnapshotsResponse, IndexerServerBacklogResponse, IndexerServerCandlesticksParams, IndexerServerCandlesticksResponse, IndexerServerDDAQueryParams, IndexerServerDDAResponse, IndexerServerEventsParams, IndexerServerEventsResponse, IndexerServerFastWithdrawalSignatureParams, IndexerServerFastWithdrawalSignatureResponse, IndexerServerFundingRate, IndexerServerFundingRateParams, IndexerServerFundingRateResponse, IndexerServerFundingRatesParams, IndexerServerFundingRatesResponse, IndexerServerInterestFundingParams, IndexerServerInterestFundingResponse, IndexerServerLeaderboardContestsParams, IndexerServerLeaderboardContestsResponse, IndexerServerLeaderboardParams, IndexerServerLeaderboardRankParams, IndexerServerLeaderboardRankResponse, IndexerServerLeaderboardRegistrationParams, IndexerServerLeaderboardRegistrationResponse, IndexerServerLeaderboardResponse, IndexerServerLinkedSignerParams, IndexerServerLinkedSignerResponse, IndexerServerListSubaccountsParams, IndexerServerListSubaccountsResponse, IndexerServerMakerStatisticsParams, IndexerServerMakerStatisticsResponse, IndexerServerMarketSnapshotsParams, IndexerServerMarketSnapshotsResponse, IndexerServerMatchEventsParams, IndexerServerMatchEventsResponse, IndexerServerMultiProductsParams, IndexerServerMultiProductsResponse, IndexerServerMultiSubaccountSnapshotsParams, IndexerServerMultiSubaccountSnapshotsResponse, IndexerServerNlpSnapshotsParams, IndexerServerNlpSnapshotsResponse, IndexerServerOraclePricesParams, IndexerServerOraclePricesResponse, IndexerServerOrdersParams, IndexerServerOrdersResponse, IndexerServerPerpPrices, IndexerServerPerpPricesParams, IndexerServerPerpPricesResponse, IndexerServerPriceParams, IndexerServerPriceResponse, IndexerServerProductsParams, IndexerServerProductsResponse, IndexerServerQueryRequestByType, IndexerServerQueryRequestType, IndexerServerQueryResponseByType, IndexerServerReferralCodeParams, IndexerServerReferralCodeResponse, IndexerServerUsdcPriceResponse };
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
export { calcIndexerPerpBalanceNotionalValue, calcIndexerPerpBalanceValue, calcIndexerSpotBalanceValue } from './indexerBalanceValue.cjs';
|
|
2
|
-
import '@nadohq/
|
|
2
|
+
import '@nadohq/shared';
|
|
3
3
|
import '../types/clientTypes.cjs';
|
|
4
|
-
import '@nadohq/contracts';
|
|
5
4
|
import 'viem';
|
|
6
5
|
import '../types/CandlestickPeriod.cjs';
|
|
7
6
|
import '../types/IndexerEventType.cjs';
|
|
8
7
|
import '../types/IndexerLeaderboardType.cjs';
|
|
9
|
-
import '../types/serverTypes.cjs';
|
|
10
8
|
import '../types/NadoTx.cjs';
|
|
9
|
+
import '../types/serverTypes.cjs';
|
|
11
10
|
import '../types/serverModelTypes.cjs';
|
|
12
11
|
import '@nadohq/engine-client';
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
export { calcIndexerPerpBalanceNotionalValue, calcIndexerPerpBalanceValue, calcIndexerSpotBalanceValue } from './indexerBalanceValue.js';
|
|
2
|
-
import '@nadohq/
|
|
2
|
+
import '@nadohq/shared';
|
|
3
3
|
import '../types/clientTypes.js';
|
|
4
|
-
import '@nadohq/contracts';
|
|
5
4
|
import 'viem';
|
|
6
5
|
import '../types/CandlestickPeriod.js';
|
|
7
6
|
import '../types/IndexerEventType.js';
|
|
8
7
|
import '../types/IndexerLeaderboardType.js';
|
|
9
|
-
import '../types/serverTypes.js';
|
|
10
8
|
import '../types/NadoTx.js';
|
|
9
|
+
import '../types/serverTypes.js';
|
|
11
10
|
import '../types/serverModelTypes.js';
|
|
12
11
|
import '@nadohq/engine-client';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/indexerBalanceValue.ts"],"sourcesContent":["import { BigDecimal } from '@nadohq/
|
|
1
|
+
{"version":3,"sources":["../../src/utils/indexerBalanceValue.ts"],"sourcesContent":["import { BigDecimal } from '@nadohq/shared';\nimport { IndexerPerpBalance, IndexerSpotBalance } from '../types';\n\n/**\n * Most of these calculations take oraclePrice as a separate parameter. This allows us to not rely on the Snapshot\n * interfaces to give clients the optionality to pass either the pre or post balance\n */\n\n/**\n * Calculates the quote value of an indexer spot balance\n *\n * @param balance\n * @param oraclePrice\n */\nexport function calcIndexerSpotBalanceValue(\n balance: IndexerSpotBalance,\n oraclePrice: BigDecimal,\n): BigDecimal {\n return balance.amount.multipliedBy(oraclePrice);\n}\n\n/**\n * Calculates the notional value of an indexer perp balance\n *\n * @param balance\n * @param oraclePrice\n */\nexport function calcIndexerPerpBalanceNotionalValue(\n balance: IndexerPerpBalance,\n oraclePrice: BigDecimal,\n): BigDecimal {\n return balance.amount.multipliedBy(oraclePrice).abs();\n}\n\n/**\n * Calculates the true quote value of a indexer perp balance, which is the same as its unrealized pnl / unsettled quote\n *\n * @param balance\n * @param oraclePrice\n */\nexport function calcIndexerPerpBalanceValue(\n balance: IndexerPerpBalance,\n oraclePrice: BigDecimal,\n): BigDecimal {\n return balance.amount.multipliedBy(oraclePrice).plus(balance.vQuoteBalance);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcO,SAAS,4BACd,SACA,aACY;AACZ,SAAO,QAAQ,OAAO,aAAa,WAAW;AAChD;AAQO,SAAS,oCACd,SACA,aACY;AACZ,SAAO,QAAQ,OAAO,aAAa,WAAW,EAAE,IAAI;AACtD;AAQO,SAAS,4BACd,SACA,aACY;AACZ,SAAO,QAAQ,OAAO,aAAa,WAAW,EAAE,KAAK,QAAQ,aAAa;AAC5E;","names":[]}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { BigDecimal } from '@nadohq/
|
|
1
|
+
import { BigDecimal } from '@nadohq/shared';
|
|
2
2
|
import { IndexerSpotBalance, IndexerPerpBalance } from '../types/clientTypes.cjs';
|
|
3
|
-
import '@nadohq/contracts';
|
|
4
3
|
import 'viem';
|
|
5
4
|
import '../types/CandlestickPeriod.cjs';
|
|
6
5
|
import '../types/IndexerEventType.cjs';
|
|
7
6
|
import '../types/IndexerLeaderboardType.cjs';
|
|
8
|
-
import '../types/serverTypes.cjs';
|
|
9
7
|
import '../types/NadoTx.cjs';
|
|
8
|
+
import '../types/serverTypes.cjs';
|
|
10
9
|
import '../types/serverModelTypes.cjs';
|
|
11
10
|
import '@nadohq/engine-client';
|
|
12
11
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { BigDecimal } from '@nadohq/
|
|
1
|
+
import { BigDecimal } from '@nadohq/shared';
|
|
2
2
|
import { IndexerSpotBalance, IndexerPerpBalance } from '../types/clientTypes.js';
|
|
3
|
-
import '@nadohq/contracts';
|
|
4
3
|
import 'viem';
|
|
5
4
|
import '../types/CandlestickPeriod.js';
|
|
6
5
|
import '../types/IndexerEventType.js';
|
|
7
6
|
import '../types/IndexerLeaderboardType.js';
|
|
8
|
-
import '../types/serverTypes.js';
|
|
9
7
|
import '../types/NadoTx.js';
|
|
8
|
+
import '../types/serverTypes.js';
|
|
10
9
|
import '../types/serverModelTypes.js';
|
|
11
10
|
import '@nadohq/engine-client';
|
|
12
11
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/indexerBalanceValue.ts"],"sourcesContent":["import { BigDecimal } from '@nadohq/
|
|
1
|
+
{"version":3,"sources":["../../src/utils/indexerBalanceValue.ts"],"sourcesContent":["import { BigDecimal } from '@nadohq/shared';\nimport { IndexerPerpBalance, IndexerSpotBalance } from '../types';\n\n/**\n * Most of these calculations take oraclePrice as a separate parameter. This allows us to not rely on the Snapshot\n * interfaces to give clients the optionality to pass either the pre or post balance\n */\n\n/**\n * Calculates the quote value of an indexer spot balance\n *\n * @param balance\n * @param oraclePrice\n */\nexport function calcIndexerSpotBalanceValue(\n balance: IndexerSpotBalance,\n oraclePrice: BigDecimal,\n): BigDecimal {\n return balance.amount.multipliedBy(oraclePrice);\n}\n\n/**\n * Calculates the notional value of an indexer perp balance\n *\n * @param balance\n * @param oraclePrice\n */\nexport function calcIndexerPerpBalanceNotionalValue(\n balance: IndexerPerpBalance,\n oraclePrice: BigDecimal,\n): BigDecimal {\n return balance.amount.multipliedBy(oraclePrice).abs();\n}\n\n/**\n * Calculates the true quote value of a indexer perp balance, which is the same as its unrealized pnl / unsettled quote\n *\n * @param balance\n * @param oraclePrice\n */\nexport function calcIndexerPerpBalanceValue(\n balance: IndexerPerpBalance,\n oraclePrice: BigDecimal,\n): BigDecimal {\n return balance.amount.multipliedBy(oraclePrice).plus(balance.vQuoteBalance);\n}\n"],"mappings":";AAcO,SAAS,4BACd,SACA,aACY;AACZ,SAAO,QAAQ,OAAO,aAAa,WAAW;AAChD;AAQO,SAAS,oCACd,SACA,aACY;AACZ,SAAO,QAAQ,OAAO,aAAa,WAAW,EAAE,IAAI;AACtD;AAQO,SAAS,4BACd,SACA,aACY;AACZ,SAAO,QAAQ,OAAO,aAAa,WAAW,EAAE,KAAK,QAAQ,aAAa;AAC5E;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nadohq/indexer-client",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "> TODO: description",
|
|
@@ -37,9 +37,8 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@nadohq/
|
|
41
|
-
"@nadohq/
|
|
42
|
-
"@nadohq/utils": "^0.1.0-alpha.2",
|
|
40
|
+
"@nadohq/engine-client": "^0.1.0-alpha.4",
|
|
41
|
+
"@nadohq/shared": "^0.1.0-alpha.4",
|
|
43
42
|
"axios": "*",
|
|
44
43
|
"ts-mixer": "*"
|
|
45
44
|
},
|
|
@@ -49,5 +48,5 @@
|
|
|
49
48
|
"devDependencies": {
|
|
50
49
|
"viem": "*"
|
|
51
50
|
},
|
|
52
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "b852ce36b851303225d3f4b81739ac667c64cf8c"
|
|
53
52
|
}
|
package/src/IndexerBaseClient.ts
CHANGED
|
@@ -4,23 +4,21 @@ import {
|
|
|
4
4
|
getDefaultRecvTime,
|
|
5
5
|
getNadoEIP712Values,
|
|
6
6
|
getSignedTransactionRequest,
|
|
7
|
+
getValidatedHex,
|
|
8
|
+
mapValues,
|
|
9
|
+
nowInSeconds,
|
|
10
|
+
removeDecimals,
|
|
7
11
|
SignableRequestType,
|
|
8
12
|
SignableRequestTypeToParams,
|
|
9
13
|
SignedTx,
|
|
10
14
|
subaccountFromHex,
|
|
11
15
|
subaccountToHex,
|
|
12
|
-
WalletClientWithAccount,
|
|
13
|
-
} from '@nadohq/contracts';
|
|
14
|
-
import {
|
|
15
|
-
getValidatedHex,
|
|
16
|
-
mapValues,
|
|
17
|
-
nowInSeconds,
|
|
18
|
-
removeDecimals,
|
|
19
16
|
toBigDecimal,
|
|
20
17
|
toBigInt,
|
|
21
18
|
toIntegerString,
|
|
19
|
+
WalletClientWithAccount,
|
|
22
20
|
WalletNotProvidedError,
|
|
23
|
-
} from '@nadohq/
|
|
21
|
+
} from '@nadohq/shared';
|
|
24
22
|
import axios, { AxiosInstance, AxiosResponse } from 'axios';
|
|
25
23
|
import {
|
|
26
24
|
mapIndexerCandlesticks,
|
|
@@ -33,11 +31,11 @@ import {
|
|
|
33
31
|
mapIndexerMakerStatistics,
|
|
34
32
|
mapIndexerMarketSnapshot,
|
|
35
33
|
mapIndexerMatchEventBalances,
|
|
34
|
+
mapIndexerNlpSnapshot,
|
|
36
35
|
mapIndexerOrder,
|
|
37
36
|
mapIndexerPerpPrices,
|
|
38
37
|
mapIndexerProductPayment,
|
|
39
38
|
mapIndexerServerProduct,
|
|
40
|
-
mapIndexerNlpSnapshot,
|
|
41
39
|
mapSnapshotsIntervalToServerParams,
|
|
42
40
|
} from './dataMappers';
|
|
43
41
|
import {
|
|
@@ -80,6 +78,8 @@ import {
|
|
|
80
78
|
GetIndexerMultiProductSnapshotsResponse,
|
|
81
79
|
GetIndexerMultiSubaccountSnapshotsParams,
|
|
82
80
|
GetIndexerMultiSubaccountSnapshotsResponse,
|
|
81
|
+
GetIndexerNlpSnapshotsParams,
|
|
82
|
+
GetIndexerNlpSnapshotsResponse,
|
|
83
83
|
GetIndexerOraclePricesParams,
|
|
84
84
|
GetIndexerOraclePricesResponse,
|
|
85
85
|
GetIndexerOrdersParams,
|
|
@@ -91,8 +91,8 @@ import {
|
|
|
91
91
|
GetIndexerQuotePriceResponse,
|
|
92
92
|
GetIndexerReferralCodeParams,
|
|
93
93
|
GetIndexerReferralCodeResponse,
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
GetIndexerSubaccountDDAParams,
|
|
95
|
+
GetIndexerSubaccountDDAResponse,
|
|
96
96
|
IndexerEventWithTx,
|
|
97
97
|
IndexerMatchEvent,
|
|
98
98
|
IndexerOraclePrice,
|
|
@@ -130,6 +130,8 @@ export class IndexerBaseClient {
|
|
|
130
130
|
this.opts = opts;
|
|
131
131
|
this.axiosInstance = axios.create({
|
|
132
132
|
withCredentials: true,
|
|
133
|
+
// We have custom logic to validate response status and create an appropriate error
|
|
134
|
+
validateStatus: () => true,
|
|
133
135
|
});
|
|
134
136
|
this.v2Url = opts.v2Url ? opts.v2Url : opts.url.replace('v1', 'v2');
|
|
135
137
|
}
|
|
@@ -787,6 +789,25 @@ export class IndexerBaseClient {
|
|
|
787
789
|
};
|
|
788
790
|
}
|
|
789
791
|
|
|
792
|
+
/**
|
|
793
|
+
* Retrieves the subaccount's DDA (Direct Deposit Address)
|
|
794
|
+
* @param params
|
|
795
|
+
*/
|
|
796
|
+
async getSubaccountDDA(
|
|
797
|
+
params: GetIndexerSubaccountDDAParams,
|
|
798
|
+
): Promise<GetIndexerSubaccountDDAResponse> {
|
|
799
|
+
const baseResponse = await this.query('direct_deposit_address', {
|
|
800
|
+
subaccount: subaccountToHex({
|
|
801
|
+
subaccountOwner: params.subaccountOwner,
|
|
802
|
+
subaccountName: params.subaccountName,
|
|
803
|
+
}),
|
|
804
|
+
});
|
|
805
|
+
|
|
806
|
+
return {
|
|
807
|
+
address: baseResponse.v1_address,
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
|
|
790
811
|
async getSequencerBacklog(): Promise<GetIndexerBacklogResponse> {
|
|
791
812
|
const baseResponse = await this.query('backlog', {});
|
|
792
813
|
|
package/src/IndexerClient.ts
CHANGED
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
QUOTE_PRODUCT_ID,
|
|
4
4
|
subaccountFromHex,
|
|
5
5
|
NLP_PRODUCT_ID,
|
|
6
|
-
} from '@nadohq/
|
|
7
|
-
import { toBigDecimal, toIntegerString } from '@nadohq/
|
|
6
|
+
} from '@nadohq/shared';
|
|
7
|
+
import { toBigDecimal, toIntegerString } from '@nadohq/shared';
|
|
8
8
|
|
|
9
9
|
import { IndexerBaseClient } from './IndexerBaseClient';
|
|
10
10
|
import {
|
package/src/dataMappers.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getRecvTimeFromOrderNonce,
|
|
3
3
|
Market,
|
|
4
|
-
parseRawExpirationTimestamp,
|
|
5
4
|
PerpMarket,
|
|
6
5
|
ProductEngineType,
|
|
7
6
|
SpotMarket,
|
|
8
7
|
subaccountFromHex,
|
|
9
|
-
|
|
8
|
+
unpackOrderAppendix,
|
|
9
|
+
} from '@nadohq/shared';
|
|
10
10
|
import {
|
|
11
11
|
mapEngineServerPerpProduct,
|
|
12
12
|
mapEngineServerSpotProduct,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
removeDecimals,
|
|
17
17
|
toBigDecimal,
|
|
18
18
|
toIntegerString,
|
|
19
|
-
} from '@nadohq/
|
|
19
|
+
} from '@nadohq/shared';
|
|
20
20
|
import {
|
|
21
21
|
Candlestick,
|
|
22
22
|
IndexerEvent,
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
IndexerMaker,
|
|
29
29
|
IndexerMarketSnapshot,
|
|
30
30
|
IndexerMatchEventBalances,
|
|
31
|
+
IndexerNlpSnapshot,
|
|
31
32
|
IndexerOrder,
|
|
32
33
|
IndexerPerpBalance,
|
|
33
34
|
IndexerPerpPrices,
|
|
@@ -42,16 +43,15 @@ import {
|
|
|
42
43
|
IndexerServerMaker,
|
|
43
44
|
IndexerServerMarketSnapshot,
|
|
44
45
|
IndexerServerMatchEventBalances,
|
|
46
|
+
IndexerServerNlpSnapshot,
|
|
45
47
|
IndexerServerOrder,
|
|
46
48
|
IndexerServerPerpPrices,
|
|
47
49
|
IndexerServerProduct,
|
|
48
50
|
IndexerServerProductPayment,
|
|
49
51
|
IndexerServerSnapshotsInterval,
|
|
50
52
|
IndexerServerTx,
|
|
51
|
-
IndexerServerNlpSnapshot,
|
|
52
53
|
IndexerSnapshotsIntervalParams,
|
|
53
54
|
IndexerSpotBalance,
|
|
54
|
-
IndexerNlpSnapshot,
|
|
55
55
|
} from './types';
|
|
56
56
|
|
|
57
57
|
export function mapSnapshotsIntervalToServerParams(
|
|
@@ -92,16 +92,13 @@ export function mapIndexerServerBalance(
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
export function mapIndexerOrder(order: IndexerServerOrder): IndexerOrder {
|
|
95
|
-
const
|
|
96
|
-
const expirationEncodedData = parseRawExpirationTimestamp(order.expiration);
|
|
95
|
+
const appendix = unpackOrderAppendix(order.appendix);
|
|
97
96
|
return {
|
|
98
97
|
amount: toBigDecimal(order.amount),
|
|
99
98
|
digest: order.digest,
|
|
100
99
|
isolated: order.isolated,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
expiration: expirationEncodedData.expirationTime,
|
|
104
|
-
orderType: expirationEncodedData.type,
|
|
100
|
+
expiration: Number(order.expiration),
|
|
101
|
+
appendix,
|
|
105
102
|
nonce: toBigDecimal(order.nonce),
|
|
106
103
|
recvTimeSeconds: getRecvTimeFromOrderNonce(order.nonce) / 1000,
|
|
107
104
|
price: removeDecimals(order.price_x18),
|
package/src/endpoints.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ChainEnv } from '@nadohq/
|
|
1
|
+
import { ChainEnv } from '@nadohq/shared';
|
|
2
2
|
|
|
3
3
|
export const INDEXER_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {
|
|
4
4
|
local: 'http://localhost:8000/indexer',
|
|
5
|
-
arbitrumTestnet: 'https://archive.sepolia-test.vertexprotocol.com/v1',
|
|
6
5
|
arbitrum: 'https://archive.prod.vertexprotocol.com/v1',
|
|
6
|
+
inkTestnet: 'https://archive.test.nado-backend.xyz/v1',
|
|
7
7
|
};
|
package/src/types/clientTypes.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EIP712OrderValues,
|
|
3
3
|
Market,
|
|
4
|
-
|
|
4
|
+
OrderAppendix,
|
|
5
5
|
PerpBalance,
|
|
6
6
|
PerpMarket,
|
|
7
7
|
ProductEngineType,
|
|
8
8
|
SpotBalance,
|
|
9
9
|
SpotMarket,
|
|
10
10
|
Subaccount,
|
|
11
|
-
} from '@nadohq/
|
|
12
|
-
import { BigDecimal } from '@nadohq/
|
|
11
|
+
} from '@nadohq/shared';
|
|
12
|
+
import { BigDecimal } from '@nadohq/shared';
|
|
13
13
|
import { Hex } from 'viem';
|
|
14
14
|
import { CandlestickPeriod } from './CandlestickPeriod';
|
|
15
15
|
import { IndexerEventType } from './IndexerEventType';
|
|
16
16
|
import { IndexerLeaderboardRankType } from './IndexerLeaderboardType';
|
|
17
|
+
import { NadoTx, NadoWithdrawCollateralTx } from './NadoTx';
|
|
17
18
|
import {
|
|
18
19
|
IndexerServerFastWithdrawalSignatureParams,
|
|
19
20
|
IndexerServerListSubaccountsParams,
|
|
20
21
|
} from './serverTypes';
|
|
21
|
-
import { NadoTx, NadoWithdrawCollateralTx } from './NadoTx';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Base types
|
|
@@ -354,11 +354,9 @@ export interface IndexerOrder {
|
|
|
354
354
|
submissionIndex: string;
|
|
355
355
|
amount: BigDecimal;
|
|
356
356
|
price: BigDecimal;
|
|
357
|
-
// This includes the order type
|
|
358
|
-
rawExpiration: BigDecimal;
|
|
359
|
-
isReduceOnly: boolean;
|
|
360
|
-
orderType: OrderExpirationType;
|
|
361
357
|
expiration: number;
|
|
358
|
+
// Order metadata from appendix
|
|
359
|
+
appendix: OrderAppendix;
|
|
362
360
|
nonce: BigDecimal;
|
|
363
361
|
// Derived from the nonce
|
|
364
362
|
recvTimeSeconds: number;
|
|
@@ -677,3 +675,9 @@ export interface GetIndexerBacklogResponse {
|
|
|
677
675
|
// Current submission rate in transactions per second (float) (null if unavailable)
|
|
678
676
|
txsPerSecond: BigDecimal | null;
|
|
679
677
|
}
|
|
678
|
+
|
|
679
|
+
export type GetIndexerSubaccountDDAParams = Subaccount;
|
|
680
|
+
|
|
681
|
+
export interface GetIndexerSubaccountDDAResponse {
|
|
682
|
+
address: string;
|
|
683
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EIP712OrderValues } from '@nadohq/
|
|
1
|
+
import { EIP712OrderValues } from '@nadohq/shared';
|
|
2
2
|
import {
|
|
3
3
|
EngineServerPerpBalance,
|
|
4
4
|
EngineServerPerpProduct,
|
|
@@ -99,6 +99,7 @@ export interface IndexerServerOrder {
|
|
|
99
99
|
amount: string;
|
|
100
100
|
price_x18: string;
|
|
101
101
|
expiration: string;
|
|
102
|
+
appendix: string;
|
|
102
103
|
nonce: string;
|
|
103
104
|
base_filled: string;
|
|
104
105
|
// Includes fee
|
package/src/types/serverTypes.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EIP712LeaderboardAuthenticationValues,
|
|
3
3
|
SignedTx,
|
|
4
|
-
} from '@nadohq/
|
|
4
|
+
} from '@nadohq/shared';
|
|
5
5
|
import { IndexerEventType } from './IndexerEventType';
|
|
6
6
|
import { IndexerLeaderboardRankType } from './IndexerLeaderboardType';
|
|
7
7
|
import { NadoWithdrawCollateralTx } from './NadoTx';
|
|
@@ -197,11 +197,16 @@ export interface IndexerServerNlpSnapshotsParams {
|
|
|
197
197
|
interval: IndexerServerSnapshotsInterval;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
export interface IndexerServerDDAQueryParams {
|
|
201
|
+
subaccount: string;
|
|
202
|
+
}
|
|
203
|
+
|
|
200
204
|
// Request
|
|
201
205
|
export interface IndexerServerQueryRequestByType {
|
|
202
206
|
account_snapshots: IndexerServerMultiSubaccountSnapshotsParams;
|
|
203
207
|
backlog: Record<string, never>;
|
|
204
208
|
candlesticks: IndexerServerCandlesticksParams;
|
|
209
|
+
direct_deposit_address: IndexerServerDDAQueryParams;
|
|
205
210
|
edge_candlesticks: IndexerEdgeServerCandlesticksParams;
|
|
206
211
|
edge_market_snapshots: IndexerEdgeServerMarketSnapshotsParams;
|
|
207
212
|
events: IndexerServerEventsParams;
|
|
@@ -379,6 +384,10 @@ export interface IndexerServerNlpSnapshotsResponse {
|
|
|
379
384
|
snapshots: IndexerServerNlpSnapshot[];
|
|
380
385
|
}
|
|
381
386
|
|
|
387
|
+
export interface IndexerServerDDAResponse {
|
|
388
|
+
v1_address: string;
|
|
389
|
+
}
|
|
390
|
+
|
|
382
391
|
export interface IndexerServerBacklogResponse {
|
|
383
392
|
// Total number of transactions stored in the indexer DB
|
|
384
393
|
total_txs: string;
|
|
@@ -399,6 +408,7 @@ export interface IndexerServerQueryResponseByType {
|
|
|
399
408
|
account_snapshots: IndexerServerMultiSubaccountSnapshotsResponse;
|
|
400
409
|
backlog: IndexerServerBacklogResponse;
|
|
401
410
|
candlesticks: IndexerServerCandlesticksResponse;
|
|
411
|
+
direct_deposit_address: IndexerServerDDAResponse;
|
|
402
412
|
edge_candlesticks: IndexerEdgeServerCandlesticksResponse;
|
|
403
413
|
edge_market_snapshots: IndexerEdgeServerMarketSnapshotsResponse;
|
|
404
414
|
events: IndexerServerEventsResponse;
|