Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds manual balance refetch capability to the supply modal. Users can click a new Refetch button in SupplyModalContent to refresh their token and ETH balances. The useSupplyMarket hook exposes a refetch function, and SupplyModalV2 improves state handling by resetting preview amounts when the modal reopens. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/components/SupplyModalContent.tsx (1)
33-36: AddrefetchtoonSuccessdependencies
onSuccesscloses the modal and callsrefetch, but the callback only depends ononClose. Ifrefetchever changes, this can use a stale version and will also trip the hooks lint rules. Suggest:- const onSuccess = useCallback(() => { - onClose(); - refetch(); - }, [onClose]); + const onSuccess = useCallback(() => { + onClose(); + refetch(); + }, [onClose, refetch]);
🧹 Nitpick comments (2)
src/components/SupplyModalV2.tsx (1)
44-55:supplyDeltamemo logic is correct but could be clearerThe positive/negative delta handling looks right and should avoid zero/no-op values. For readability you might replace the
x && x > 0npattern with an explicitif (!x || x <= 0n) return undefined;style, but that’s optional.src/hooks/useSupplyMarket.ts (1)
96-100: Combinedrefetchimplementation is fine; async variant optionalCalling both
refetchTokenandrefetchETHinside a memoized callback is enough here. If you ever need to await completion, you could switch to:const refetch = useCallback(async () => { await Promise.all([refetchToken(), refetchETH()]); }, [refetchETH, refetchToken]);For now, the void-fire-and-forget version is acceptable.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/components/SupplyModalContent.tsx(3 hunks)src/components/SupplyModalV2.tsx(4 hunks)src/hooks/useSupplyMarket.ts(4 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{ts,tsx,js,jsx,css,scss}
📄 CodeRabbit inference engine (AGENTS.md)
Run
pnpm format(Prettier) before pushing with 2-space indentation, 100-character width, single quotes, and Tailwind-aware class ordering
Files:
src/components/SupplyModalV2.tsxsrc/hooks/useSupplyMarket.tssrc/components/SupplyModalContent.tsx
**/*.tsx
📄 CodeRabbit inference engine (AGENTS.md)
Use PascalCase for React component file names (e.g.,
VaultBanner.tsx)
Files:
src/components/SupplyModalV2.tsxsrc/components/SupplyModalContent.tsx
src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use camelCase for helper function names (e.g.,
formatApr)
Files:
src/components/SupplyModalV2.tsxsrc/hooks/useSupplyMarket.tssrc/components/SupplyModalContent.tsx
**/*.{tsx,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{tsx,jsx}: Keep Tailwind class lists lean and dedupe variants withtailwind-merge
All toggles must use the sharedIconSwitchcomponent from@/components/common/IconSwitchfor consistent sizing and animation
Files:
src/components/SupplyModalV2.tsxsrc/components/SupplyModalContent.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
ESLint (Airbnb + Next.js) enforces hook safety and import hygiene
Files:
src/components/SupplyModalV2.tsxsrc/hooks/useSupplyMarket.tssrc/components/SupplyModalContent.tsx
src/hooks/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
When building on-chain hooks, mirror
useERC20ApprovalanduseTransactionWithToastpatterns and memoize arrays/objects before using them in effect dependencies to prevent redundant RPC calls
Files:
src/hooks/useSupplyMarket.ts
🧠 Learnings (3)
📚 Learning: 2024-11-25T09:39:42.148Z
Learnt from: antoncoding
Repo: antoncoding/monarch PR: 87
File: app/home/HomePage.tsx:17-39
Timestamp: 2024-11-25T09:39:42.148Z
Learning: In `app/home/HomePage.tsx`, the `useEffect` hook depends on `[showCustomized]` because changing `showCustomized` triggers updates to the yield and risk terms.
Applied to files:
src/components/SupplyModalV2.tsxsrc/components/SupplyModalContent.tsx
📚 Learning: 2025-11-25T14:45:50.378Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T14:45:50.378Z
Learning: Applies to src/hooks/**/*.{ts,tsx} : When building on-chain hooks, mirror `useERC20Approval` and `useTransactionWithToast` patterns and memoize arrays/objects before using them in effect dependencies to prevent redundant RPC calls
Applied to files:
src/components/SupplyModalV2.tsxsrc/hooks/useSupplyMarket.ts
📚 Learning: 2025-11-25T14:45:50.378Z
Learnt from: CR
Repo: antoncoding/monarch PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T14:45:50.378Z
Learning: Applies to **/*.{tsx,jsx} : All toggles must use the shared `IconSwitch` component from `@/components/common/IconSwitch` for consistent sizing and animation
Applied to files:
src/components/SupplyModalContent.tsx
🧬 Code graph analysis (2)
src/components/SupplyModalV2.tsx (1)
src/hooks/useFreshMarketsState.ts (1)
useFreshMarketsState(28-154)
src/components/SupplyModalContent.tsx (2)
src/utils/balance.ts (1)
formatBalance(21-23)src/utils/networks.ts (1)
getNativeTokenSymbol(211-213)
🔇 Additional comments (8)
src/components/SupplyModalV2.tsx (3)
31-36: Effect reset ondefaultModelooks fine; confirm open behaviorResetting
modeand preview amounts whendefaultModechanges should prevent stale previews. This assumes the modal is either remounted on close ordefaultModeis updated when reopening; worth double‑checking usage in parents but the effect itself is sound.
83-90: Good call resetting previews on mode toggleToggling between supply/withdraw while clearing both preview amounts directly addresses stale preview state when switching modes.
105-105: Using sharedsupplyDeltaforMarketDetailsBlockis consistentPassing the memoized
supplyDeltakeeps preview logic in one place and should avoid divergent calculations between the modal and details block.Please confirm
MarketDetailsBlockexpects a signed delta (positive for supply, negative for withdraw) so the new behavior matches its internal assumptions.src/components/SupplyModalContent.tsx (2)
57-57: Aliasrefetch→refetchBalanceis straightforwardDestructuring
refetchfromuseSupplyMarketasrefetchBalancekeeps the hook’s API generic while naming is clear at the call site.
115-130: Balance display + Refetch button look goodThe balance formatting and symbol selection match the existing pattern, and the small ReloadIcon button with
aria-labelcleanly hooks intorefetchBalance. No issues from a UX or code perspective.src/hooks/useSupplyMarket.ts (3)
18-44: AddingrefetchtoUseSupplyMarketReturnis a clean API extensionExtending the return type with a
refetchaction is backward‑compatible and matches how the hook is now used fromSupplyModalContent.
60-71: Usingrefetchfrom bothuseBalancecalls is appropriateGrabbing
refetchfor token and ETH balances gives you explicit, controllable refreshes without changing existing balance usage.
354-368: Exposingrefetchin the returned object is consistentReturning
refetchalongsidetokenBalance/ethBalancemakes sense for consumers likeSupplyModalContentthat want a manual refresh.
Summary by CodeRabbit
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.