Skip to content
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

Sky changes #4028

Merged
merged 6 commits into from
Sep 23, 2024
Merged

Sky changes #4028

merged 6 commits into from
Sep 23, 2024

Conversation

marcinciarka
Copy link
Member

@marcinciarka marcinciarka commented Sep 23, 2024

  • better wallet handling (non owner view, not connected view)
  • fixed icons warning
  • sky upgrade page banner

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a mechanism to display an action banner based on the user's USDS balance, encouraging staking interactions.
    • Added functionality to fetch stake details related to skyUsds.
  • Improvements

    • Simplified data handling for staking and wallet information, enhancing UI consistency and flexibility.
    • Enhanced readability of allowance checks in the UI components.
    • Updated the logic for displaying allowance information based on user inputs.
  • Bug Fixes

    • Improved state management and error handling for wallet and stake data.
  • Style

    • Standardized SVG attribute naming conventions to align with React's JSX syntax.

Copy link
Contributor

coderabbitai bot commented Sep 23, 2024

Warning

Rate limit exceeded

@marcinciarka has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 26 minutes and 26 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between da7e65c and 1742a27.

Walkthrough

The changes involve modifications across several files, primarily focusing on the sky.ts file, which now retrieves fewer values from the skyStakingContract. Other updates include the introduction of new constants for improved readability, adjustments to state management in components, and enhancements to SVG attribute naming conventions. These changes collectively streamline data handling and improve the structure of various components within the Sky ecosystem.

Changes

Files Change Summary
blockchain/better-calls/sky.ts Updated skyUsdsWalletStakeDetails function to retrieve only balance and earned, removing rewardRate and totalUSDSLocked. Adjusted return type accordingly.
features/sky/components/SwapCard.tsx Introduced showAllowanceInfo constant for conditional rendering of allowance information, improving code readability.
features/sky/components/stake/SkyStakePositionView.tsx Updated SkyStakeViewType interface to make usdsAllowance and skyAllowance optional, added skyStakeWalletData, and adjusted component logic to reference the new wallet data structure.
features/sky/hooks/useSky.ts Made allowance and balance optional in ResolvedDepositParamsType and useSkyType interfaces. Added viewWalletAddress for ownership checks and adjusted logic accordingly.
features/sky/helpers.ts Introduced showAllowanceInfo helper function to evaluate allowance conditions based on amount and allowance.
pages/[networkOrProduct]/sky/upgrade.tsx Introduced conditional rendering of an ActionBanner based on USDS balance and simplified the layout of the swap cards.
pages/earn/srr/[wallet].tsx Made walletAddress prop optional, split state management for wallet-specific and general stake data, and updated rendering logic accordingly.
pages/earn/srr/index.tsx Removed AppLayout and WithWalletConnection components, simplifying the structure to focus on rendering SkyStakeUsdsViewWrapper.
theme/icons/oeth.tsx Changed SVG attributes from kebab-case to camelCase for consistency with JSX conventions.
theme/icons/sky.tsx Converted SVG attributes to camelCase, standardizing naming conventions.
theme/icons/susds.tsx Updated SVG attributes to camelCase, aligning with React's JSX syntax.
handlers/portfolio/positions/handlers/sky/index.ts Added import of skyUsdsStakeDetails and updated skyPositionsHandler to include a call to this function, modifying the return object to reference usdsStakeDetails.rewardRate.

Possibly related PRs

  • Sky USDS staking view #4027: Focuses on introducing a staking view for Sky USDS, directly related to the changes made in the sky.ts file regarding the retrieval of staking details and wallet stake information.

Poem

🐇 In the garden where the tokens play,
A rabbit hops and shouts hooray!
With balances trimmed and logic refined,
The sky is bright, our paths aligned.
So let us stake and share the cheer,
For every change brings us near! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Outside diff range and nitpick comments (6)
blockchain/better-calls/sky.ts (1)

Line range hint 118-133: Consider documenting the separation of concerns between stake detail functions.

The changes to skyUsdsWalletStakeDetails and the unchanged skyUsdsStakeDetails function suggest a clear separation of concerns:

  1. skyUsdsWalletStakeDetails: Focuses on user-specific data (balance and earned rewards).
  2. skyUsdsStakeDetails: Handles global staking data (reward rate and total locked USDS).

This separation aligns well with the PR objectives of improving UX for different view types (owner vs. non-owner).

