-
Notifications
You must be signed in to change notification settings - Fork 3
Add accrue interest button and move tables to top of positions tab #306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds an "Accrue Interest" action to the Market header which triggers a chain-switch and Morpho contract call, and extends supplied positions UI with multiple new columns (chain, asset, APR/APY, accrued interest, collateral, risk, actions). Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Header as MarketHeader
participant View as MarketView
participant Switcher as ChainSwitcher
participant Contract as MorphoContract
participant Toast as Toasts
participant Data as MarketData
User->>Header: Click "Accrue Interest"
Header->>View: accrueInterest()
View->>Switcher: switchChainAsync(targetChain)
Switcher-->>View: chain switched
View->>Contract: sendTransaction(calldata: accrueInterest)
Contract-->>View: tx mined/confirmed
View->>Toasts: show success
View->>Data: refetch market
Data-->>View: updated market state
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/features/positions/components/supplied-morpho-blue-grouped-table.tsx (2)
227-230: Stop row toggle when clicking the Actions menu.
The rowonClickwill also fire when users open the Actions dropdown, which can toggle the row unexpectedly. Stop propagation on the Actions cell/button.Suggested fix
- <TableCell - data-label="Actions" - className="justify-center px-4 py-3" - > + <TableCell + data-label="Actions" + className="justify-center px-4 py-3" + onClick={(event) => event.stopPropagation()} + >Also applies to: 324-346
219-241: Conditionally render Image when network icon exists.
getNetworkImgcan returnundefinedfor unsupported chains. Next.js Image rejects empty stringsrc, so the?? ''fallback will error at runtime. Use conditional rendering instead.Suggested fix
- return ( + const networkImg = getNetworkImg(groupedPosition.chainId); + return ( <Fragment key={rowKey}> <TableRow className="cursor-pointer hover:bg-gray-50" onClick={() => toggleRow(rowKey)} > {/* Chain image */} <TableCell className="w-10"> <div className="flex items-center justify-center"> - <Image - src={getNetworkImg(groupedPosition.chainId) ?? ''} - alt={`Chain ${groupedPosition.chainId}`} - width={24} - height={24} - /> + {networkImg && ( + <Image + src={networkImg} + alt={`Chain ${groupedPosition.chainId}`} + width={24} + height={24} + /> + )} </div> </TableCell>
🤖 Fix all issues with AI agents
In `@src/features/market-detail/market-view.tsx`:
- Around line 82-96: The success toast is shown too early because
handleAccrueInterest calls writeContractAsync directly and doesn't await the
transaction lifecycle or surface errors; instead route the action through the
transaction hook by calling sendAccrueInterest (or sendTransactionAsync returned
by useTransactionWithToast) and await it so pending/success/error toasts and
onSuccess/refetchMarket run after on-chain confirmation; update
handleAccrueInterest to call sendAccrueInterest with the same params you pass to
writeContractAsync, await the returned promise, and ensure errors are
caught/propagated (and apply the same change to other handlers that call
writeContractAsync directly, e.g., the similar handlers referenced around the
file that perform writes).
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.