strideutils 0.3.4__tar.gz → 0.3.6__tar.gz

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.
Files changed (33) hide show
  1. {strideutils-0.3.4 → strideutils-0.3.6}/PKG-INFO +2 -4
  2. {strideutils-0.3.4 → strideutils-0.3.6}/pyproject.toml +2 -2
  3. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils/stride_requests.py +61 -4
  4. {strideutils-0.3.4 → strideutils-0.3.6}/README.md +0 -0
  5. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils/Makefile +0 -0
  6. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils/__init__.py +0 -0
  7. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils/coingecko.py +0 -0
  8. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils/config_examples/strideutils_config.yaml.example +0 -0
  9. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils/config_examples/strideutils_secrets.yaml.example +0 -0
  10. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils/cryptography.py +0 -0
  11. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils/exec_tx.py +0 -0
  12. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils/invariant_helpers.py +0 -0
  13. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils/run_safely.py +0 -0
  14. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils/sheets_connector.py +0 -0
  15. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils/slack_connector.py +0 -0
  16. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils/stride_alerts.py +0 -0
  17. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils/stride_config.py +0 -0
  18. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils/stride_upstash.py +0 -0
  19. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils/twilio_connector.py +0 -0
  20. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils/types.py +0 -0
  21. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils-stubs/__init__.pyi +0 -0
  22. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils-stubs/coingecko.pyi +0 -0
  23. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils-stubs/cryptography.pyi +0 -0
  24. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils-stubs/exec_tx.pyi +0 -0
  25. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils-stubs/invariant_helpers.pyi +0 -0
  26. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils-stubs/run_safely.pyi +0 -0
  27. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils-stubs/sheets_connector.pyi +0 -0
  28. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils-stubs/slack_connector.pyi +0 -0
  29. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils-stubs/stride_alerts.pyi +0 -0
  30. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils-stubs/stride_config.pyi +0 -0
  31. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils-stubs/stride_requests.pyi +0 -0
  32. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils-stubs/stride_upstash.pyi +0 -0
  33. {strideutils-0.3.4 → strideutils-0.3.6}/strideutils-stubs/twilio_connector.pyi +0 -0
@@ -1,13 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strideutils
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary:
5
5
  Author: Your Name
6
6
  Author-email: you@example.com
7
- Requires-Python: >=3.9
7
+ Requires-Python: >=3.11
8
8
  Classifier: Programming Language :: Python :: 3
9
- Classifier: Programming Language :: Python :: 3.9
10
- Classifier: Programming Language :: Python :: 3.10
11
9
  Classifier: Programming Language :: Python :: 3.11
12
10
  Classifier: Programming Language :: Python :: 3.12
13
11
  Requires-Dist: bech32 (>=1.2.0)
@@ -1,13 +1,13 @@
1
1
  [tool.poetry]
2
2
  name = "strideutils"
3
- version = "0.3.4"
3
+ version = "0.3.6"
4
4
  description = ""
5
5
  authors = ["Your Name <you@example.com>"]
6
6
  readme = "README.md"
7
7
  include = ["strideutils", "strideutils-stubs"]
8
8
 
9
9
  [tool.poetry.dependencies]
10
- python = ">=3.9"
10
+ python = ">=3.11"
11
11
  google-api-python-client = ">=2.100.0"
12
12
  google-auth-httplib2 = ">=0.1.1"
13
13
  google-auth-oauthlib = ">=1.1.0"
@@ -7,7 +7,6 @@ from functools import lru_cache
7
7
  from typing import Any, Dict, List, Optional, Tuple, Union, cast
8
8
 
9
9
  import bech32
10
- import dateutil.parser
11
10
  import pandas as pd
12
11
  import pytz
13
12
  import requests
