abstract-math 0.0.0.18__py3-none-any.whl → 0.0.0.20__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.

Potentially problematic release.


This version of abstract-math might be problematic. Click here for more details.

@@ -1,18 +1,18 @@
1
1
  from decimal import Decimal, getcontext
2
2
  from .safe_math import *
3
3
 
4
- # Set high precision for decimal operations
4
+ # High precision for decimal ops
5
5
  getcontext().prec = 50
6
6
 
7
- # Constants for SOL decimal places and lamports conversion
7
+ # SOL constants
8
8
  SOL_DECIMAL_PLACE = 9
9
- SOL_LAMPORTS = sol_lamports = int(exponential(1, SOL_DECIMAL_PLACE, 1))
9
+ # lamports per SOL = 10**9
10
+ SOL_LAMPORTS = sol_lamports = int(exponential(1, exp=SOL_DECIMAL_PLACE, num=1))
10
11
 
11
12
 
12
13
  def get_proper_args(strings, *args, **kwargs):
13
14
  """
14
- Extracts values from kwargs based on the provided keys (strings). If not present in kwargs,
15
- falls back to positional args in order.
15
+ Extract values for keys in `strings` from kwargs; if missing, pull from positional args in order.
16
16
  """
17
17
  properArgs = []
18
18
  for key in strings:
@@ -23,25 +23,26 @@ def get_proper_args(strings, *args, **kwargs):
23
23
  properArgs.append(kwarg)
24
24
  return properArgs
25
25
 
26
- # Lamports calculations
27
26
 
28
- def get_lamports(integer):
27
+ # ---------- Lamports helpers ----------
28
+ def get_lamports(integer: int):
29
29
  """
30
- Given an integer representing SOL, returns lamports (10^(digits_in_integer+1)).
30
+ Convert an integer N to 10^(len(str(N)) + 1).
31
+ NOTE: this is your original behavior, not 10**9 unless N is 1 with exp=9.
31
32
  """
32
33
  return exp_it(10, len(str(integer)) + 1, 1)
33
34
 
34
35
 
35
- def get_lamport_difference(lamports, virtual_lamports):
36
+ def get_lamport_difference(lamports: int, virtual_lamports: int):
36
37
  """
37
- Compares actual lamports to virtual lamports and returns the corresponding exponent-based difference.
38
+ Compare 'lamports' vs 'virtual_lamports' and return 10^(len(str(int(virtual/actual))))
38
39
  """
39
40
  integer = int(virtual_lamports / lamports)
40
41
  exp = len(str(integer))
41
42
  return int(exponential(1, exp, 1))
42
43
 
43
- # Virtual reserves and ratios
44
44
 
45
+ # ---------- Virtual reserves / ratios ----------
45
46
  def get_vitual_reserves(*args, **kwargs):
46
47
  return get_proper_args(["virtualSolReserves", "virtualTokenReserves"], *args, **kwargs)
47
48
 
@@ -50,8 +51,8 @@ def get_virtual_reserve_ratio(*args, **kwargs):
50
51
  sol_res, token_res = get_vitual_reserves(*args, **kwargs)
51
52
  return divide_it(sol_res, token_res)
52
53
 
53
- # SOL-specific calculations
54
54
 
55
+ # ---------- SOL-specific ----------
55
56
  def get_virtual_sol_reservs(*args, **kwargs):
56
57
  reserves = get_proper_args(["virtualSolReserves"], *args, **kwargs)
57
58
  return reserves[0] if reserves else None
@@ -66,7 +67,6 @@ def get_virtual_sol_lamp_difference(*args, **kwargs):
66
67
  v_lam = get_virtual_sol_lamports(*args, **kwargs)
67
68
  return get_lamport_difference(SOL_LAMPORTS, v_lam)
68
69
 
69
- # SOL amount conversions
70
70
 
71
71
  def get_sol_amount(*args, **kwargs):
72
72
  amounts = get_proper_args(["solAmount"], *args, **kwargs)
