Applied Use Cases: Morpho Demo
Integrate crypto-backed loans into your app using Gelato’s Smart Wallet SDK and Morpho’s lending protocol. This guide walks you through setting up embedded wallet onboarding and implementing both the Supply/Earn and Borrow flows.
This guide assumes you’re using React + TypeScript.
Smart Wallet Onboarding Setup
Before users can supply or borrow assets, they must onboard into a Smart Wallet via a frictionless embedded flow. Powered by Gelato’s SDK and Dynamic, users can create smart accounts using just their email, social login, or passkeys — no browser extensions or seed phrases needed.
Key Features of Embedded Wallets
- EIP-7702 & ERC-4337 compliant
- Supports gasless transactions (sponsored execution)
- Runs across 50+ EVM chains
- Session-based login — no need to reconnect every time
Code Snippet
Embed the following setup within your app to configure the provider:
This context enables smart wallet access throughout your app, setting up:
- Wallet creation and session
- Transaction preparation and sending
- Provider availability across your components
Part 1: Supply & Earn
Allow users to supply assets (e.g., USDC) and earn yield in Morpho’s vaults — fully onchain, without user signatures or gas fees.
Flow Overview
- Approve vault to spend USDC
- Deposit USDC to Morpho vault
- Optionally, record stats to external tracking contract
Code Snippet
Users never sign a transaction or pay gas. All logic executes onchain using their smart account.
Part 2: Borrow
Let users borrow stablecoins (like USDC) using crypto collateral (cbBTC) — trustless, non-custodial, and instant.
Flow Overview
- Approve Morpho to move collateral
- Supply collateral to Morpho
- Borrow USDC
Code Snippet
Summary
Feature | Available Now |
---|---|
Smart wallet onboarding (social/email) | Yes |
Embedded supply to Morpho vaults | Yes |
Embedded borrow against crypto | Yes |
Gasless transactions via Gelato | Yes |
Fully onchain, no custody | Yes |
What You Can Build
Using these flows, your app can now offer:
- Embedded lending dashboards
- Crypto credit lines
- Non-custodial stablecoin loans
- Yield vault integrations
- Composable DeFi automations
You get the power of Morpho and the abstraction of Gelato — without the overhead of building wallets, managing custody, or dealing with onchain UX friction.