Skip to content

nm-de/morpho_python_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Morpho USDC Vault Interaction

A Python automation script for depositing USDC on (and withdrawing USDC from) Morpho vaults on the Arbitrum blockchain. This tool provides a simple command-line interface to interact with Morpho's decentralized lending protocol.

Features

  • Automated Vault Discovery: Fetches available USDC vaults from Morpho's GraphQL API
  • Interactive Vault Selection: Browse and select from available vaults with APY and TVL information
  • Deposit Management: Deposit USDC into selected Morpho vaults with automatic approvals
  • Withdrawal Management: Withdraw USDC from vaults with multi-vault support
  • Portfolio Tracking: View all active deposits across multiple vaults
  • Gas Estimation: Real-time gas estimation with cost breakdown in USD
  • Safety Features: Balance checks, transaction confirmations, and error handling

Prerequisites

  • Python 3.7+
  • Arbitrum-compatible wallet with private key
  • USDC balance on Arbitrum
  • ETH balance for gas fees
  • Arbitrum RPC endpoint

Installation

  1. Clone or download the script:
git clone <repository-url>
cd morpho_automation
  1. Install required dependencies:
pip install web3 eth-account requests
  1. Create a .env file in the project directory:
PRIVATE_KEY=your_private_key_here
ARBITRUM_RPC_URL=https://arb1.arbitrum.io/rpc

Usage

Run the script:

python morpho_lender.py

The script provides an interactive menu with the following options:

  1. 💰 Deposit USDC: Select a vault and deposit USDC
  2. 💸 Withdraw USDC: Withdraw USDC from your active deposits
  3. 📊 Check Status: View your balances and active deposits
  4. ❌ Exit: Close the application

Example Workflow

  1. Start the script and check your current status
  2. Select "Deposit USDC" to browse available vaults
  3. Choose a vault based on APY and TVL
  4. Enter the amount to deposit
  5. Confirm the transaction after reviewing gas costs
  6. Monitor your deposits using "Check Status"

⚠️ Current Limitations

  • Arbitrum Only: Currently supports only Arbitrum blockchain
  • USDC Only: Supports only USDC vaults
  • No Multi-Asset: Cannot handle vaults with other tokens (ETH, WBTC, etc.)
  • CLI Only: Command-line interface only, no GUI
  • Single User: Designed for single wallet operation
  • No Scheduling: No automated/scheduled deposits or withdrawals

Technical Details

Smart Contract Integration

  • ERC-20 Standard: Uses standard USDC contract for balance checks and approvals
  • ERC-4626 Vaults: Integrates with Morpho's ERC-4626 compliant vault contracts
  • Direct Web3 Integration: Built on Web3.py for direct Ethereum blockchain interaction. This project does NOT use the official Morpho SDK because the SDK is only available in JavaScript/TypeScript, not Python.

Use at your own risk. The authors are not responsible for any financial losses.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages