A Node.js script to monitor your Morpho Finance positions and receive liquidation risk alerts via Telegram.
This tool monitors your Morpho lending/borrowing positions to help prevent liquidations. It continuously checks your Liquidation Loan-to-Value (LLTV) ratio and sends alerts to your Telegram when your position approaches liquidation risk.
- Real-time monitoring of your Morpho positions
- Automated Telegram alerts when positions approach liquidation
- Customizable risk thresholds to receive warnings at your preferred safety level
- Detailed position information including current LTV, buffer percentage, and liquidation price
- Supports all Morpho markets (single-collateral vaults)
- The script connects to the Morpho smart contracts on network of choice
- It periodically checks your position's health by:
- Retrieving your collateral and borrowed amounts
- Getting current oracle prices
- Calculating your current LTV and liquidation thresholds
- When your position exceeds your set risk threshold, it sends a warning to your Telegram
- Node.js and npm/yarn installed
- A Telegram account
- A Morpho position
-
Clone this repository:
git clone https://github.com/yourusername/morpho-monitor.git cd morpho-monitor
-
Install dependencies:
npm install
or
yarn install
-
Create a
.env
file based on the example:cp .env.example .env
-
Create a Telegram bot:
- Open Telegram and search for "BotFather"
- Send "/newbot" and follow instructions to create a bot
- Copy the API token provided
-
Get your Telegram channel ID:
- Create a new channel or group
- Add "@getidsbot" to your channel/group
- Copy the channel ID that the bot provides
-
Find your Morpho market ID:
- After depositing into a Morpho vault, check the transaction logs
- Find the market ID in the event data (as shown in the tutorial)
-
Update your
.env
file with:- Your wallet address
- The market ID for your position
- Your Telegram bot token
- Your Telegram channel ID
- Your preferred risk threshold and check intervals
Edit the .env
file to customize your monitoring:
# RPC endpoint - use your own for reliability
RPC_URL=https://mainnet.base.org
# Morpho contract address on Base
MORPHO_ADDRESS=0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb
# Your wallet address that has the Morpho position
WALLET_ADDRESS="Your wallet address"
# Morpho market ID where you have your position
MARKET_ID="Your market ID"
# Alert when LTV reaches this percentage of LLTV (0.7 = 70%)
LTV_ALERT_THRESHOLD=0.74
# Check interval in seconds (300 = 5 minutes)
CHECK_INTERVAL=300
# Space out notifications (360 = 6 minutes)
ALERT_COOLDOWN=360
# Token for Telegram bot
TOKEN="Your Telegram bot token"
# Channel ID for Telegram
CHANNEL="Your Telegram channel ID"
Start the monitoring script:
npm start
or
yarn start
For production use, consider using a process manager like PM2 or running it on a cloud service.
For 24/7 monitoring:
# Install PM2
npm install -g pm2
# Start with PM2
pm2 start src/monitor.js --name morpho-monitor
# Ensure it starts on reboot
pm2 startup
pm2 save
This tool is provided as is, without warranty of any kind. Always monitor your positions manually as well. Crypto markets can move quickly, and automated tools may have delays or errors.