@@ -77,8 +77,8 @@ def getSolAmountUi(*args, **kwargs):
77
77
  sol_amt = get_sol_amount(*args, **kwargs)
78
78
  return exponential(sol_amt, SOL_DECIMAL_PLACE)
79
79
 
80
- # Token-specific calculations
81
80
 
81
+ # ---------- Token-specific ----------
82
82
  def get_virtual_token_reserves(*args, **kwargs):
83
83
  reserves = get_proper_args(["virtualTokenReserves"], *args, **kwargs)
84
84
  return reserves[0] if reserves else None
@@ -94,22 +94,10 @@ def get_token_amount(*args, **kwargs):
94
94
  return amounts[0] if amounts else None
95
95
 
96
96
 
97
- def get_token_amount_ui(*args, **kwargs):
98
- token_amt = get_token_amount(*args, **kwargs)
99
- token_decimals = derive_decimals_from_vars(*args, **kwargs)
100
- return exponential(token_amt, token_decimals)
101
-
102
-
103
- def derive_token_decimals_from_token_variables(**variables):
104
- variables["price"] = get_price(**variables)
105
- variables["tokenDecimals"] = derive_decimals_from_vars(**variables)
106
- return variables
107
-
108
-
109
- def get_derived_token_ratio(*args, **kwargs):
110
- derived_amt = derive_token_amount(*args, **kwargs)
111
- token_amt = get_token_amount(*args, **kwargs)
112
- return divide_it(derived_amt, token_amt)
97
+ def get_price(*args, **kwargs):
98
+ reserve_ratio = get_virtual_reserve_ratio(*args, **kwargs)
99
+ sol_diff = get_virtual_sol_lamp_difference(*args, **kwargs)
100
+ return divide_it(reserve_ratio, sol_diff)
113
101
 
114
102
 
115
103
  def derive_token_amount(*args, **kwargs):
@@ -118,22 +106,35 @@ def derive_token_amount(*args, **kwargs):
118
106
  return divide_it(token_res, price)
119
107
 
120
108
 
121
- def get_price(*args, **kwargs):
122
- reserve_ratio = get_virtual_reserve_ratio(*args, **kwargs)
123
- sol_diff = get_virtual_sol_lamp_difference(*args, **kwargs)
124
- return divide_it(reserve_ratio, sol_diff)
109
+ def get_derived_token_ratio(*args, **kwargs):
110
+ derived_amt = derive_token_amount(*args, **kwargs)
111
+ token_amt = get_token_amount(*args, **kwargs)
112
+ return divide_it(derived_amt, token_amt)
125
113
 
126
114
 
127
115
  def derive_decimals_from_vars(*args, **kwargs):
128
116
  ratio = get_derived_token_ratio(*args, **kwargs)
129
117
  decimals = -1
118
+ # Count how many decimal places are needed to make ratio an integer (<= 1e-9 tolerance)
130
119
  while abs(ratio - round(ratio)) > 1e-9:
131
120
  ratio *= 10
132
121
  decimals += 1
133
122
  return decimals
134
123
 
135
124
 
136
- def update_token_variables(variables):
125
+ def get_token_amount_ui(*args, **kwargs):
126
+ token_amt = get_token_amount(*args, **kwargs)
127
+ token_decimals = derive_decimals_from_vars(*args, **kwargs)
128
+ return exponential(token_amt, token_decimals)
129
+
130
+
131
+ def derive_token_decimals_from_token_variables(**variables):
132
+ variables["price"] = get_price(**variables)
133
+ variables["tokenDecimals"] = derive_decimals_from_vars(**variables)
134
+ return variables
135
+
136
+
137
+ def update_token_variables(variables: dict):
137
138
  variables['solAmountUi'] = getSolAmountUi(**variables)
138
139
  variables['solDecimals'] = SOL_DECIMAL_PLACE
139
140
  variables = derive_token_decimals_from_token_variables(**variables)
