abstract-math 0.0.0.21__tar.gz → 0.0.0.23__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.21 → abstract_math-0.0.0.23}/PKG-INFO +1 -1
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/setup.py +1 -1
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/derive_tokens.py +2 -0
- abstract_math-0.0.0.23/src/abstract_math/safe_math.py +207 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/solar_math/src/imports.py +1 -1
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math.egg-info/PKG-INFO +1 -1
- abstract_math-0.0.0.21/src/abstract_math/safe_math.py +0 -163
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/README.md +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/pyproject.toml +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/setup.cfg +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/__init__.py +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/flask_scripts/__init__.py +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/flask_scripts/flask_utils.py +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/solar_math/__init__.py +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/solar_math/flask_utils.py +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/solar_math/main.py +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/solar_math/src/__init__.py +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/solar_math/src/constants/__init__.py +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/solar_math/src/constants/distance_constants.py +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/solar_math/src/constants/planet_constants.py +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/solar_math/src/constants/time_constants.py +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/solar_math/src/utils/__init__.py +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/solar_math/src/utils/escape_velocity.py +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/solar_math/src/utils/geometry_utils.py +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/solar_math/src/utils/velocity_utils.py +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math.egg-info/SOURCES.txt +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math.egg-info/dependency_links.txt +0 -0
- {abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
from abstract_utilities import *
|
|
2
|
+
import math
|
|
3
|
+
import operator
|
|
4
|
+
from functools import reduce
|
|
5
|
+
|
|
6
|
+
# -------------------------------
|
|
7
|
+
# Core numeric hygiene
|
|
8
|
+
# -------------------------------
|
|
9
|
+
def _is_bad(x):
|
|
10
|
+
return (x is None) or (not is_number(x)) or (str(x).strip().lower() in ('', 'null'))
|
|
11
|
+
|
|
12
|
+
def gather_0(*args):
|
|
13
|
+
"""Convert any bad / empty / 'null' to 0.0, keep others as float."""
|
|
14
|
+
out = []
|
|
15
|
+
for a in args:
|
|
16
|
+
out.append(0.0 if _is_bad(a) else float(a))
|
|
17
|
+
return out
|
|
18
|
+
|
|
19
|
+
# -------------------------------
|
|
20
|
+
# Basic ops (single definitions)
|
|
21
|
+
# -------------------------------
|
|
22
|
+
def add_it(*args):
|
|
23
|
+
"""Sum all args; bad values become 0."""
|
|
24
|
+
return float(sum(gather_0(*args)))
|
|
25
|
+
|
|
26
|
+
def subtract_it(*args):
|
|
27
|
+
"""a0 - a1 - a2 - ... ; bad values become 0."""
|
|
28
|
+
nums = gather_0(*args)
|
|
29
|
+
if not nums:
|
|
30
|
+
return 0.0
|
|
31
|
+
return float(reduce(operator.sub, nums))
|
|
32
|
+
|
|
33
|
+
def multiply_it(*args):
|
|
34
|
+
"""Multiply all args; if any becomes 0 (bad or literal zero), result is 0."""
|
|
35
|
+
nums = gather_0(*args)
|
|
36
|
+
if any(n == 0.0 for n in nums):
|
|
37
|
+
return 0.0
|
|
38
|
+
return float(reduce(operator.mul, nums, 1.0))
|
|
39
|
+
|
|
40
|
+
def divide_it(*args):
|
|
41
|
+
"""a0 / a1 / a2 / ... ; bad => 0, safe against ZeroDivisionError (returns 0)."""
|
|
42
|
+
nums = gather_0(*args)
|
|
43
|
+
try:
|
|
44
|
+
return float(reduce(operator.truediv, nums))
|
|
45
|
+
except ZeroDivisionError:
|
|
46
|
+
return 0.0
|
|
47
|
+
|
|
48
|
+
def floor_divide_it(*args):
|
|
49
|
+
"""a0 // a1 // a2 // ... ; bad => 0, safe against ZeroDivisionError (returns 0)."""
|
|
50
|
+
nums = gather_0(*args)
|
|
51
|
+
try:
|
|
52
|
+
return float(reduce(operator.floordiv, nums))
|
|
53
|
+
except ZeroDivisionError:
|
|
54
|
+
return 0.0
|
|
55
|
+
|
|
56
|
+
# -------------------------------
|
|
57
|
+
# Exponent helpers (deduplicated)
|
|
58
|
+
# -------------------------------
|
|
59
|
+
def exp_it(base, *factors):
|
|
60
|
+
"""
|
|
61
|
+
Raise `base` to the power of (product of all `factors`).
|
|
62
|
+
exp_it(10, 2, 3) -> 10 ** (2*3) == 10**6
|
|
63
|
+
If any input is bad or no factors given, returns 0.0 (consistent with other helpers).
|
|
64
|
+
"""
|
|
65
|
+
nums = gather_0(base, *factors)
|
|
66
|
+
b, *f = nums
|
|
67
|
+
if not f or any(n == 0.0 for n in nums):
|
|
68
|
+
return 0.0
|
|
69
|
+
exponent = float(reduce(operator.mul, f, 1.0))
|
|
70
|
+
return float(b) ** exponent
|
|
71
|
+
|
|
72
|
+
def pow10(exp):
|
|
73
|
+
"""10**exp with float output; bad exp -> 0.0^? -> return 1.0 (neutral for scaling)."""
|
|
74
|
+
if _is_bad(exp):
|
|
75
|
+
return 1.0
|
|
76
|
+
return 10.0 ** float(exp)
|
|
77
|
+
|
|
78
|
+
def scale_pow10(value, exp):
|
|
79
|
+
"""Scale value by 10**exp. Neutral if exp is bad."""
|
|
80
|
+
return multiply_it(value, pow10(exp))
|
|
81
|
+
|
|
82
|
+
# Canonical public API for “multiply by 10^…”:
|
|
83
|
+
def exponential(value, *exp_factors):
|
|
84
|
+
"""
|
|
85
|
+
Multiply `value` by 10 ** (product(exp_factors)).
|
|
86
|
+
exponential(5, 2, 3) -> 5 * 10**(2*3) == 5e6
|
|
87
|
+
If no exp_factors are given, returns value.
|
|
88
|
+
"""
|
|
89
|
+
if not exp_factors:
|
|
90
|
+
return float(value) if not _is_bad(value) else 0.0
|
|
91
|
+
exp_prod = multiply_it(*exp_factors)
|
|
92
|
+
if exp_prod == 0.0 and all(not _is_bad(x) for x in exp_factors):
|
|
93
|
+
# valid inputs produced 0 exponent => scale by 1
|
|
94
|
+
return float(value) if not _is_bad(value) else 0.0
|
|
95
|
+
return scale_pow10(value, exp_prod)
|
|
96
|
+
|
|
97
|
+
# Back-compat alias for legacy callers:
|
|
98
|
+
def exponentials(value, exp=9, num=1):
|
|
99
|
+
"""
|
|
100
|
+
Legacy alias: multiply `value` by 10 ** (exp * num).
|
|
101
|
+
Prefer: exponential(value, exp, num) or scale_pow10(value, exp*num).
|
|
102
|
+
"""
|
|
103
|
+
return exponential(value, exp, num)
|
|
104
|
+
|
|
105
|
+
# -------------------------------
|
|
106
|
+
# Argument picker
|
|
107
|
+
# -------------------------------
|
|
108
|
+
def get_proper_args(strings, *args, **kwargs):
|
|
109
|
+
"""
|
|
110
|
+
Extract values by key order from kwargs first; if missing, consume positional args in order.
|
|
111
|
+
Example: get_proper_args(["a","b"], 1, b=3) -> [1, 3]
|
|
112
|
+
"""
|
|
113
|
+
proper = []
|
|
114
|
+
args = list(args)
|
|
115
|
+
for key in strings:
|
|
116
|
+
if key in kwargs:
|
|
117
|
+
proper.append(kwargs[key])
|
|
118
|
+
elif args:
|
|
119
|
+
proper.append(args.pop(0))
|
|
120
|
+
else:
|
|
121
|
+
proper.append(None)
|
|
122
|
+
return proper
|
|
123
|
+
|
|
124
|
+
# -------------------------------
|
|
125
|
+
# Your SOL / token helpers (using the unified expo)
|
|
126
|
+
# -------------------------------
|
|
127
|
+
SOL_DECIMAL_PLACE = 9
|
|
128
|
+
SOL_LAMPORTS = int(pow10(SOL_DECIMAL_PLACE)) # 10**9
|
|
129
|
+
|
|
130
|
+
def get_lamp_difference(*args, **kwargs):
|
|
131
|
+
"""
|
|
132
|
+
Keep behavior: compute a lamport “scale” based on digit length of virtualSolReserves.
|
|
133
|
+
"""
|
|
134
|
+
sol_lamports = SOL_LAMPORTS
|
|
135
|
+
[virtualSolReserves] = get_proper_args(["virtualSolReserves"], *args, **kwargs)
|
|
136
|
+
if _is_bad(virtualSolReserves):
|
|
137
|
+
return 0
|
|
138
|
+
virtual_len = len(str(int(float(virtualSolReserves))))
|
|
139
|
+
virtual_sol_lamports = int(pow10(virtual_len)) # 10**virtual_len
|
|
140
|
+
scale_len = len(str(int(virtual_sol_lamports / sol_lamports))) if sol_lamports else 0
|
|
141
|
+
return int(pow10(scale_len))
|
|
142
|
+
|
|
143
|
+
def get_price(*args, **kwargs):
|
|
144
|
+
"""
|
|
145
|
+
price = virtualSolReserves / virtualTokenReserves / lamp_difference
|
|
146
|
+
"""
|
|
147
|
+
virtualSolReserves, virtualTokenReserves = get_proper_args(
|
|
148
|
+
["virtualSolReserves", "virtualTokenReserves"], *args, **kwargs
|
|
149
|
+
)
|
|
150
|
+
base = divide_it(virtualSolReserves, virtualTokenReserves)
|
|
151
|
+
return divide_it(base, get_lamp_difference(*args, **kwargs))
|
|
152
|
+
|
|
153
|
+
def get_amount_price(*args, **kwargs):
|
|
154
|
+
solAmount, tokenAmount = get_proper_args(["solAmount", "tokenAmount"], *args, **kwargs)
|
|
155
|
+
return divide_it(solAmount, tokenAmount)
|
|
156
|
+
|
|
157
|
+
def getSolAmountUi(*args, **kwargs):
|
|
158
|
+
[solAmount] = get_proper_args(["solAmount"], *args, **kwargs)
|
|
159
|
+
# scale by 10**9
|
|
160
|
+
return exponential(solAmount, SOL_DECIMAL_PLACE)
|
|
161
|
+
|
|
162
|
+
def getTokenAmountUi(*args, **kwargs):
|
|
163
|
+
solAmountUi = getSolAmountUi(*args, **kwargs)
|
|
164
|
+
price = get_price(*args, **kwargs)
|
|
165
|
+
return divide_it(solAmountUi, price)
|
|
166
|
+
|
|
167
|
+
def derive_token_decimals(*args, **kwargs):
|
|
168
|
+
virtualTokenReserves, tokenAmount = get_proper_args(
|
|
169
|
+
["virtualTokenReserves", "tokenAmount"], *args, **kwargs
|
|
170
|
+
)
|
|
171
|
+
price = get_price(*args, **kwargs)
|
|
172
|
+
if not (virtualTokenReserves and tokenAmount and price) or any(
|
|
173
|
+
float(x) <= 0 for x in [virtualTokenReserves, tokenAmount, price]
|
|
174
|
+
):
|
|
175
|
+
raise ValueError("All inputs must be positive.")
|
|
176
|
+
derived_token_amount = divide_it(virtualTokenReserves, price)
|
|
177
|
+
ratio = divide_it(derived_token_amount, tokenAmount)
|
|
178
|
+
# count decimal places needed to make ratio an integer (tolerant to fp noise)
|
|
179
|
+
decimals = -1
|
|
180
|
+
while abs(ratio - round(ratio)) > 1e-9:
|
|
181
|
+
ratio *= 10
|
|
182
|
+
decimals += 1
|
|
183
|
+
return decimals
|
|
184
|
+
|
|
185
|
+
def derive_token_decimals_from_token_variables(variables):
|
|
186
|
+
variables["price"] = get_price(**variables)
|
|
187
|
+
derived_token_amount = divide_it(variables["virtualTokenReserves"], variables["price"])
|
|
188
|
+
ratio = divide_it(derived_token_amount, variables["tokenAmount"])
|
|
189
|
+
decimals = -1
|
|
190
|
+
while abs(ratio - round(ratio)) > 1e-9:
|
|
191
|
+
ratio *= 10
|
|
192
|
+
decimals += 1
|
|
193
|
+
variables["tokenDecimals"] = decimals
|
|
194
|
+
return variables
|
|
195
|
+
|
|
196
|
+
def get_token_amount_ui(*args, **kwargs):
|
|
197
|
+
[tokenAmount] = get_proper_args(["tokenAmount"], *args, **kwargs)
|
|
198
|
+
# scale by 10**(-token_decimals)
|
|
199
|
+
dec = derive_token_decimals(*args, **kwargs)
|
|
200
|
+
return exponential(tokenAmount, -dec, 1)
|
|
201
|
+
|
|
202
|
+
def update_token_variables(variables):
|
|
203
|
+
variables['solAmountUi'] = getSolAmountUi(**variables)
|
|
204
|
+
variables['solDecimals'] = SOL_DECIMAL_PLACE
|
|
205
|
+
variables = derive_token_decimals_from_token_variables(variables)
|
|
206
|
+
variables['tokenAmountUi'] = exponential(variables['tokenAmount'], -variables["tokenDecimals"], 1)
|
|
207
|
+
return variables
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
from abstract_utilities import *
|
|
2
|
-
import math
|
|
3
|
-
#math functions ------------------------------------------------------------------------------------------------------
|
|
4
|
-
|
|
5
|
-
def add_it(number_1,number_2):
|
|
6
|
-
if return_0(number_1,number_2)==float(0):
|
|
7
|
-
return float(0)
|
|
8
|
-
return float(number_1)+float(number_2)
|
|
9
|
-
|
|
10
|
-
def subtract_it(number_1,number_2):
|
|
11
|
-
if return_0(number_1,number_2)==float(0):
|
|
12
|
-
return float(0)
|
|
13
|
-
return float(number_1)-float(number_2)
|
|
14
|
-
|
|
15
|
-
def get_percentage(owner_balance,address_balance):
|
|
16
|
-
retained_div = divide_it(owner_balance,address_balance)
|
|
17
|
-
retained_mul = multiply_it(retained_div,100)
|
|
18
|
-
return round(retained_mul,2)
|
|
19
|
-
|
|
20
|
-
def return_0(*args):
|
|
21
|
-
"""Return True if *any* arg is “falsy” (None, non-number, or zero‐like)."""
|
|
22
|
-
for arg in args:
|
|
23
|
-
if arg is None or not is_number(arg) or str(arg).strip().lower() in ('0', '', 'null'):
|
|
24
|
-
return True
|
|
25
|
-
return False
|
|
26
|
-
|
|
27
|
-
def gather_0(*args):
|
|
28
|
-
"""Convert any “falsy” arg into float(0), leave others alone."""
|
|
29
|
-
cleaned = []
|
|
30
|
-
for arg in args:
|
|
31
|
-
if arg is None or not is_number(arg) or str(arg).strip().lower() in ('0', '', 'null'):
|
|
32
|
-
cleaned.append(0.0)
|
|
33
|
-
else:
|
|
34
|
-
cleaned.append(float(arg))
|
|
35
|
-
return cleaned
|
|
36
|
-
|
|
37
|
-
def add_it(*args):
|
|
38
|
-
"""Sum together any number of args, treating bad values as 0."""
|
|
39
|
-
nums = gather_0(*args)
|
|
40
|
-
return float(sum(nums))
|
|
41
|
-
|
|
42
|
-
def multiply_it(*args):
|
|
43
|
-
"""Multiply any number of args, but return 0 if any input is ‘bad’ or zero-like."""
|
|
44
|
-
nums = gather_0(*args)
|
|
45
|
-
if any(n == 0.0 for n in nums):
|
|
46
|
-
return 0.0
|
|
47
|
-
return float(reduce(operator.mul, nums, 1.0))
|
|
48
|
-
|
|
49
|
-
def divide_it(*args):
|
|
50
|
-
"""
|
|
51
|
-
Divide args[0] by args[1] by args[2]…
|
|
52
|
-
If any input is bad or you hit a zero‐division, return 0.
|
|
53
|
-
"""
|
|
54
|
-
nums = gather_0(*args)
|
|
55
|
-
try:
|
|
56
|
-
return float(reduce(operator.truediv, nums))
|
|
57
|
-
except ZeroDivisionError:
|
|
58
|
-
return 0.0
|
|
59
|
-
|
|
60
|
-
def floor_divide_it(*args):
|
|
61
|
-
"""
|
|
62
|
-
Floor‐divide args[0] by args[1] by args[2]…
|
|
63
|
-
If any input is bad or you hit a zero‐division, return 0.
|
|
64
|
-
"""
|
|
65
|
-
nums = gather_0(*args)
|
|
66
|
-
try:
|
|
67
|
-
return float(reduce(operator.floordiv, nums))
|
|
68
|
-
except ZeroDivisionError:
|
|
69
|
-
return 0.0
|
|
70
|
-
|
|
71
|
-
def subtract_it(*args):
|
|
72
|
-
"""
|
|
73
|
-
Subtract all subsequent args from the first:
|
|
74
|
-
args[0] - args[1] - args[2] - …
|
|
75
|
-
Bad values become 0.
|
|
76
|
-
"""
|
|
77
|
-
nums = gather_0(*args)
|
|
78
|
-
if not nums:
|
|
79
|
-
return 0.0
|
|
80
|
-
return float(reduce(operator.sub, nums))
|
|
81
|
-
|
|
82
|
-
def exp_it(base, *factors):
|
|
83
|
-
"""
|
|
84
|
-
Raise `base` to the power of (product of all `factors`).
|
|
85
|
-
e.g. exp_it(10, 2, 3) → 10**(2*3) == 10**6
|
|
86
|
-
Bad values become 0 (and so the result is 0).
|
|
87
|
-
"""
|
|
88
|
-
nums = gather_0(base, *factors)
|
|
89
|
-
b, *f = nums
|
|
90
|
-
if return_0(*nums) or not f:
|
|
91
|
-
return 0.0
|
|
92
|
-
exponent = reduce(operator.mul, f, 1.0)
|
|
93
|
-
return float(b) ** exponent
|
|
94
|
-
|
|
95
|
-
def exponential(value, *exp_factors):
|
|
96
|
-
"""
|
|
97
|
-
Multiply `value` by 10 to the power of (product of exp_factors).
|
|
98
|
-
e.g. exponential(5, 2, 3) → 5 * (10**(2*3)) == 5 * 1_000_000
|
|
99
|
-
If you give no exp_factors, it just returns value.
|
|
100
|
-
"""
|
|
101
|
-
power = exp_it(10, *exp_factors) or 1.0
|
|
102
|
-
return multiply_it(value, power)
|
|
103
|
-
|
|
104
|
-
def get_proper_args(strings,*args,**kwargs):
|
|
105
|
-
properArgs = []
|
|
106
|
-
for key in strings:
|
|
107
|
-
kwarg = kwargs.get(key)
|
|
108
|
-
if kwarg == None and args:
|
|
109
|
-
kwarg = args[0]
|
|
110
|
-
args = [] if len(args) == 1 else args[1:]
|
|
111
|
-
properArgs.append(kwarg)
|
|
112
|
-
return properArgs
|
|
113
|
-
def get_lamp_difference(*args,**kwargs):
|
|
114
|
-
sol_lamports =int(exponential(1,exp=9,num=1))
|
|
115
|
-
proper_args = get_proper_args(["virtualSolReserves"],*args,**kwargs)
|
|
116
|
-
virtualLamports = len(str(proper_args[0]))
|
|
117
|
-
virtual_sol_lamports =int(exponential(1,exp=virtualLamports,num=1))
|
|
118
|
-
return int(exponential(1,exp=len(str(int(virtual_sol_lamports/sol_lamports))),num=1))
|
|
119
|
-
def get_price(*args,**kwargs):
|
|
120
|
-
proper_args = get_proper_args(["virtualSolReserves","virtualTokenReserves"],*args,**kwargs)
|
|
121
|
-
return divide_it(*proper_args)/get_lamp_difference(*args,**kwargs)
|
|
122
|
-
def get_amount_price(*args,**kwargs):
|
|
123
|
-
proper_args = get_proper_args(["solAmount","tokenAmount"],*args,**kwargs)
|
|
124
|
-
return divide_it(*proper_args)
|
|
125
|
-
def getSolAmountUi(*args,**kwargs):
|
|
126
|
-
proper_args = get_proper_args(["solAmount"],*args,**kwargs)
|
|
127
|
-
return exponential(proper_args[0],9)
|
|
128
|
-
def getTokenAmountUi(*args,**kwargs):
|
|
129
|
-
solAmountUi = getSolAmountUi(*args,**kwargs)
|
|
130
|
-
price = get_price(*args,**kwargs)
|
|
131
|
-
return solAmountUi/price
|
|
132
|
-
def derive_token_decimals(*args,**kwargs):
|
|
133
|
-
proper_args = get_proper_args(["virtualTokenReserves","tokenAmount"],*args,**kwargs)
|
|
134
|
-
price = get_price(*args,**kwargs)
|
|
135
|
-
if not (proper_args[1] > 0 and proper_args[0] > 0 and price > 0):
|
|
136
|
-
raise ValueError("All inputs must be positive.")
|
|
137
|
-
derived_token_amount = proper_args[0] / price
|
|
138
|
-
ratio = derived_token_amount / proper_args[1]
|
|
139
|
-
decimals = -1
|
|
140
|
-
while abs(ratio - round(ratio)) > 1e-9:
|
|
141
|
-
ratio *= 10
|
|
142
|
-
decimals += 1
|
|
143
|
-
return decimals
|
|
144
|
-
def derive_token_decimals_from_token_variables(variables):
|
|
145
|
-
variables["price"] = get_price(**variables)
|
|
146
|
-
derived_token_amount = variables["virtualTokenReserves"] / variables["price"]
|
|
147
|
-
ratio = derived_token_amount / variables["tokenAmount"]
|
|
148
|
-
decimals = -1
|
|
149
|
-
while abs(ratio - round(ratio)) > 1e-9:
|
|
150
|
-
ratio *= 10
|
|
151
|
-
decimals += 1
|
|
152
|
-
variables["tokenDecimals"] = decimals
|
|
153
|
-
return variables
|
|
154
|
-
def get_token_amount_ui(*args,**kwargs):
|
|
155
|
-
proper_args = get_proper_args(["tokenAmount"],*args,**kwargs)
|
|
156
|
-
return exponential(proper_args[0],exp=-derive_token_decimals(*args,**kwargs),num=1)
|
|
157
|
-
def update_token_variables(variables):
|
|
158
|
-
variables['solAmountUi'] = getSolAmountUi(**variables)
|
|
159
|
-
variables['solDecimals'] = 9
|
|
160
|
-
variables = derive_token_decimals_from_token_variables(variables)
|
|
161
|
-
variables['tokenAmountUi'] = exponential(variables['tokenAmount'],exp=-variables["tokenDecimals"],num=1)
|
|
162
|
-
return variables
|
|
163
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/flask_scripts/__init__.py
RENAMED
|
File without changes
|
{abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/flask_scripts/flask_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
{abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/solar_math/flask_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
{abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/solar_math/src/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math/solar_math/src/utils/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{abstract_math-0.0.0.21 → abstract_math-0.0.0.23}/src/abstract_math.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|