lending.cpython-311.pyc•14.5 kB
�
R\�h38 � �h � d dl Z d dlZd dlmZ d dlmZ ej e� � Z G d� d� � Z dS )� N)�EthereumClient)�
PolygonClientc �~ � e Zd ZdZd� Zd� Zd� Zd� Zd� Zd� Z d� Z
d � Zd
� Zd� Z
d� Zd
� Zd� Zd� Zd� Zd� Zd� Zd� ZdS )�LendingOperationszLending protocol operationsc �p � t � � | _ t � � | _ ddd�ddid�| _ d S )N�*0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9�*0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B)�aave�compoundr
�*0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf)�ethereum�polygon)r �ethereum_clientr �polygon_client� protocols)�selfs �,/home/runner/workspace/defi_tools/lending.py�__init__zLendingOperations.__init__ sN � �-�/�/���+�o�o���
E�H�� �
�D��
�
����� c �z � |� � � dk r| � ||||� � S |� � � dk r| � ||||� � S dd|� �d�S # t $ rF}t � dt
|� � � �� � dt
|� � d�cY d}~S d}~ww xY w)zLend asset to a protocolr
r F�Unsupported blockchain: ��success�errorzLending operation failed: N)�lower�_lend_ethereum�
_lend_polygon� Exception�loggerr �str�r �
blockchain�protocol�wallet_address�token�amount�es r �
lend_assetzLendingOperations.lend_asset s� � �
7����!�!�Z�/�/��*�*�8�^�U�F�S�S�S��!�!�#�#�y�0�0��)�)�(�N�E�6�R�R�R�#(�3Z�j�3Z�3Z�[�[�[��� 7� 7� 7��L�L�>�c�!�f�f�>�>�?�?�?�$�s�1�v�v�6�6�6�6�6�6�6�6����� 7����( �/A* �/A* �"A* �*
B:�4;B5�/B:�5B:c �v � |� � � dk r| � |||� � S |� � � dk r| � |||� � S dd|� �d�S # t $ rF}t � dt
|� � � �� � dt
|� � d�cY d}~S d}~ww xY w)zLend on Ethereumr
r F�Unsupported protocol: r zEthereum lending failed: N)r �_lend_aave_ethereum�_lend_compound_ethereumr r r r �r r# r$ r% r&