abstract-math 0.0.0.17__py3-none-any.whl → 0.0.0.19__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/__init__.py +1 -0
- abstract_math/derive_tokens.py +37 -35
- abstract_math/flask_scripts/__init__.py +0 -0
- abstract_math/flask_scripts/flask_utils.py +664 -0
- abstract_math/safe_math.py +20 -3
- abstract_math/solar_math/__init__.py +2 -0
- abstract_math/solar_math/flask_utils.py +11 -0
- abstract_math/solar_math/main.py +263 -0
- abstract_math/solar_math/src/__init__.py +4 -0
- abstract_math/solar_math/src/constants/__init__.py +19 -0
- abstract_math/solar_math/src/constants/distance_constants.py +45 -0
- abstract_math/solar_math/src/constants/planet_constants.py +156 -0
- abstract_math/solar_math/src/constants/time_constants.py +56 -0
- abstract_math/solar_math/src/imports.py +5 -0
- abstract_math/solar_math/src/utils/__init__.py +3 -0
- abstract_math/solar_math/src/utils/escape_velocity.py +78 -0
- abstract_math/solar_math/src/utils/geometry_utils.py +104 -0
- abstract_math/solar_math/src/utils/velocity_utils.py +26 -0
- abstract_math-0.0.0.19.dist-info/METADATA +81 -0
- abstract_math-0.0.0.19.dist-info/RECORD +22 -0
- {abstract_math-0.0.0.17.dist-info → abstract_math-0.0.0.19.dist-info}/WHEEL +1 -1
- abstract_math/deriveit.py +0 -97
- abstract_math-0.0.0.17.dist-info/METADATA +0 -47
- abstract_math-0.0.0.17.dist-info/RECORD +0 -8
- {abstract_math-0.0.0.17.dist-info → abstract_math-0.0.0.19.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# src/utils/escape_velocity.py
|
|
2
|
+
from ..imports import math, mul, div, add
|
|
3
|
+
from ..constants.planet_constants import get_body
|
|
4
|
+
from ..constants.distance_constants import convert as dconvert
|
|
5
|
+
from ..constants.time_constants import get_time_unit_conversions, normalize_time_unit
|
|
6
|
+
|
|
7
|
+
def _seconds_per(unit: str) -> float:
|
|
8
|
+
"""
|
|
9
|
+
Map a time unit (alias-friendly) to seconds per that unit, using your time schema.
|
|
10
|
+
"""
|
|
11
|
+
return get_time_unit_conversions(normalize_time_unit(unit))["conv"]["seconds"]
|
|
12
|
+
|
|
13
|
+
def escape_velocity_at(
|
|
14
|
+
planet: str = "earth",
|
|
15
|
+
distance: float = 0.0,
|
|
16
|
+
*,
|
|
17
|
+
input_units: str = "meters", # how to interpret `distance`
|
|
18
|
+
output_units: str = "meters", # distance unit for the *speed*
|
|
19
|
+
output_time: str = "s", # time unit for the *speed*
|
|
20
|
+
as_radius: bool = False # False => `distance` is altitude above surface; True => radius from center
|
|
21
|
+
) -> dict:
|
|
22
|
+
"""
|
|
23
|
+
Compute v_escape at a given location around `planet`.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
planet: body name (must exist in PLANETS)
|
|
27
|
+
distance: if as_radius=False => altitude above surface; if as_radius=True => radius from center
|
|
28
|
+
input_units: units of `distance`
|
|
29
|
+
output_units: distance unit of the returned speed
|
|
30
|
+
output_time: time unit of the returned speed ('s'|'min'|'h' etc.)
|
|
31
|
+
as_radius: interpret `distance` as radius-from-center when True
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
{
|
|
35
|
+
"ok": True,
|
|
36
|
+
"planet": str,
|
|
37
|
+
"radius_from_center": <float in output_units>,
|
|
38
|
+
"v_escape": <float in output_units/output_time>,
|
|
39
|
+
"v_escape_mps": <float in m/s>,
|
|
40
|
+
"units": {"distance": output_units, "time": output_time}
|
|
41
|
+
}
|
|
42
|
+
"""
|
|
43
|
+
if not (isinstance(distance, (int, float)) and math.isfinite(distance) and distance >= 0):
|
|
44
|
+
return {"ok": False, "error": "distance must be a non-negative number"}
|
|
45
|
+
|
|
46
|
+
body = get_body(planet)
|
|
47
|
+
mu = body["mu"] # m^3/s^2
|
|
48
|
+
R = body["radius"] # m
|
|
49
|
+
|
|
50
|
+
# Determine radius from center in meters
|
|
51
|
+
if as_radius:
|
|
52
|
+
r_m = dconvert(distance, input_units, "meters")
|
|
53
|
+
else:
|
|
54
|
+
alt_m = dconvert(distance, input_units, "meters")
|
|
55
|
+
r_m = add(R, alt_m)
|
|
56
|
+
|
|
57
|
+
if r_m <= 0:
|
|
58
|
+
return {"ok": False, "error": "computed radius is non-positive"}
|
|
59
|
+
|
|
60
|
+
# v_esc (m/s)
|
|
61
|
+
vesc_mps = math.sqrt(mul(2.0, div(mu, r_m)))
|
|
62
|
+
|
|
63
|
+
# Convert speed to <output_units>/<output_time>
|
|
64
|
+
vesc_units_per_sec = dconvert(vesc_mps, "meters", output_units)
|
|
65
|
+
sec_per = _seconds_per(output_time) # seconds per 1 output_time
|
|
66
|
+
vesc_out = mul(vesc_units_per_sec, sec_per) # <output_units>/<output_time>
|
|
67
|
+
|
|
68
|
+
# Also return the radius in output_units for convenience
|
|
69
|
+
r_out = dconvert(r_m, "meters", output_units)
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
"ok": True,
|
|
73
|
+
"planet": planet,
|
|
74
|
+
"radius_from_center": r_out,
|
|
75
|
+
"v_escape": vesc_out,
|
|
76
|
+
"v_escape_mps": vesc_mps,
|
|
77
|
+
"units": {"distance": output_units, "time": output_time}
|
|
78
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
from ..imports import *
|
|
2
|
+
from ..constants import *
|
|
3
|
+
# --- Spherical cap (true horizon-limited visibility) ---
|
|
4
|
+
def get_central_angle(r_m: float, h_m: float) -> float:
|
|
5
|
+
"""Angle at Earth's center from observer to horizon (radians)."""
|
|
6
|
+
rh = add(r_m, h_m)
|
|
7
|
+
# clamp to avoid domain issues
|
|
8
|
+
val = max(-1.0, min(1.0, div(r_m, rh)))
|
|
9
|
+
return math.acos(val)
|
|
10
|
+
|
|
11
|
+
def get_h_cap(r_m: float, h_m: float, theta: Optional[float] = None) -> float:
|
|
12
|
+
"""Spherical cap height (meters)."""
|
|
13
|
+
if theta is None:
|
|
14
|
+
theta = get_central_angle(r_m, h_m)
|
|
15
|
+
return mul(r_m, sub(1.0, math.cos(theta)))
|
|
16
|
+
|
|
17
|
+
def spherical_cap_area(observer_altitude: float, units: str = 'meters'):
|
|
18
|
+
"""
|
|
19
|
+
Visible spherical cap area from altitude (same units as input returned in unit^2).
|
|
20
|
+
"""
|
|
21
|
+
r_m = earth_radius('meters')
|
|
22
|
+
h_m = convert(observer_altitude, units, 'meters')
|
|
23
|
+
|
|
24
|
+
theta = get_central_angle(r_m, h_m)
|
|
25
|
+
h_cap_m = get_h_cap(r_m, h_m, theta)
|
|
26
|
+
area_m2 = mul(2 * pi() * r_m, h_cap_m) # 2π R h
|
|
27
|
+
# return in requested units^2
|
|
28
|
+
area_u2 = mul(area_m2, exp(_factor('meters', units), 2))
|
|
29
|
+
return area_u2, convert(h_cap_m, 'meters', units), theta
|
|
30
|
+
|
|
31
|
+
def percent_visible(observer_altitude: float, units: str = 'meters') -> float:
|
|
32
|
+
cap_area_u2, _, _ = spherical_cap_area(observer_altitude, units)
|
|
33
|
+
full_area_u2 = full_earth_surface_area(units)
|
|
34
|
+
return mul(div(cap_area_u2, full_area_u2), 100.0)
|
|
35
|
+
|
|
36
|
+
# --- Camera/FOV flat-projection helper (approximate) ---
|
|
37
|
+
def visible_area_flat(fov_degrees: float, altitude_m: float, units: str = 'meters'):
|
|
38
|
+
"""
|
|
39
|
+
Given altitude in meters, return (area_m2, visible_radius_m). `units` arg is ignored,
|
|
40
|
+
kept for backward compatibility.
|
|
41
|
+
"""
|
|
42
|
+
fov_radians = math.radians(fov_degrees)
|
|
43
|
+
visible_radius_m = altitude_m * math.tan(fov_radians / 2.0)
|
|
44
|
+
area_m2 = math.pi * (visible_radius_m ** 2)
|
|
45
|
+
return area_m2, visible_radius_m
|
|
46
|
+
|
|
47
|
+
def visible_surface_angle(visible_radius: float, sphere_radius: float) -> tuple[float, float]:
|
|
48
|
+
"""Chord-based angular span (approximate)."""
|
|
49
|
+
chord_length = mul(2.0, visible_radius)
|
|
50
|
+
angle_rad = mul(2.0, math.asin(div(chord_length, mul(2.0, sphere_radius))))
|
|
51
|
+
angle_deg = math.degrees(angle_rad)
|
|
52
|
+
return angle_rad, angle_deg
|
|
53
|
+
|
|
54
|
+
# --- FOV triangle pack (kept but made unit-consistent) ---
|
|
55
|
+
def get_triangle_area(a: float, b: float, c: float):
|
|
56
|
+
s = (a + b + c) / 2.0
|
|
57
|
+
area = math.sqrt(max(0.0, s * (s - a) * (s - b) * (s - c)))
|
|
58
|
+
return area, s
|
|
59
|
+
|
|
60
|
+
def get_medians(a: float, b: float, c: float) -> float:
|
|
61
|
+
# median from side 'a'
|
|
62
|
+
return 0.5 * math.sqrt(max(0.0, 2*b*b + 2*c*c - a*a))
|
|
63
|
+
|
|
64
|
+
def get_triangle_medians(a: float, b: float, c: float):
|
|
65
|
+
return {"ma": get_medians(b, c, a), "mb": get_medians(a, c, b), "mc": get_medians(a, b, c)}
|
|
66
|
+
|
|
67
|
+
def get_triangle_heights(a: float, b: float, c: float, area: float):
|
|
68
|
+
ha = mul(2.0, div(area, a))
|
|
69
|
+
hb = mul(2.0, div(area, b))
|
|
70
|
+
hc = mul(2.0, div(area, c))
|
|
71
|
+
return {"ha": ha, "hb": hb, "hc": hc}
|
|
72
|
+
|
|
73
|
+
def compute_fov_triangle(altitude: float, fov_angle_deg: float, units: str = 'meters'):
|
|
74
|
+
"""Simple isosceles triangle model for a camera at altitude."""
|
|
75
|
+
a = convert(altitude, units, 'meters')
|
|
76
|
+
fov_angle_rad = math.radians(fov_angle_deg)
|
|
77
|
+
base = 2.0 * a * math.tan(fov_angle_rad / 2.0)
|
|
78
|
+
b = c = a
|
|
79
|
+
|
|
80
|
+
# Triangle inequality guard
|
|
81
|
+
if not ((base + b > c) and (base + c > b) and (b + c > base)):
|
|
82
|
+
return {"error": "Invalid triangle geometry. Lower FOV or increase altitude.",
|
|
83
|
+
"sides": {"a": base, "b": b, "c": c}}
|
|
84
|
+
|
|
85
|
+
triangle_area, s = get_triangle_area(base, b, c)
|
|
86
|
+
medians = get_triangle_medians(base, b, c)
|
|
87
|
+
heights = get_triangle_heights(base, b, c, triangle_area)
|
|
88
|
+
vertices = {"A": (0, 0), "B": (base / 2.0, a), "C": (-base / 2.0, a)}
|
|
89
|
+
inradius = div(triangle_area, s)
|
|
90
|
+
circumradius = 0.5 * a # right-ish simplification for this layout
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
"sides": {"a": base, "b": b, "c": c},
|
|
94
|
+
"area": triangle_area,
|
|
95
|
+
"perimeter": base + 2.0 * a,
|
|
96
|
+
"semiperimeter": s,
|
|
97
|
+
"heights": heights,
|
|
98
|
+
"medians": medians,
|
|
99
|
+
"vertices": vertices,
|
|
100
|
+
"inradius": inradius,
|
|
101
|
+
"circumradius": circumradius
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#src/utils/velocity_utils.py
|
|
2
|
+
from ..imports import *
|
|
3
|
+
from ..constants import *
|
|
4
|
+
|
|
5
|
+
def distance_per_time_to_mps(v: float, dist_units: str, time_units: str) -> float:
|
|
6
|
+
"""
|
|
7
|
+
Convert <v> in (<dist_units>/<time_units>) to m/s.
|
|
8
|
+
"""
|
|
9
|
+
# distance: unit -> meters
|
|
10
|
+
norm_dist_unit = normalize_distance_unit(dist_units) # <-- was normalize_time_unit
|
|
11
|
+
meters_per_unit = get_distance_unit_conversions(norm_dist_unit)["conv"]["meters"]
|
|
12
|
+
v_meters_per_timeunit = mul(v, meters_per_unit)
|
|
13
|
+
|
|
14
|
+
# time: timeunit -> seconds
|
|
15
|
+
sec_per_time = seconds_per(time_units) # from time_constants.py
|
|
16
|
+
return div(v_meters_per_timeunit, sec_per_time)
|
|
17
|
+
|
|
18
|
+
def mps_to_distance_per_time(v_mps: float, dist_units: str, time_units: str) -> float:
|
|
19
|
+
"""
|
|
20
|
+
Convert m/s to <dist_units>/<time_units>.
|
|
21
|
+
"""
|
|
22
|
+
norm_dist_unit = normalize_distance_unit(dist_units)
|
|
23
|
+
meters_per_unit = get_distance_unit_conversions(norm_dist_unit)["conv"]["meters"]
|
|
24
|
+
v_units_per_sec = div(v_mps, meters_per_unit) # [dist_units / s]
|
|
25
|
+
sec_per_time = seconds_per(time_units)
|
|
26
|
+
return mul(v_units_per_sec, sec_per_time) # [dist_units / time_units]
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: abstract_math
|
|
3
|
+
Version: 0.0.0.19
|
|
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
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
abstract_math/__init__.py,sha256=wr-kwaB8micSsR1nCHuDXRlsL59DWlqZQFN7M_rfZys,80
|
|
2
|
+
abstract_math/derive_tokens.py,sha256=mVrr8UJvS8mOOLMuowKVT0h9htiraHResjMuYBR4EhA,4559
|
|
3
|
+
abstract_math/safe_math.py,sha256=dZzxR2glwmzYKD0YlNaxOTYAg_ZNKYhDSVu7KRVIbjk,6047
|
|
4
|
+
abstract_math/flask_scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
abstract_math/flask_scripts/flask_utils.py,sha256=z6gpPshiOeqNANBQkZMZPkegCzj-GK3OpSOi1lN19Sc,28483
|
|
6
|
+
abstract_math/solar_math/__init__.py,sha256=FfPkmWi3cQ3BLvUUUf6k22rGBE8scDL1EoM5l24biVo,39
|
|
7
|
+
abstract_math/solar_math/flask_utils.py,sha256=c82LrZ0dKC3Y8LxqOs1zDR6gRy8oXSx9balBD18gNB0,459
|
|
8
|
+
abstract_math/solar_math/main.py,sha256=EtcUmUWj27c7mcnm-hlfeCeYFuPytPevXx5vClVu6Q8,10000
|
|
9
|
+
abstract_math/solar_math/src/__init__.py,sha256=qeal73F-NLu6sO_YSmD_komVpe17f0OFy2IfBR2QU_s,70
|
|
10
|
+
abstract_math/solar_math/src/imports.py,sha256=GfkWfXDc6fzLe7kHYlSdghkN0Nob0xApxhEyRyDcZS0,182
|
|
11
|
+
abstract_math/solar_math/src/constants/__init__.py,sha256=HpRa4MWkJZu3Wcx6KchB8__RL4FfkVqRw78TAnjRRwo,691
|
|
12
|
+
abstract_math/solar_math/src/constants/distance_constants.py,sha256=stM3nWxpANQEtoxFcbxpO0ly_UM4JJ2aH0VK42fHw6s,1985
|
|
13
|
+
abstract_math/solar_math/src/constants/planet_constants.py,sha256=tt2nbFtRtYhUU9D918WK91D-S5Cv0HEJ-1j7f9Yb50w,6602
|
|
14
|
+
abstract_math/solar_math/src/constants/time_constants.py,sha256=uVDMldwjJqKwXzHcAb-Z8QM20JrxSwLXlogjD_SXwRo,1874
|
|
15
|
+
abstract_math/solar_math/src/utils/__init__.py,sha256=Vb2bfx1p9YSmhnbqXBjGVPt1OQZ9I7PG_fMQdFqj-3k,91
|
|
16
|
+
abstract_math/solar_math/src/utils/escape_velocity.py,sha256=9oixNxWyY4pxa7e1INwbreD8GJEw2BZIgV_IqXiDd9Y,2971
|
|
17
|
+
abstract_math/solar_math/src/utils/geometry_utils.py,sha256=Ij4mASNFp2-CWy425fxMTEuMPuAZHs-E0qvi3BjaNkk,4169
|
|
18
|
+
abstract_math/solar_math/src/utils/velocity_utils.py,sha256=_SyOscVvYsvbm1T1Rh4uqegXdf61mHll5s3UfQcdUnU,1162
|
|
19
|
+
abstract_math-0.0.0.19.dist-info/METADATA,sha256=a-8SS2TnfGaM3ayj-3douwCk5qkcFuRtF5e3-iUN_cg,3081
|
|
20
|
+
abstract_math-0.0.0.19.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
21
|
+
abstract_math-0.0.0.19.dist-info/top_level.txt,sha256=b7jOgD9c0U-CGH-l7yxhMPukzD40kMEQkQRV_sGyVfE,14
|
|
22
|
+
abstract_math-0.0.0.19.dist-info/RECORD,,
|
abstract_math/deriveit.py
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
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
|
-
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: abstract_math
|
|
3
|
-
Version: 0.0.0.17
|
|
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
|
-
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
abstract_math/__init__.py,sha256=3I0YJakDUyWD7qXpdRsaEsmcA7IxwcWhoyecvDfOE98,54
|
|
2
|
-
abstract_math/derive_tokens.py,sha256=0rHanu6-UweOXxVuPn-DQsbUn7Xaoz39TQJiWDe7K5Q,4382
|
|
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.17.dist-info/METADATA,sha256=dcY6VVLpIcr_Vhm2AniROKDBdHi60GlbhxoXGC3s70Y,1150
|
|
6
|
-
abstract_math-0.0.0.17.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
7
|
-
abstract_math-0.0.0.17.dist-info/top_level.txt,sha256=b7jOgD9c0U-CGH-l7yxhMPukzD40kMEQkQRV_sGyVfE,14
|
|
8
|
-
abstract_math-0.0.0.17.dist-info/RECORD,,
|
|
File without changes
|