Skip to content

Conversation

@creed-victor
Copy link
Contributor

No description provided.

@creed-victor creed-victor self-assigned this Dec 11, 2025
Copilot AI review requested due to automatic review settings December 11, 2025 08:02
@creed-victor creed-victor merged commit 97745cc into develop Dec 11, 2025
1 check passed
@creed-victor creed-victor deleted the feat/SOV-5258-money-market-calculate-and branch December 11, 2025 08:02
@netlify
Copy link

netlify bot commented Dec 11, 2025

Deploy Preview for sovryn-layer ready!

Name Link
🔨 Latest commit cc0ef83
🔍 Latest deploy log https://app.netlify.com/projects/sovryn-layer/deploys/693a7a7c8397ab000882bf00
😎 Deploy Preview https://deploy-preview-19--sovryn-layer.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements health factor calculation and APY display functionality for the money market feature. The changes enable users to see real-time collateral ratios, liquidation prices, and borrowing costs when interacting with the money market.

Key changes:

  • Added health factor visualization with color-coded bar component
  • Implemented APY calculations for both lending and borrowing positions
  • Enhanced form components with improved validation and user feedback

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/shared/src/lib/decimal.ts Added toNumber() method and exposed DEFAULT_PRECISION constant
packages/sdk/src/types.ts Added priceUsd field to MoneyMarketPoolReserve interface
apps/web-app/src/routes/money-market.tsx Refactored to use new useMoneyMarketPositions hook
apps/web-app/src/lib/validations.ts Enhanced validation error messages with formatted decimal values
apps/web-app/src/hooks/app-form.ts Added CheckBox component to form components
apps/web-app/src/components/ui/item.tsx New component for displaying structured item lists
apps/web-app/src/components/ui/input-group.tsx New component for grouped input fields with addons
apps/web-app/src/components/ui/health-factor-bar.tsx New visual component for health factor display
apps/web-app/src/components/ui/field.tsx Updated styling and changed gap from gap-3 to gap-1
apps/web-app/src/components/ui/amount-renderer.tsx Enhanced formatting logic and approximate sign rendering
apps/web-app/src/components/MoneyMarket/hooks/use-money-positions.ts New hook for fetching user positions
apps/web-app/src/components/MoneyMarket/components/LendDialog/LendDialog.tsx Added APY display and collateralization info
apps/web-app/src/components/MoneyMarket/components/LendAssetsList/components/AssetsTable/AssetsTable.tsx Removed "Details" button
apps/web-app/src/components/MoneyMarket/components/LendAssetsList/components/AssetsTable/AssetsTable.constants.tsx Deleted mock data constants file
apps/web-app/src/components/MoneyMarket/components/BorrowDialog/BorrowDialog.tsx Added health factor, liquidation price, and borrow APY calculations
apps/web-app/src/components/MoneyMarket/components/BorrowAssetsList/components/AssetsTable/AssetsTable.tsx Removed "Details" button and aligned table cell content
apps/web-app/src/components/FormComponents.tsx Enhanced AmountField with max balance button and improved validation
apps/web-app/package.json Updated @tanstack/react-form from 1.23.0 to 1.27.2
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

static ONE = new Decimal('1');
static INFINITY = new Decimal('Infinity', 0);

static DEFAULT_PRECISION = DEFAULT_PRECISION;
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The static property DEFAULT_PRECISION is redundantly named, simply exposing the constant DEFAULT_PRECISION. Consider renaming either the static property or the constant to avoid confusion, such as renaming the static property to precision or defaultPrecision.

Suggested change
static DEFAULT_PRECISION = DEFAULT_PRECISION;
static defaultPrecision = DEFAULT_PRECISION;

Copilot uses AI. Check for mistakes.

return (value >= end ? 1 : (value - start) / (end - start)) * 100;
},
[value, options.start],
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependency array includes options.start but the getBlurWidth callback uses multiple properties from options (start, middleStart, middleEnd, end). Either include all used options properties in the dependency array or include the entire options object to prevent stale closures.

Suggested change
[value, options.start],
[value, options],

Copilot uses AI. Check for mistakes.
}) =>
useQuery({
queryKey: ['money-market:positions', pool, address],
queryFn: () => sdk.moneyMarket.listUserPositions(pool, address!),
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The non-null assertion operator address! is unnecessary here since the query is already guarded by enabled: !!address && !!pool. The function won't execute when address is falsy. Remove the non-null assertion.

Suggested change
queryFn: () => sdk.moneyMarket.listUserPositions(pool, address!),
queryFn: () => sdk.moneyMarket.listUserPositions(pool, address),

Copilot uses AI. Check for mistakes.
selector={(state) =>
[
state.values.amount,
computeHealthFactor(state.values.amount ?? 0),
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing 0 as a fallback when state.values.amount is nullish will cause type mismatch since computeHealthFactor expects a string parameter but receives a number. Pass '0' instead.

Suggested change
computeHealthFactor(state.values.amount ?? 0),
computeHealthFactor(state.values.amount ?? '0'),

Copilot uses AI. Check for mistakes.
});

return unsub;
}, []);
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The useEffect has an empty dependency array but accesses field.store which could change between renders. Include field.store in the dependency array to ensure the subscription is updated when the store changes.

Suggested change
}, []);
}, [field.store]);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants