strideutils 0.7.4__tar.gz → 0.7.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 (41) hide show
  1. {strideutils-0.7.4 → strideutils-0.7.6}/.bumpversion.cfg +1 -1
  2. {strideutils-0.7.4 → strideutils-0.7.6}/PKG-INFO +1 -1
  3. {strideutils-0.7.4 → strideutils-0.7.6}/pyproject.toml +1 -1
  4. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils/redis_connector.py +44 -13
  5. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils/stride_requests.py +1 -25
  6. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils.egg-info/PKG-INFO +1 -1
  7. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils.egg-info/SOURCES.txt +0 -1
  8. strideutils-0.7.4/strideutils/stride_upstash.py +0 -134
  9. {strideutils-0.7.4 → strideutils-0.7.6}/.github/workflows/lint.yml +0 -0
  10. {strideutils-0.7.4 → strideutils-0.7.6}/.github/workflows/publish.yml +0 -0
  11. {strideutils-0.7.4 → strideutils-0.7.6}/.github/workflows/test.yml +0 -0
  12. {strideutils-0.7.4 → strideutils-0.7.6}/.github/workflows/version.yaml +0 -0
  13. {strideutils-0.7.4 → strideutils-0.7.6}/.gitignore +0 -0
  14. {strideutils-0.7.4 → strideutils-0.7.6}/LICENSE +0 -0
  15. {strideutils-0.7.4 → strideutils-0.7.6}/Makefile +0 -0
  16. {strideutils-0.7.4 → strideutils-0.7.6}/README.md +0 -0
  17. {strideutils-0.7.4 → strideutils-0.7.6}/setup.cfg +0 -0
  18. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils/Makefile +0 -0
  19. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils/__init__.py +0 -0
  20. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils/coingecko.py +0 -0
  21. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils/config_examples/env.local.example +0 -0
  22. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils/config_examples/strideutils_config.yaml.example +0 -0
  23. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils/cryptography.py +0 -0
  24. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils/exec_tx.py +0 -0
  25. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils/invariant_helpers.py +0 -0
  26. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils/run_safely.py +0 -0
  27. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils/sheets_connector.py +0 -0
  28. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils/slack_connector.py +0 -0
  29. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils/stride_alerts.py +0 -0
  30. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils/stride_config.py +0 -0
  31. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils/twilio_connector.py +0 -0
  32. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils/types.py +0 -0
  33. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils.egg-info/dependency_links.txt +0 -0
  34. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils.egg-info/requires.txt +0 -0
  35. {strideutils-0.7.4 → strideutils-0.7.6}/strideutils.egg-info/top_level.txt +0 -0
  36. {strideutils-0.7.4 → strideutils-0.7.6}/tests/test_config.py +0 -0
  37. {strideutils-0.7.4 → strideutils-0.7.6}/tests/test_encryption.py +0 -0
  38. {strideutils-0.7.4 → strideutils-0.7.6}/tests/test_redis_connector.py +0 -0
  39. {strideutils-0.7.4 → strideutils-0.7.6}/tests/test_sheets_connector.py +0 -0
  40. {strideutils-0.7.4 → strideutils-0.7.6}/tests/test_slack_connector.py +0 -0
  41. {strideutils-0.7.4 → strideutils-0.7.6}/tests/test_twilio_connector.py +0 -0
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.7.4
2
+ current_version = 0.7.6
3
3
  commit = False
4
4
  tag = False
5
5
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strideutils
3
- Version: 0.7.4
3
+ Version: 0.7.6
4
4
  Summary: Utility functions for monitoring the Stride blockchain
5
5
  Author-email: Stride Labs <hello@stridelabs.co>
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "strideutils"
7
- version = "0.7.4"
7
+ version = "0.7.6"
8
8
  authors = [
9
9
  {name = "Stride Labs", email = "hello@stridelabs.co"},
10
10
  ]
@@ -14,22 +14,44 @@ import redis
14
14
  from strideutils.stride_config import Environment as e
15
15
  from strideutils.stride_config import get_env_or_raise
16
16
 
