{"id":50708320,"url":"https://github.com/morpho-org/privy-morpho-recipe","last_synced_at":"2026-06-09T13:30:37.540Z","repository":{"id":356305187,"uuid":"1200256741","full_name":"morpho-org/privy-morpho-recipe","owner":"morpho-org","description":"Privy - Morpho Recipies","archived":false,"fork":false,"pushed_at":"2026-05-20T08:19:08.000Z","size":2006,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-20T11:59:28.036Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/morpho-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-03T07:48:55.000Z","updated_at":"2026-05-20T08:19:13.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/morpho-org/privy-morpho-recipe","commit_stats":null,"previous_names":["morpho-org/privy-morpho-recipe"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/morpho-org/privy-morpho-recipe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fprivy-morpho-recipe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fprivy-morpho-recipe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fprivy-morpho-recipe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fprivy-morpho-recipe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/morpho-org","download_url":"https://codeload.github.com/morpho-org/privy-morpho-recipe/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fprivy-morpho-recipe/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34110009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-09T13:30:36.696Z","updated_at":"2026-06-09T13:30:37.532Z","avatar_url":"https://github.com/morpho-org.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Privy x Morpho: DeFi Lending Recipe\n\n![Home](public/landing/home.png)\n\nA developer recipe for building **Earn** and **Borrow** products using [Privy](https://privy.io) embedded wallets and [Morpho](https://morpho.org) lending markets. Clone, configure, ship.\n\n## Disclaimer\n\nThis is an **educational demonstration** showcasing integration patterns between Privy and Morpho. It is functional but intended for learning purposes. **Do not use in production without security audits, testing, and risk assessment.**\n\n- Always exercise caution when interacting with real smart contracts and funds\n- Always use minimal amounts\n- Never Hardcode any private keys \n- Consider professional security audits for production applications\n\n## Overview\n\nThis recipe demonstrates how to build a **one-click DeFi lending application** combining:\n\n- **[Privy](https://privy.io)** — Embedded wallet infrastructure for seamless user onboarding\n- **[Morpho](https://morpho.org)** — Hyper-efficient lending markets and vault yield optimization\n- **Multi-chain discovery** — Browse Morpho deployments on Ethereum, Base, Arbitrum, Polygon, Optimism, and more, with SDK-backed transaction execution currently enabled on Base\n\n### Earn Product\n\nBrowse and deposit into Morpho vaults across chains. Real-time APY, TVL, and position tracking with value transitions on deposit/withdraw.\n\n![Earn Product](public/landing/earn.png)\n\n### Borrow Product\n\nBrowse top 50 markets, supply collateral, borrow assets. Full position simulation with LTV, health factor, liquidation price, and review step before execution.\n\n![Borrow Product](public/landing/borrow.png)\n\n### Key Features\n\n- Privy wallet authentication (social login, email, or external wallet)\n- Multi-vault and multi-market discovery via Morpho's GraphQL API\n- Transaction building via `@morpho-org/morpho-sdk` for vault deposits/withdrawals and market borrow/repay flows\n- Real-time position simulation with before/after projections\n- Input validation with clear disabled reasons\n- Review step before wallet execution\n- Responsive split-view UI (table + action panel)\n\n## Prerequisites\n\n- **Node.js 20+** and **pnpm**\n- **Privy App ID** from the [Privy Dashboard](https://dashboard.privy.io)\n- **Basic DeFi knowledge** (ERC-20 tokens, lending markets, vaults)\n\n## Getting Started\n\n```bash\ngit clone https://github.com/morpho-org/privy-morpho-recipe.git\ncd privy-morpho-recipe\npnpm install\n```\n\nCreate `.env.local`:\n\n```bash\nNEXT_PUBLIC_PRIVY_APP_ID=your_privy_app_id\n```\n\nRun the development server:\n\n```bash\npnpm dev\n```\n\n## Architecture\n\n### Core Components\n\n| Component | Purpose |\n|-----------|---------|\n| `MarketOperationsModal` | Borrow/repay panel with simulation, validation, and review step |\n| `VaultOperationsModal` | Deposit/withdraw panel with value transitions and review step |\n| `MarketTable` | Top 50 markets by size with rate, utilization, and liquidity |\n| `VaultTable` | Top 20 vaults by TVL with APY breakdown and curator info |\n| `SimulationSummary` | Before/after position projections (collateral, debt, LTV, HF) |\n| `ReviewStep` | Inline transaction review before wallet execution |\n\n### Hooks\n\n| Hook | Purpose |\n|------|---------|\n| `useMarketPosition` | Borrow position state, simulation, validation, transaction handlers |\n| `useVaultPosition` | Vault deposit/withdraw state, slippage detection, safety checks |\n| `useMarkets` / `useVaults` | GraphQL data fetching and market/vault selection |\n| `useSmartAccount` | Privy wallet integration for transaction signing |\n| `useTxLifecycle` | Transaction state machine (processing, success, error) |\n\n### Data Flow\n\n```\nMorpho GraphQL API → Apollo Client → useMarkets/useVaults hooks\n                                         ↓\nUser selects market/vault → useMarketPosition/useVaultPosition hooks\n                                         ↓\nOn-chain reads (viem + Morpho SDK) → Position, oracle price, market data\n                                         ↓\nSimulation engine → Projected LTV, HF, liquidation price\n                                         ↓\nValidation engine → CTA state, disabled reasons\n                                         ↓\nMorpho SDK action → requirements, signatures/approvals, built transaction\n                                         ↓\nReview step → Wallet execution via Privy wallet client\n```\n\n### Libraries\n\n| Library | Purpose |\n|---------|---------|\n| `@privy-io/react-auth` | Wallet authentication and embedded wallets |\n| `@morpho-org/morpho-sdk` | Recommended Morpho SDK for building VaultV2 and MarketV1 transactions, resolving approvals, Permit/Permit2 signatures, and Morpho authorizations |\n| `@morpho-org/blue-sdk` | Morpho market params and offchain entity types used by the SDK flow |\n| `@morpho-org/blue-sdk-viem` | Morpho contract ABIs and viem-compatible helpers |\n| `@apollo/client` | GraphQL data fetching from Morpho API |\n| `wagmi` + `viem` | Blockchain interactions and contract calls |\n| `framer-motion` | UI animations |\n\n## Extending This Recipe\n\n### Adding a New Chain\n\nThe app already supports multiple chains for market and vault discovery. Current SDK-backed transaction execution is enabled on Base.\n\nTo add a new Morpho deployment:\n\n1. Add the chain to `CHAIN_ID_MAP` in `src/context/ChainContext.tsx`\n2. Add the chain config to `wagmiConfig` in `src/app/providers.tsx`\n3. The GraphQL API will automatically include markets/vaults on the new chain\n4. Enable the transaction handlers for that chain after validating Morpho SDK support, RPC configuration, and wallet signing behavior\n\n### Optional Features (Not Yet Implemented)\n\n- **Gas Sponsorship** — Privy paymaster integration for gasless transactions\n- **Health Monitoring** — Server-side position monitoring with Privy server wallets\n- **Batch** - Using smart wallet and batching transactions\n\n## Security Considerations\n\n- Morpho vaults and markets are subject to smart contract risks\n- ERC-20 approvals are scoped to the specific transaction amount\n- Input validation prevents unsafe positions (LTV checks, balance checks)\n- Health factor simulation warns before liquidation-risk actions\n- Always test with small amounts first\n\n## Resources\n\n- [Privy Documentation](https://docs.privy.io)\n- [Morpho Documentation](https://docs.morpho.org)\n- [Morpho SDK Documentation](https://docs.morpho.org/tools/offchain/sdks/morpho-sdk/)\n- [Morpho SDK Source](https://github.com/morpho-org/sdks/tree/main/packages/morpho-sdk)\n- [Morpho GraphQL API](https://blue-api.morpho.org/graphql)\n- [Morpho App](https://app.morpho.org)\n\n## License\n\nMIT License — see [LICENSE](LICENSE) for details.\n\n---\n\nBuilt to demonstrate the power of Privy x Morpho integration.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorpho-org%2Fprivy-morpho-recipe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorpho-org%2Fprivy-morpho-recipe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorpho-org%2Fprivy-morpho-recipe/lists"}