React web app for Morpho Blue and MetaMorpho contracts that's designed to work using only public RPCs-no other infrastructure required.
To get started:
git clone https://github.com/morpho-org/morpho-lite-apps.git
cd morpho-lite-apps
# Install packages and run
pnpm install
pnpm run devAfter running the commands above, open http://localhost:5173/ in your browser to use the app.
- 🦋 View your deposits in MetaMorpho vaults
- 🌌 View your borrow positions
- 📤 Withdraw from MetaMorpho vaults
- ⚡️ Repay loans, add collateral, and remove collateral
- ⛓️ Support any chain with Morpho contracts
- 🏗️ Requires no additional infrastructure/services
Tip
The app uses your wallet RPC by default, then falls back to drpc. You can switch the order or add additional RPCs by modifying the wagmiConfig in App.tsx.
This is a single page app built with React 19, Vite, shadcn, and wagmi.
Key Components
- src/App.tsx -- Defines a
wagmiConfigand sets up various providers and contexts for data caching - src/hooks/use-contract-events.ts -- React hook for calling
eth_getLogswith retries and caching, respecting an optional constraint on the largest-fetchable block range - src/app/dashboard/earn-subpage.tsx -- Main component for the Earn page. Fetches data as follows:
CreateMetaMorphoevents, so we know addresses of all MetaMorpho vault contracts- The user's
Depositevents for all ERC4626 vaults (even non-Morpho). We filter these down using results from (1) - ERC20 symbols and decimals for each underlying asset
- Vault info, including name, curator, timelock, and
totalAssets
- src/app/dashboard/borrow-subpage.tsx -- Main component for the Borrow page
SupplyCollateralevents on the Morpho Blue contract, so we know where the user has (or had) positionsmarketParamsstruct for eachmarketIdreferenced in events from (1)marketsstruct for eachmarketIdreferenced in events from (1)- ERC20 symbols and decimals for each
collateralTokenandloanToken
- src/components/ui/... -- shadcn reusable component library
- Update the
wagmiConfigin App.tsx. You'll need at least 1 public RPC node that supportseth_getLogs. - Update the
DEPLOYMENTSmapping in constants.ts. You should match the formatting of existing chains, and properly capitalize addresses. - [Optional] Add chain icon SVG to src/assets/chains, and update the
ChainIconcomponent. - Test!
Warning
Currently, we split block ranges into 10_000-block chunks for eth_getLogs.
If there's a new chain with a more restrictive RPC, some additional work
will be required to add support.
