1
0
Fork 0
This repository has been archived on 2024-12-18. You can view files and clone it, but cannot push or open issues or pull requests.
mining-companion/companion/utils.py

16 lines
439 B
Python
Raw Normal View History

def convert_weis(weis, precision=5):
return round(weis / 10**18, precision)
def format_weis(weis, precision=5):
amount = convert_weis(weis=weis, precision=precision)
if amount == int(amount):
amount = int(amount)
return f'{amount} ETH'
def convert_fiat(amount, exchange_rate, currency):
converted = round(convert_weis(amount)*exchange_rate, 2)
converted = f'{converted} {currency}'
return converted