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
Julien Riou 14aa8a6d59
Add "state" tests
Signed-off-by: Julien Riou <julien@riou.xyz>
2021-02-12 09:43:38 +01:00

15 lines
439 B
Python

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