clean up and add web3

This commit is contained in:
mvonsteinkirch 2022-12-24 14:45:32 -08:00
parent a0cfa09ec4
commit fc8d690a51
29 changed files with 3043 additions and 31 deletions

View file

@ -0,0 +1,25 @@
# -*- encoding: utf-8 -*-
# arithmetics.py
# This class implements math methods used by the other classes.
# author: steinkirch
from decimal import Decimal, getcontext
from utils.strings import log_error
def div(dividend, divisor) -> Decimal:
"""Return higher precision division."""
if divisor == 0:
log_error('Found a zero division error. Returning 0.')
return 0
return to_decimal(dividend) / to_decimal(divisor)
def to_decimal(value, precision=None) -> Decimal:
"""Return Decimal value for higher (defined) precision."""
precision = precision or 22
getcontext().prec = precision
return Decimal(value)