@@ -1 +0,0 @@
1
- from flask_utils import *
@@ -1,6 +1,23 @@
1
- from abstract_utilities import is_number
2
- from functools import reduce
3
- import operator
1
+ from abstract_utilities import *
2
+ import math
3
+ #math functions ------------------------------------------------------------------------------------------------------
4
+ def exponential(value,exp=9,num=-1):
5
+ return multiply_it(value,exp_it(10,exp,num))
6
+
7
+ def add_it(number_1,number_2):
8
+ if return_0(number_1,number_2)==float(0):
9
+ return float(0)
10
+ return float(number_1)+float(number_2)
11
+
12
+ def subtract_it(number_1,number_2):
13
+ if return_0(number_1,number_2)==float(0):
14
+ return float(0)
15
+ return float(number_1)-float(number_2)
16
+
17
+ def get_percentage(owner_balance,address_balance):
18
+ retained_div = divide_it(owner_balance,address_balance)
19
+ retained_mul = multiply_it(retained_div,100)
20
+ return round(retained_mul,2)
4
21
 
5
22
  def return_0(*args):
6
23
  """Return True if *any* arg is “falsy” (None, non-number, or zero‐like)."""
@@ -1,5 +1,5 @@
1
1
  import math
2
2
  from typing import Dict, Callable, Optional, Any
