o
    ¢ØÆh4  ã                   @   s  d dl Z d dl mZ d dlmZ ddlmZmZ ddlmZ G dd„ dƒZd Z	d	d
 d Z
eeeee jf Zdede jdeee jf fdd„Zdede jdefdd„Zdededeee jf fdd„Zdededefdd„Zdededeee jf fdd„Zdededefdd„ZdS )é    N)Úlocalcontext)ÚUnioné   )Ú
is_integerÚ	is_string)Úunitsc                   @   s   e Zd Zeed ƒZeed ƒZeed ƒZeed ƒZeed ƒZ	eed ƒZ
eed ƒZeed ƒZeed	 ƒZeed
 ƒZeed ƒZeed ƒZeed ƒZeed ƒZeed ƒZeed ƒZeed ƒZeed ƒZeed ƒZeed ƒZeed ƒZeed ƒZeed ƒZdS )ÚdenomsÚweiÚkweiÚbabbageÚ
femtoetherÚmweiÚlovelaceÚ	picoetherÚgweiÚshannonÚ	nanoetherÚnanoÚszaboÚ
microetherÚmicroÚfinneyÚ
millietherÚmilliÚetherÚketherÚgrandÚmetherÚgetherÚtetherN)Ú__name__Ú
__module__Ú__qualname__Úintr   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   © r$   r$   ú_/var/www/html/HyperOracle/crypto_trader/venv/lib/python3.10/site-packages/eth_utils/currency.pyr      s0    r   é   é   ÚnumberÚ
unit_valueÚreturnc                 C   sl   | dkrdS | t k s| tkrtdƒ‚tƒ �}d|_tj| |d�}|| }W d   ƒ |S 1 s/w   Y  |S )Nr   z&value must be between 0 and 2**256 - 1éç  ©ÚvalueÚcontext)ÚMIN_WEIÚMAX_WEIÚ
ValueErrorr   ÚprecÚdecimalÚDecimal)r(   r)   ÚctxÚd_numberÚresult_valuer$   r$   r%   Ú	_from_wei2   s   

ýûr8   c                 C   s@  t | ƒst| ƒrtj| d�}nt| tƒrtjt| ƒd�}nt| tjƒr&| }ntdƒ‚|t d¡kr3dS t| ƒ}|dk rqd|v rqtƒ �!}t	|ƒ| 
d¡ d }||_tj| |d�d|  }W d   ƒ n1 sfw   Y  |d|  }tƒ �}d|_tj||d�| }W d   ƒ n1 s‹w   Y  |tk s˜|tkrœtd	ƒ‚t|ƒS )
N©r-   z:Unsupported type. Must be one of integer, float, or stringr   r   Ú.r,   é
   r+   z4Resulting wei value must be between 0 and 2**256 - 1)r   r   r3   r4   Ú
isinstanceÚfloatÚstrÚ	TypeErrorr   ÚlenÚindexr2   r/   r0   r1   r#   )r(   r)   r6   Ús_numberr5   Ú
multiplierr7   r$   r$   r%   Ú_to_weiA   s0   
ýþrD   Úunitc                 C   ó:   |  ¡ tvrtdd t ¡ ¡› �ƒ‚t|  ¡  }t| |ƒS )zH
    Takes a number of wei and converts it to any other ether unit.
    úUnknown unit. Must be one of ú/)Úlowerr   r1   ÚjoinÚkeysr8   ©r(   rE   r)   r$   r$   r%   Úfrom_weia   ó   
rM   c                 C   rF   )z:
    Takes a number of a unit and converts it to wei.
    rG   rH   )rI   r   r1   rJ   rK   rD   rL   r$   r$   r%   Úto_weim   rN   rO   Údecimalsc                 C   ó    t  d¡t j|d� }t| |ƒS )zg
    Takes a number of wei and converts it to a decimal with the specified
    number of decimals.
    r;   r9   )r3   r4   r8   ©r(   rP   r)   r$   r$   r%   Úfrom_wei_decimalsy   ó   
rS   c                 C   rQ   )zd
    Takes a number of a unit and converts it to wei with the specified
    number of decimals.
    r;   r9   )r3   r4   rD   rR   r$   r$   r%   Úto_wei_decimalsƒ   rT   rU   )r3   r   Útypingr   Útypesr   r   r   r   r/   r0   r#   r=   r>   r4   Ú_NumberTyper8   rD   rM   rO   rS   rU   r$   r$   r$   r%   Ú<module>   s    "   
