Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f254f47

Browse files
author
Kotsias, Panagiotis-Christos
committed
Added unit conversions
1 parent 7caac2a commit f254f47

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

etherscan/conversions.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from decimal import Decimal
2+
3+
4+
class Conversions:
5+
@staticmethod
6+
def to_ticker_unit(val: int, decimals: int = 18) -> Decimal:
7+
factor = Decimal("10") ** Decimal("-{}".format(decimals))
8+
return Decimal(val) * factor
9+
10+
@staticmethod
11+
def to_smallest_unit(val: int, decimals: int = 18) -> Decimal:
12+
factor = Decimal("10") ** Decimal("+{}".format(decimals))
13+
return Decimal(val) * factor

0 commit comments

Comments
 (0)