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,466 @@
|
|
|
1
|
+
from typing import Optional, Union
|
|
2
|
+
import requests
|
|
3
|
+
from functools import singledispatchmethod
|
|
4
|
+
from nado_protocol.indexer_client.types import IndexerClientOpts
|
|
5
|
+
from nado_protocol.indexer_client.types.models import MarketType, VrtxTokenQueryType
|
|
6
|
+
from nado_protocol.indexer_client.types.query import (
|
|
7
|
+
IndexerCandlesticksParams,
|
|
8
|
+
IndexerCandlesticksData,
|
|
9
|
+
IndexerEventsParams,
|
|
10
|
+
IndexerEventsData,
|
|
11
|
+
IndexerFundingRateParams,
|
|
12
|
+
IndexerFundingRateData,
|
|
13
|
+
IndexerFundingRatesParams,
|
|
14
|
+
IndexerFundingRatesData,
|
|
15
|
+
IndexerHistoricalOrdersByDigestParams,
|
|
16
|
+
IndexerHistoricalOrdersData,
|
|
17
|
+
IndexerReferralCodeData,
|
|
18
|
+
IndexerReferralCodeParams,
|
|
19
|
+
IndexerSubaccountHistoricalOrdersParams,
|
|
20
|
+
IndexerLinkedSignerRateLimitData,
|
|
21
|
+
IndexerLinkedSignerRateLimitParams,
|
|
22
|
+
IndexerLiquidationFeedData,
|
|
23
|
+
IndexerLiquidationFeedParams,
|
|
24
|
+
IndexerMarketSnapshotsData,
|
|
25
|
+
IndexerMarketSnapshotsParams,
|
|
26
|
+
IndexerMakerStatisticsData,
|
|
27
|
+
IndexerMakerStatisticsParams,
|
|
28
|
+
IndexerMatchesParams,
|
|
29
|
+
IndexerMatchesData,
|
|
30
|
+
IndexerOraclePricesData,
|
|
31
|
+
IndexerOraclePricesParams,
|
|
32
|
+
IndexerParams,
|
|
33
|
+
IndexerPerpPricesData,
|
|
34
|
+
IndexerPerpPricesParams,
|
|
35
|
+
IndexerProductSnapshotsData,
|
|
36
|
+
IndexerProductSnapshotsParams,
|
|
37
|
+
IndexerRequest,
|
|
38
|
+
IndexerResponse,
|
|
39
|
+
IndexerSubaccountSummaryParams,
|
|
40
|
+
IndexerSubaccountSummaryData,
|
|
41
|
+
IndexerSubaccountsData,
|
|
42
|
+
IndexerSubaccountsParams,
|
|
43
|
+
IndexerTokenRewardsData,
|
|
44
|
+
IndexerTokenRewardsParams,
|
|
45
|
+
IndexerUsdcPriceParams,
|
|
46
|
+
IndexerUsdcPriceData,
|
|
47
|
+
IndexerVrtxMerkleProofsParams,
|
|
48
|
+
IndexerFoundationRewardsMerkleProofsParams,
|
|
49
|
+
IndexerMerkleProofsData,
|
|
50
|
+
IndexerInterestAndFundingParams,
|
|
51
|
+
IndexerInterestAndFundingData,
|
|
52
|
+
IndexerTickersData,
|
|
53
|
+
IndexerPerpContractsData,
|
|
54
|
+
IndexerHistoricalTradesData,
|
|
55
|
+
to_indexer_request,
|
|
56
|
+
)
|
|
57
|
+
from nado_protocol.utils.model import (
|
|
58
|
+
NadoBaseModel,
|
|
59
|
+
ensure_data_type,
|
|
60
|
+
is_instance_of_union,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class IndexerQueryClient:
|
|
65
|
+
"""
|
|
66
|
+
Client for querying data from the indexer service.
|
|
67
|
+
|
|
68
|
+
Attributes:
|
|
69
|
+
_opts (IndexerClientOpts): Client configuration options for connecting and interacting with the indexer service.
|
|
70
|
+
url (str): URL of the indexer service.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
def __init__(self, opts: IndexerClientOpts):
|
|
74
|
+
"""
|
|
75
|
+
Initializes the IndexerQueryClient with the provided options.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
opts (IndexerClientOpts): Client configuration options for connecting and interacting with the indexer service.
|
|
79
|
+
"""
|
|
80
|
+
self._opts = IndexerClientOpts.parse_obj(opts)
|
|
81
|
+
self.url = self._opts.url
|
|
82
|
+
self.url_v2: str = self.url.replace("/v1", "") + "/v2"
|
|
83
|
+
self.session = requests.Session()
|
|
84
|
+
|
|
85
|
+
@singledispatchmethod
|
|
86
|
+
def query(self, params: Union[IndexerParams, IndexerRequest]) -> IndexerResponse:
|
|
87
|
+
"""
|
|
88
|
+
Sends a query request to the indexer service and returns the response.
|
|
89
|
+
|
|
90
|
+
The `query` method is overloaded to accept either `IndexerParams` or a dictionary or `IndexerRequest`
|
|
91
|
+
as the input parameters. Based on the type of the input, the appropriate internal method is invoked
|
|
92
|
+
to process the query request.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
params (IndexerParams | dict | IndexerRequest): The parameters for the query request.
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
IndexerResponse: The response from the indexer service.
|
|
99
|
+
"""
|
|
100
|
+
req: IndexerRequest = (
|
|
101
|
+
params if is_instance_of_union(params, IndexerRequest) else to_indexer_request(params) # type: ignore
|
|
102
|
+
)
|
|
103
|
+
return self._query(req)
|
|
104
|
+
|
|
105
|
+
@query.register
|
|
106
|
+
def _(self, req: dict) -> IndexerResponse:
|
|
107
|
+
return self._query(NadoBaseModel.parse_obj(req)) # type: ignore
|
|
108
|
+
|
|
109
|
+
def _query(self, req: IndexerRequest) -> IndexerResponse:
|
|
110
|
+
res = self.session.post(self.url, json=req.dict())
|
|
111
|
+
if res.status_code != 200:
|
|
112
|
+
raise Exception(res.text)
|
|
113
|
+
try:
|
|
114
|
+
indexer_res = IndexerResponse(data=res.json())
|
|
115
|
+
except Exception:
|
|
116
|
+
raise Exception(res.text)
|
|
117
|
+
return indexer_res
|
|
118
|
+
|
|
119
|
+
def _query_v2(self, url):
|
|
120
|
+
res = self.session.get(url)
|
|
121
|
+
if res.status_code != 200:
|
|
122
|
+
raise Exception(res.text)
|
|
123
|
+
return res.json()
|
|
124
|
+
|
|
125
|
+
def get_subaccount_historical_orders(
|
|
126
|
+
self, params: IndexerSubaccountHistoricalOrdersParams
|
|
127
|
+
) -> IndexerHistoricalOrdersData:
|
|
128
|
+
"""
|
|
129
|
+
Retrieves the historical orders associated with a specific subaccount.
|
|
130
|
+
|
|
131
|
+
Args:
|
|
132
|
+
params (IndexerSubaccountHistoricalOrdersParams): The parameters specifying the subaccount for which to retrieve historical orders.
|
|
133
|
+
|
|
134
|
+
Returns:
|
|
135
|
+
IndexerHistoricalOrdersData: The historical orders associated with the specified subaccount.
|
|
136
|
+
"""
|
|
137
|
+
return ensure_data_type(
|
|
138
|
+
self.query(IndexerSubaccountHistoricalOrdersParams.parse_obj(params)).data,
|
|
139
|
+
IndexerHistoricalOrdersData,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
def get_historical_orders_by_digest(
|
|
143
|
+
self, digests: list[str]
|
|
144
|
+
) -> IndexerHistoricalOrdersData:
|
|
145
|
+
"""
|
|
146
|
+
Retrieves historical orders using their unique digests.
|
|
147
|
+
|
|
148
|
+
Args:
|
|
149
|
+
digests (list[str]): A list of order digests.
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
IndexerHistoricalOrdersData: The historical orders corresponding to the provided digests.
|
|
153
|
+
"""
|
|
154
|
+
return ensure_data_type(
|
|
155
|
+
self.query(IndexerHistoricalOrdersByDigestParams(digests=digests)).data,
|
|
156
|
+
IndexerHistoricalOrdersData,
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
def get_matches(self, params: IndexerMatchesParams) -> IndexerMatchesData:
|
|
160
|
+
"""
|
|
161
|
+
Retrieves match data based on provided parameters.
|
|
162
|
+
|
|
163
|
+
Args:
|
|
164
|
+
params (IndexerMatchesParams): The parameters for the match data retrieval request.
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
IndexerMatchesData: The match data corresponding to the provided parameters.
|
|
168
|
+
"""
|
|
169
|
+
return ensure_data_type(
|
|
170
|
+
self.query(IndexerMatchesParams.parse_obj(params)).data, IndexerMatchesData
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
def get_events(self, params: IndexerEventsParams) -> IndexerEventsData:
|
|
174
|
+
"""
|
|
175
|
+
Retrieves event data based on provided parameters.
|
|
176
|
+
|
|
177
|
+
Args:
|
|
178
|
+
params (IndexerEventsParams): The parameters for the event data retrieval request.
|
|
179
|
+
|
|
180
|
+
Returns:
|
|
181
|
+
IndexerEventsData: The event data corresponding to the provided parameters.
|
|
182
|
+
"""
|
|
183
|
+
return ensure_data_type(
|
|
184
|
+
self.query(IndexerEventsParams.parse_obj(params)).data, IndexerEventsData
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
def get_subaccount_summary(
|
|
188
|
+
self, subaccount: str, timestamp: Optional[int] = None
|
|
189
|
+
) -> IndexerSubaccountSummaryData:
|
|
190
|
+
"""
|
|
191
|
+
Retrieves a summary of a specified subaccount at a certain timestamp.
|
|
192
|
+
|
|
193
|
+
Args:
|
|
194
|
+
subaccount (str): The identifier for the subaccount.
|
|
195
|
+
|
|
196
|
+
timestamp (int | None, optional): The timestamp for which to retrieve the subaccount summary. If not provided, the most recent summary is retrieved.
|
|
197
|
+
|
|
198
|
+
Returns:
|
|
199
|
+
IndexerSubaccountSummaryData: The summary of the specified subaccount at the provided timestamp.
|
|
200
|
+
"""
|
|
201
|
+
return ensure_data_type(
|
|
202
|
+
self.query(
|
|
203
|
+
IndexerSubaccountSummaryParams(
|
|
204
|
+
subaccount=subaccount, timestamp=timestamp
|
|
205
|
+
)
|
|
206
|
+
).data,
|
|
207
|
+
IndexerSubaccountSummaryData,
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
def get_product_snapshots(
|
|
211
|
+
self, params: IndexerProductSnapshotsParams
|
|
212
|
+
) -> IndexerProductSnapshotsData:
|
|
213
|
+
"""
|
|
214
|
+
Retrieves snapshot data for specific products.
|
|
215
|
+
|
|
216
|
+
Args:
|
|
217
|
+
params (IndexerProductSnapshotsParams): Parameters specifying the products for which to retrieve snapshot data.
|
|
218
|
+
|
|
219
|
+
Returns:
|
|
220
|
+
IndexerProductSnapshotsData: The product snapshot data corresponding to the provided parameters.
|
|
221
|
+
"""
|
|
222
|
+
return ensure_data_type(
|
|
223
|
+
self.query(IndexerProductSnapshotsParams.parse_obj(params)).data,
|
|
224
|
+
IndexerProductSnapshotsData,
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
def get_market_snapshots(
|
|
228
|
+
self, params: IndexerMarketSnapshotsParams
|
|
229
|
+
) -> IndexerMarketSnapshotsData:
|
|
230
|
+
"""
|
|
231
|
+
Retrieves historical market snapshots.
|
|
232
|
+
|
|
233
|
+
Args:
|
|
234
|
+
params (IndexerMarketSnapshotsParams): Parameters specifying the historical market snapshot request.
|
|
235
|
+
|
|
236
|
+
Returns:
|
|
237
|
+
IndexerMarketSnapshotsData: The market snapshot data corresponding to the provided parameters.
|
|
238
|
+
"""
|
|
239
|
+
return ensure_data_type(
|
|
240
|
+
self.query(IndexerMarketSnapshotsParams.parse_obj(params)).data,
|
|
241
|
+
IndexerMarketSnapshotsData,
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
def get_candlesticks(
|
|
245
|
+
self, params: IndexerCandlesticksParams
|
|
246
|
+
) -> IndexerCandlesticksData:
|
|
247
|
+
"""
|
|
248
|
+
Retrieves candlestick data based on provided parameters.
|
|
249
|
+
|
|
250
|
+
Args:
|
|
251
|
+
params (IndexerCandlesticksParams): The parameters for retrieving candlestick data.
|
|
252
|
+
|
|
253
|
+
Returns:
|
|
254
|
+
IndexerCandlesticksData: The candlestick data corresponding to the provided parameters.
|
|
255
|
+
"""
|
|
256
|
+
return ensure_data_type(
|
|
257
|
+
self.query(IndexerCandlesticksParams.parse_obj(params)).data,
|
|
258
|
+
IndexerCandlesticksData,
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
def get_perp_funding_rate(self, product_id: int) -> IndexerFundingRateData:
|
|
262
|
+
"""
|
|
263
|
+
Retrieves the funding rate data for a specific perp product.
|
|
264
|
+
|
|
265
|
+
Args:
|
|
266
|
+
product_id (int): The identifier of the perp product.
|
|
267
|
+
|
|
268
|
+
Returns:
|
|
269
|
+
IndexerFundingRateData: The funding rate data for the specified perp product.
|
|
270
|
+
"""
|
|
271
|
+
return ensure_data_type(
|
|
272
|
+
self.query(IndexerFundingRateParams(product_id=product_id)).data,
|
|
273
|
+
IndexerFundingRateData,
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
def get_perp_funding_rates(self, product_ids: list) -> IndexerFundingRatesData:
|
|
277
|
+
"""
|
|
278
|
+
Fetches the latest funding rates for a list of perp products.
|
|
279
|
+
|
|
280
|
+
Args:
|
|
281
|
+
product_ids (list): List of identifiers for the perp products.
|
|
282
|
+
|
|
283
|
+
Returns:
|
|
284
|
+
dict: A dictionary mapping each product_id to its latest funding rate and related details.
|
|
285
|
+
"""
|
|
286
|
+
return ensure_data_type(
|
|
287
|
+
self.query(IndexerFundingRatesParams(product_ids=product_ids)).data, dict
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
def get_perp_prices(self, product_id: int) -> IndexerPerpPricesData:
|
|
291
|
+
"""
|
|
292
|
+
Retrieves the price data for a specific perp product.
|
|
293
|
+
|
|
294
|
+
Args:
|
|
295
|
+
product_id (int): The identifier of the perp product.
|
|
296
|
+
|
|
297
|
+
Returns:
|
|
298
|
+
IndexerPerpPricesData: The price data for the specified perp product.
|
|
299
|
+
"""
|
|
300
|
+
return ensure_data_type(
|
|
301
|
+
self.query(IndexerPerpPricesParams(product_id=product_id)).data,
|
|
302
|
+
IndexerPerpPricesData,
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
def get_oracle_prices(self, product_ids: list[int]) -> IndexerOraclePricesData:
|
|
306
|
+
"""
|
|
307
|
+
Retrieves the oracle price data for specific products.
|
|
308
|
+
|
|
309
|
+
Args:
|
|
310
|
+
product_ids (list[int]): A list of product identifiers.
|
|
311
|
+
|
|
312
|
+
Returns:
|
|
313
|
+
IndexerOraclePricesData: The oracle price data for the specified products.
|
|
314
|
+
"""
|
|
315
|
+
return ensure_data_type(
|
|
316
|
+
self.query(IndexerOraclePricesParams(product_ids=product_ids)).data,
|
|
317
|
+
IndexerOraclePricesData,
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
def get_token_rewards(self, address: str) -> IndexerTokenRewardsData:
|
|
321
|
+
"""
|
|
322
|
+
Retrieves the token reward data for a specific address.
|
|
323
|
+
|
|
324
|
+
Args:
|
|
325
|
+
address (str): The address for which to retrieve token reward data.
|
|
326
|
+
|
|
327
|
+
Returns:
|
|
328
|
+
IndexerTokenRewardsData: The token reward data for the specified address.
|
|
329
|
+
"""
|
|
330
|
+
return ensure_data_type(
|
|
331
|
+
self.query(IndexerTokenRewardsParams(address=address)).data,
|
|
332
|
+
IndexerTokenRewardsData,
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
def get_maker_statistics(
|
|
336
|
+
self, params: IndexerMakerStatisticsParams
|
|
337
|
+
) -> IndexerMakerStatisticsData:
|
|
338
|
+
"""
|
|
339
|
+
Retrieves maker statistics based on provided parameters.
|
|
340
|
+
|
|
341
|
+
Args:
|
|
342
|
+
params (IndexerMakerStatisticsParams): The parameters for retrieving maker statistics.
|
|
343
|
+
|
|
344
|
+
Returns:
|
|
345
|
+
IndexerMakerStatisticsData: The maker statistics corresponding to the provided parameters.
|
|
346
|
+
"""
|
|
347
|
+
return ensure_data_type(
|
|
348
|
+
self.query(IndexerMakerStatisticsParams.parse_obj(params)).data,
|
|
349
|
+
IndexerMakerStatisticsData,
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
def get_liquidation_feed(self) -> IndexerLiquidationFeedData:
|
|
353
|
+
"""
|
|
354
|
+
Retrieves the liquidation feed data.
|
|
355
|
+
|
|
356
|
+
Returns:
|
|
357
|
+
IndexerLiquidationFeedData: The latest liquidation feed data.
|
|
358
|
+
"""
|
|
359
|
+
return ensure_data_type(self.query(IndexerLiquidationFeedParams()).data, list)
|
|
360
|
+
|
|
361
|
+
def get_linked_signer_rate_limits(
|
|
362
|
+
self, subaccount: str
|
|
363
|
+
) -> IndexerLinkedSignerRateLimitData:
|
|
364
|
+
"""
|
|
365
|
+
Retrieves the rate limits for a linked signer of a specific subaccount.
|
|
366
|
+
|
|
367
|
+
Args:
|
|
368
|
+
subaccount (str): The identifier of the subaccount.
|
|
369
|
+
|
|
370
|
+
Returns:
|
|
371
|
+
IndexerLinkedSignerRateLimitData: The rate limits for the linked signer of the specified subaccount.
|
|
372
|
+
"""
|
|
373
|
+
return ensure_data_type(
|
|
374
|
+
self.query(IndexerLinkedSignerRateLimitParams(subaccount=subaccount)).data,
|
|
375
|
+
IndexerLinkedSignerRateLimitData,
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
def get_referral_code(self, subaccount: str) -> IndexerReferralCodeData:
|
|
379
|
+
"""
|
|
380
|
+
Retrieves the referral code for a given address.
|
|
381
|
+
|
|
382
|
+
Args:
|
|
383
|
+
subaccount (str): Unique identifier for the subaccount.
|
|
384
|
+
|
|
385
|
+
Returns:
|
|
386
|
+
IndexerReferralCodeData: The referral code for the specific address.
|
|
387
|
+
"""
|
|
388
|
+
return ensure_data_type(
|
|
389
|
+
self.query(IndexerReferralCodeParams(subaccount=subaccount)).data,
|
|
390
|
+
IndexerReferralCodeData,
|
|
391
|
+
)
|
|
392
|
+
|
|
393
|
+
def get_subaccounts(
|
|
394
|
+
self, params: IndexerSubaccountsParams
|
|
395
|
+
) -> IndexerSubaccountsData:
|
|
396
|
+
"""
|
|
397
|
+
Retrieves subaccounts via the indexer.
|
|
398
|
+
|
|
399
|
+
Args:
|
|
400
|
+
params (IndexerSubaccountsParams): The filter parameters for retrieving subaccounts.
|
|
401
|
+
|
|
402
|
+
Returns:
|
|
403
|
+
IndexerSubaccountsData: List of subaccounts found.
|
|
404
|
+
"""
|
|
405
|
+
return ensure_data_type(
|
|
406
|
+
self.query(params).data,
|
|
407
|
+
IndexerSubaccountsData,
|
|
408
|
+
)
|
|
409
|
+
|
|
410
|
+
def get_usdc_price(self) -> IndexerUsdcPriceData:
|
|
411
|
+
return ensure_data_type(
|
|
412
|
+
self.query(IndexerUsdcPriceParams()).data,
|
|
413
|
+
IndexerUsdcPriceData,
|
|
414
|
+
)
|
|
415
|
+
|
|
416
|
+
def get_vrtx_merkle_proofs(self, address: str) -> IndexerMerkleProofsData:
|
|
417
|
+
return ensure_data_type(
|
|
418
|
+
self.query(IndexerVrtxMerkleProofsParams(address=address)).data,
|
|
419
|
+
IndexerMerkleProofsData,
|
|
420
|
+
)
|
|
421
|
+
|
|
422
|
+
def get_foundation_rewards_merkle_proofs(
|
|
423
|
+
self, address: str
|
|
424
|
+
) -> IndexerMerkleProofsData:
|
|
425
|
+
return ensure_data_type(
|
|
426
|
+
self.query(
|
|
427
|
+
IndexerFoundationRewardsMerkleProofsParams(address=address)
|
|
428
|
+
).data,
|
|
429
|
+
IndexerMerkleProofsData,
|
|
430
|
+
)
|
|
431
|
+
|
|
432
|
+
def get_interest_and_funding_payments(
|
|
433
|
+
self, params: IndexerInterestAndFundingParams
|
|
434
|
+
) -> IndexerInterestAndFundingData:
|
|
435
|
+
return ensure_data_type(
|
|
436
|
+
self.query(
|
|
437
|
+
params,
|
|
438
|
+
).data,
|
|
439
|
+
IndexerInterestAndFundingData,
|
|
440
|
+
)
|
|
441
|
+
|
|
442
|
+
def get_tickers(
|
|
443
|
+
self, market_type: Optional[MarketType] = None
|
|
444
|
+
) -> IndexerTickersData:
|
|
445
|
+
url = f"{self.url_v2}/tickers"
|
|
446
|
+
if market_type is not None:
|
|
447
|
+
url += f"?market={str(market_type)}"
|
|
448
|
+
return ensure_data_type(self._query_v2(url), dict)
|
|
449
|
+
|
|
450
|
+
def get_perp_contracts_info(self) -> IndexerPerpContractsData:
|
|
451
|
+
return ensure_data_type(self._query_v2(f"{self.url_v2}/contracts"), dict)
|
|
452
|
+
|
|
453
|
+
def get_historical_trades(
|
|
454
|
+
self, ticker_id: str, limit: Optional[int], max_trade_id: Optional[int] = None
|
|
455
|
+
) -> IndexerHistoricalTradesData:
|
|
456
|
+
url = f"{self.url_v2}/trades?ticker_id={ticker_id}"
|
|
457
|
+
if limit is not None:
|
|
458
|
+
url += f"&limit={limit}"
|
|
459
|
+
if max_trade_id is not None:
|
|
460
|
+
url += f"&max_trade_id={max_trade_id}"
|
|
461
|
+
return ensure_data_type(self._query_v2(url), list)
|
|
462
|
+
|
|
463
|
+
def get_vrtx_token_info(self, query_type: VrtxTokenQueryType) -> float:
|
|
464
|
+
return ensure_data_type(
|
|
465
|
+
self._query_v2(f"{self.url_v2}/vrtx?q={str(query_type)}"), float
|
|
466
|
+
)
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
from pydantic import BaseModel, AnyUrl, validator
|
|
2
|
+
from nado_protocol.indexer_client.types.models import *
|
|
3
|
+
from nado_protocol.indexer_client.types.query import *
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class IndexerClientOpts(BaseModel):
|
|
7
|
+
"""
|
|
8
|
+
Model representing the options for the Indexer Client
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
url: AnyUrl
|
|
12
|
+
|
|
13
|
+
@validator("url")
|
|
14
|
+
def clean_url(cls, v: AnyUrl) -> str:
|
|
15
|
+
return v.rstrip("/")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"IndexerQueryType",
|
|
20
|
+
"IndexerBaseParams",
|
|
21
|
+
"IndexerSubaccountHistoricalOrdersParams",
|
|
22
|
+
"IndexerHistoricalOrdersByDigestParams",
|
|
23
|
+
"IndexerMatchesParams",
|
|
24
|
+
"IndexerEventsRawLimit",
|
|
25
|
+
"IndexerEventsTxsLimit",
|
|
26
|
+
"IndexerEventsLimit",
|
|
27
|
+
"IndexerEventsParams",
|
|
28
|
+
"IndexerSubaccountSummaryParams",
|
|
29
|
+
"IndexerProductSnapshotsParams",
|
|
30
|
+
"IndexerCandlesticksParams",
|
|
31
|
+
"IndexerFundingRateParams",
|
|
32
|
+
"IndexerPerpPricesParams",
|
|
33
|
+
"IndexerOraclePricesParams",
|
|
34
|
+
"IndexerTokenRewardsParams",
|
|
35
|
+
"IndexerMakerStatisticsParams",
|
|
36
|
+
"IndexerLiquidationFeedParams",
|
|
37
|
+
"IndexerLinkedSignerRateLimitParams",
|
|
38
|
+
"IndexerReferralCodeParams",
|
|
39
|
+
"IndexerSubaccountsParams",
|
|
40
|
+
"IndexerParams",
|
|
41
|
+
"IndexerHistoricalOrdersRequest",
|
|
42
|
+
"IndexerMatchesRequest",
|
|
43
|
+
"IndexerEventsRequest",
|
|
44
|
+
"IndexerSubaccountSummaryRequest",
|
|
45
|
+
"IndexerProductSnapshotsRequest",
|
|
46
|
+
"IndexerCandlesticksRequest",
|
|
47
|
+
"IndexerFundingRateRequest",
|
|
48
|
+
"IndexerFundingRatesRequest",
|
|
49
|
+
"IndexerPerpPricesRequest",
|
|
50
|
+
"IndexerOraclePricesRequest",
|
|
51
|
+
"IndexerTokenRewardsRequest",
|
|
52
|
+
"IndexerMakerStatisticsRequest",
|
|
53
|
+
"IndexerLiquidationFeedRequest",
|
|
54
|
+
"IndexerLinkedSignerRateLimitRequest",
|
|
55
|
+
"IndexerReferralCodeRequest",
|
|
56
|
+
"IndexerSubaccountsRequest",
|
|
57
|
+
"IndexerRequest",
|
|
58
|
+
"IndexerHistoricalOrdersData",
|
|
59
|
+
"IndexerMatchesData",
|
|
60
|
+
"IndexerEventsData",
|
|
61
|
+
"IndexerSubaccountSummaryData",
|
|
62
|
+
"IndexerProductSnapshotsData",
|
|
63
|
+
"IndexerCandlesticksData",
|
|
64
|
+
"IndexerFundingRateData",
|
|
65
|
+
"IndexerPerpPricesData",
|
|
66
|
+
"IndexerOraclePricesData",
|
|
67
|
+
"IndexerTokenRewardsData",
|
|
68
|
+
"IndexerMakerStatisticsData",
|
|
69
|
+
"IndexerLinkedSignerRateLimitData",
|
|
70
|
+
"IndexerReferralCodeData",
|
|
71
|
+
"IndexerSubaccountsData",
|
|
72
|
+
"IndexerLiquidationFeedData",
|
|
73
|
+
"IndexerResponseData",
|
|
74
|
+
"IndexerResponse",
|
|
75
|
+
"IndexerEventType",
|
|
76
|
+
"IndexerCandlesticksGranularity",
|
|
77
|
+
"IndexerBaseModel",
|
|
78
|
+
"IndexerBaseOrder",
|
|
79
|
+
"IndexerOrderFill",
|
|
80
|
+
"IndexerHistoricalOrder",
|
|
81
|
+
"IndexerSignedOrder",
|
|
82
|
+
"IndexerMatch",
|
|
83
|
+
"IndexerMatchOrdersTxData",
|
|
84
|
+
"IndexerMatchOrdersTx",
|
|
85
|
+
"IndexerWithdrawCollateralTxData",
|
|
86
|
+
"IndexerWithdrawCollateralTx",
|
|
87
|
+
"IndexerLiquidateSubaccountTxData",
|
|
88
|
+
"IndexerLiquidateSubaccountTx",
|
|
89
|
+
"IndexerMintLpTxData",
|
|
90
|
+
"IndexerMintLpTx",
|
|
91
|
+
"IndexerBurnLpTxData",
|
|
92
|
+
"IndexerBurnLpTx",
|
|
93
|
+
"IndexerTxData",
|
|
94
|
+
"IndexerTx",
|
|
95
|
+
"IndexerSpotProductBalanceData",
|
|
96
|
+
"IndexerSpotProductData",
|
|
97
|
+
"IndexerPerpProductData",
|
|
98
|
+
"IndexerProductData",
|
|
99
|
+
"IndexerEventTrackedData",
|
|
100
|
+
"IndexerEvent",
|
|
101
|
+
"IndexerProduct",
|
|
102
|
+
"IndexerCandlestick",
|
|
103
|
+
"IndexerOraclePrice",
|
|
104
|
+
"IndexerAddressReward",
|
|
105
|
+
"IndexerGlobalRewards",
|
|
106
|
+
"IndexerTokenReward",
|
|
107
|
+
"IndexerMarketMakerData",
|
|
108
|
+
"IndexerMarketMaker",
|
|
109
|
+
"IndexerLiquidatableAccount",
|
|
110
|
+
"IndexerSubaccount",
|
|
111
|
+
"IndexerUsdcPriceData",
|
|
112
|
+
"IndexerInterestAndFundingParams",
|
|
113
|
+
"IndexerInterestAndFundingRequest",
|
|
114
|
+
"IndexerInterestAndFundingData",
|
|
115
|
+
"IndexerTickerInfo",
|
|
116
|
+
"IndexerPerpContractInfo",
|
|
117
|
+
"IndexerTradeInfo",
|
|
118
|
+
"VrtxTokenQueryType",
|
|
119
|
+
"IndexerTickersData",
|
|
120
|
+
"IndexerPerpContractsData",
|
|
121
|
+
"IndexerHistoricalTradesData",
|
|
122
|
+
]
|