feat(lite): ⚠️ Proof of Concept: Client-Side Notifications (PWA)#117
Open
nicosampler wants to merge 3 commits intomorpho-org:mainfrom
Open
feat(lite): ⚠️ Proof of Concept: Client-Side Notifications (PWA)#117nicosampler wants to merge 3 commits intomorpho-org:mainfrom
nicosampler wants to merge 3 commits intomorpho-org:mainfrom
Conversation
- Integrated VitePWA plugin in vite.config.ts with a manifest for the Morpho Lite app. - Updated package.json to include vite-plugin-pwa dependency. - Included InstallBanner component in header.tsx for user installation prompts.
|
@nicosampler is attempting to deploy a commit to the Morpho Association Team on Vercel. A member of the Team first needs to authorize it. |
88169fd to
33c34b2
Compare
- Added a PWAProvider to manage PWA installation and notification permissions. - Refactored InstallBanner to use the new usePWA hook. - Implemented a service worker for user notifications. - Added demo jobs to handle health factors and market yields (no real functionality, only to show how it could work). - Created utility functions for sending notifications and managing job states in the service worker.
33c34b2 to
bbba181
Compare
- Replaced the existing job handlers for health factors and market yields with new implementations. - Introduced a dedicated handler for health factor checks, which calculates and monitors health factors for user positions. - Updated the service worker to utilize the new health factor handler and adjusted job scheduling intervals. - Added a new job for market yield checks, with a placeholder for future implementation. - Removed obsolete job files and notification utility functions to streamline the user notifications architecture.
Author
|
Hello @garethfuller @haydenshively @cashd 👋🏾 Sorry to tag you directly! As an external contributor, I wasn't sure of the best channel to introduce this idea to the team. I would love to hear your opinions on this approach whenever you have a moment. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Status:
Experimental/Do Not MergeMotivation
This PR explores a feature I believe would be a valuable addition to the Morpho app: automated user notifications. As a user, I want to be alerted about critical changes to my positions - such as a Health Factor dropping below a specific threshold or a significant dip in APY for supplied assets - without constantly monitoring the interface.
While there are existing solutions that solve this via server-side monitoring and messaging layers (Email, Telegram, etc.), they typically require sacrificing privacy by sharing user data with a centralized service.
Proposed Solution
I propose a privacy-first, client-side solution leveraging Progressive Web App (PWA) capabilities and Service Workers.
By converting the Morpho app into a PWA, we can run background processes locally on the user's device. This allows for:
Future UX Vision
While this PR focuses on the underlying architecture, I envision the final implementation featuring a "Notification Center" (e.g., a Bell icon in the header).
This UI component would allow users to:
Implementation Overview
This PR demonstrates the feasibility of this architecture through three main steps:
Technical Notes, Trade-offs & Workarounds
viemdirectly within the Service Worker due to restricted dynamic imports in that environment.eth_call. This required adjustments to thewagmi-config.borrow-subpagehooks had to be duplicated/re-implemented for the worker context. A future refactor would be needed to abstract this shared logic into pure TS functions compatible with both environments.5. This allows testing the notification flow by taking a real, low-risk loan (high HF) and still receiving the alert immediately.eth_callpolling from every client's background worker could strain public RPC endpoints. A production version could allow the user to input their own custom RPC URL to avoid rate limits.