Consider adding comments to both functions to clarify their specific purposes and usage scenarios. This will help maintain the clear separation of concerns in future development. For example:

/**
 * Retrieves user-specific staking details.
 * Use this for personalized wallet views.
 */
export const skyUsdsWalletStakeDetails = async ({ ownerAddress }: { ownerAddress?: string }) => {
  // ... (existing implementation)
}

/**
 * Retrieves global staking details.
 * Use this for general staking information views.
 */
export const skyUsdsStakeDetails = async () => {
  // ... (existing implementation)
}

Also applies to: 136-155

features/sky/components/SwapCard.tsx (1)

130-135: Approve changes with a minor suggestion.

The introduction of the showAllowanceInfo constant improves code readability and reduces duplication by centralizing the allowance check logic. This is a good refactoring step.

Consider renaming showAllowanceInfo to something more specific like showAllowanceWarning or requiresAllowanceUpdate to better reflect its purpose. This would make the intent clearer to other developers.

helpers/context/ProductContext.ts (2)

692-693: LGTM: New observable function added correctly

The new skyUsdsStakeDetails$ function has been implemented correctly, following the same pattern as the existing skyUsdsWalletStakeDetails$ function. It will update on every new block, which is consistent with other observables in this context.

For consistency, consider adding a comment explaining the purpose of this new function, similar to how other functions in this file are documented.


3-3: Summary: Sky USDS stake details functionality added successfully

The changes in this file successfully introduce a new observable skyUsdsStakeDetails$ for fetching Sky USDS stake details. The modifications are well-integrated with the existing codebase, following established patterns and conventions. These changes enhance the product context by providing access to Sky USDS staking information, which can now be used in other parts of the application.

As the product context grows with new observables and functions, consider grouping related functionality (e.g., all Sky USDS related observables) into separate modules or services to maintain code organization and scalability.

Also applies to: 692-693, 737-737

pages/[networkOrProduct]/sky/upgrade.tsx (1)

41-41: Include wallet account address in dependency array

Inside the useMemo, you're using wallet?.accounts[0].address, but the dependency array only includes wallet?.accounts. For proper memoization, include wallet?.accounts?.[0]?.address in the dependency array.

Apply this diff:

-[balancesFromAddressInfoArray$, wallet?.accounts],
+[balancesFromAddressInfoArray$, wallet?.accounts?.[0]?.address],
pages/earn/srr/[wallet].tsx (1)

50-55: Optimize useObservable Hook for skyStakeData

The useObservable hook for skyStakeData seems to be correctly set up. However, consider if any additional dependencies should be included in the useMemo dependency array to prevent unnecessary re-renders.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 62669fe and 4f2a386.

Files selected for processing (11)
  • blockchain/better-calls/sky.ts (2 hunks)
  • features/sky/components/SwapCard.tsx (2 hunks)
  • features/sky/components/stake/SkyStakePositionView.tsx (11 hunks)
  • features/sky/hooks/useSky.ts (7 hunks)
  • helpers/context/ProductContext.ts (3 hunks)
  • pages/[networkOrProduct]/sky/upgrade.tsx (3 hunks)
  • pages/earn/srr/[wallet].tsx (4 hunks)
  • pages/earn/srr/index.tsx (2 hunks)
  • theme/icons/oeth.tsx (2 hunks)
  • theme/icons/sky.tsx (12 hunks)
  • theme/icons/susds.tsx (2 hunks)
Files skipped from review due to trivial changes (2)
  • theme/icons/oeth.tsx
  • theme/icons/sky.tsx
Additional context used
Biome
pages/[networkOrProduct]/sky/upgrade.tsx

[error] 78-78: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (42)
pages/earn/srr/index.tsx (3)

1-7: LGTM: Import changes align with component updates

The import changes are consistent with the simplification of the SkyProxyPage component. The removal of unused imports and the addition of the SkyStakeUsdsViewWrapper import improve code cleanliness and reflect the new component structure.


Line range hint 8-16: LGTM: getServerSideProps function remains valid

The getServerSideProps function has not been modified. It continues to provide necessary server-side props, including translations and the walletAddress. This is consistent with the component's needs and the overall page functionality.


Line range hint 18-24: Simplification of SkyProxyPage component needs clarification

