defistream 1.3.0__py3-none-any.whl → 1.4.1__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.
- defistream/__init__.py +1 -1
- defistream/query.py +30 -0
- {defistream-1.3.0.dist-info → defistream-1.4.1.dist-info}/METADATA +31 -1
- {defistream-1.3.0.dist-info → defistream-1.4.1.dist-info}/RECORD +6 -6
- {defistream-1.3.0.dist-info → defistream-1.4.1.dist-info}/WHEEL +0 -0
- {defistream-1.3.0.dist-info → defistream-1.4.1.dist-info}/licenses/LICENSE +0 -0
defistream/__init__.py
CHANGED
defistream/query.py
CHANGED
|
@@ -109,14 +109,18 @@ class QueryBuilder:
|
|
|
109
109
|
self._endpoint = endpoint
|
|
110
110
|
self._params: dict[str, Any] = initial_params or {}
|
|
111
111
|
self._verbose = False
|
|
112
|
+
self._with_price = False
|
|
112
113
|
|
|
113
114
|
def _copy_with(self, **updates: Any) -> "QueryBuilder":
|
|
114
115
|
"""Create a copy with updated parameters."""
|
|
115
116
|
new_builder = QueryBuilder(self._client, self._endpoint, self._params.copy())
|
|
116
117
|
new_builder._verbose = self._verbose
|
|
118
|
+
new_builder._with_price = self._with_price
|
|
117
119
|
for key, value in updates.items():
|
|
118
120
|
if key == "verbose":
|
|
119
121
|
new_builder._verbose = value
|
|
122
|
+
elif key == "with_price":
|
|
123
|
+
new_builder._with_price = value
|
|
120
124
|
elif value is not None:
|
|
121
125
|
new_builder._params[key] = value
|
|
122
126
|
return new_builder
|
|
@@ -232,6 +236,11 @@ class QueryBuilder:
|
|
|
232
236
|
"""Include all metadata fields (tx_hash, tx_id, log_index, network, name)."""
|
|
233
237
|
return self._copy_with(verbose=enabled)
|
|
234
238
|
|
|
239
|
+
# Price enrichment
|
|
240
|
+
def with_price(self, enabled: bool = True) -> "QueryBuilder":
|
|
241
|
+
"""Enrich events with USD price data (adds ``price`` and ``value_usd`` columns)."""
|
|
242
|
+
return self._copy_with(with_price=enabled)
|
|
243
|
+
|
|
235
244
|
# Build final params
|
|
236
245
|
def _build_params(self) -> dict[str, Any]:
|
|
237
246
|
"""Build the final query parameters."""
|
|
@@ -240,6 +249,8 @@ class QueryBuilder:
|
|
|
240
249
|
_validate_mutual_exclusivity(params)
|
|
241
250
|
if self._verbose:
|
|
242
251
|
params["verbose"] = "true"
|
|
252
|
+
if self._with_price:
|
|
253
|
+
params["with_price"] = "true"
|
|
243
254
|
return params
|
|
244
255
|
|
|
245
256
|
# Terminal methods - execute the query
|
|
@@ -345,6 +356,7 @@ class QueryBuilder:
|
|
|
345
356
|
self._params.copy(),
|
|
346
357
|
)
|
|
347
358
|
builder._verbose = self._verbose
|
|
359
|
+
builder._with_price = self._with_price
|
|
348
360
|
builder._params["group_by"] = group_by
|
|
349
361
|
builder._params["period"] = period
|
|
350
362
|
return builder
|
|
@@ -365,9 +377,12 @@ class AggregateQueryBuilder(QueryBuilder):
|
|
|
365
377
|
"""Create a copy preserving aggregate builder type."""
|
|
366
378
|
new_builder = AggregateQueryBuilder(self._client, self._endpoint, self._params.copy())
|
|
367
379
|
new_builder._verbose = self._verbose
|
|
380
|
+
new_builder._with_price = self._with_price
|
|
368
381
|
for key, value in updates.items():
|
|
369
382
|
if key == "verbose":
|
|
370
383
|
new_builder._verbose = value
|
|
384
|
+
elif key == "with_price":
|
|
385
|
+
new_builder._with_price = value
|
|
371
386
|
elif value is not None:
|
|
372
387
|
new_builder._params[key] = value
|
|
373
388
|
return new_builder
|
|
@@ -449,14 +464,18 @@ class AsyncQueryBuilder:
|
|
|
449
464
|
self._endpoint = endpoint
|
|
450
465
|
self._params: dict[str, Any] = initial_params or {}
|
|
451
466
|
self._verbose = False
|
|
467
|
+
self._with_price = False
|
|
452
468
|
|
|
453
469
|
def _copy_with(self, **updates: Any) -> "AsyncQueryBuilder":
|
|
454
470
|
"""Create a copy with updated parameters."""
|
|
455
471
|
new_builder = AsyncQueryBuilder(self._client, self._endpoint, self._params.copy())
|
|
456
472
|
new_builder._verbose = self._verbose
|
|
473
|
+
new_builder._with_price = self._with_price
|
|
457
474
|
for key, value in updates.items():
|
|
458
475
|
if key == "verbose":
|
|
459
476
|
new_builder._verbose = value
|
|
477
|
+
elif key == "with_price":
|
|
478
|
+
new_builder._with_price = value
|
|
460
479
|
elif value is not None:
|
|
461
480
|
new_builder._params[key] = value
|
|
462
481
|
return new_builder
|
|
@@ -572,6 +591,11 @@ class AsyncQueryBuilder:
|
|
|
572
591
|
"""Include all metadata fields (tx_hash, tx_id, log_index, network, name)."""
|
|
573
592
|
return self._copy_with(verbose=enabled)
|
|
574
593
|
|
|
594
|
+
# Price enrichment
|
|
595
|
+
def with_price(self, enabled: bool = True) -> "AsyncQueryBuilder":
|
|
596
|
+
"""Enrich events with USD price data (adds ``price`` and ``value_usd`` columns)."""
|
|
597
|
+
return self._copy_with(with_price=enabled)
|
|
598
|
+
|
|
575
599
|
# Build final params
|
|
576
600
|
def _build_params(self) -> dict[str, Any]:
|
|
577
601
|
"""Build the final query parameters."""
|
|
@@ -580,6 +604,8 @@ class AsyncQueryBuilder:
|
|
|
580
604
|
_validate_mutual_exclusivity(params)
|
|
581
605
|
if self._verbose:
|
|
582
606
|
params["verbose"] = "true"
|
|
607
|
+
if self._with_price:
|
|
608
|
+
params["with_price"] = "true"
|
|
583
609
|
return params
|
|
584
610
|
|
|
585
611
|
# Terminal methods - execute the query (async)
|
|
@@ -685,6 +711,7 @@ class AsyncQueryBuilder:
|
|
|
685
711
|
self._params.copy(),
|
|
686
712
|
)
|
|
687
713
|
builder._verbose = self._verbose
|
|
714
|
+
builder._with_price = self._with_price
|
|
688
715
|
builder._params["group_by"] = group_by
|
|
689
716
|
builder._params["period"] = period
|
|
690
717
|
return builder
|
|
@@ -705,9 +732,12 @@ class AsyncAggregateQueryBuilder(AsyncQueryBuilder):
|
|
|
705
732
|
"""Create a copy preserving async aggregate builder type."""
|
|
706
733
|
new_builder = AsyncAggregateQueryBuilder(self._client, self._endpoint, self._params.copy())
|
|
707
734
|
new_builder._verbose = self._verbose
|
|
735
|
+
new_builder._with_price = self._with_price
|
|
708
736
|
for key, value in updates.items():
|
|
709
737
|
if key == "verbose":
|
|
710
738
|
new_builder._verbose = value
|
|
739
|
+
elif key == "with_price":
|
|
740
|
+
new_builder._with_price = value
|
|
711
741
|
elif value is not None:
|
|
712
742
|
new_builder._params[key] = value
|
|
713
743
|
return new_builder
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: defistream
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: Python client for the DeFiStream API
|
|
5
5
|
Project-URL: Homepage, https://defistream.dev
|
|
6
6
|
Project-URL: Documentation, https://docs.defistream.dev
|
|
@@ -337,6 +337,35 @@ df = (
|
|
|
337
337
|
)
|
|
338
338
|
```
|
|
339
339
|
|
|
340
|
+
### Price Enrichment
|
|
341
|
+
|
|
342
|
+
Use `.with_price()` to enrich events with USD price data. This adds `price` (unit price) and `value_usd` (amount × price) columns to individual events. On aggregate endpoints, it produces an `agg_value_usd` (sum) column.
|
|
343
|
+
|
|
344
|
+
Supported protocols: AAVE, Uniswap, Lido, Stader, ERC20, Native Token.
|
|
345
|
+
|
|
346
|
+
```python
|
|
347
|
+
# Individual events with price data
|
|
348
|
+
df = (
|
|
349
|
+
client.aave.deposits()
|
|
350
|
+
.network("ETH")
|
|
351
|
+
.block_range(21000000, 21010000)
|
|
352
|
+
.with_price()
|
|
353
|
+
.as_df()
|
|
354
|
+
)
|
|
355
|
+
# df now includes 'price' and 'value_usd' columns
|
|
356
|
+
|
|
357
|
+
# Aggregate with price — adds agg_value_usd column
|
|
358
|
+
df = (
|
|
359
|
+
client.aave.deposits()
|
|
360
|
+
.network("ETH")
|
|
361
|
+
.block_range(21000000, 21100000)
|
|
362
|
+
.with_price()
|
|
363
|
+
.aggregate(group_by="time", period="2h")
|
|
364
|
+
.as_df()
|
|
365
|
+
)
|
|
366
|
+
# df now includes 'agg_value_usd' column
|
|
367
|
+
```
|
|
368
|
+
|
|
340
369
|
### Return as DataFrame
|
|
341
370
|
|
|
342
371
|
```python
|
|
@@ -541,6 +570,7 @@ print(f"Request cost: {client.last_response.request_cost}")
|
|
|
541
570
|
| `.end_time(ts)` | Set ending time (ISO format or Unix timestamp) |
|
|
542
571
|
| `.time_range(start, end)` | Set both start and end times |
|
|
543
572
|
| `.verbose()` | Include all metadata fields |
|
|
573
|
+
| `.with_price()` | Enrich events with USD price data (`price` and `value_usd` columns) |
|
|
544
574
|
|
|
545
575
|
### Protocol-Specific Parameters
|
|
546
576
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
defistream/__init__.py,sha256=
|
|
1
|
+
defistream/__init__.py,sha256=VwTy9GK84IWHtxN-uHBtbN1c5ecw_u9hEsD0vQ4_MpE,1224
|
|
2
2
|
defistream/client.py,sha256=OZsaa7kgDxWCS37geoTGlp-IFaO3Kn8bm1ghNE9tqB4,13973
|
|
3
3
|
defistream/exceptions.py,sha256=_GxZQ18_YvXFtmNHeddWV8fHPIllHgFeP7fP0CmHF1k,1492
|
|
4
4
|
defistream/models.py,sha256=Zw3DHAISxB6pivKybNzyHXR5IcRwvTZl23DHbjfyKwM,622
|
|
5
5
|
defistream/protocols.py,sha256=lVWtFnZwjyyVjH_9glvFDxVs-bpHlFLXEyIEbEAKN1Q,16174
|
|
6
6
|
defistream/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
defistream/query.py,sha256=
|
|
8
|
-
defistream-1.
|
|
9
|
-
defistream-1.
|
|
10
|
-
defistream-1.
|
|
11
|
-
defistream-1.
|
|
7
|
+
defistream/query.py,sha256=vcQ7rvsODZued0ZIqq497cP82nHpuK0GL6Bq0dCJ0bE,31916
|
|
8
|
+
defistream-1.4.1.dist-info/METADATA,sha256=J-A1KXDNOOqokVd1TW2AbZE0yWHaRYjdKt7GAKkHxIU,16752
|
|
9
|
+
defistream-1.4.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
10
|
+
defistream-1.4.1.dist-info/licenses/LICENSE,sha256=72DWAof8dMePfFQmfaswClW5d-sE6k7p-7VpuSKLmU4,1067
|
|
11
|
+
defistream-1.4.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|