nado-protocol 0.1.0__py3-none-any.whl
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.
- nado_protocol/__init__.py +0 -0
- nado_protocol/client/__init__.py +200 -0
- nado_protocol/client/apis/__init__.py +26 -0
- nado_protocol/client/apis/base.py +42 -0
- nado_protocol/client/apis/market/__init__.py +23 -0
- nado_protocol/client/apis/market/execute.py +192 -0
- nado_protocol/client/apis/market/query.py +310 -0
- nado_protocol/client/apis/perp/__init__.py +18 -0
- nado_protocol/client/apis/perp/query.py +30 -0
- nado_protocol/client/apis/rewards/__init__.py +6 -0
- nado_protocol/client/apis/rewards/execute.py +131 -0
- nado_protocol/client/apis/rewards/query.py +12 -0
- nado_protocol/client/apis/spot/__init__.py +23 -0
- nado_protocol/client/apis/spot/base.py +32 -0
- nado_protocol/client/apis/spot/execute.py +117 -0
- nado_protocol/client/apis/spot/query.py +79 -0
- nado_protocol/client/apis/subaccount/__init__.py +24 -0
- nado_protocol/client/apis/subaccount/execute.py +54 -0
- nado_protocol/client/apis/subaccount/query.py +145 -0
- nado_protocol/client/context.py +90 -0
- nado_protocol/contracts/__init__.py +377 -0
- nado_protocol/contracts/abis/Endpoint.json +636 -0
- nado_protocol/contracts/abis/FQuerier.json +1909 -0
- nado_protocol/contracts/abis/IClearinghouse.json +876 -0
- nado_protocol/contracts/abis/IERC20.json +185 -0
- nado_protocol/contracts/abis/IEndpoint.json +250 -0
- nado_protocol/contracts/abis/IFoundationRewardsAirdrop.json +76 -0
- nado_protocol/contracts/abis/IOffchainBook.json +536 -0
- nado_protocol/contracts/abis/IPerpEngine.json +931 -0
- nado_protocol/contracts/abis/IProductEngine.json +352 -0
- nado_protocol/contracts/abis/ISpotEngine.json +813 -0
- nado_protocol/contracts/abis/IStaking.json +288 -0
- nado_protocol/contracts/abis/IVrtxAirdrop.json +138 -0
- nado_protocol/contracts/abis/MockERC20.json +311 -0
- nado_protocol/contracts/deployments/deployment.test.json +18 -0
- nado_protocol/contracts/eip712/__init__.py +16 -0
- nado_protocol/contracts/eip712/domain.py +36 -0
- nado_protocol/contracts/eip712/sign.py +79 -0
- nado_protocol/contracts/eip712/types.py +154 -0
- nado_protocol/contracts/loader.py +55 -0
- nado_protocol/contracts/types.py +141 -0
- nado_protocol/engine_client/__init__.py +35 -0
- nado_protocol/engine_client/execute.py +416 -0
- nado_protocol/engine_client/query.py +481 -0
- nado_protocol/engine_client/types/__init__.py +113 -0
- nado_protocol/engine_client/types/execute.py +680 -0
- nado_protocol/engine_client/types/models.py +247 -0
- nado_protocol/engine_client/types/query.py +516 -0
- nado_protocol/engine_client/types/stream.py +6 -0
- nado_protocol/indexer_client/__init__.py +28 -0
- nado_protocol/indexer_client/query.py +466 -0
- nado_protocol/indexer_client/types/__init__.py +122 -0
- nado_protocol/indexer_client/types/models.py +364 -0
- nado_protocol/indexer_client/types/query.py +819 -0
- nado_protocol/trigger_client/__init__.py +17 -0
- nado_protocol/trigger_client/execute.py +118 -0
- nado_protocol/trigger_client/query.py +61 -0
- nado_protocol/trigger_client/types/__init__.py +7 -0
- nado_protocol/trigger_client/types/execute.py +89 -0
- nado_protocol/trigger_client/types/models.py +44 -0
- nado_protocol/trigger_client/types/query.py +77 -0
- nado_protocol/utils/__init__.py +37 -0
- nado_protocol/utils/backend.py +111 -0
- nado_protocol/utils/bytes32.py +159 -0
- nado_protocol/utils/enum.py +6 -0
- nado_protocol/utils/exceptions.py +58 -0
- nado_protocol/utils/execute.py +403 -0
- nado_protocol/utils/expiration.py +45 -0
- nado_protocol/utils/interest.py +66 -0
- nado_protocol/utils/math.py +67 -0
- nado_protocol/utils/model.py +79 -0
- nado_protocol/utils/nonce.py +33 -0
- nado_protocol/utils/subaccount.py +18 -0
- nado_protocol/utils/time.py +21 -0
- nado_protocol-0.1.0.dist-info/METADATA +157 -0
- nado_protocol-0.1.0.dist-info/RECORD +78 -0
- nado_protocol-0.1.0.dist-info/WHEEL +4 -0
- nado_protocol-0.1.0.dist-info/entry_points.txt +11 -0
|
@@ -0,0 +1,819 @@
|
|
|
1
|
+
from nado_protocol.utils.enum import StrEnum
|
|
2
|
+
from typing import Dict, Optional, Union
|
|
3
|
+
|
|
4
|
+
from pydantic import Field, validator
|
|
5
|
+
from nado_protocol.indexer_client.types.models import (
|
|
6
|
+
IndexerCandlestick,
|
|
7
|
+
IndexerCandlesticksGranularity,
|
|
8
|
+
IndexerEvent,
|
|
9
|
+
IndexerEventType,
|
|
10
|
+
IndexerHistoricalOrder,
|
|
11
|
+
IndexerLiquidatableAccount,
|
|
12
|
+
IndexerMarketMaker,
|
|
13
|
+
IndexerMatch,
|
|
14
|
+
IndexerOraclePrice,
|
|
15
|
+
IndexerPerpContractInfo,
|
|
16
|
+
IndexerProduct,
|
|
17
|
+
IndexerMarketSnapshot,
|
|
18
|
+
IndexerSubaccount,
|
|
19
|
+
IndexerTickerInfo,
|
|
20
|
+
IndexerTokenReward,
|
|
21
|
+
IndexerTradeInfo,
|
|
22
|
+
IndexerTx,
|
|
23
|
+
IndexerMerkleProof,
|
|
24
|
+
IndexerPayment,
|
|
25
|
+
)
|
|
26
|
+
from nado_protocol.utils.model import NadoBaseModel
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class IndexerQueryType(StrEnum):
|
|
30
|
+
"""
|
|
31
|
+
Enumeration of query types available in the Indexer service.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
ORDERS = "orders"
|
|
35
|
+
MATCHES = "matches"
|
|
36
|
+
EVENTS = "events"
|
|
37
|
+
SUMMARY = "summary"
|
|
38
|
+
PRODUCTS = "products"
|
|
39
|
+
MARKET_SNAPSHOTS = "market_snapshots"
|
|
40
|
+
CANDLESTICKS = "candlesticks"
|
|
41
|
+
FUNDING_RATE = "funding_rate"
|
|
42
|
+
FUNDING_RATES = "funding_rates"
|
|
43
|
+
PERP_PRICES = "price"
|
|
44
|
+
ORACLE_PRICES = "oracle_price"
|
|
45
|
+
REWARDS = "rewards"
|
|
46
|
+
MAKER_STATISTICS = "maker_statistics"
|
|
47
|
+
LIQUIDATION_FEED = "liquidation_feed"
|
|
48
|
+
LINKED_SIGNER_RATE_LIMIT = "linked_signer_rate_limit"
|
|
49
|
+
REFERRAL_CODE = "referral_code"
|
|
50
|
+
SUBACCOUNTS = "subaccounts"
|
|
51
|
+
USDC_PRICE = "usdc_price"
|
|
52
|
+
VRTX_MERKLE_PROOFS = "vrtx_merkle_proofs"
|
|
53
|
+
FOUNDATION_REWARDS_MERKLE_PROOFS = "foundation_rewards_merkle_proofs"
|
|
54
|
+
INTEREST_AND_FUNDING = "interest_and_funding"
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class IndexerBaseParams(NadoBaseModel):
|
|
58
|
+
"""
|
|
59
|
+
Base parameters for the indexer queries.
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
idx: Optional[int] = Field(alias="submission_idx")
|
|
63
|
+
max_time: Optional[int]
|
|
64
|
+
limit: Optional[int]
|
|
65
|
+
|
|
66
|
+
class Config:
|
|
67
|
+
allow_population_by_field_name = True
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class IndexerSubaccountHistoricalOrdersParams(IndexerBaseParams):
|
|
71
|
+
"""
|
|
72
|
+
Parameters for querying historical orders by subaccount.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
subaccount: str
|
|
76
|
+
product_ids: Optional[list[int]]
|
|
77
|
+
isolated: Optional[bool]
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class IndexerHistoricalOrdersByDigestParams(NadoBaseModel):
|
|
81
|
+
"""
|
|
82
|
+
Parameters for querying historical orders by digests.
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
digests: list[str]
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class IndexerMatchesParams(IndexerBaseParams):
|
|
89
|
+
"""
|
|
90
|
+
Parameters for querying matches.
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
subaccount: Optional[str]
|
|
94
|
+
product_ids: Optional[list[int]]
|
|
95
|
+
isolated: Optional[bool]
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class IndexerEventsRawLimit(NadoBaseModel):
|
|
99
|
+
"""
|
|
100
|
+
Parameters for limiting by events count.
|
|
101
|
+
"""
|
|
102
|
+
|
|
103
|
+
raw: int
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class IndexerEventsTxsLimit(NadoBaseModel):
|
|
107
|
+
"""
|
|
108
|
+
Parameters for limiting events by transaction count.
|
|
109
|
+
"""
|
|
110
|
+
|
|
111
|
+
txs: int
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
IndexerEventsLimit = Union[IndexerEventsRawLimit, IndexerEventsTxsLimit]
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class IndexerEventsParams(IndexerBaseParams):
|
|
118
|
+
"""
|
|
119
|
+
Parameters for querying events.
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
subaccount: Optional[str]
|
|
123
|
+
product_ids: Optional[list[int]]
|
|
124
|
+
event_types: Optional[list[IndexerEventType]]
|
|
125
|
+
isolated: Optional[bool]
|
|
126
|
+
limit: Optional[IndexerEventsLimit] # type: ignore
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class IndexerSubaccountSummaryParams(NadoBaseModel):
|
|
130
|
+
"""
|
|
131
|
+
Parameters for querying subaccount summary.
|
|
132
|
+
"""
|
|
133
|
+
|
|
134
|
+
subaccount: str
|
|
135
|
+
timestamp: Optional[int]
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class IndexerProductSnapshotsParams(IndexerBaseParams):
|
|
139
|
+
"""
|
|
140
|
+
Parameters for querying product snapshots.
|
|
141
|
+
"""
|
|
142
|
+
|
|
143
|
+
product_id: int
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
class IndexerMarketSnapshotInterval(NadoBaseModel):
|
|
147
|
+
count: int
|
|
148
|
+
granularity: int
|
|
149
|
+
max_time: Optional[int]
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
class IndexerMarketSnapshotsParams(NadoBaseModel):
|
|
153
|
+
"""
|
|
154
|
+
Parameters for querying market snapshots.
|
|
155
|
+
"""
|
|
156
|
+
|
|
157
|
+
interval: IndexerMarketSnapshotInterval
|
|
158
|
+
product_ids: Optional[list[int]]
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class IndexerCandlesticksParams(IndexerBaseParams):
|
|
162
|
+
"""
|
|
163
|
+
Parameters for querying candlestick data.
|
|
164
|
+
"""
|
|
165
|
+
|
|
166
|
+
product_id: int
|
|
167
|
+
granularity: IndexerCandlesticksGranularity
|
|
168
|
+
|
|
169
|
+
class Config:
|
|
170
|
+
fields = {"idx": {"exclude": True}}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
class IndexerFundingRateParams(NadoBaseModel):
|
|
174
|
+
"""
|
|
175
|
+
Parameters for querying funding rates.
|
|
176
|
+
"""
|
|
177
|
+
|
|
178
|
+
product_id: int
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
class IndexerFundingRatesParams(NadoBaseModel):
|
|
182
|
+
"""
|
|
183
|
+
Parameters for querying funding rates.
|
|
184
|
+
"""
|
|
185
|
+
|
|
186
|
+
product_ids: list
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
class IndexerPerpPricesParams(NadoBaseModel):
|
|
190
|
+
"""
|
|
191
|
+
Parameters for querying perpetual prices.
|
|
192
|
+
"""
|
|
193
|
+
|
|
194
|
+
product_id: int
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
class IndexerOraclePricesParams(NadoBaseModel):
|
|
198
|
+
"""
|
|
199
|
+
Parameters for querying oracle prices.
|
|
200
|
+
"""
|
|
201
|
+
|
|
202
|
+
product_ids: list[int]
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
class IndexerTokenRewardsParams(NadoBaseModel):
|
|
206
|
+
"""
|
|
207
|
+
Parameters for querying token rewards.
|
|
208
|
+
"""
|
|
209
|
+
|
|
210
|
+
address: str
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
class IndexerMakerStatisticsParams(NadoBaseModel):
|
|
214
|
+
"""
|
|
215
|
+
Parameters for querying maker statistics.
|
|
216
|
+
"""
|
|
217
|
+
|
|
218
|
+
product_id: int
|
|
219
|
+
epoch: int
|
|
220
|
+
interval: int
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
class IndexerLiquidationFeedParams(NadoBaseModel):
|
|
224
|
+
"""
|
|
225
|
+
Parameters for querying liquidation feed.
|
|
226
|
+
"""
|
|
227
|
+
|
|
228
|
+
pass
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
class IndexerLinkedSignerRateLimitParams(NadoBaseModel):
|
|
232
|
+
"""
|
|
233
|
+
Parameters for querying linked signer rate limits.
|
|
234
|
+
"""
|
|
235
|
+
|
|
236
|
+
subaccount: str
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
class IndexerReferralCodeParams(NadoBaseModel):
|
|
240
|
+
"""
|
|
241
|
+
Parameters for querying a referral code.
|
|
242
|
+
"""
|
|
243
|
+
|
|
244
|
+
subaccount: str
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
class IndexerSubaccountsParams(NadoBaseModel):
|
|
248
|
+
"""
|
|
249
|
+
Parameters for querying subaccounts.
|
|
250
|
+
"""
|
|
251
|
+
|
|
252
|
+
address: Optional[str]
|
|
253
|
+
limit: Optional[int]
|
|
254
|
+
start: Optional[int]
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
class IndexerUsdcPriceParams(NadoBaseModel):
|
|
258
|
+
"""
|
|
259
|
+
Parameters for querying usdc price.
|
|
260
|
+
"""
|
|
261
|
+
|
|
262
|
+
pass
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
class IndexerVrtxMerkleProofsParams(NadoBaseModel):
|
|
266
|
+
"""
|
|
267
|
+
Parameters for querying VRTX merkle proofs.
|
|
268
|
+
"""
|
|
269
|
+
|
|
270
|
+
address: str
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
class IndexerFoundationRewardsMerkleProofsParams(NadoBaseModel):
|
|
274
|
+
"""
|
|
275
|
+
Parameters for querying Foundation Rewards merkle proofs.
|
|
276
|
+
"""
|
|
277
|
+
|
|
278
|
+
address: str
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
class IndexerInterestAndFundingParams(NadoBaseModel):
|
|
282
|
+
"""
|
|
283
|
+
Parameters for querying interest and funding payments.
|
|
284
|
+
"""
|
|
285
|
+
|
|
286
|
+
subaccount: str
|
|
287
|
+
product_ids: list[int]
|
|
288
|
+
max_idx: Optional[Union[str, int]]
|
|
289
|
+
limit: int
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
IndexerParams = Union[
|
|
293
|
+
IndexerSubaccountHistoricalOrdersParams,
|
|
294
|
+
IndexerHistoricalOrdersByDigestParams,
|
|
295
|
+
IndexerMatchesParams,
|
|
296
|
+
IndexerEventsParams,
|
|
297
|
+
IndexerSubaccountSummaryParams,
|
|
298
|
+
IndexerProductSnapshotsParams,
|
|
299
|
+
IndexerCandlesticksParams,
|
|
300
|
+
IndexerFundingRateParams,
|
|
301
|
+
IndexerPerpPricesParams,
|
|
302
|
+
IndexerOraclePricesParams,
|
|
303
|
+
IndexerTokenRewardsParams,
|
|
304
|
+
IndexerMakerStatisticsParams,
|
|
305
|
+
IndexerLiquidationFeedParams,
|
|
306
|
+
IndexerLinkedSignerRateLimitParams,
|
|
307
|
+
IndexerReferralCodeParams,
|
|
308
|
+
IndexerSubaccountsParams,
|
|
309
|
+
IndexerUsdcPriceParams,
|
|
310
|
+
IndexerMarketSnapshotsParams,
|
|
311
|
+
IndexerVrtxMerkleProofsParams,
|
|
312
|
+
IndexerFoundationRewardsMerkleProofsParams,
|
|
313
|
+
IndexerInterestAndFundingParams,
|
|
314
|
+
]
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
class IndexerHistoricalOrdersRequest(NadoBaseModel):
|
|
318
|
+
"""
|
|
319
|
+
Request object for querying historical orders.
|
|
320
|
+
"""
|
|
321
|
+
|
|
322
|
+
orders: Union[
|
|
323
|
+
IndexerSubaccountHistoricalOrdersParams, IndexerHistoricalOrdersByDigestParams
|
|
324
|
+
]
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
class IndexerMatchesRequest(NadoBaseModel):
|
|
328
|
+
"""
|
|
329
|
+
Request object for querying matches.
|
|
330
|
+
"""
|
|
331
|
+
|
|
332
|
+
matches: IndexerMatchesParams
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
class IndexerEventsRequest(NadoBaseModel):
|
|
336
|
+
"""
|
|
337
|
+
Request object for querying events.
|
|
338
|
+
"""
|
|
339
|
+
|
|
340
|
+
events: IndexerEventsParams
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
class IndexerSubaccountSummaryRequest(NadoBaseModel):
|
|
344
|
+
"""
|
|
345
|
+
Request object for querying subaccount summary.
|
|
346
|
+
"""
|
|
347
|
+
|
|
348
|
+
summary: IndexerSubaccountSummaryParams
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
class IndexerProductSnapshotsRequest(NadoBaseModel):
|
|
352
|
+
"""
|
|
353
|
+
Request object for querying product snapshots.
|
|
354
|
+
"""
|
|
355
|
+
|
|
356
|
+
products: IndexerProductSnapshotsParams
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
class IndexerMarketSnapshotsRequest(NadoBaseModel):
|
|
360
|
+
"""
|
|
361
|
+
Request object for querying market snapshots.
|
|
362
|
+
"""
|
|
363
|
+
|
|
364
|
+
market_snapshots: IndexerMarketSnapshotsParams
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
class IndexerCandlesticksRequest(NadoBaseModel):
|
|
368
|
+
"""
|
|
369
|
+
Request object for querying candlestick data.
|
|
370
|
+
"""
|
|
371
|
+
|
|
372
|
+
candlesticks: IndexerCandlesticksParams
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
class IndexerFundingRateRequest(NadoBaseModel):
|
|
376
|
+
"""
|
|
377
|
+
Request object for querying funding rates.
|
|
378
|
+
"""
|
|
379
|
+
|
|
380
|
+
funding_rate: IndexerFundingRateParams
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
class IndexerFundingRatesRequest(NadoBaseModel):
|
|
384
|
+
"""
|
|
385
|
+
Request object for querying funding rates.
|
|
386
|
+
"""
|
|
387
|
+
|
|
388
|
+
funding_rates: IndexerFundingRatesParams
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
class IndexerPerpPricesRequest(NadoBaseModel):
|
|
392
|
+
"""
|
|
393
|
+
Request object for querying perpetual prices.
|
|
394
|
+
"""
|
|
395
|
+
|
|
396
|
+
price: IndexerPerpPricesParams
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
class IndexerOraclePricesRequest(NadoBaseModel):
|
|
400
|
+
"""
|
|
401
|
+
Request object for querying oracle prices.
|
|
402
|
+
"""
|
|
403
|
+
|
|
404
|
+
oracle_price: IndexerOraclePricesParams
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
class IndexerTokenRewardsRequest(NadoBaseModel):
|
|
408
|
+
"""
|
|
409
|
+
Request object for querying token rewards.
|
|
410
|
+
"""
|
|
411
|
+
|
|
412
|
+
rewards: IndexerTokenRewardsParams
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
class IndexerMakerStatisticsRequest(NadoBaseModel):
|
|
416
|
+
"""
|
|
417
|
+
Request object for querying maker statistics.
|
|
418
|
+
"""
|
|
419
|
+
|
|
420
|
+
maker_statistics: IndexerMakerStatisticsParams
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
class IndexerLiquidationFeedRequest(NadoBaseModel):
|
|
424
|
+
"""
|
|
425
|
+
Request object for querying liquidation feed.
|
|
426
|
+
"""
|
|
427
|
+
|
|
428
|
+
liquidation_feed: IndexerLiquidationFeedParams
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
class IndexerLinkedSignerRateLimitRequest(NadoBaseModel):
|
|
432
|
+
"""
|
|
433
|
+
Request object for querying linked signer rate limits.
|
|
434
|
+
"""
|
|
435
|
+
|
|
436
|
+
linked_signer_rate_limit: IndexerLinkedSignerRateLimitParams
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
class IndexerReferralCodeRequest(NadoBaseModel):
|
|
440
|
+
"""
|
|
441
|
+
Request object for querying a referral code.
|
|
442
|
+
"""
|
|
443
|
+
|
|
444
|
+
referral_code: IndexerReferralCodeParams
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
class IndexerSubaccountsRequest(NadoBaseModel):
|
|
448
|
+
"""
|
|
449
|
+
Request object for querying subaccounts.
|
|
450
|
+
"""
|
|
451
|
+
|
|
452
|
+
subaccounts: IndexerSubaccountsParams
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
class IndexerUsdcPriceRequest(NadoBaseModel):
|
|
456
|
+
"""
|
|
457
|
+
Request object for querying usdc price.
|
|
458
|
+
"""
|
|
459
|
+
|
|
460
|
+
usdc_price: IndexerUsdcPriceParams
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
class IndexerVrtxMerkleProofsRequest(NadoBaseModel):
|
|
464
|
+
"""
|
|
465
|
+
Request object for querying VRTX merkle proofs.
|
|
466
|
+
"""
|
|
467
|
+
|
|
468
|
+
vrtx_merkle_proofs: IndexerVrtxMerkleProofsParams
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
class IndexerFoundationRewardsMerkleProofsRequest(NadoBaseModel):
|
|
472
|
+
"""
|
|
473
|
+
Request object for querying Foundation Rewards merkle proofs.
|
|
474
|
+
"""
|
|
475
|
+
|
|
476
|
+
foundation_rewards_merkle_proofs: IndexerFoundationRewardsMerkleProofsParams
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
class IndexerInterestAndFundingRequest(NadoBaseModel):
|
|
480
|
+
"""
|
|
481
|
+
Request object for querying Interest and funding payments.
|
|
482
|
+
"""
|
|
483
|
+
|
|
484
|
+
interest_and_funding: IndexerInterestAndFundingParams
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
IndexerRequest = Union[
|
|
488
|
+
IndexerHistoricalOrdersRequest,
|
|
489
|
+
IndexerMatchesRequest,
|
|
490
|
+
IndexerEventsRequest,
|
|
491
|
+
IndexerSubaccountSummaryRequest,
|
|
492
|
+
IndexerProductSnapshotsRequest,
|
|
493
|
+
IndexerCandlesticksRequest,
|
|
494
|
+
IndexerFundingRateRequest,
|
|
495
|
+
IndexerPerpPricesRequest,
|
|
496
|
+
IndexerOraclePricesRequest,
|
|
497
|
+
IndexerTokenRewardsRequest,
|
|
498
|
+
IndexerMakerStatisticsRequest,
|
|
499
|
+
IndexerLiquidationFeedRequest,
|
|
500
|
+
IndexerLinkedSignerRateLimitRequest,
|
|
501
|
+
IndexerReferralCodeRequest,
|
|
502
|
+
IndexerSubaccountsRequest,
|
|
503
|
+
IndexerUsdcPriceRequest,
|
|
504
|
+
IndexerMarketSnapshotsRequest,
|
|
505
|
+
IndexerVrtxMerkleProofsRequest,
|
|
506
|
+
IndexerFoundationRewardsMerkleProofsRequest,
|
|
507
|
+
IndexerInterestAndFundingRequest,
|
|
508
|
+
]
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
class IndexerHistoricalOrdersData(NadoBaseModel):
|
|
512
|
+
"""
|
|
513
|
+
Data object for historical orders.
|
|
514
|
+
"""
|
|
515
|
+
|
|
516
|
+
orders: list[IndexerHistoricalOrder]
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
class IndexerMatchesData(NadoBaseModel):
|
|
520
|
+
"""
|
|
521
|
+
Data object for matches.
|
|
522
|
+
"""
|
|
523
|
+
|
|
524
|
+
matches: list[IndexerMatch]
|
|
525
|
+
txs: list[IndexerTx]
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
class IndexerEventsData(NadoBaseModel):
|
|
529
|
+
"""
|
|
530
|
+
Data object for events.
|
|
531
|
+
"""
|
|
532
|
+
|
|
533
|
+
events: list[IndexerEvent]
|
|
534
|
+
txs: list[IndexerTx]
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
class IndexerSubaccountSummaryData(NadoBaseModel):
|
|
538
|
+
"""
|
|
539
|
+
Data object for subaccount summary.
|
|
540
|
+
"""
|
|
541
|
+
|
|
542
|
+
events: list[IndexerEvent]
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
class IndexerProductSnapshotsData(NadoBaseModel):
|
|
546
|
+
"""
|
|
547
|
+
Data object for product snapshots.
|
|
548
|
+
"""
|
|
549
|
+
|
|
550
|
+
products: list[IndexerProduct]
|
|
551
|
+
txs: list[IndexerTx]
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
class IndexerMarketSnapshotsData(NadoBaseModel):
|
|
555
|
+
"""
|
|
556
|
+
Data object for market snapshots.
|
|
557
|
+
"""
|
|
558
|
+
|
|
559
|
+
snapshots: list[IndexerMarketSnapshot]
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
class IndexerCandlesticksData(NadoBaseModel):
|
|
563
|
+
"""
|
|
564
|
+
Data object for candlestick data.
|
|
565
|
+
"""
|
|
566
|
+
|
|
567
|
+
candlesticks: list[IndexerCandlestick]
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
class IndexerFundingRateData(NadoBaseModel):
|
|
571
|
+
"""
|
|
572
|
+
Data object for funding rates.
|
|
573
|
+
"""
|
|
574
|
+
|
|
575
|
+
product_id: int
|
|
576
|
+
funding_rate_x18: str
|
|
577
|
+
update_time: str
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
IndexerFundingRatesData = Dict[str, IndexerFundingRateData]
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
class IndexerPerpPricesData(NadoBaseModel):
|
|
584
|
+
"""
|
|
585
|
+
Data object for perpetual prices.
|
|
586
|
+
"""
|
|
587
|
+
|
|
588
|
+
product_id: int
|
|
589
|
+
index_price_x18: str
|
|
590
|
+
mark_price_x18: str
|
|
591
|
+
update_time: str
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
class IndexerOraclePricesData(NadoBaseModel):
|
|
595
|
+
"""
|
|
596
|
+
Data object for oracle prices.
|
|
597
|
+
"""
|
|
598
|
+
|
|
599
|
+
prices: list[IndexerOraclePrice]
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
class IndexerTokenRewardsData(NadoBaseModel):
|
|
603
|
+
"""
|
|
604
|
+
Data object for token rewards.
|
|
605
|
+
"""
|
|
606
|
+
|
|
607
|
+
rewards: list[IndexerTokenReward]
|
|
608
|
+
update_time: str
|
|
609
|
+
total_referrals: str
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
class IndexerMakerStatisticsData(NadoBaseModel):
|
|
613
|
+
"""
|
|
614
|
+
Data object for maker statistics.
|
|
615
|
+
"""
|
|
616
|
+
|
|
617
|
+
reward_coefficient: float
|
|
618
|
+
makers: list[IndexerMarketMaker]
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
class IndexerLinkedSignerRateLimitData(NadoBaseModel):
|
|
622
|
+
"""
|
|
623
|
+
Data object for linked signer rate limits.
|
|
624
|
+
"""
|
|
625
|
+
|
|
626
|
+
remaining_tx: str
|
|
627
|
+
total_tx_limit: str
|
|
628
|
+
wait_time: int
|
|
629
|
+
signer: str
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
class IndexerReferralCodeData(NadoBaseModel):
|
|
633
|
+
"""
|
|
634
|
+
Data object for referral codes.
|
|
635
|
+
"""
|
|
636
|
+
|
|
637
|
+
referral_code: str
|
|
638
|
+
|
|
639
|
+
@validator("referral_code", pre=True, always=True)
|
|
640
|
+
def set_default_referral_code(cls, v):
|
|
641
|
+
return v or ""
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
class IndexerSubaccountsData(NadoBaseModel):
|
|
645
|
+
"""
|
|
646
|
+
Data object for subaccounts response from the indexer.
|
|
647
|
+
"""
|
|
648
|
+
|
|
649
|
+
subaccounts: list[IndexerSubaccount]
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
class IndexerUsdcPriceData(NadoBaseModel):
|
|
653
|
+
"""
|
|
654
|
+
Data object for the usdc price response from the indexer.
|
|
655
|
+
"""
|
|
656
|
+
|
|
657
|
+
price_x18: str
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
class IndexerMerkleProofsData(NadoBaseModel):
|
|
661
|
+
"""
|
|
662
|
+
Data object for the merkle proofs response from the indexer.
|
|
663
|
+
"""
|
|
664
|
+
|
|
665
|
+
merkle_proofs: list[IndexerMerkleProof]
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
class IndexerInterestAndFundingData(NadoBaseModel):
|
|
669
|
+
"""
|
|
670
|
+
Data object for the interest and funding payments response from the indexer.
|
|
671
|
+
"""
|
|
672
|
+
|
|
673
|
+
interest_payments: list[IndexerPayment]
|
|
674
|
+
funding_payments: list[IndexerPayment]
|
|
675
|
+
next_idx: str
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
IndexerLiquidationFeedData = list[IndexerLiquidatableAccount]
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
IndexerResponseData = Union[
|
|
682
|
+
IndexerHistoricalOrdersData,
|
|
683
|
+
IndexerMatchesData,
|
|
684
|
+
IndexerEventsData,
|
|
685
|
+
IndexerSubaccountSummaryData,
|
|
686
|
+
IndexerProductSnapshotsData,
|
|
687
|
+
IndexerCandlesticksData,
|
|
688
|
+
IndexerFundingRateData,
|
|
689
|
+
IndexerPerpPricesData,
|
|
690
|
+
IndexerOraclePricesData,
|
|
691
|
+
IndexerTokenRewardsData,
|
|
692
|
+
IndexerMakerStatisticsData,
|
|
693
|
+
IndexerLinkedSignerRateLimitData,
|
|
694
|
+
IndexerReferralCodeData,
|
|
695
|
+
IndexerSubaccountsData,
|
|
696
|
+
IndexerUsdcPriceData,
|
|
697
|
+
IndexerMarketSnapshotsData,
|
|
698
|
+
IndexerMerkleProofsData,
|
|
699
|
+
IndexerInterestAndFundingData,
|
|
700
|
+
IndexerLiquidationFeedData,
|
|
701
|
+
IndexerFundingRatesData,
|
|
702
|
+
]
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
class IndexerResponse(NadoBaseModel):
|
|
706
|
+
"""
|
|
707
|
+
Represents the response returned by the indexer.
|
|
708
|
+
|
|
709
|
+
Attributes:
|
|
710
|
+
data (IndexerResponseData): The data contained in the response.
|
|
711
|
+
"""
|
|
712
|
+
|
|
713
|
+
data: IndexerResponseData
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
def to_indexer_request(params: IndexerParams) -> IndexerRequest:
|
|
717
|
+
"""
|
|
718
|
+
Converts an IndexerParams object to the corresponding IndexerRequest object.
|
|
719
|
+
|
|
720
|
+
Args:
|
|
721
|
+
params (IndexerParams): The IndexerParams object to convert.
|
|
722
|
+
|
|
723
|
+
Returns:
|
|
724
|
+
IndexerRequest: The converted IndexerRequest object.
|
|
725
|
+
"""
|
|
726
|
+
indexer_request_mapping = {
|
|
727
|
+
IndexerSubaccountHistoricalOrdersParams: (
|
|
728
|
+
IndexerHistoricalOrdersRequest,
|
|
729
|
+
IndexerQueryType.ORDERS.value,
|
|
730
|
+
),
|
|
731
|
+
IndexerHistoricalOrdersByDigestParams: (
|
|
732
|
+
IndexerHistoricalOrdersRequest,
|
|
733
|
+
IndexerQueryType.ORDERS.value,
|
|
734
|
+
),
|
|
735
|
+
IndexerMatchesParams: (IndexerMatchesRequest, IndexerQueryType.MATCHES.value),
|
|
736
|
+
IndexerEventsParams: (IndexerEventsRequest, IndexerQueryType.EVENTS.value),
|
|
737
|
+
IndexerSubaccountSummaryParams: (
|
|
738
|
+
IndexerSubaccountSummaryRequest,
|
|
739
|
+
IndexerQueryType.SUMMARY.value,
|
|
740
|
+
),
|
|
741
|
+
IndexerProductSnapshotsParams: (
|
|
742
|
+
IndexerProductSnapshotsRequest,
|
|
743
|
+
IndexerQueryType.PRODUCTS.value,
|
|
744
|
+
),
|
|
745
|
+
IndexerMarketSnapshotsParams: (
|
|
746
|
+
IndexerMarketSnapshotsRequest,
|
|
747
|
+
IndexerQueryType.MARKET_SNAPSHOTS.value,
|
|
748
|
+
),
|
|
749
|
+
IndexerCandlesticksParams: (
|
|
750
|
+
IndexerCandlesticksRequest,
|
|
751
|
+
IndexerQueryType.CANDLESTICKS.value,
|
|
752
|
+
),
|
|
753
|
+
IndexerFundingRateParams: (
|
|
754
|
+
IndexerFundingRateRequest,
|
|
755
|
+
IndexerQueryType.FUNDING_RATE.value,
|
|
756
|
+
),
|
|
757
|
+
IndexerFundingRatesParams: (
|
|
758
|
+
IndexerFundingRatesRequest,
|
|
759
|
+
IndexerQueryType.FUNDING_RATES.value,
|
|
760
|
+
),
|
|
761
|
+
IndexerPerpPricesParams: (
|
|
762
|
+
IndexerPerpPricesRequest,
|
|
763
|
+
IndexerQueryType.PERP_PRICES.value,
|
|
764
|
+
),
|
|
765
|
+
IndexerOraclePricesParams: (
|
|
766
|
+
IndexerOraclePricesRequest,
|
|
767
|
+
IndexerQueryType.ORACLE_PRICES.value,
|
|
768
|
+
),
|
|
769
|
+
IndexerTokenRewardsParams: (
|
|
770
|
+
IndexerTokenRewardsRequest,
|
|
771
|
+
IndexerQueryType.REWARDS.value,
|
|
772
|
+
),
|
|
773
|
+
IndexerMakerStatisticsParams: (
|
|
774
|
+
IndexerMakerStatisticsRequest,
|
|
775
|
+
IndexerQueryType.MAKER_STATISTICS.value,
|
|
776
|
+
),
|
|
777
|
+
IndexerLiquidationFeedParams: (
|
|
778
|
+
IndexerLiquidationFeedRequest,
|
|
779
|
+
IndexerQueryType.LIQUIDATION_FEED.value,
|
|
780
|
+
),
|
|
781
|
+
IndexerLinkedSignerRateLimitParams: (
|
|
782
|
+
IndexerLinkedSignerRateLimitRequest,
|
|
783
|
+
IndexerQueryType.LINKED_SIGNER_RATE_LIMIT.value,
|
|
784
|
+
),
|
|
785
|
+
IndexerReferralCodeParams: (
|
|
786
|
+
IndexerReferralCodeRequest,
|
|
787
|
+
IndexerQueryType.REFERRAL_CODE.value,
|
|
788
|
+
),
|
|
789
|
+
IndexerSubaccountsParams: (
|
|
790
|
+
IndexerSubaccountsRequest,
|
|
791
|
+
IndexerQueryType.SUBACCOUNTS.value,
|
|
792
|
+
),
|
|
793
|
+
IndexerUsdcPriceParams: (
|
|
794
|
+
IndexerUsdcPriceRequest,
|
|
795
|
+
IndexerQueryType.USDC_PRICE.value,
|
|
796
|
+
),
|
|
797
|
+
IndexerVrtxMerkleProofsParams: (
|
|
798
|
+
IndexerVrtxMerkleProofsRequest,
|
|
799
|
+
IndexerQueryType.VRTX_MERKLE_PROOFS.value,
|
|
800
|
+
),
|
|
801
|
+
IndexerFoundationRewardsMerkleProofsParams: (
|
|
802
|
+
IndexerFoundationRewardsMerkleProofsRequest,
|
|
803
|
+
IndexerQueryType.FOUNDATION_REWARDS_MERKLE_PROOFS.value,
|
|
804
|
+
),
|
|
805
|
+
IndexerInterestAndFundingParams: (
|
|
806
|
+
IndexerInterestAndFundingRequest,
|
|
807
|
+
IndexerQueryType.INTEREST_AND_FUNDING.value,
|
|
808
|
+
),
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
RequestClass, field_name = indexer_request_mapping[type(params)]
|
|
812
|
+
return RequestClass(**{field_name: params})
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
IndexerTickersData = Dict[str, IndexerTickerInfo]
|
|
816
|
+
|
|
817
|
+
IndexerPerpContractsData = Dict[str, IndexerPerpContractInfo]
|
|
818
|
+
|
|
819
|
+
IndexerHistoricalTradesData = list[IndexerTradeInfo]
|