@nadohq/indexer-client 0.1.0-alpha.1 → 0.1.0-alpha.10
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 -58
- package/dist/IndexerBaseClient.cjs.map +1 -1
- package/dist/IndexerBaseClient.d.cts +8 -4
- package/dist/IndexerBaseClient.d.ts +8 -4
- package/dist/IndexerBaseClient.js +23 -10
- package/dist/IndexerBaseClient.js.map +1 -1
- package/dist/IndexerClient.cjs +20 -20
- package/dist/IndexerClient.cjs.map +1 -1
- package/dist/IndexerClient.d.cts +4 -5
- package/dist/IndexerClient.d.ts +4 -5
- package/dist/IndexerClient.js +9 -9
- package/dist/IndexerClient.js.map +1 -1
- package/dist/dataMappers.cjs +107 -112
- package/dist/dataMappers.cjs.map +1 -1
- package/dist/dataMappers.d.cts +5 -6
- package/dist/dataMappers.d.ts +5 -6
- package/dist/dataMappers.js +11 -17
- 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 +5 -6
- package/dist/index.d.ts +5 -6
- package/dist/types/IndexerEventType.cjs.map +1 -1
- package/dist/types/IndexerEventType.d.cts +1 -1
- package/dist/types/IndexerEventType.d.ts +1 -1
- package/dist/types/NadoTx.cjs.map +1 -1
- package/dist/types/clientTypes.cjs.map +1 -1
- package/dist/types/clientTypes.d.cts +16 -14
- package/dist/types/clientTypes.d.ts +16 -14
- package/dist/types/index.d.cts +5 -6
- package/dist/types/index.d.ts +5 -6
- package/dist/types/paginatedEventsTypes.cjs.map +1 -1
- package/dist/types/paginatedEventsTypes.d.cts +7 -8
- package/dist/types/paginatedEventsTypes.d.ts +7 -8
- package/dist/types/serverModelTypes.cjs.map +1 -1
- package/dist/types/serverModelTypes.d.cts +5 -5
- package/dist/types/serverModelTypes.d.ts +5 -5
- package/dist/types/serverTypes.cjs.map +1 -1
- package/dist/types/serverTypes.d.cts +16 -8
- package/dist/types/serverTypes.d.ts +16 -8
- 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 +35 -16
- package/src/IndexerClient.ts +17 -17
- package/src/dataMappers.ts +16 -22
- package/src/endpoints.ts +2 -2
- package/src/types/IndexerEventType.ts +2 -2
- package/src/types/NadoTx.ts +1 -1
- package/src/types/clientTypes.ts +21 -16
- package/src/types/paginatedEventsTypes.ts +7 -8
- package/src/types/serverModelTypes.ts +4 -4
- package/src/types/serverTypes.ts +17 -7
- package/src/utils/indexerBalanceValue.ts +1 -1
|
@@ -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.10",
|
|
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.1",
|
|
40
|
+
"@nadohq/engine-client": "^0.1.0-alpha.10",
|
|
41
|
+
"@nadohq/shared": "^0.1.0-alpha.10",
|
|
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": "d4907c30fee146e4463cab4bac0a7f5f07bb9299"
|
|
53
52
|
}
|
package/src/IndexerBaseClient.ts
CHANGED
|
@@ -4,23 +4,22 @@ import {
|
|
|
4
4
|
getDefaultRecvTime,
|
|
5
5
|
getNadoEIP712Values,
|
|
6
6
|
getSignedTransactionRequest,
|
|
7
|
+
getValidatedAddress,
|
|
8
|
+
getValidatedHex,
|
|
9
|
+
mapValues,
|
|
10
|
+
nowInSeconds,
|
|
11
|
+
removeDecimals,
|
|
7
12
|
SignableRequestType,
|
|
8
13
|
SignableRequestTypeToParams,
|
|
9
14
|
SignedTx,
|
|
10
15
|
subaccountFromHex,
|
|
11
16
|
subaccountToHex,
|
|
12
|
-
WalletClientWithAccount,
|
|
13
|
-
} from '@nadohq/contracts';
|
|
14
|
-
import {
|
|
15
|
-
getValidatedHex,
|
|
16
|
-
mapValues,
|
|
17
|
-
nowInSeconds,
|
|
18
|
-
removeDecimals,
|
|
19
17
|
toBigDecimal,
|
|
20
18
|
toBigInt,
|
|
21
19
|
toIntegerString,
|
|
20
|
+
WalletClientWithAccount,
|
|
22
21
|
WalletNotProvidedError,
|
|
23
|
-
} from '@nadohq/
|
|
22
|
+
} from '@nadohq/shared';
|
|
24
23
|
import axios, { AxiosInstance, AxiosResponse } from 'axios';
|
|
25
24
|
import {
|
|
26
25
|
mapIndexerCandlesticks,
|
|
@@ -33,11 +32,11 @@ import {
|
|
|
33
32
|
mapIndexerMakerStatistics,
|
|
34
33
|
mapIndexerMarketSnapshot,
|
|
35
34
|
mapIndexerMatchEventBalances,
|
|
35
|
+
mapIndexerNlpSnapshot,
|
|
36
36
|
mapIndexerOrder,
|
|
37
37
|
mapIndexerPerpPrices,
|
|
38
38
|
mapIndexerProductPayment,
|
|
39
39
|
mapIndexerServerProduct,
|
|
40
|
-
mapIndexerVlpSnapshot,
|
|
41
40
|
mapSnapshotsIntervalToServerParams,
|
|
42
41
|
} from './dataMappers';
|
|
43
42
|
import {
|
|
@@ -80,6 +79,8 @@ import {
|
|
|
80
79
|
GetIndexerMultiProductSnapshotsResponse,
|
|
81
80
|
GetIndexerMultiSubaccountSnapshotsParams,
|
|
82
81
|
GetIndexerMultiSubaccountSnapshotsResponse,
|
|
82
|
+
GetIndexerNlpSnapshotsParams,
|
|
83
|
+
GetIndexerNlpSnapshotsResponse,
|
|
83
84
|
GetIndexerOraclePricesParams,
|
|
84
85
|
GetIndexerOraclePricesResponse,
|
|
85
86
|
GetIndexerOrdersParams,
|
|
@@ -91,8 +92,8 @@ import {
|
|
|
91
92
|
GetIndexerQuotePriceResponse,
|
|
92
93
|
GetIndexerReferralCodeParams,
|
|
93
94
|
GetIndexerReferralCodeResponse,
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
GetIndexerSubaccountDDAParams,
|
|
96
|
+
GetIndexerSubaccountDDAResponse,
|
|
96
97
|
IndexerEventWithTx,
|
|
97
98
|
IndexerMatchEvent,
|
|
98
99
|
IndexerOraclePrice,
|
|
@@ -130,6 +131,8 @@ export class IndexerBaseClient {
|
|
|
130
131
|
this.opts = opts;
|
|
131
132
|
this.axiosInstance = axios.create({
|
|
132
133
|
withCredentials: true,
|
|
134
|
+
// We have custom logic to validate response status and create an appropriate error
|
|
135
|
+
validateStatus: () => true,
|
|
133
136
|
});
|
|
134
137
|
this.v2Url = opts.v2Url ? opts.v2Url : opts.url.replace('v1', 'v2');
|
|
135
138
|
}
|
|
@@ -769,10 +772,10 @@ export class IndexerBaseClient {
|
|
|
769
772
|
};
|
|
770
773
|
}
|
|
771
774
|
|
|
772
|
-
async
|
|
773
|
-
params:
|
|
774
|
-
): Promise<
|
|
775
|
-
const baseResponse = await this.query('
|
|
775
|
+
async getNlpSnapshots(
|
|
776
|
+
params: GetIndexerNlpSnapshotsParams,
|
|
777
|
+
): Promise<GetIndexerNlpSnapshotsResponse> {
|
|
778
|
+
const baseResponse = await this.query('nlp_snapshots', {
|
|
776
779
|
interval: {
|
|
777
780
|
count: params.limit,
|
|
778
781
|
max_time: params.maxTimeInclusive
|
|
@@ -783,7 +786,23 @@ export class IndexerBaseClient {
|
|
|
783
786
|
});
|
|
784
787
|
|
|
785
788
|
return {
|
|
786
|
-
snapshots: baseResponse.snapshots.map(
|
|
789
|
+
snapshots: baseResponse.snapshots.map(mapIndexerNlpSnapshot),
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* Retrieves the subaccount's DDA (Direct Deposit Address)
|
|
795
|
+
* @param params
|
|
796
|
+
*/
|
|
797
|
+
async getSubaccountDDA(
|
|
798
|
+
params: GetIndexerSubaccountDDAParams,
|
|
799
|
+
): Promise<GetIndexerSubaccountDDAResponse> {
|
|
800
|
+
const baseResponse = await this.query('direct_deposit_address', {
|
|
801
|
+
subaccount: subaccountToHex(params.subaccount),
|
|
802
|
+
});
|
|
803
|
+
|
|
804
|
+
return {
|
|
805
|
+
address: getValidatedAddress(baseResponse.v1_address),
|
|
787
806
|
};
|
|
788
807
|
}
|
|
789
808
|
|
package/src/IndexerClient.ts
CHANGED
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
ProductEngineType,
|
|
3
3
|
QUOTE_PRODUCT_ID,
|
|
4
4
|
subaccountFromHex,
|
|
5
|
-
|
|
6
|
-
} from '@nadohq/
|
|
7
|
-
import { toBigDecimal, toIntegerString } from '@nadohq/
|
|
5
|
+
NLP_PRODUCT_ID,
|
|
6
|
+
} from '@nadohq/shared';
|
|
7
|
+
import { toBigDecimal, toIntegerString } from '@nadohq/shared';
|
|
8
8
|
|
|
9
9
|
import { IndexerBaseClient } from './IndexerBaseClient';
|
|
10
10
|
import {
|
|
@@ -24,15 +24,15 @@ import {
|
|
|
24
24
|
GetIndexerSubaccountMatchEventsResponse,
|
|
25
25
|
GetIndexerSubaccountSettlementEventsParams,
|
|
26
26
|
GetIndexerSubaccountSettlementEventsResponse,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
GetIndexerSubaccountNlpEventsParams,
|
|
28
|
+
GetIndexerSubaccountNlpEventsResponse,
|
|
29
29
|
IndexerCollateralEvent,
|
|
30
30
|
IndexerEventPerpStateSnapshot,
|
|
31
31
|
IndexerEventSpotStateSnapshot,
|
|
32
32
|
IndexerEventWithTx,
|
|
33
33
|
IndexerLiquidationEvent,
|
|
34
34
|
IndexerSettlementEvent,
|
|
35
|
-
|
|
35
|
+
IndexerNlpEvent,
|
|
36
36
|
PaginatedIndexerEventsResponse,
|
|
37
37
|
} from './types';
|
|
38
38
|
|
|
@@ -66,9 +66,9 @@ export class IndexerClient extends IndexerBaseClient {
|
|
|
66
66
|
return this.getPaginationEventsResponse(events, requestedLimit);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
async
|
|
70
|
-
params:
|
|
71
|
-
): Promise<
|
|
69
|
+
async getPaginatedSubaccountNlpEvents(
|
|
70
|
+
params: GetIndexerSubaccountNlpEventsParams,
|
|
71
|
+
): Promise<GetIndexerSubaccountNlpEventsResponse> {
|
|
72
72
|
const {
|
|
73
73
|
startCursor,
|
|
74
74
|
maxTimestampInclusive,
|
|
@@ -77,12 +77,12 @@ export class IndexerClient extends IndexerBaseClient {
|
|
|
77
77
|
subaccountOwner,
|
|
78
78
|
} = params;
|
|
79
79
|
|
|
80
|
-
// There are 2 events per mint/burn for spot - one associated with the
|
|
80
|
+
// There are 2 events per mint/burn for spot - one associated with the NLP product & the other with the primary quote
|
|
81
81
|
const limit = requestedLimit + 1;
|
|
82
82
|
const baseResponse = await this.getEvents({
|
|
83
83
|
startCursor,
|
|
84
84
|
maxTimestampInclusive,
|
|
85
|
-
eventTypes: ['
|
|
85
|
+
eventTypes: ['mint_nlp', 'burn_nlp'],
|
|
86
86
|
limit: {
|
|
87
87
|
type: 'txs',
|
|
88
88
|
value: limit,
|
|
@@ -91,7 +91,7 @@ export class IndexerClient extends IndexerBaseClient {
|
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
// Now aggregate results by the submission index, use map to maintain insertion order
|
|
94
|
-
const eventsBySubmissionIdx = new Map<string,
|
|
94
|
+
const eventsBySubmissionIdx = new Map<string, IndexerNlpEvent>();
|
|
95
95
|
|
|
96
96
|
baseResponse.forEach((event) => {
|
|
97
97
|
const mappedEvent = (() => {
|
|
@@ -100,8 +100,8 @@ export class IndexerClient extends IndexerBaseClient {
|
|
|
100
100
|
return existingEvent;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
const newEvent:
|
|
104
|
-
|
|
103
|
+
const newEvent: IndexerNlpEvent = {
|
|
104
|
+
nlpDelta: toBigDecimal(0),
|
|
105
105
|
primaryQuoteDelta: toBigDecimal(0),
|
|
106
106
|
timestamp: event.timestamp,
|
|
107
107
|
submissionIndex: event.submissionIndex,
|
|
@@ -120,10 +120,10 @@ export class IndexerClient extends IndexerBaseClient {
|
|
|
120
120
|
const productId = event.state.market.productId;
|
|
121
121
|
if (productId === QUOTE_PRODUCT_ID) {
|
|
122
122
|
mappedEvent.primaryQuoteDelta = balanceDelta;
|
|
123
|
-
} else if (productId ===
|
|
124
|
-
mappedEvent.
|
|
123
|
+
} else if (productId === NLP_PRODUCT_ID) {
|
|
124
|
+
mappedEvent.nlpDelta = balanceDelta;
|
|
125
125
|
} else {
|
|
126
|
-
throw Error(`Invalid product ID for
|
|
126
|
+
throw Error(`Invalid product ID for NLP event ${productId}`);
|
|
127
127
|
}
|
|
128
128
|
});
|
|
129
129
|
|
package/src/dataMappers.ts
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getRecvTimeFromOrderNonce,
|
|
3
|
-
Market,
|
|
4
|
-
parseRawExpirationTimestamp,
|
|
5
|
-
PerpMarket,
|
|
6
|
-
ProductEngineType,
|
|
7
|
-
SpotMarket,
|
|
8
|
-
subaccountFromHex,
|
|
9
|
-
} from '@nadohq/contracts';
|
|
10
1
|
import {
|
|
11
2
|
mapEngineServerPerpProduct,
|
|
12
3
|
mapEngineServerSpotProduct,
|
|
13
4
|
} from '@nadohq/engine-client';
|
|
14
5
|
import {
|
|
6
|
+
getRecvTimeFromOrderNonce,
|
|
15
7
|
mapValues,
|
|
8
|
+
Market,
|
|
9
|
+
PerpMarket,
|
|
10
|
+
ProductEngineType,
|
|
16
11
|
removeDecimals,
|
|
12
|
+
SpotMarket,
|
|
13
|
+
subaccountFromHex,
|
|
17
14
|
toBigDecimal,
|
|
18
15
|
toIntegerString,
|
|
19
|
-
|
|
16
|
+
unpackOrderAppendix,
|
|
17
|
+
} from '@nadohq/shared';
|
|
20
18
|
import {
|
|
21
19
|
Candlestick,
|
|
22
20
|
IndexerEvent,
|
|
@@ -28,6 +26,7 @@ import {
|
|
|
28
26
|
IndexerMaker,
|
|
29
27
|
IndexerMarketSnapshot,
|
|
30
28
|
IndexerMatchEventBalances,
|
|
29
|
+
IndexerNlpSnapshot,
|
|
31
30
|
IndexerOrder,
|
|
32
31
|
IndexerPerpBalance,
|
|
33
32
|
IndexerPerpPrices,
|
|
@@ -42,16 +41,15 @@ import {
|
|
|
42
41
|
IndexerServerMaker,
|
|
43
42
|
IndexerServerMarketSnapshot,
|
|
44
43
|
IndexerServerMatchEventBalances,
|
|
44
|
+
IndexerServerNlpSnapshot,
|
|
45
45
|
IndexerServerOrder,
|
|
46
46
|
IndexerServerPerpPrices,
|
|
47
47
|
IndexerServerProduct,
|
|
48
48
|
IndexerServerProductPayment,
|
|
49
49
|
IndexerServerSnapshotsInterval,
|
|
50
50
|
IndexerServerTx,
|
|
51
|
-
IndexerServerVlpSnapshot,
|
|
52
51
|
IndexerSnapshotsIntervalParams,
|
|
53
52
|
IndexerSpotBalance,
|
|
54
|
-
IndexerVlpSnapshot,
|
|
55
53
|
} from './types';
|
|
56
54
|
|
|
57
55
|
export function mapSnapshotsIntervalToServerParams(
|
|
@@ -92,16 +90,12 @@ export function mapIndexerServerBalance(
|
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
export function mapIndexerOrder(order: IndexerServerOrder): IndexerOrder {
|
|
95
|
-
const
|
|
96
|
-
const expirationEncodedData = parseRawExpirationTimestamp(order.expiration);
|
|
93
|
+
const appendix = unpackOrderAppendix(order.appendix);
|
|
97
94
|
return {
|
|
98
95
|
amount: toBigDecimal(order.amount),
|
|
99
96
|
digest: order.digest,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
isReduceOnly: expirationEncodedData.reduceOnly,
|
|
103
|
-
expiration: expirationEncodedData.expirationTime,
|
|
104
|
-
orderType: expirationEncodedData.type,
|
|
97
|
+
expiration: Number(order.expiration),
|
|
98
|
+
appendix,
|
|
105
99
|
nonce: toBigDecimal(order.nonce),
|
|
106
100
|
recvTimeSeconds: getRecvTimeFromOrderNonce(order.nonce) / 1000,
|
|
107
101
|
price: removeDecimals(order.price_x18),
|
|
@@ -344,9 +338,9 @@ export function mapIndexerMarketSnapshot(
|
|
|
344
338
|
};
|
|
345
339
|
}
|
|
346
340
|
|
|
347
|
-
export function
|
|
348
|
-
snapshot:
|
|
349
|
-
):
|
|
341
|
+
export function mapIndexerNlpSnapshot(
|
|
342
|
+
snapshot: IndexerServerNlpSnapshot,
|
|
343
|
+
): IndexerNlpSnapshot {
|
|
350
344
|
return {
|
|
351
345
|
submissionIndex: snapshot.submission_idx,
|
|
352
346
|
timestamp: toBigDecimal(snapshot.timestamp),
|
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/NadoTx.ts
CHANGED
package/src/types/clientTypes.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BigDecimal,
|
|
2
3
|
EIP712OrderValues,
|
|
3
4
|
Market,
|
|
4
|
-
|
|
5
|
+
OrderAppendix,
|
|
5
6
|
PerpBalance,
|
|
6
7
|
PerpMarket,
|
|
7
8
|
ProductEngineType,
|
|
8
9
|
SpotBalance,
|
|
9
10
|
SpotMarket,
|
|
10
11
|
Subaccount,
|
|
11
|
-
} from '@nadohq/
|
|
12
|
-
import {
|
|
13
|
-
import { Hex } from 'viem';
|
|
12
|
+
} from '@nadohq/shared';
|
|
13
|
+
import { Address, 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
|
|
@@ -349,16 +349,13 @@ export interface GetIndexerOrdersParams {
|
|
|
349
349
|
export interface IndexerOrder {
|
|
350
350
|
digest: string;
|
|
351
351
|
subaccount: string;
|
|
352
|
-
isolated: boolean;
|
|
353
352
|
productId: number;
|
|
354
353
|
submissionIndex: string;
|
|
355
354
|
amount: BigDecimal;
|
|
356
355
|
price: BigDecimal;
|
|
357
|
-
// This includes the order type
|
|
358
|
-
rawExpiration: BigDecimal;
|
|
359
|
-
isReduceOnly: boolean;
|
|
360
|
-
orderType: OrderExpirationType;
|
|
361
356
|
expiration: number;
|
|
357
|
+
// Order metadata from appendix
|
|
358
|
+
appendix: OrderAppendix;
|
|
362
359
|
nonce: BigDecimal;
|
|
363
360
|
// Derived from the nonce
|
|
364
361
|
recvTimeSeconds: number;
|
|
@@ -640,15 +637,15 @@ export interface GetIndexerFastWithdrawalSignatureResponse {
|
|
|
640
637
|
}
|
|
641
638
|
|
|
642
639
|
/**
|
|
643
|
-
*
|
|
640
|
+
* NLP
|
|
644
641
|
*/
|
|
645
642
|
|
|
646
|
-
export type
|
|
643
|
+
export type GetIndexerNlpSnapshotsParams = IndexerSnapshotsIntervalParams;
|
|
647
644
|
|
|
648
|
-
export interface
|
|
645
|
+
export interface IndexerNlpSnapshot {
|
|
649
646
|
submissionIndex: string;
|
|
650
647
|
timestamp: BigDecimal;
|
|
651
|
-
// Total volume traded by the
|
|
648
|
+
// Total volume traded by the NLP, in terms of the primary quote
|
|
652
649
|
cumulativeVolume: BigDecimal;
|
|
653
650
|
cumulativeTrades: BigDecimal;
|
|
654
651
|
cumulativeMintAmountUsdc: BigDecimal;
|
|
@@ -659,8 +656,8 @@ export interface IndexerVlpSnapshot {
|
|
|
659
656
|
depositors: BigDecimal;
|
|
660
657
|
}
|
|
661
658
|
|
|
662
|
-
export interface
|
|
663
|
-
snapshots:
|
|
659
|
+
export interface GetIndexerNlpSnapshotsResponse {
|
|
660
|
+
snapshots: IndexerNlpSnapshot[];
|
|
664
661
|
}
|
|
665
662
|
|
|
666
663
|
export interface GetIndexerBacklogResponse {
|
|
@@ -677,3 +674,11 @@ export interface GetIndexerBacklogResponse {
|
|
|
677
674
|
// Current submission rate in transactions per second (float) (null if unavailable)
|
|
678
675
|
txsPerSecond: BigDecimal | null;
|
|
679
676
|
}
|
|
677
|
+
|
|
678
|
+
export interface GetIndexerSubaccountDDAParams {
|
|
679
|
+
subaccount: Subaccount;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
export interface GetIndexerSubaccountDDAResponse {
|
|
683
|
+
address: Address;
|
|
684
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Subaccount } from '@nadohq/
|
|
2
|
-
import { BigDecimal } from '@nadohq/utils';
|
|
1
|
+
import { BigDecimal, Subaccount } from '@nadohq/shared';
|
|
3
2
|
import {
|
|
4
3
|
GetIndexerInterestFundingPaymentsParams,
|
|
5
4
|
GetIndexerInterestFundingPaymentsResponse,
|
|
@@ -75,18 +74,18 @@ export type GetIndexerSubaccountCollateralEventsResponse =
|
|
|
75
74
|
PaginatedIndexerEventsResponse<IndexerCollateralEvent>;
|
|
76
75
|
|
|
77
76
|
/**
|
|
78
|
-
*
|
|
77
|
+
* NLP
|
|
79
78
|
*/
|
|
80
|
-
export type
|
|
79
|
+
export type GetIndexerSubaccountNlpEventsParams =
|
|
81
80
|
BaseSubaccountPaginationParams;
|
|
82
81
|
|
|
83
|
-
export interface
|
|
84
|
-
|
|
82
|
+
export interface IndexerNlpEvent extends BaseIndexerPaginatedEvent {
|
|
83
|
+
nlpDelta: BigDecimal;
|
|
85
84
|
primaryQuoteDelta: BigDecimal;
|
|
86
85
|
}
|
|
87
86
|
|
|
88
|
-
export type
|
|
89
|
-
PaginatedIndexerEventsResponse<
|
|
87
|
+
export type GetIndexerSubaccountNlpEventsResponse =
|
|
88
|
+
PaginatedIndexerEventsResponse<IndexerNlpEvent>;
|
|
90
89
|
|
|
91
90
|
/**
|
|
92
91
|
* Match events
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { EIP712OrderValues } from '@nadohq/contracts';
|
|
2
1
|
import {
|
|
3
2
|
EngineServerPerpBalance,
|
|
4
3
|
EngineServerPerpProduct,
|
|
5
4
|
EngineServerSpotBalance,
|
|
6
5
|
EngineServerSpotProduct,
|
|
7
6
|
} from '@nadohq/engine-client';
|
|
7
|
+
import { EIP712OrderValues } from '@nadohq/shared';
|
|
8
8
|
import { IndexerEventType } from './IndexerEventType';
|
|
9
9
|
import { NadoTx } from './NadoTx';
|
|
10
10
|
|
|
@@ -92,13 +92,13 @@ export interface IndexerServerTx {
|
|
|
92
92
|
|
|
93
93
|
export interface IndexerServerOrder {
|
|
94
94
|
digest: string;
|
|
95
|
-
isolated: boolean;
|
|
96
95
|
subaccount: string;
|
|
97
96
|
product_id: number;
|
|
98
97
|
submission_idx: string;
|
|
99
98
|
amount: string;
|
|
100
99
|
price_x18: string;
|
|
101
100
|
expiration: string;
|
|
101
|
+
appendix: string;
|
|
102
102
|
nonce: string;
|
|
103
103
|
base_filled: string;
|
|
104
104
|
// Includes fee
|
|
@@ -254,10 +254,10 @@ export interface IndexerServerLeaderboardRegistration {
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
/**
|
|
257
|
-
*
|
|
257
|
+
* NLP
|
|
258
258
|
*/
|
|
259
259
|
|
|
260
|
-
export interface
|
|
260
|
+
export interface IndexerServerNlpSnapshot {
|
|
261
261
|
cumulative_burn_usdc: string;
|
|
262
262
|
cumulative_mint_usdc: string;
|
|
263
263
|
cumulative_pnl: string;
|
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';
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
IndexerServerProductSnapshot,
|
|
22
22
|
IndexerServerSnapshotsInterval,
|
|
23
23
|
IndexerServerTx,
|
|
24
|
-
|
|
24
|
+
IndexerServerNlpSnapshot,
|
|
25
25
|
} from './serverModelTypes';
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -193,15 +193,20 @@ export interface IndexerServerFastWithdrawalSignatureParams {
|
|
|
193
193
|
idx: number | string;
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
export interface
|
|
196
|
+
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;
|
|
@@ -226,7 +231,7 @@ export interface IndexerServerQueryRequestByType {
|
|
|
226
231
|
referral_code: IndexerServerReferralCodeParams;
|
|
227
232
|
subaccounts: IndexerServerListSubaccountsParams;
|
|
228
233
|
usdc_price: Record<string, never>;
|
|
229
|
-
|
|
234
|
+
nlp_snapshots: IndexerServerNlpSnapshotsParams;
|
|
230
235
|
}
|
|
231
236
|
|
|
232
237
|
export type IndexerServerQueryRequestType =
|
|
@@ -375,8 +380,12 @@ export interface IndexerServerFastWithdrawalSignatureResponse {
|
|
|
375
380
|
signatures: string[];
|
|
376
381
|
}
|
|
377
382
|
|
|
378
|
-
export interface
|
|
379
|
-
snapshots:
|
|
383
|
+
export interface IndexerServerNlpSnapshotsResponse {
|
|
384
|
+
snapshots: IndexerServerNlpSnapshot[];
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export interface IndexerServerDDAResponse {
|
|
388
|
+
v1_address: string;
|
|
380
389
|
}
|
|
381
390
|
|
|
382
391
|
export interface IndexerServerBacklogResponse {
|
|
@@ -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;
|
|
@@ -423,5 +433,5 @@ export interface IndexerServerQueryResponseByType {
|
|
|
423
433
|
referral_code: IndexerServerReferralCodeResponse;
|
|
424
434
|
subaccounts: IndexerServerListSubaccountsResponse;
|
|
425
435
|
usdc_price: IndexerServerUsdcPriceResponse;
|
|
426
|
-
|
|
436
|
+
nlp_snapshots: IndexerServerNlpSnapshotsResponse;
|
|
427
437
|
}
|