abstract-math 0.0.0.1__tar.gz → 0.0.0.2__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.
Potentially problematic release.
This version of abstract-math might be problematic. Click here for more details.
- {abstract_math-0.0.0.1 → abstract_math-0.0.0.2}/PKG-INFO +1 -1
- {abstract_math-0.0.0.1 → abstract_math-0.0.0.2}/README.md +0 -0
- abstract_math-0.0.0.2/pyproject.toml +3 -0
- {abstract_math-0.0.0.1 → abstract_math-0.0.0.2}/setup.py +26 -26
- abstract_math-0.0.0.2/src/abstract_math/__init__.py +2 -0
- abstract_math-0.0.0.2/src/abstract_math/deriveit.py +97 -0
- abstract_math-0.0.0.2/src/abstract_math/safe_math.py +100 -0
- {abstract_math-0.0.0.1 → abstract_math-0.0.0.2}/src/abstract_math.egg-info/PKG-INFO +1 -1
- {abstract_math-0.0.0.1 → abstract_math-0.0.0.2}/src/abstract_math.egg-info/SOURCES.txt +2 -0
- {abstract_math-0.0.0.1 → abstract_math-0.0.0.2}/src/abstract_math.egg-info/dependency_links.txt +0 -0
- {abstract_math-0.0.0.1 → abstract_math-0.0.0.2}/src/abstract_math.egg-info/top_level.txt +0 -0
- abstract_math-0.0.0.1/src/abstract_math/__init__.py +0 -1
- abstract_math-0.0.0.1/src/abstract_math/safe_math.py +0 -33
- {abstract_math-0.0.0.1 → abstract_math-0.0.0.2}/setup.cfg +0 -0
|
File without changes
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
from time import time
|
|
2
|
-
import setuptools
|
|
3
|
-
with open("README.md", "r", encoding="utf-8") as fh:
|
|
4
|
-
long_description = fh.read()
|
|
5
|
-
setuptools.setup(
|
|
6
|
-
name='abstract_math',
|
|
7
|
-
version='0.0.0.
|
|
8
|
-
author='putkoff',
|
|
9
|
-
author_email='partners@abstractendeavors.com',
|
|
10
|
-
description="",
|
|
11
|
-
long_description=long_description,
|
|
12
|
-
long_description_content_type='text/markdown',
|
|
13
|
-
classifiers=[
|
|
14
|
-
'Development Status :: 3 - Alpha',
|
|
15
|
-
'Intended Audience :: Developers',
|
|
16
|
-
'License :: OSI Approved :: MIT License',
|
|
17
|
-
'Programming Language :: Python :: 3',
|
|
18
|
-
'Programming Language :: Python :: 3.11',
|
|
19
|
-
],
|
|
20
|
-
install_requires=[],
|
|
21
|
-
package_dir={"": "src"},
|
|
22
|
-
packages=setuptools.find_packages(where="src"),
|
|
23
|
-
python_requires=">=3.6",
|
|
24
|
-
# Add this line to include wheel format in your distribution
|
|
25
|
-
setup_requires=['wheel'],
|
|
26
|
-
)
|
|
1
|
+
from time import time
|
|
2
|
+
import setuptools
|
|
3
|
+
with open("README.md", "r", encoding="utf-8") as fh:
|
|
4
|
+
long_description = fh.read()
|
|
5
|
+
setuptools.setup(
|
|
6
|
+
name='abstract_math',
|
|
7
|
+
version='0.0.0.02',
|
|
8
|
+
author='putkoff',
|
|
9
|
+
author_email='partners@abstractendeavors.com',
|
|
10
|
+
description="",
|
|
11
|
+
long_description=long_description,
|
|
12
|
+
long_description_content_type='text/markdown',
|
|
13
|
+
classifiers=[
|
|
14
|
+
'Development Status :: 3 - Alpha',
|
|
15
|
+
'Intended Audience :: Developers',
|
|
16
|
+
'License :: OSI Approved :: MIT License',
|
|
17
|
+
'Programming Language :: Python :: 3',
|
|
18
|
+
'Programming Language :: Python :: 3.11',
|
|
19
|
+
],
|
|
20
|
+
install_requires=[],
|
|
21
|
+
package_dir={"": "src"},
|
|
22
|
+
packages=setuptools.find_packages(where="src"),
|
|
23
|
+
python_requires=">=3.6",
|
|
24
|
+
# Add this line to include wheel format in your distribution
|
|
25
|
+
setup_requires=['wheel'],
|
|
26
|
+
)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
from decimal import Decimal, getcontext
|
|
2
|
+
from .safe_math import *
|
|
3
|
+
getcontext().prec = 50 # High precision for accuracy
|
|
4
|
+
SOL_DECIMAL_PLACE = 9
|
|
5
|
+
SOL_LAMPORTS = sol_lamports =int(exponential(1,exp=SOL_DECIMAL_PLACE,num=1))
|
|
6
|
+
def get_proper_args(strings,*args,**kwargs):
|
|
7
|
+
properArgs = []
|
|
8
|
+
for key in strings:
|
|
9
|
+
kwarg = kwargs.get(key)
|
|
10
|
+
if kwarg == None and args:
|
|
11
|
+
kwarg = args[0]
|
|
12
|
+
args = [] if len(args) == 1 else args[1:]
|
|
13
|
+
properArgs.append(kwarg)
|
|
14
|
+
return properArgs
|
|
15
|
+
|
|
16
|
+
#lamports
|
|
17
|
+
def get_lamports(integer):
|
|
18
|
+
return exp_it(10,len(str(integer))+1,1)
|
|
19
|
+
def get_lamport_difference(lamports,virtual_lamports):
|
|
20
|
+
integer = int(virtual_lamports/lamports)
|
|
21
|
+
exponential = len(str(integer))
|
|
22
|
+
return int(exponential(1,exp=exponential,num=1))
|
|
23
|
+
#virtual reserves
|
|
24
|
+
def get_vitual_reserves(*args,**kwargs):
|
|
25
|
+
proper_args = get_proper_args(["virtualSolReserves","virtualTokenReserves"],*args,**kwargs)
|
|
26
|
+
return proper_args
|
|
27
|
+
def get_virtual_reserve_ratio(*ars,**kwargs):
|
|
28
|
+
proper_args = get_vitual_reserves(*args,**kwargs)
|
|
29
|
+
return divide_it(*proper_args)
|
|
30
|
+
#sol reserves
|
|
31
|
+
def get_virtual_sol_reservs(*args,**kwargs):
|
|
32
|
+
proper_args = get_proper_args(["virtualSolReserves"],*args,**kwargs)
|
|
33
|
+
return proper_args[0] if proper_args else proper_args
|
|
34
|
+
def get_virtual_sol_lamports(*args,**kwargs):
|
|
35
|
+
virtual_sol_reserves = get_virtual_sol_reservs(*args,**kwargs)
|
|
36
|
+
virtual_sol_lamports = get_lamports(virtual_sol_reserves)
|
|
37
|
+
return virtual_sol_lamports
|
|
38
|
+
def get_virtual_sol_lamp_difference(*args,**kwargs):
|
|
39
|
+
virtual_sol_lamports = get_virtual_sol_lamports(*args,**kwargs)
|
|
40
|
+
return get_lamport_difference(SOL_LAMPORTS,virtual_sol_lamports)
|
|
41
|
+
#sol Amount
|
|
42
|
+
def get_sol_amount(*args,**kwargs):
|
|
43
|
+
proper_args = get_proper_args(["solAmount"],*args,**kwargs)
|
|
44
|
+
return proper_args[0] if proper_args else proper_args
|
|
45
|
+
def getSolAmountUi(*args,**kwargs):
|
|
46
|
+
sol_amount = get_sol_amount(*args,**kwargs)
|
|
47
|
+
return exponential(sol_amount,SOL_DECIMAL_PLACE)
|
|
48
|
+
#token reserves
|
|
49
|
+
def get_virtual_token_reservs(*args,**kwargs):
|
|
50
|
+
proper_args = get_proper_args(["virtualTokenReserves"],*args,**kwargs)
|
|
51
|
+
return proper_args[0] if proper_args else proper_args
|
|
52
|
+
def get_virtual_token_lamports(*args,**kwargs):
|
|
53
|
+
virtual_token_reserves = get_virtual_token_reservs(*args,**kwargs)
|
|
54
|
+
virtual_token_lamports = get_lamports(virtual_token_reserves)
|
|
55
|
+
return virtual_token_lamports
|
|
56
|
+
#token amount
|
|
57
|
+
def get_token_amount(*args,**kwargs):
|
|
58
|
+
proper_args = get_proper_args(["tokenAmount"],*args,**kwargs)
|
|
59
|
+
return proper_args[0] if proper_args else proper_args
|
|
60
|
+
def get_token_amount_ui(*args,**kwargs):
|
|
61
|
+
token_amount = get_token_amount(*args,**kwargs)
|
|
62
|
+
token_decimals = derive_token_decimals(*args,**kwargs)
|
|
63
|
+
return exponential(token_amount,exp=token_decimals)
|
|
64
|
+
#token derivision
|
|
65
|
+
def derive_token_decimals_from_token_variables(variables):
|
|
66
|
+
variables["price"] = get_price(**variables)
|
|
67
|
+
variables["tokenDecimals"] = derive_decimals_from_vars(*args,**kwargs)
|
|
68
|
+
return variables
|
|
69
|
+
def get_derived_token_ratio(*args,**kwarg):
|
|
70
|
+
derived_token_amount = derive_token_amount(*args,**kwargs)
|
|
71
|
+
token_amount = get_token_amount(*args,**kwargs)
|
|
72
|
+
ratio = divide_it(derived_token_amount,token_amount)
|
|
73
|
+
return ratio
|
|
74
|
+
def derive_token_amount(*args,**kwargs):
|
|
75
|
+
virtual_token_reserves = get_virtual_token_reserves(*args,**kwargs)
|
|
76
|
+
price = get_price(*args,**kwargs)
|
|
77
|
+
derived_token_amount = divide_it(virtual_token_reserves,price)
|
|
78
|
+
return derived_token_amount
|
|
79
|
+
#derive variables
|
|
80
|
+
def get_price(*args,**kwargs):
|
|
81
|
+
reserve_ratios = get_virtual_reserve_ratio(*ars,**kwargs)
|
|
82
|
+
virtual_sol_lamp_difference = get_virtual_sol_lamp_difference(*args,**kwargs)
|
|
83
|
+
return reserve_ratios/virtual_sol_lamp_difference
|
|
84
|
+
def derive_decimals_from_vars(*args,**kwargs):
|
|
85
|
+
ratio = get_derived_token_ratio(*args,**kwarg)
|
|
86
|
+
decimals = -1
|
|
87
|
+
while abs(ratio - round(ratio)) > 1e-9:
|
|
88
|
+
ratio *= 10
|
|
89
|
+
decimals += 1
|
|
90
|
+
return decimals
|
|
91
|
+
def update_token_variables(variables):
|
|
92
|
+
variables['solAmountUi'] = getSolAmountUi(**variables)
|
|
93
|
+
variables['solDecimals'] = 9
|
|
94
|
+
variables = derive_token_decimals_from_token_variables(variables)
|
|
95
|
+
variables['tokenAmountUi'] = exponential(variables['tokenAmount'],variables["tokenDecimals"])
|
|
96
|
+
return variables
|
|
97
|
+
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
from abstract_utilities import *
|
|
2
|
+
#math functions ------------------------------------------------------------------------------------------------------
|
|
3
|
+
def exponential(value,exp=9,num=-1):
|
|
4
|
+
return multiply_it(value,exp_it(10,exp,num))
|
|
5
|
+
|
|
6
|
+
def return_0(*args):
|
|
7
|
+
for arg in args:
|
|
8
|
+
if arg == None or not is_number(arg) or arg in [0,'0','','null',' ']:
|
|
9
|
+
return float(0)
|
|
10
|
+
|
|
11
|
+
def exp_it(number,integer,mul):
|
|
12
|
+
if return_0(number,integer,mul)==float(0):
|
|
13
|
+
return float(0)
|
|
14
|
+
return float(number)**float(float(integer)*int(mul))
|
|
15
|
+
|
|
16
|
+
def divide_it(number_1,number_2):
|
|
17
|
+
if return_0(number_1,number_2)==float(0):
|
|
18
|
+
return float(0)
|
|
19
|
+
return float(number_1)/float(number_2)
|
|
20
|
+
|
|
21
|
+
def multiply_it(number_1,number_2):
|
|
22
|
+
if return_0(number_1,number_2)==float(0):
|
|
23
|
+
return float(0)
|
|
24
|
+
return float(number_1)*float(number_2)
|
|
25
|
+
|
|
26
|
+
def add_it(number_1,number_2):
|
|
27
|
+
if return_0(number_1,number_2)==float(0):
|
|
28
|
+
return float(0)
|
|
29
|
+
return float(number_1)+float(number_2)
|
|
30
|
+
|
|
31
|
+
def get_percentage(owner_balance,address_balance):
|
|
32
|
+
retained_div = divide_it(owner_balance,address_balance)
|
|
33
|
+
retained_mul = multiply_it(retained_div,100)
|
|
34
|
+
return round(retained_mul,2)
|
|
35
|
+
|
|
36
|
+
def get_proper_args(strings,*args,**kwargs):
|
|
37
|
+
properArgs = []
|
|
38
|
+
for key in strings:
|
|
39
|
+
kwarg = kwargs.get(key)
|
|
40
|
+
if kwarg == None and args:
|
|
41
|
+
kwarg = args[0]
|
|
42
|
+
args = [] if len(args) == 1 else args[1:]
|
|
43
|
+
properArgs.append(kwarg)
|
|
44
|
+
return properArgs
|
|
45
|
+
def get_lamp_difference(*args,**kwargs):
|
|
46
|
+
sol_lamports =int(exponential(1,exp=9,num=1))
|
|
47
|
+
proper_args = get_proper_args(["virtualSolReserves"],*args,**kwargs)
|
|
48
|
+
virtualLamports = len(str(proper_args[0]))
|
|
49
|
+
virtual_sol_lamports =int(exponential(1,exp=virtualLamports,num=1))
|
|
50
|
+
return int(exponential(1,exp=len(str(int(virtual_sol_lamports/sol_lamports))),num=1))
|
|
51
|
+
def get_price(*args,**kwargs):
|
|
52
|
+
proper_args = get_proper_args(["virtualSolReserves","virtualTokenReserves"],*args,**kwargs)
|
|
53
|
+
return divide_it(*proper_args)/get_lamp_difference(*args,**kwargs)
|
|
54
|
+
def get_amount_price(*args,**kwargs):
|
|
55
|
+
proper_args = get_proper_args(["solAmount","tokenAmount"],*args,**kwargs)
|
|
56
|
+
return divide_it(*proper_args)
|
|
57
|
+
def getSolAmountUi(*args,**kwargs):
|
|
58
|
+
proper_args = get_proper_args(["solAmount"],*args,**kwargs)
|
|
59
|
+
return exponential(proper_args[0],9)
|
|
60
|
+
def getTokenAmountUi(*args,**kwargs):
|
|
61
|
+
solAmountUi = getSolAmountUi(*args,**kwargs)
|
|
62
|
+
price = get_price(*args,**kwargs)
|
|
63
|
+
return solAmountUi/price
|
|
64
|
+
def derive_token_decimals(*args,**kwargs):
|
|
65
|
+
proper_args = get_proper_args(["virtualTokenReserves","tokenAmount"],*args,**kwargs)
|
|
66
|
+
price = get_price(*args,**kwargs)
|
|
67
|
+
if not (proper_args[1] > 0 and proper_args[0] > 0 and price > 0):
|
|
68
|
+
raise ValueError("All inputs must be positive.")
|
|
69
|
+
derived_token_amount = proper_args[0] / price
|
|
70
|
+
ratio = derived_token_amount / proper_args[1]
|
|
71
|
+
decimals = -1
|
|
72
|
+
while abs(ratio - round(ratio)) > 1e-9:
|
|
73
|
+
ratio *= 10
|
|
74
|
+
decimals += 1
|
|
75
|
+
return decimals
|
|
76
|
+
def derive_token_decimals_from_token_variables(variables):
|
|
77
|
+
variables["price"] = get_price(**variables)
|
|
78
|
+
derived_token_amount = variables["virtualTokenReserves"] / variables["price"]
|
|
79
|
+
ratio = derived_token_amount / variables["tokenAmount"]
|
|
80
|
+
decimals = -1
|
|
81
|
+
while abs(ratio - round(ratio)) > 1e-9:
|
|
82
|
+
ratio *= 10
|
|
83
|
+
decimals += 1
|
|
84
|
+
variables["tokenDecimals"] = decimals
|
|
85
|
+
return variables
|
|
86
|
+
def get_token_amount_ui(*args,**kwargs):
|
|
87
|
+
proper_args = get_proper_args(["tokenAmount"],*args,**kwargs)
|
|
88
|
+
return exponential(proper_args[0],exp=-derive_token_decimals(*args,**kwargs),num=1)
|
|
89
|
+
def update_token_variables(variables):
|
|
90
|
+
variables['solAmountUi'] = getSolAmountUi(**variables)
|
|
91
|
+
variables['solDecimals'] = 9
|
|
92
|
+
variables = derive_token_decimals_from_token_variables(variables)
|
|
93
|
+
variables['tokenAmountUi'] = exponential(variables['tokenAmount'],exp=-variables["tokenDecimals"],num=1)
|
|
94
|
+
return variables
|
|
95
|
+
variables = {"solAmount": 396000000,
|
|
96
|
+
"tokenAmount": 1627047727651,
|
|
97
|
+
"virtualSolReserves": 88711399815,
|
|
98
|
+
"virtualTokenReserves":362862046933704}
|
|
99
|
+
|
|
100
|
+
input(update_token_variables(variables))
|
{abstract_math-0.0.0.1 → abstract_math-0.0.0.2}/src/abstract_math.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .safe_math impoort *
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#math functions ------------------------------------------------------------------------------------------------------
|
|
2
|
-
def exponential(value,exp=9,num=-1):
|
|
3
|
-
return multiply_it(value,exp_it(10,exp,num))
|
|
4
|
-
|
|
5
|
-
def return_0(*args):
|
|
6
|
-
for arg in args:
|
|
7
|
-
if arg == None or not is_number(arg) or arg in [0,'0','','null',' ']:
|
|
8
|
-
return float(0)
|
|
9
|
-
|
|
10
|
-
def exp_it(number,integer,mul):
|
|
11
|
-
if return_0(number,integer,mul)==float(0):
|
|
12
|
-
return float(0)
|
|
13
|
-
return float(number)**float(float(integer)*int(mul))
|
|
14
|
-
|
|
15
|
-
def divide_it(number_1,number_2):
|
|
16
|
-
if return_0(number_1,number_2)==float(0):
|
|
17
|
-
return float(0)
|
|
18
|
-
return float(number_1)/float(number_2)
|
|
19
|
-
|
|
20
|
-
def multiply_it(number_1,number_2):
|
|
21
|
-
if return_0(number_1,number_2)==float(0):
|
|
22
|
-
return float(0)
|
|
23
|
-
return float(number_1)*float(number_2)
|
|
24
|
-
|
|
25
|
-
def add_it(number_1,number_2):
|
|
26
|
-
if return_0(number_1,number_2)==float(0):
|
|
27
|
-
return float(0)
|
|
28
|
-
return float(number_1)+float(number_2)
|
|
29
|
-
|
|
30
|
-
def get_percentage(owner_balance,address_balance):
|
|
31
|
-
retained_div = divide_it(owner_balance,address_balance)
|
|
32
|
-
retained_mul = multiply_it(retained_div,100)
|
|
33
|
-
return round(retained_mul,2)
|
|
File without changes
|