-
Notifications
You must be signed in to change notification settings - Fork 0
[app] fetch balance from contract #15
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
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughReplaces inline balance sheet constants with data from a new useBalanceSheet hook. Adds exports in hooks index. Introduces useBalanceSheet to read on-chain values via wagmi, compute percentages for SPOT/PERP/USDC, and return structured balanceData plus totals. Updates BalanceSheetSection to consume the hook-derived data. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant BalanceSheetSection as BalanceSheetSection (UI)
participant useBalanceSheet as useBalanceSheet (hook)
participant wagmi as wagmi useReadContract
participant Accountant as Crest.Accountant
participant Manager as Crest.Manager
User->>BalanceSheetSection: Open landing balance sheet
BalanceSheetSection->>useBalanceSheet: invoke()
rect #e8f5e9
note right of useBalanceSheet: Fetch on-chain data
useBalanceSheet->>wagmi: read getTotalAssets()
wagmi->>Accountant: getTotalAssets
Accountant-->>wagmi: totalAssets (bigint)
wagmi-->>useBalanceSheet: totalAssets
useBalanceSheet->>wagmi: read getPositions()
wagmi->>Manager: getPositions
Manager-->>wagmi: positions
wagmi-->>useBalanceSheet: positions
useBalanceSheet->>wagmi: read estimatePositionValue()
wagmi->>Manager: estimatePositionValue
Manager-->>wagmi: value (bigint)
wagmi-->>useBalanceSheet: corePositionValue
end
note over useBalanceSheet: Format values, compute SPOT/PERP/USDC percentages
useBalanceSheet-->>BalanceSheetSection: { balanceData, totals, positions }
BalanceSheetSection-->>User: Render pie chart & list from balanceData
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Free 📒 Files selected for processing (3)
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Summary by CodeRabbit
New Features
Improvements