17
+ # TODO: Remove and use from environment variables
18
+ DATABASE_HOSTS = {
19
+ "public": "usw1-certain-beagle-33773.upstash.io",
20
+ "frontend": "usw1-hot-bat-33320.upstash.io",
21
+ "backend": "usw1-mutual-mule-33971.upstash.io",
22
+ "dydx": "us1-diverse-dog-39216.upstash.io",
23
+ "dydx_airdrop": "pleasant-pipefish-54904.upstash.io",
24
+ "saga_airdrop": "super-gnu-55216.upstash.io",
25
+ "milestones": "adapting-snail-56076.upstash.io",
26
+ }
27
+
28
+ # TODO: Remove and use from environment variables
29
+ DATABASE_PORTS = {
30
+ "public": 33773,
31
+ "frontend": 33320,
32
+ "backend": 33971,
33
+ "dydx": 39216,
34
+ "dydx_airdrop": 6379,
35
+ "saga_airdrop": 6379,
36
+ "milestones": 6379,
37
+ }
38
+
17
39
  DATABASE_ENVIRONMENT_CONFIGS = {
18
- 'public': (e.UPSTASH_PUBLIC_HOST, e.UPSTASH_PUBLIC_PORT, e.UPSTASH_PUBLIC_PASSWORD),
19
- 'frontend': (e.UPSTASH_STRIDE_FRONTEND_HOST, e.UPSTASH_STRIDE_FRONTEND_PORT, e.UPSTASH_STRIDE_FRONTEND_PASSWORD),
20
- 'backend': (e.UPSTASH_STRIDE_BACKEND_HOST, e.UPSTASH_STRIDE_BACKEND_PORT, e.UPSTASH_STRIDE_BACKEND_PASSWORD),
21
- 'dydx': (e.UPSTASH_STRIDE_DYDX_HOST, e.UPSTASH_STRIDE_DYDX_PORT, e.UPSTASH_STRIDE_DYDX_PASSWORD),
22
- 'dydx_airdrop': (
40
+ "public": (e.UPSTASH_PUBLIC_HOST, e.UPSTASH_PUBLIC_PORT, e.UPSTASH_PUBLIC_PASSWORD),
41
+ "frontend": (e.UPSTASH_STRIDE_FRONTEND_HOST, e.UPSTASH_STRIDE_FRONTEND_PORT, e.UPSTASH_STRIDE_FRONTEND_PASSWORD),
42
+ "backend": (e.UPSTASH_STRIDE_BACKEND_HOST, e.UPSTASH_STRIDE_BACKEND_PORT, e.UPSTASH_STRIDE_BACKEND_PASSWORD),
43
+ "dydx": (e.UPSTASH_STRIDE_DYDX_HOST, e.UPSTASH_STRIDE_DYDX_PORT, e.UPSTASH_STRIDE_DYDX_PASSWORD),
44
+ "dydx_airdrop": (
23
45
  e.UPSTASH_STRIDE_DYDX_AIRDROP_HOST,
24
46
  e.UPSTASH_STRIDE_DYDX_AIRDROP_PORT,
25
47
  e.UPSTASH_STRIDE_DYDX_AIRDROP_PASSWORD,
26
48
  ),
27
- 'saga_airdrop': (
49
+ "saga_airdrop": (
28
50
  e.UPSTASH_STRIDE_SAGA_AIRDROP_HOST,
29
51
  e.UPSTASH_STRIDE_SAGA_AIRDROP_PORT,
30
52
  e.UPSTASH_STRIDE_SAGA_AIRDROP_PASSWORD,
31
53
  ),
32
- 'milestones': (
54
+ "milestones": (
33
55
  e.UPSTASH_STRIDE_MILESTONES_HOST,
34
56
  e.UPSTASH_STRIDE_MILESTONES_PORT,
35
57
  e.UPSTASH_STRIDE_MILESTONES_PASSWORD,
@@ -90,14 +112,23 @@ class RedisClient:
90
112
  Returns:
91
113
  redis.Redis: Initialized Redis client.
92
114
  """
93
- host_env, port_env, password_env = DATABASE_ENVIRONMENT_CONFIGS[database_name]
115
+ # TODO: Use host and port from environment variables
116
+ _, _, password_env = DATABASE_ENVIRONMENT_CONFIGS[database_name]
117
+ host = DATABASE_ENVIRONMENT_CONFIGS.get(database_name)
118
+ port = DATABASE_ENVIRONMENT_CONFIGS.get(database_name)
119
+ password = get_env_or_raise(password_env)
120
+
121
+ if not host or not port:
122
+ raise ValueError(f"Host or port not known for database {database_name}")
123
+
94
124
  db_config = {
95
- 'host': get_env_or_raise(host_env),
96
- 'port': int(get_env_or_raise(port_env)),
97
- 'password': get_env_or_raise(password_env),
98
- 'ssl': True,
99
- 'decode_responses': True,
125
+ "host": host,
126
+ "port": port,
127
+ "password": password,
128
+ "ssl": True,
129
+ "decode_responses": True,
100
130
  }
131
+
101
132
  return redis.Redis(**db_config)
102
133
 
103
134
  def get_db(self, name: Optional[str] = None) -> redis.Redis:
@@ -12,7 +12,7 @@ import pytz
12
12
  import requests
13
13
  from requests.adapters import HTTPAdapter, Retry
14
14
 
15
- from strideutils import stride_upstash, types
15
+ from strideutils import types
16
16
  from strideutils.stride_config import config
17
17
 
18
18
  ACCOUNT_QUERY = "cosmos/auth/v1beta1/accounts/{address}"
@@ -914,17 +914,6 @@ def get_block_height_one_day_ago() -> int:
914
914
  return get_block_height_in_past(target_time_offset=datetime.timedelta(hours=24))
915
915
 
916
916
 
917
- def get_sttoken_apr(token: str) -> Optional[float]:
918
- """
919
- Gets the APR of an stToken by querying upstash
920
- e.g. get_sttoken_apr('ATOM') will return roughly 0.19
921
- """
922
- apr = stride_upstash.get("STTOKEN_APR_" + token.upper(), db_name="public")
923
- if apr is None:
924
- raise ValueError("sttoken apr not found")
925
- return float(cast(str, apr))
926
-
927
-
928
917
  def get_unbonding_tokens_on_address(
929
918
  delegator_address: str,
930
919
  api_endpoint: str = config.stride.api_endpoint,
@@ -1227,19 +1216,6 @@ def get_module_accounts(api_endpoint: str = config.stride.api_endpoint) -> List[
1227
1216
  return request(f"{api_endpoint}/{MODULE_ACCOUNTS_QUERY}")["accounts"]
1228
1217
 
1229
1218
 
1230
- def get_empirical_annual_fees(ticker: str) -> float:
1231
- """
1232
- Returns the empirical annual fee, in dollars, that Stride collects for a given stToken.
1233
-
1234
- For example:
1235
- get_empirical_annual_fees("ATOM") == 1005994.0745893999
1236
- """
1237
- empirical_dollar_fees = (
1238
- stride_upstash.get("sheet_STRD_STAKING_ST{}_DOLLARS".format(ticker.upper()), db_name="frontend") or "0"
1239
- )
1240
- return float(cast(str, empirical_dollar_fees))
1241
-
1242
-
1243
1219
  def query_evm_method(method: str, params: list[str], rpc_endpoint: str) -> str:
1244
1220
  """
1245
1221
  Generic querier for evm contract calls
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strideutils
3
- Version: 0.7.4
3
+ Version: 0.7.6
4
4
  Summary: Utility functions for monitoring the Stride blockchain
5
5
  Author-email: Stride Labs <hello@stridelabs.co>
6
6
  License: MIT License
@@ -21,7 +21,6 @@ strideutils/slack_connector.py
21
21
  strideutils/stride_alerts.py
22
22
  strideutils/stride_config.py
23
23
  strideutils/stride_requests.py
24
- strideutils/stride_upstash.py
25
24
  strideutils/twilio_connector.py
26
25
  strideutils/types.py
27
26
  strideutils.egg-info/PKG-INFO
@@ -1,134 +0,0 @@
1
- from typing import Dict, List, Optional
2
-
3
- import redis
4
-
5
- from strideutils.stride_config import config
6
-
7
- redis_dbs = {} # stores the redis dbs so we don't have to keep reconnecting
8
-
9
-
10
- def get_redis_db(redis_db_name: str) -> redis.Redis:
11
- """
12
- Returns the redis db specified by redis_db_name.
13
-
14
- Currently supports 'public', 'frontend', and 'backend' dbs.
15
- """
16
- if redis_db_name not in redis_dbs:
17
- if redis_db_name == 'public':
18
- r = redis.Redis(
19
- host='usw1-certain-beagle-33773.upstash.io',
20
- port=33773,
21
- password=config.UPSTASH_PUBLIC_PASSWORD,
22
- )
23
-
24
- elif redis_db_name == 'frontend':
25
- r = redis.Redis(
26
- host='usw1-hot-bat-33320.upstash.io',
27
- port=33320,
28
- password=config.UPSTASH_STRIDE_FRONTEND_PASSWORD,
29
- ssl=True,
30
- )
31
-
32
- elif redis_db_name == 'backend':
33
- r = redis.Redis(
34
- host='usw1-mutual-mule-33971.upstash.io',
35
- port=33971,
36
- password=config.UPSTASH_STRIDE_BACKEND_PASSWORD,
37
- ssl=True,
38
- )
39
- elif redis_db_name == 'dydx':
40
- r = redis.Redis(
41
- host='us1-diverse-dog-39216.upstash.io',
42
- port=39216,
43
- password=config.UPSTASH_STRIDE_DYDX_PUBLIC_PASSWORD,
44
- ssl=True,
45
- )
46
- elif redis_db_name == 'dydx_airdrop':
47
- r = redis.Redis(
48
- host='pleasant-pipefish-54904.upstash.io',
49
- port=6379,
50
- password=config.UPSTASH_STRIDE_DYDX_AIRDROP_PASSWORD,
51
- ssl=True,
52
- )
53
- elif redis_db_name == 'saga_airdrop':
54
- r = redis.Redis(
55
- host='super-gnu-55216.upstash.io',
56
- port=6379,
57
- password='AdewAAIjcDE5YjhhNjg3ZmIxMWQ0YTEwYmNlMzgwNzA5ODZmN2FhZnAxMA',
58
- ssl=True,
59
- )
60
- elif redis_db_name == "milestones":
61
- r = redis.Redis(
62
- host='adapting-snail-56076.upstash.io',
63
- port=6379,
64
- password=config.UPSTASH_STRIDE_MILESTONES_PASSWORD,
65
- ssl=True,
66
- )
67
- else:
68
- raise ValueError(f'Invalid Redis DB: {redis_db_name}')
69
-
70
- redis_dbs[redis_db_name] = r
71
-
72
- return redis_dbs[redis_db_name]
73
-
74
-
75
- def get(redis_key: str, db_name='frontend') -> Optional[str]:
76
- """
77
- This function will read the given Redis key and return the value.
78
-
79
- Pulls from the specified redis db.
80
- """
81
- db = get_redis_db(db_name)
82
- value = db.get(redis_key)
83
-
84
- return value.decode('utf-8') if value is not None else None
85
-
86
-
87
- def get_multiple_keys(redis_keys: List[str], db_name='frontend') -> List[Optional[str]]:
88
- """
89
- This function will read multiple keys in at once.
90
- Value will be "None" if the key does not exist.
91
-
92
- Pulls from the specified redis db.
93
- """
94
- db = get_redis_db(db_name)
95
- values = db.mget(redis_keys)
96
-
97
- return [value.decode('utf-8') if value is not None else None for value in values]
98
-
99
-
100
- def get_all_keys(db_name='dydx_airdrop') -> List[str]:
101
- """
102
- This function will return all keys in the redis db specified.
103
- """
104
- db = get_redis_db(db_name)
105
-
106
- out = []
107
-
108
- cursor = '0'
109
- while cursor != 0:
110
- cursor, keys = db.scan(cursor, count=1000)
111
- if keys:
112
- out.extend(keys)
113
- return [key.decode('utf-8') for key in out]
114
-
115
-
116
- def set(redis_key: str, redis_val: str, db_name='frontend'):
117
- """
118
- This function will set the given key to value in the redis_db specified.
119
- """
120
- db = get_redis_db(db_name)
121
- db.set(redis_key, redis_val)
122
-
123
-
124
- def set_keys(dict_to_upload: Dict[str, str], db_name='frontend', prefix=''):
125
- """
126
- Loops through all values in dict_to_upload and sets the keys+values in the redis db
127
-
128
- Will append "prefix" to all keys in the dict.
129
- """
130
- db = get_redis_db(db_name)
131
- pipe = db.pipeline()
132
- for k, v in dict_to_upload.items():
133
- pipe.set(prefix + k, v)
134
- pipe.execute()
File without changes
File without changes
File without changes
File without changes
File without changes