@@ -289,6 +288,7 @@ def get_unbonding_records(
289
288
  E.g.
290
289
  [
291
290
  {
291
+ "epoch_number": "575",
292
292
  "st_token_amount": "3218590",
293
293
  "native_token_amount": "0",
294
294
  "denom": "ucmdx",
@@ -313,17 +313,74 @@ def get_unbonding_records(
313
313
  # This function returns the host zone unbonding record
314
314
  host_zone_unbondings = []
315
315
  for epoch_unbonding in epoch_unbondings:
316
+ epoch_number = epoch_unbonding["epoch_number"]
316
317
  for host_zone_unbonding in epoch_unbonding["host_zone_unbondings"]:
317
318
 
318
319
  chain_id_match = host_zone_unbonding["host_zone_id"] == chain_id
319
320
  status_match = not status or host_zone_unbonding["status"] == status
320
321
 
321
322
  if chain_id_match and status_match:
323
+ host_zone_unbonding["epoch_number"] = epoch_number
322
324
  host_zone_unbondings.append(host_zone_unbonding)
323
325
 
324
326
  return host_zone_unbondings
325
327
 
326
328
 
329
+ def get_unbonding_queue_records(chain_id: str, block_height: int = 0) -> List[Dict[str, Any]]:
330
+ """
331
+ Queries all the unbonding records that are ready to initiate an unbonding
332
+ This is identified by records in status UNBONDING_QUEUE with a non-zero unbonding amount
333
+ """
334
+ unbonding_records = get_unbonding_records(
335
+ chain_id=chain_id,
336
+ block_height=block_height,
337
+ status=types.UnbondingRecordStatus.UNBONDING_QUEUE,
338
+ )
339
+ return [ur for ur in unbonding_records if int(ur["native_token_amount"]) > 0]
340
+
341
+
342
+ def get_unbonded_records(
343
+ chain_id: str,
344
+ block_height: int = 0,
345
+ filter_unbonded_last_epoch: bool = False,
346
+ ) -> List[Dict[str, Any]]:
347
+ """
348
+ Queries the list of all unbonding records records that have finished unbonding
349
+ This is identified by records in status EXIT_TRANSFER_QUEUE with an unbonding time
350
+ in the past
351
+ Optionally filter to records that just unbonded last epoch
352
+ """
353
+ unbonding_records = get_unbonding_records(
354
+ chain_id=chain_id,
355
+ block_height=block_height,
356
+ status=types.UnbondingRecordStatus.EXIT_TRANSFER_QUEUE,
357
+ )
358
+
359
+ # If we're fetching an older block, use that block's time as the "current time"
360
+ current_time = int(datetime.datetime.now().timestamp() * 1e9)
361
+ if block_height != 0:
362
+ current_time = int(get_block_time(block_height).timestamp() * 1e9)
363
+
364
+ # Filter to the records that have finished unbonding, and optionally also
365
+ # filter to records that just finished during the last epoch
366
+ day = 24 * 60 * 60 * 1e9
367
+ filtered_unbonding_records = []
368
+ for unbonding_record in unbonding_records:
369
+ unbonding_time = int(unbonding_record["unbonding_time"])
370
+
371
+ # Ignore records that haven't finished unbonding yet
372
+ if unbonding_time > current_time:
373
+ continue
374
+
375
+ # If filtering from last epoch, ignore records that unbonded over a day ago
376
+ if filter_unbonded_last_epoch and (current_time - unbonding_time) > day:
377
+ continue
378
+
379
+ filtered_unbonding_records.append(unbonding_record)
380
+
381
+ return filtered_unbonding_records
382
+
383
+
327
384
  def get_lsm_deposit_records(chain_id: str) -> List[Dict[str, Any]]:
328
385
  """
329
386
  Queries all the LSM deposit records
@@ -627,7 +684,7 @@ def get_block_time(height: int, rpc_endpoint: str = config.stride.rpc_endpoint)
627
684
  url = f"{rpc_endpoint}/block?height={height}"
628
685
  resp = request(url)
629
686
  block_time = resp["result"]["block"]["header"]["time"]
630
- block_datetime = dateutil.parser.parse(block_time).replace(tzinfo=None)
687
+ block_datetime = datetime.datetime.fromisoformat(block_time)
631
688
  return block_datetime
632
689
 
633
690
 
@@ -1027,7 +1084,7 @@ def get_stride_epoch_start_time() -> datetime.datetime:
1027
1084
  Returns the epoch start time for the current "stride" epoch
1028
1085
  """
1029
1086
  stride_epoch = get_stride_epoch()
1030
- return dateutil.parser.parse(stride_epoch["current_epoch_start_time"]).replace(tzinfo=None)
1087
+ return datetime.datetime.fromisoformat(stride_epoch["current_epoch_start_time"])
1031
1088
 
1032
1089
 
1033
1090
  def get_day_epoch_start_time() -> datetime.datetime:
@@ -1035,7 +1092,7 @@ def get_day_epoch_start_time() -> datetime.datetime:
1035
1092
  Returns the epoch start time for the current "day" epoch
1036
1093
  """
1037
1094
  day_epoch = get_day_epoch()
1038
- return dateutil.parser.parse(day_epoch["current_epoch_start_time"]).replace(tzinfo=None)
1095
+ return datetime.datetime.fromisoformat(day_epoch["current_epoch_start_time"])
1039
1096
 
1040
1097
 
1041
1098
  def get_stride_epoch_start_height() -> int:
File without changes