The SkyProxyPage component has been significantly simplified, which aligns with the PR objectives of enhancing wallet handling. However, there are a few points that need clarification:

  1. The AppLayout and WithWalletConnection components have been removed. Could you confirm if these responsibilities have been moved elsewhere in the application?

  2. The component still uses useAccount and useRouter hooks, but their usage in the simplified component is not clear. Are these still necessary?

  3. The logic for replacing the URL when walletAddress is not provided but walletContextAddress is available remains unchanged. Is this still required given the new component structure?

To verify the usage of useAccount and useRouter hooks, please run the following script:

This will help us understand if these hooks are still necessary in the new component structure.

theme/icons/susds.tsx (4)

5-5: LGTM: Correct attribute naming for React JSX

The change from clip-path to clipPath is correct and necessary for React JSX syntax. This modification prevents warnings and ensures proper rendering of the SVG in React components.


24-24: LGTM: Consistent attribute naming for React JSX

The change from stop-color to stopColor is correct and consistent with React JSX syntax. This modification maintains the pattern of using camelCase for attribute names in React components.


25-25: LGTM: Consistent attribute naming and preserved functionality

The change from stop-color to stopColor is correct and consistent with the previous modifications. These changes collectively ensure that all SVG attributes in this file now use the correct camelCase naming convention required by React JSX.

The functionality and appearance of the SVG remain unchanged, as only the attribute names were modified. These updates will resolve any warnings related to attribute naming and improve the overall code quality.


Line range hint 5-25: Summary: Successful resolution of icon warnings

The changes made to this file successfully address the icon warnings mentioned in the PR objectives. By updating the SVG attribute names from kebab-case to camelCase, the code now adheres to React JSX syntax requirements. This modification improves code quality and ensures proper rendering of the SVG icon without any warnings.

Key points:

  1. All instances of clip-path and stop-color have been updated to clipPath and stopColor respectively.
  2. The functionality and appearance of the SVG remain unchanged.
  3. These changes contribute to a more robust and warning-free codebase.

Great job on implementing these necessary updates!

blockchain/better-calls/sky.ts (1)

Line range hint 118-133: LGTM! Verify impact on dependent code.

The simplification of skyUsdsWalletStakeDetails by removing rewardRate and totalUSDSLocked aligns with the PR objectives of enhancing wallet handling. This change potentially improves performance and simplifies the data model for non-owner views.

Please ensure that any code depending on the removed rewardRate and totalUSDSLocked values has been updated accordingly. Run the following script to check for any remaining usage:

Also, consider updating any relevant documentation or comments that might reference these removed properties.

Verification successful

Verification Successful: No usages found for rewardRate and totalUSDSLocked.

The removal of these properties from skyUsdsWalletStakeDetails does not affect other parts of the codebase and aligns with the PR objectives.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of removed properties from skyUsdsWalletStakeDetails

# Test: Search for usage of rewardRate and totalUSDSLocked from skyUsdsWalletStakeDetails
rg --type typescript "skyUsdsWalletStakeDetails.*rewardRate" 
rg --type typescript "skyUsdsWalletStakeDetails.*totalUSDSLocked"

Length of output: 200


Script:

#!/bin/bash
# Description: Check for usage of removed properties from skyUsdsWalletStakeDetails

# Test: Search for usage of rewardRate and totalUSDSLocked from skyUsdsWalletStakeDetails

rg --glob '*.ts' 'skyUsdsWalletStakeDetails.*rewardRate'
rg --glob '*.ts' 'skyUsdsWalletStakeDetails.*totalUSDSLocked'

rg --glob '*.tsx' 'skyUsdsWalletStakeDetails.*rewardRate'
rg --glob '*.tsx' 'skyUsdsWalletStakeDetails.*totalUSDSLocked'

Length of output: 247

features/sky/components/SwapCard.tsx (2)

Line range hint 278-290: Approve the usage of showAllowanceInfo.

The showAllowanceInfo constant is correctly used to conditionally render a MessageCard component. This implementation ensures that users are informed about the need to update their allowance only when necessary, improving the user experience.


Line range hint 1-390: Alignment with PR objectives and request for clarification.

The changes in this file align well with the PR objective of enhancing wallet handling, particularly in improving the user experience for allowance information display. The introduction of showAllowanceInfo and its usage in conditional rendering contribute to this goal.

However, I couldn't find specific changes addressing the user experience for non-owner views, as mentioned in the PR objectives. Could you please clarify if these changes are implemented in other files or if they're planned for future commits?

To ensure we haven't missed any non-owner view related changes, let's search for relevant keywords:

Consider documenting the different view types (owner vs non-owner) and their specific behaviors in the component or in a separate documentation file. This would help maintain clarity as the component evolves.

helpers/context/ProductContext.ts (2)

3-3: LGTM: Import statement updated correctly

The import statement has been properly updated to include skyUsdsStakeDetails, which is consistent with the new functionality added in this file.


737-737: LGTM: New observable correctly exposed in the product context

The skyUsdsStakeDetails$ observable has been properly added to the object returned by setupProductContext, making it available for use in other parts of the application. This is consistent with how other observables are exposed in this context.

pages/[networkOrProduct]/sky/upgrade.tsx (1)

99-106: LGTM: Swap cards rendered correctly

The swap cards are being mapped and rendered as expected using the skySwapTokensConfig. The implementation is clear and efficient.

pages/earn/srr/[wallet].tsx (6)

25-25: Handle Optional walletAddress Properly

The walletAddress prop has been made optional in the SkyStakeUsdsView component. Please ensure that all usages of walletAddress within this component and its child components correctly handle cases when walletAddress is undefined.


37-37: Confirm Ownership Logic with Optional walletAddress

The isOwner variable compares the connected wallet address to the optional walletAddress. Since walletAddress can be undefined, ensure that this comparison accurately reflects ownership status and does not cause any unexpected behavior.


44-49: Check Observable Dependencies in useObservable Hook

The useObservable hook for skyStakeWalletData depends on reloadingTokenInfo and walletAddress. Make sure that changes to these dependencies correctly trigger updates and that the observables handle undefined walletAddress gracefully.


57-63: Ensure State Synchronization in useEffect Hook

The useEffect hook updates tempSkyStakeWalletData when skyStakeWalletData changes. Verify that all conditions are correctly set to prevent missed updates or infinite loops.


126-129: Validate Conditional Rendering Logic

The conditional rendering of the VaultOwnershipBanner component checks for !isOwner && walletAddress. Since walletAddress is optional, confirm that this condition behaves as expected when walletAddress is undefined, and that it doesn't unintentionally hide or show the banner.


163-170: Consistent Handling of Optional walletAddress in Wrapper Component

In SkyStakeUsdsViewWrapper, the walletAddress prop is also made optional. Ensure that all nested components, including WithTermsOfService and WithWalletAssociatedRisk, correctly handle the optional walletAddress to prevent any runtime errors.

features/sky/hooks/useSky.ts (10)

15-16: Verify handling of optional 'allowance' and 'balance' properties

By making allowance and balance optional in ResolvedDepositParamsType, ensure that all usages of these properties correctly handle cases where they might be undefined to prevent potential runtime errors.


22-25: Ensure safe access to optional balance and allowance properties

The properties primaryTokenBalance, primaryTokenAllowance, secondaryTokenBalance, and secondaryTokenAllowance are now optional in useSkyType. Verify that all code accessing these properties checks for undefined to avoid unintended behavior.


28-28: Addition of 'viewWalletAddress' property

The viewWalletAddress property has been added to useSkyType. This allows for ownership checks within the hook. Ensure that this property is correctly passed and utilized where necessary.


46-46: Include 'viewWalletAddress' in 'useSky' parameters

The viewWalletAddress parameter has been added to the useSky hook function signature. Confirm that this parameter is properly provided when the hook is used elsewhere in the codebase.


48-48: Destructure 'replace' from 'useRouter'

The replace function from useRouter is now being used. Ensure that this import is necessary and that replace is used appropriately for navigation purposes within the hook.


219-223: Confirm navigation logic for non-owners

When the user is not the owner (!isOwner), the action function redirects to /earn/srr/${walletAddress}. Verify that walletAddress is the intended address for redirection, and that this behavior aligns with the desired user experience.


237-238: Dependencies correctly include 'isOwner' and 'replace'

The dependencies array for the useMemo hook includes isOwner and replace, which are used within the action function. This ensures that the memoization behaves correctly when these values change.


251-253: Update 'actionLabel' for non-owner users

The actionLabel is set to 'Go to your position' when the user is not the owner. Ensure that this label is clear and appropriately guides the user to their correct position or page.


255-256: Handle optional 'allowance' in conditions

The condition checks if resolvedPrimaryTokenData.allowance is falsy or insufficient. Since allowance is now optional, ensure that the condition properly handles cases when allowance is undefined to prevent logical errors.


263-271: Include 'isOwner' in 'actionLabel' dependencies

