
    i/                     J    d dl Z d dlZdZde j                  fdZdedz  fdZy)    Nzhttps://mempool.space/apisessionc                   K   	 | j                  t         dd      4 d{   }|j                          |j                          d{   }ddd      d{    	 | j                  t         dd      4 d{   }|j                          |j                          d{   }ddd      d{    	 | j                  t         dd      4 d{   }|j                          |j                          d{   }ddd      d{    t        t              r/t        |      dkD  r!|d   }t        |j                  dd            }nd}t        j                  dd            t        |j                  dd            t        j                  d
d            |dS 7 7 c7 V# 1 d{  7  sw Y   gxY w# t        $ r}t        d|        dddddcY d}~S d}~ww xY w7 v7 Q7 D# 1 d{  7  sw Y   UxY w# t        $ r}t        d	|        d
di}Y d}~yd}~ww xY w7 b7 =7 0# 1 d{  7  sw Y   AxY w# t        $ r}t        d|        g }Y d}~cd}~ww xY ww)u   
    מחזיר dict מאוחד עם:
    - tx_count
    - mempool_vsize
    - fee_high
    - block_tx_count

    במידה ויש כשל → מחזיר fallback עם ערכים 0 כדי לא להפיל את הבוט.
    z/mempool   )timeoutNu   [MEMPOOL ERROR] /mempool →         )tx_countmempool_vsizefee_highblock_tx_countz/v1/fees/recommendedu)   [MEMPOOL ERROR] /v1/fees/recommended → 
fastestFeer   z/blocksu   [MEMPOOL ERROR] /blocks → r   countvsize)
getMEMPOOL_API_BASEraise_for_statusjson	Exceptionprint
isinstancelistlenfloat)r   resmempoolefeesblockslatest_blockblock_txs            /var/www/html/binance/mempool.pyfetch_mempoolr!      s^    
;;"2!38<a;H 	' 	'C  "HHJ&G	' 	'!;;"2!33GHRS;T 	$ 	$X[  "#D	$ 	$;;"2!37;Q;G 	& 	&3  "88:%F	& 	& &$CK!Oay))*c:; '++gs34w{{7C89$((<56"	 W	'&	' 	' 	' 	'  
-aS12 !	
 	

	$#	$ 	$ 	$ 	$  !9!=>a !	&%	& 	& 	& 	&  ,QC01s  JG	 F*G	 $F3
F-F3G	 F0G	  H >G4?H $G=&G7'G=+H 6G:7H <I H<I $IH?II II BJ*G	 -F30G	 3G9F<:GG	 		G1G,&G1'J,G11J4H 7G=:H =HHHH 	H9H4.J4H99J<I ?II IIII 	I?$I:4J:I??Jmc                 \   | sy| j                  dd      }| j                  dd      }| j                  dd      }| j                  dd      }|dkD  rt        j                  |dz        nd}|dkD  rt        j                  |d	z        nd}|dkD  rt        j                  |d
z        nd}|||fS )u   
    Normalizes mempool data into 3 onchain factors:
    - f_mempool (0–1 range)
    - f_fee (0–1 range)
    - f_block_tx (0–1 range)

    מחזיר שלישיות שמתאימות ל-V6 ENGINE.

    אם m=None → מחזיר (0, 0, 0)
    )r   r   r   r   r   r	   r
   r   r   i   i  )r   mathtanh)r"   r   r	   r
   r   	f_mempoolf_fee
f_block_txs           r    normalize_mempoolr*   H   s     uuZ%HEE/3/MuuZ%Huu%s+H :G9J		-*45PSI *2ADIIhn%3E 08!|8d?+JeZ''    )aiohttpr%   r   ClientSessionr!   dictr*    r+   r    <module>r0      s4     . >!6!6 >B!( !(r+   