feat: enhance market data display by adding percentMultiplier and upd…#168
feat: enhance market data display by adding percentMultiplier and upd…#168
Conversation
…ating discount formatting across components
WalkthroughThe Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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: 1
♻️ Duplicate comments (2)
packages/app/src/features/liquidity-flow/components/lend-first-position-modal/lend-first-position-modal.tsx (1)
11-11: LGTM: Discount formatting is correct and consistent.The discount formatting logic matches the pattern used in other components. The formatter creation is duplicated across files (already flagged in position-cell.tsx), but the implementation here is correct.
Also applies to: 32-38, 51-54
packages/app/src/features/liquidity-flow/components/lend-increase-modal/lend-increase-modal.tsx (1)
11-11: LGTM: Discount formatting is correct and consistent.The discount formatting logic correctly uses
percentMultiplier - discountand handles the undefined case. The formatter creation is duplicated across files (already flagged in position-cell.tsx), but the implementation here is correct.Also applies to: 89-89, 121-123
🧹 Nitpick comments (1)
packages/app/src/widgets/position-section/components/position-cell/position-cell.tsx (1)
15-15: Consider returning the formatter from the hook to reduce duplication.The same pattern of importing
makeFormatPercentWithPrecisionand creating a localformatPercentageformatter is duplicated across four components (position-cell.tsx, lend-first-position-modal.tsx, lend-increase-modal.tsx, and market-card.tsx). Consider havinguseMarketDataForDisplayreturn a pre-configuredformatPercentagefunction to eliminate this duplication.For example, in
use-market-data-for-display.ts:export function useMarketDataForDisplay(token: TokenContracts): { borrowInterestRate: string; lendInterestRate: string; totalSupplied: number; totalBorrowed: number; reserved: number; availableToBorrow: number; percentMultiplier: number; discount: number | undefined; + formatPercentage: (value?: number | bigint) => string; } { const { percentMultiplier, borrowInterestRate, lendInterestRate, contractMultiplier } = usePoolData(token.address); const marketData = useMarketData(); const { discount } = marketData?.[token.address] ?? {}; const { availableToBorrow, reserved, totalBorrowed, totalSupplied } = useAvailableToBorrow(token); const formatInterestRate = makeFormatPercentWithPrecision(contractMultiplier); + const formatPercentage = makeFormatPercentWithPrecision(percentMultiplier); return { discount, borrowInterestRate: formatInterestRate(borrowInterestRate?.toNumber()), lendInterestRate: formatInterestRate(lendInterestRate?.toNumber()), totalSupplied, totalBorrowed, reserved, availableToBorrow, percentMultiplier, + formatPercentage, }; }Then remove the local formatter creation from all consuming components.
Also applies to: 38-41
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
packages/app/src/entities/token/hooks/use-market-data-for-display.ts(2 hunks)packages/app/src/features/liquidity-flow/components/lend-first-position-modal/lend-first-position-modal.tsx(3 hunks)packages/app/src/features/liquidity-flow/components/lend-increase-modal/lend-increase-modal.tsx(3 hunks)packages/app/src/widgets/market-section/components/market-card/market-card.tsx(3 hunks)packages/app/src/widgets/position-section/components/position-cell/position-cell.tsx(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
packages/app/src/widgets/position-section/components/position-cell/position-cell.tsx (4)
packages/app/src/entities/token/hooks/use-market-data-for-display.ts (1)
useMarketDataForDisplay(7-36)packages/app/src/shared/stellar/constants/tokens.ts (1)
tokenContracts(46-56)packages/app/src/entities/token/context/hooks.ts (1)
useTokenCache(4-4)packages/app/src/entities/token/utils/make-format-percent-with-precision.ts (1)
makeFormatPercentWithPrecision(3-6)
packages/app/src/features/liquidity-flow/components/lend-increase-modal/lend-increase-modal.tsx (1)
packages/app/src/entities/token/utils/make-format-percent-with-precision.ts (1)
makeFormatPercentWithPrecision(3-6)
packages/app/src/features/liquidity-flow/components/lend-first-position-modal/lend-first-position-modal.tsx (3)
packages/app/src/features/liquidity-flow/hooks/use-token-info.ts (1)
useTokenInfo(8-42)packages/app/src/entities/token/utils/make-format-percent-with-precision.ts (1)
makeFormatPercentWithPrecision(3-6)packages/app/src/shared/components/info-row/info-row.tsx (1)
InfoRow(11-27)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: test-build-image (landing)
- GitHub Check: test-build-image (app)
🔇 Additional comments (2)
packages/app/src/widgets/position-section/components/position-cell/position-cell.tsx (1)
70-70: LGTM: Discount calculation and formatting are correct.The formula
percentMultiplier - discountcorrectly computes the discount percentage, and the ternary operator properly handles theundefinedcase. The formatter will display '...' when discount is unavailable.packages/app/src/entities/token/hooks/use-market-data-for-display.ts (1)
14-15: Verified:percentMultiplieris always a positive constant and safe from division by zero.The
usePoolDatahook always returnspercentMultiplierset toPERCENT_PRECISION(10000), which is a constant positive number. The type is non-optional (number), and there are no conditional paths that could make it undefined or zero. The divisor inmakeFormatPercentWithPrecisionis therefore always safe.
…ating discount formatting across components
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.