The actionLabel uses isOwner, and it's correctly included in the dependencies array of the useMemo hook. This ensures that the label updates appropriately when the ownership status changes.

features/sky/components/stake/SkyStakePositionView.tsx (13)

25-25: Import of 'zero' is appropriate

The zero constant is used for default values when wallet data may be undefined.


34-40: Optional properties are appropriately added

The properties usdsAllowance, skyAllowance, and skyStakeWalletData have been made optional in SkyStakeViewType, which aligns with the updated handling of wallet data. Their usage in the component correctly utilizes optional chaining to handle potential undefined values.


46-46: Addition of optional 'viewWalletAddress' property

The optional viewWalletAddress property has been added to SkyStakeViewType, allowing the component to handle different wallet addresses appropriately.


56-58: Props updated to include optional wallet data

The component now accepts skyStakeWalletData and viewWalletAddress as props, aligning with the updated SkyStakeViewType interface and enhancing flexibility in handling wallet-specific data.


97-103: Verify handling of 'skyStakeWalletData' in 'primaryTokenBalance'

In the useSky hook, primaryTokenBalance is set based on stakingAction. When stakingAction is not 'stake', it uses skyStakeWalletData?.balance. Please ensure that skyStakeWalletData is defined in these cases to prevent possible undefined values causing issues within the useSky hook.


141-147: Logic for 'showAllowanceInfo' appears correct

The showAllowanceInfo variable is computed appropriately to determine if the user needs to update the allowance based on the entered amount and current allowance.


154-171: Action pills updated correctly with appropriate disabled states

The ActionPills items for 'stake', 'unstake', and 'claim' have been updated to include appropriate disabled conditions based on loading status and ownership. This ensures that actions are only available when the user is permitted to perform them.


181-181: Displaying earned SKY amount correctly

The earned SKY amount is displayed using skyStakeWalletData?.earned || zero, which appropriately handles cases where wallet data may be undefined.


194-196: Verify availability of 'skyStakeWalletData' when setting 'maxAmount'

When stakingAction is not 'stake', maxAmount is set to skyStakeWalletData?.balance. Please ensure that skyStakeWalletData is defined in these cases to prevent maxAmount from being undefined, which could affect the VaultActionInput component's functionality.


264-264: Conditional rendering of allowance info message

The MessageCard for updating allowance is correctly conditionally rendered based on !isLoading && showAllowanceInfo.


282-282: Primary button configured appropriately based on 'stakingAction'

The primaryButton label and action are set correctly depending on whether the action is 'claim' or not. Loading and disabled states correctly consider both isLoading and reloadingTokenInfo.


307-307: Displaying USDS Deposited using optional wallet data

The USDS Deposited value correctly uses skyStakeWalletData?.balance || zero to handle cases where wallet data may be undefined.


317-317: Displaying SKY Earned using optional wallet data

The SKY Earned value correctly uses skyStakeWalletData?.earned || zero to handle cases where wallet data may be undefined.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Outside diff range and nitpick comments (1)
handlers/portfolio/positions/handlers/sky/index.ts (1)

13-14: LGTM: New stake details fetched correctly

The addition of skyUsdsStakeDetails() to the Promise.all call is correct and consistent with the new import. The destructuring has been properly updated to match.

Consider renaming usdsStakeDetails to usdsGeneralStakeDetails or similar to clearly differentiate it from the wallet-specific details. This would improve code readability:

