Notes
- Amounts are in the token’s smallest units (USDC has 6 decimals).
1
=0.000001
USDC.- Use the correct vault address for your asset.
- You need a bit of ETH on Base for gas and some USDC for the deposit.
- Full source code is available in our public GitHub repository: CompassLabs/api_usecases – deposit_on_morpho/python_example.
Prerequisites
1
Install Dependencies
2
Set Environment Variables
Create a
.env
:Implementation
Set a USDC allowance and deposit into a Morpho vault.1
Initialize SDK and Web3
2
Helper to sign and send
3
Build allowance transaction
Approve the vault to spend your USDC (smallest units).
4
Send allowance
5
Build deposit transaction
6
Send deposit
Full Code
Troubleshooting (quick)
- Revert or underflow: Check amount units and token decimals.
- Allowance errors: Ensure the vault address matches the USDC vault.
- Insufficient funds: Top up ETH on Base for gas.
- Wrong network: Confirm your RPC URL is Base mainnet.