abstract-math 0.0.0.13__py3-none-any.whl → 0.0.0.15__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.
- abstract_math/derive_tokens.py +0 -13
- abstract_math/safe_math.py +79 -32
- abstract_math-0.0.0.15.dist-info/METADATA +47 -0
- abstract_math-0.0.0.15.dist-info/RECORD +8 -0
- {abstract_math-0.0.0.13.dist-info → abstract_math-0.0.0.15.dist-info}/WHEEL +1 -1
- {abstract_math-0.0.0.13.dist-info → abstract_math-0.0.0.15.dist-info}/top_level.txt +0 -0
- abstract_math-0.0.0.13.dist-info/METADATA +0 -20
- abstract_math-0.0.0.13.dist-info/RECORD +0 -8
abstract_math/derive_tokens.py
CHANGED
|
@@ -94,16 +94,3 @@ def update_token_variables(variables):
|
|
|
94
94
|
variables = derive_token_decimals_from_token_variables(**variables)
|
|
95
95
|
variables['tokenAmountUi'] = get_token_amount_ui(**variables)
|
|
96
96
|
return variables
|
|
97
|
-
def get_liq():
|
|
98
|
-
# get the liquidity and sqrt of price
|
|
99
|
-
pool_contract = web3.eth.contract(address=pool_address, abi=v3_pool_abi)
|
|
100
|
-
slot0 = pool_contract.functions.slot0().call()
|
|
101
|
-
sqrt_price_x96 = slot0[0]
|
|
102
|
-
liquidity = pool_contract.functions.liquidity().call()
|
|
103
|
-
|
|
104
|
-
# compute the virtual reserves
|
|
105
|
-
Q96 = 2 ** 96
|
|
106
|
-
Q192 = 2 ** 192
|
|
107
|
-
reserve0_x96 = liquidity * Q192 / sqrt_price_x96
|
|
108
|
-
reserve1_x96 = liquidity * sqrt_price_x96
|
|
109
|
-
token_decimals = math.log10((int(data['virtualTokenReserves']["data"]) * (10**int(9) / (int(data['virtualSolReserves']["data"])) * (int(data['tokenAmount']["data"]) / int(data['solAmount']["data"])))))
|
abstract_math/safe_math.py
CHANGED
|
@@ -1,43 +1,90 @@
|
|
|
1
|
-
from abstract_utilities import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
def exponential(value,exp=9,num=-1):
|
|
5
|
-
return multiply_it(value,exp_it(10,exp,num))
|
|
1
|
+
from abstract_utilities import is_number
|
|
2
|
+
from functools import reduce
|
|
3
|
+
import operator
|
|
6
4
|
|
|
7
5
|
def return_0(*args):
|
|
6
|
+
"""Return True if *any* arg is “falsy” (None, non-number, or zero‐like)."""
|
|
8
7
|
for arg in args:
|
|
9
|
-
if arg
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
def exp_it(number,integer,mul):
|
|
13
|
-
if return_0(number,integer,mul)==float(0):
|
|
14
|
-
return float(0)
|
|
15
|
-
return float(number)**float(float(integer)*int(mul))
|
|
8
|
+
if arg is None or not is_number(arg) or str(arg).strip().lower() in ('0', '', 'null'):
|
|
9
|
+
return True
|
|
10
|
+
return False
|
|
16
11
|
|
|
17
|
-
def
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
def gather_0(*args):
|
|
13
|
+
"""Convert any “falsy” arg into float(0), leave others alone."""
|
|
14
|
+
cleaned = []
|
|
15
|
+
for arg in args:
|
|
16
|
+
if arg is None or not is_number(arg) or str(arg).strip().lower() in ('0', '', 'null'):
|
|
17
|
+
cleaned.append(0.0)
|
|
18
|
+
else:
|
|
19
|
+
cleaned.append(float(arg))
|
|
20
|
+
return cleaned
|
|
21
|
+
|
|
22
|
+
def add_it(*args):
|
|
23
|
+
"""Sum together any number of args, treating bad values as 0."""
|
|
24
|
+
nums = gather_0(*args)
|
|
25
|
+
return float(sum(nums))
|
|
26
|
+
|
|
27
|
+
def multiply_it(*args):
|
|
28
|
+
"""Multiply any number of args, but return 0 if any input is ‘bad’ or zero-like."""
|
|
29
|
+
nums = gather_0(*args)
|
|
30
|
+
if any(n == 0.0 for n in nums):
|
|
31
|
+
return 0.0
|
|
32
|
+
return float(reduce(operator.mul, nums, 1.0))
|
|
33
|
+
|
|
34
|
+
def divide_it(*args):
|
|
35
|
+
"""
|
|
36
|
+
Divide args[0] by args[1] by args[2]…
|
|
37
|
+
If any input is bad or you hit a zero‐division, return 0.
|
|
38
|
+
"""
|
|
39
|
+
nums = gather_0(*args)
|
|
40
|
+
try:
|
|
41
|
+
return float(reduce(operator.truediv, nums))
|
|
42
|
+
except ZeroDivisionError:
|
|
43
|
+
return 0.0
|
|
21
44
|
|
|
22
|
-
def
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return
|
|
45
|
+
def floor_divide_it(*args):
|
|
46
|
+
"""
|
|
47
|
+
Floor‐divide args[0] by args[1] by args[2]…
|
|
48
|
+
If any input is bad or you hit a zero‐division, return 0.
|
|
49
|
+
"""
|
|
50
|
+
nums = gather_0(*args)
|
|
51
|
+
try:
|
|
52
|
+
return float(reduce(operator.floordiv, nums))
|
|
53
|
+
except ZeroDivisionError:
|
|
54
|
+
return 0.0
|
|
26
55
|
|
|
27
|
-
def
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
56
|
+
def subtract_it(*args):
|
|
57
|
+
"""
|
|
58
|
+
Subtract all subsequent args from the first:
|
|
59
|
+
args[0] - args[1] - args[2] - …
|
|
60
|
+
Bad values become 0.
|
|
61
|
+
"""
|
|
62
|
+
nums = gather_0(*args)
|
|
63
|
+
if not nums:
|
|
64
|
+
return 0.0
|
|
65
|
+
return float(reduce(operator.sub, nums))
|
|
31
66
|
|
|
32
|
-
def
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
67
|
+
def exp_it(base, *factors):
|
|
68
|
+
"""
|
|
69
|
+
Raise `base` to the power of (product of all `factors`).
|
|
70
|
+
e.g. exp_it(10, 2, 3) → 10**(2*3) == 10**6
|
|
71
|
+
Bad values become 0 (and so the result is 0).
|
|
72
|
+
"""
|
|
73
|
+
nums = gather_0(base, *factors)
|
|
74
|
+
b, *f = nums
|
|
75
|
+
if return_0(*nums) or not f:
|
|
76
|
+
return 0.0
|
|
77
|
+
exponent = reduce(operator.mul, f, 1.0)
|
|
78
|
+
return float(b) ** exponent
|
|
36
79
|
|
|
37
|
-
def
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
80
|
+
def exponential(value, *exp_factors):
|
|
81
|
+
"""
|
|
82
|
+
Multiply `value` by 10 to the power of (product of exp_factors).
|
|
83
|
+
e.g. exponential(5, 2, 3) → 5 * (10**(2*3)) == 5 * 1_000_000
|
|
84
|
+
If you give no exp_factors, it just returns value.
|
|
85
|
+
"""
|
|
86
|
+
power = exp_it(10, *exp_factors) or 1.0
|
|
87
|
+
return multiply_it(value, power)
|
|
41
88
|
|
|
42
89
|
def get_proper_args(strings,*args,**kwargs):
|
|
43
90
|
properArgs = []
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: abstract_math
|
|
3
|
+
Version: 0.0.0.15
|
|
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
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
abstract_math/__init__.py,sha256=3I0YJakDUyWD7qXpdRsaEsmcA7IxwcWhoyecvDfOE98,54
|
|
2
|
+
abstract_math/derive_tokens.py,sha256=Ba2hq3-W3NPmfko-Lf-58HfkBtl4kfN-GFuSZJMyiWM,4233
|
|
3
|
+
abstract_math/deriveit.py,sha256=Og8QtDGRrgGbmaHTh-jEusg35jUpb74DgzslsxZ_2iU,4271
|
|
4
|
+
abstract_math/safe_math.py,sha256=Rt5STOAuRRKhV1-YNfhX-OlhwVgRpk6XdN74UjnHvRc,5394
|
|
5
|
+
abstract_math-0.0.0.15.dist-info/METADATA,sha256=EbxF2NusfTsxKEggOOsfpW-4Nyd7fXh_Z9pll8Yg4Oc,1150
|
|
6
|
+
abstract_math-0.0.0.15.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
7
|
+
abstract_math-0.0.0.15.dist-info/top_level.txt,sha256=b7jOgD9c0U-CGH-l7yxhMPukzD40kMEQkQRV_sGyVfE,14
|
|
8
|
+
abstract_math-0.0.0.15.dist-info/RECORD,,
|
|
File without changes
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.2
|
|
2
|
-
Name: abstract_math
|
|
3
|
-
Version: 0.0.0.13
|
|
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
|
-
Safe math for delicate Processes, paralell in use case to SafeMath For SmartContracts in that it is designed to circumvent fatal errors for low level MDAS.
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
abstract_math/__init__.py,sha256=3I0YJakDUyWD7qXpdRsaEsmcA7IxwcWhoyecvDfOE98,54
|
|
2
|
-
abstract_math/derive_tokens.py,sha256=L0EgzKhu406B-cUxcpPxfKp3T0mzmYWoZMP6yZAFOd0,4887
|
|
3
|
-
abstract_math/deriveit.py,sha256=Og8QtDGRrgGbmaHTh-jEusg35jUpb74DgzslsxZ_2iU,4271
|
|
4
|
-
abstract_math/safe_math.py,sha256=wDWiZzgjymhZbpy3431fgQpetLn1WmiRo9_pP2YpRj8,4110
|
|
5
|
-
abstract_math-0.0.0.13.dist-info/METADATA,sha256=tvCbv_D8YLBvsVaSLwsmo3Fyuvq5hdjyCaYTCtWiTsU,718
|
|
6
|
-
abstract_math-0.0.0.13.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
7
|
-
abstract_math-0.0.0.13.dist-info/top_level.txt,sha256=b7jOgD9c0U-CGH-l7yxhMPukzD40kMEQkQRV_sGyVfE,14
|
|
8
|
-
abstract_math-0.0.0.13.dist-info/RECORD,,
|