3
- from abstract_math import (
3
+ from ....safe_math import (
4
4
  multiply_it as mul, divide_it as div, add_it as add, subtract_it as sub, exp_it as exp
5
5
  )
@@ -1,5 +1,4 @@
1
1
  # src/utils/escape_velocity.py
2
-
3
2
  from ..imports import math, mul, div, add
4
3
  from ..constants.planet_constants import get_body
5
4
  from ..constants.distance_constants import convert as dconvert
@@ -0,0 +1,81 @@
1
+ Metadata-Version: 2.4
2
+ Name: abstract_math
3
+ Version: 0.0.0.20
4
+ Author: putkoff
5
+ Author-email: partners@abstractendeavors.com
6
+ Classifier: Development Status :: 3 - Alpha
7
+ Classifier: Intended Audience :: Developers
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Requires-Python: >=3.6
12
+ Description-Content-Type: text/markdown
13
+ Dynamic: author
14
+ Dynamic: author-email
15
+ Dynamic: classifier
16
+ Dynamic: description
17
+ Dynamic: description-content-type
18
+ Dynamic: requires-python
19
+
20
+ # abstract_math
21
+
22
+ ## Description
23
+ The abstract_math Python module, currently in its Alpha development stage (version 0.0.0.14), is designed for performing complex mathematical operations and token manipulations. This module comprises primarily of two scripts: `safe_math` and `derive_tokens`.
24
+
25
+ ## Features
26
+ - Performing complex mathematical operations.
27
+ - Manipulation and derivation of mathematical tokens, referred to as 'lamports'.
28
+ - High precision for decimal calculations for better accuracy.
29
+ - Functions for deriving quantities like lamports, virtual reserves, sol reserves, sol amounts, token reserves, token amounts, derived token ratio, price, and token decimals.
30
+ - Module components for updating Sol and token variables.
31
+
32
+ ## Scripts Overview
33
+
34
+ - `derive_tokens.py`: This script is involved in the complex manipulation or derivation of mathematical tokens, referred to as 'lamports'. The functions defined in this script handle various aspects of token manipulations and calculations.
35
+
36
+
37
+ ## Installation
38
+ To install the abstract_math module, ensure that your Python version is 3.6 or later. This module currently does not have any external dependencies to be installed.
39
+
40
+ ## Usage
41
+ This module could potentially be used as a framework for handling complex mathematical operations or token manipulations. Developers interested in working with and enhancing this module can access the source code at the repository (provide repo link here).
42
+
43
+ ## Dependencies
44
+ Currently, the module does not require any external dependencies.
45
+
46
+ ## License
47
+ The module is provided under the MIT License.
48
+
49
+ ## Author & Contact
50
+ This Python module was authored by 'putkoff', who can be reached at partners@abstractendeavors.com for further queries or assistance.
51
+
52
+ ## Contributing
53
+ Contributions are welcome to help in the development of the abstract_math module, particularly with the 'safe_math' and 'derive_tokens' scripts that form the core of the module.
54
+ # Unknown Package (vUnknown Version)
55
+
56
+ No description available
57
+
58
+ ## Installation
59
+
60
+ ```bash
61
+ pip install Unknown Package
62
+ ```
63
+
64
+ ## Dependencies
65
+
66
+ None
67
+
68
+ ## Modules
69
+
70
+ ### src/abstract_math/safe_math.py
71
+
72
+ Description of script based on prompt: You are analyzing a Python script 'safe_math.py' l (mock response)
73
+
74
+ ### src/abstract_math/__init__.py
75
+
76
+ Description of script based on prompt: You are analyzing a Python script '__init__.py' lo (mock response)
77
+
78
+ ### src/abstract_math/derive_tokens.py
79
+
80
+ Description of script based on prompt: You are analyzing a Python script 'derive_tokens.p (mock response)
81
+
@@ -1,23 +1,22 @@
1
1
  abstract_math/__init__.py,sha256=wr-kwaB8micSsR1nCHuDXRlsL59DWlqZQFN7M_rfZys,80
2
- abstract_math/derive_tokens.py,sha256=0rHanu6-UweOXxVuPn-DQsbUn7Xaoz39TQJiWDe7K5Q,4382
3
- abstract_math/safe_math.py,sha256=Rt5STOAuRRKhV1-YNfhX-OlhwVgRpk6XdN74UjnHvRc,5394
4
- abstract_math/flask_scripts/__init__.py,sha256=En366EX8hQ7FRsh_8hgjrgHFAQkkVi72wFcpSiOxz-s,26
2
+ abstract_math/derive_tokens.py,sha256=jEd82Z5jiG-Gsv3TwLVq39-mCehgyt5emvpte91Dk7g,4497
3
+ abstract_math/safe_math.py,sha256=dZzxR2glwmzYKD0YlNaxOTYAg_ZNKYhDSVu7KRVIbjk,6047
4
+ abstract_math/flask_scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  abstract_math/flask_scripts/flask_utils.py,sha256=z6gpPshiOeqNANBQkZMZPkegCzj-GK3OpSOi1lN19Sc,28483
6
- abstract_math/flask_scripts/make_flask.py,sha256=6c7Vt_iSTDf_bhmBkK5E-GIiHGbhkwHl_B_79C3BTZY,104
7
6
  abstract_math/solar_math/__init__.py,sha256=FfPkmWi3cQ3BLvUUUf6k22rGBE8scDL1EoM5l24biVo,39
8
7
  abstract_math/solar_math/flask_utils.py,sha256=c82LrZ0dKC3Y8LxqOs1zDR6gRy8oXSx9balBD18gNB0,459
9
8
  abstract_math/solar_math/main.py,sha256=EtcUmUWj27c7mcnm-hlfeCeYFuPytPevXx5vClVu6Q8,10000
10
9
  abstract_math/solar_math/src/__init__.py,sha256=qeal73F-NLu6sO_YSmD_komVpe17f0OFy2IfBR2QU_s,70
11
- abstract_math/solar_math/src/imports.py,sha256=U2wY9NwbzarE6IXrIRpPbRV2e42V3cX8HS8f_80CZ7I,182
10
+ abstract_math/solar_math/src/imports.py,sha256=GfkWfXDc6fzLe7kHYlSdghkN0Nob0xApxhEyRyDcZS0,182
12
11
  abstract_math/solar_math/src/constants/__init__.py,sha256=HpRa4MWkJZu3Wcx6KchB8__RL4FfkVqRw78TAnjRRwo,691
13
12
  abstract_math/solar_math/src/constants/distance_constants.py,sha256=stM3nWxpANQEtoxFcbxpO0ly_UM4JJ2aH0VK42fHw6s,1985
14
13
  abstract_math/solar_math/src/constants/planet_constants.py,sha256=tt2nbFtRtYhUU9D918WK91D-S5Cv0HEJ-1j7f9Yb50w,6602
15
14
  abstract_math/solar_math/src/constants/time_constants.py,sha256=uVDMldwjJqKwXzHcAb-Z8QM20JrxSwLXlogjD_SXwRo,1874
16
15
  abstract_math/solar_math/src/utils/__init__.py,sha256=Vb2bfx1p9YSmhnbqXBjGVPt1OQZ9I7PG_fMQdFqj-3k,91
17
- abstract_math/solar_math/src/utils/escape_velocity.py,sha256=K_t6q5kO0jJjkhWfIpTJlfJCLBneYh0LKf3FwQf0ye4,2972
16
+ abstract_math/solar_math/src/utils/escape_velocity.py,sha256=9oixNxWyY4pxa7e1INwbreD8GJEw2BZIgV_IqXiDd9Y,2971
18
17
  abstract_math/solar_math/src/utils/geometry_utils.py,sha256=Ij4mASNFp2-CWy425fxMTEuMPuAZHs-E0qvi3BjaNkk,4169
19
18
  abstract_math/solar_math/src/utils/velocity_utils.py,sha256=_SyOscVvYsvbm1T1Rh4uqegXdf61mHll5s3UfQcdUnU,1162
20
- abstract_math-0.0.0.18.dist-info/METADATA,sha256=tb1dh0iK-jG-yHIQerV-P6E2Kwoqt7VsXvT-C59YhN0,1150
21
- abstract_math-0.0.0.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
- abstract_math-0.0.0.18.dist-info/top_level.txt,sha256=b7jOgD9c0U-CGH-l7yxhMPukzD40kMEQkQRV_sGyVfE,14
23
- abstract_math-0.0.0.18.dist-info/RECORD,,
19
+ abstract_math-0.0.0.20.dist-info/METADATA,sha256=nwFpUGpHZFDq9GYmCnFrX4yHFvJxUpVEs0d6XJb_9zg,3081
20
+ abstract_math-0.0.0.20.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
21
+ abstract_math-0.0.0.20.dist-info/top_level.txt,sha256=b7jOgD9c0U-CGH-l7yxhMPukzD40kMEQkQRV_sGyVfE,14
22
+ abstract_math-0.0.0.20.dist-info/RECORD,,
@@ -1 +0,0 @@
1
- /home/computron/Documents/pythonTools/modules/abstract_math/src/abstract_math/solar_math/flask_utils.py
@@ -1,47 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: abstract_math
3
- Version: 0.0.0.18
4
- Author: putkoff
5
- Author-email: partners@abstractendeavors.com
6
- Classifier: Development Status :: 3 - Alpha
7
- Classifier: Intended Audience :: Developers
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Programming Language :: Python :: 3.11
11
- Requires-Python: >=3.6
12
- Description-Content-Type: text/markdown
13
- Dynamic: author
14
- Dynamic: author-email
15
- Dynamic: classifier
16
- Dynamic: description
17
- Dynamic: description-content-type
18
- Dynamic: requires-python
19
-
20
- # Unknown Package (vUnknown Version)
21
-
22
- No description available
23
-
24
- ## Installation
25
-
26
- ```bash
27
- pip install Unknown Package
28
- ```
29
-
30
- ## Dependencies
31
-
32
- None
33
-
34
- ## Modules
35
-
36
- ### src/abstract_math/safe_math.py
37
-
38
- Description of script based on prompt: You are analyzing a Python script 'safe_math.py' l (mock response)
39
-
40
- ### src/abstract_math/__init__.py
41
-
42
- Description of script based on prompt: You are analyzing a Python script '__init__.py' lo (mock response)
43
-
44
- ### src/abstract_math/derive_tokens.py
45
-
46
- Description of script based on prompt: You are analyzing a Python script 'derive_tokens.p (mock response)
47
-