-  ]).then(([usdsWalletStakeDetails, usdsStakeDetails]) => {
+  ]).then(([usdsWalletStakeDetails, usdsGeneralStakeDetails]) => {
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4f2a386 and da7e65c.

Files selected for processing (5)
  • features/sky/components/SwapCard.tsx (3 hunks)
  • features/sky/components/stake/SkyStakePositionView.tsx (11 hunks)
  • features/sky/helpers.ts (1 hunks)
  • features/sky/hooks/useSky.ts (7 hunks)
  • handlers/portfolio/positions/handlers/sky/index.ts (3 hunks)
Files skipped from review as they are similar to previous changes (3)
  • features/sky/components/SwapCard.tsx
  • features/sky/components/stake/SkyStakePositionView.tsx
  • features/sky/hooks/useSky.ts
Additional comments not posted (5)
features/sky/helpers.ts (2)

1-1: LGTM: Import statement is correct.

The import statement for BigNumber is correctly using the type keyword, which is a good practice for TypeScript as it ensures the import is used only for type checking and not at runtime.


1-4: Overall assessment: Function serves its purpose but could be improved.

The showAllowanceInfo function correctly implements the logic to determine when allowance information should be shown. However, there's room for improvement in terms of naming, type annotations, and error handling. Consider implementing the suggested refactoring to enhance the function's robustness and readability.

handlers/portfolio/positions/handlers/sky/index.ts (3)

1-1: LGTM: New import added correctly

The addition of skyUsdsStakeDetails import is appropriate as it's used in the function below. The import statement follows the existing code style.


Line range hint 1-52: Summary: Enhancements to skyPositionsHandler look good

The changes to skyPositionsHandler improve its functionality by incorporating both wallet-specific and general stake details. The modifications are well-structured, consistent, and maintain the existing code style.

Key points:

  1. New import and usage of skyUsdsStakeDetails function.
  2. Updated Promise.all call to fetch both types of stake details.
  3. Change in APY calculation source from wallet-specific to general stake details.

Consider the suggested variable renaming for clarity and ensure the APY calculation change aligns with the intended business logic.

Overall, these changes enhance the handler's capabilities and should provide more comprehensive stake information.


34-34: Verify business logic: APY source changed

The change from usdsWalletStakeDetails.rewardRate to usdsStakeDetails.rewardRate for the APY calculation is consistent with the new data fetching logic. This implies that the APY is now based on general stake information rather than wallet-specific data.

Please confirm that this change aligns with the intended business logic. Does the APY need to be the same for all users (general stake details) rather than potentially different for each wallet (wallet-specific details)?

To verify the impact of this change, you can run the following script:

This will help ensure that the change is consistent across the codebase and that no other APY calculations are affected unintentionally.

Verification successful

Update Shell Script to Correctly Search TypeScript Files

The previous script failed to recognize the typescript file type. Let's adjust the rg commands to target .ts and .tsx files specifically.


To further investigate the impact and consistency of this change, we need to perform additional searches. Let's run the following scripts:

These scripts will help us understand if the change is isolated to this specific instance or if there are other places where similar changes might be needed.


The investigation confirms that the change from usdsWalletStakeDetails.rewardRate to usdsStakeDetails.rewardRate is appropriate and isolated to this specific instance in the sky handler file. The change is consistent with using more general stake details for the reward rate calculation, while wallet-specific details are still used for other properties like balance and earned amounts.

This modification appears to be intentional and does not negatively impact other parts of the codebase. The change aligns with the goal of using general stake information rather than wallet-specific data for the APY calculation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other usages of rewardRate from usdsWalletStakeDetails

# Test: Search for usages of rewardRate from usdsWalletStakeDetails
rg --type typescript "usdsWalletStakeDetails\.rewardRate"

# Test: Search for other potential APY calculations
rg --type typescript "(apy|APY|reward.?rate)"

Length of output: 177


Script:

#!/bin/bash
# Description: Check for other usages of rewardRate from usdsWalletStakeDetails

# Test: Search for usages of rewardRate from usdsWalletStakeDetails in .ts and .tsx files
rg "usdsWalletStakeDetails\.rewardRate" -g "*.ts" -g "*.tsx"

# Test: Search for other potential APY calculations in .ts and .tsx files
rg "(apy|APY|reward.?rate)" -g "*.ts" -g "*.tsx"

Length of output: 114636


Script:

#!/bin/bash
# Search for other occurrences of usdsWalletStakeDetails.rewardRate
echo "Searching for usdsWalletStakeDetails.rewardRate:"
rg "usdsWalletStakeDetails\.rewardRate" -g "*.ts" -g "*.tsx"

# Look for similar patterns in other portfolio handler files
echo "\nSearching for rewardRate in portfolio handlers:"
rg "rewardRate" -g "handlers/portfolio/positions/handlers/*.ts"

# Examine the sky handler file more closely
echo "\nExamining the sky handler file:"
rg "usdsWalletStakeDetails" handlers/portfolio/positions/handlers/sky/index.ts
rg "usdsStakeDetails" handlers/portfolio/positions/handlers/sky/index.ts

Length of output: 1238

@marcinciarka marcinciarka merged commit 2fc971f into dev Sep 23, 2024
13 checks passed
@marcinciarka marcinciarka deleted the marcinciarka/sky-changes branch September 23, 2024 11:18
This was referenced Sep 23, 2024
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.

2 participants