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 USDS staking view #4027

Merged
merged 4 commits into from
Sep 19, 2024
Merged

Conversation

marcinciarka
Copy link
Member

@marcinciarka marcinciarka commented Sep 19, 2024

Sky USDS staking view (basic one)

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a staking contract that allows users to stake tokens, withdraw, and claim rewards.
    • Added a user interface component for managing staking activities, including staking, unstaking, and reward claiming.
    • Implemented real-time staking information retrieval for user wallets.
    • Added support for the Sky lending protocol across various components and functionalities.
    • Enhanced the product hub with detailed staking information for the Sky lending protocol.
  • Bug Fixes

    • Enhanced error handling and loading indicators in the staking UI components.
  • Documentation

    • Updated type definitions for better clarity and type safety across the staking functionalities.
  • Refactor

    • Consolidated hooks for improved code readability and maintainability.

Copy link
Contributor

coderabbitai bot commented Sep 19, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes introduce a comprehensive staking mechanism within the blockchain ecosystem, encapsulated in a smart contract that manages token staking, reward distribution, and ownership management. New functions and events are added to facilitate staking operations, while user interface components enhance interaction with these functionalities. Observable functions are introduced to retrieve staking details, and various components are implemented to display and manage staking information effectively.

Changes

Files Change Summary
blockchain/abi/sky-staking.json Introduced a new ABI JSON file defining a smart contract for staking, including functions for staking, withdrawing, and reward management, along with relevant events for tracking actions.
blockchain/better-calls/sky-swaps.ts Added functions for staking, unstaking, and claiming rewards, integrating with the SkyStaking contract, and providing detailed staking information retrieval.
blockchain/contracts/arbitrum.ts Added a new entry for a staking contract in the arbitrumContracts object.
blockchain/contracts/base.ts Introduced a new contract descriptor for 'staking' in the baseContracts object.
blockchain/contracts/goerli.ts Added a new entry for staking in the goerliContracts object.
blockchain/contracts/mainnet.ts Integrated the skyStaking ABI into mainnetContracts, linking it to a specific contract address.
blockchain/contracts/optimism.ts Added a contract descriptor for 'staking' in the optimismContracts object.
blockchain/networks/networks-config.ts Renamed a parameter in the emptyContractDesc function and commented out a logging line to reduce console noise.
features/sky/components/SwapCard.tsx Refactored import statements and replaced the useSkyTokenSwap hook with useSky, enhancing code clarity and type safety.
features/sky/components/stake/SkyStakePositionView.tsx Introduced a new component for managing staking activities, allowing users to stake, unstake, or claim rewards with real-time feedback.
features/sky/config.ts Added a new TypeScript type definition for sky swap token configuration, enhancing type safety for the skySwapTokensConfig array.
features/sky/hooks/useSky.ts Refactored the useSkyTokenSwap hook, renaming it to useSky and modifying state handling for improved transaction clarity.
helpers/context/ProductContext.ts Introduced a new observable function for retrieving stake details, enhancing the product context with relevant data.
pages/earn/sky/[wallet].tsx Implemented a component for displaying and managing staking information for a wallet address, utilizing various hooks and context providers for state management.
pages/earn/sky/index.tsx Added a component for managing wallet connections and routing based on wallet address presence, enhancing user experience through server-side rendering.
features/omni-kit/constants.ts Added a new entry for the sky lending protocol in the paybackAllAmountAllowanceMaxMultiplier constant.
features/omni-kit/helpers/getOmniProtocolUrlMap.ts Added a mapping entry for the LendingProtocol.Sky protocol in the protocolUrlMap object.
features/productHub/helpers/getGenericPositionUrl.ts Introduced a new case for the LendingProtocol.Sky in the getGenericPositionUrl function.
features/refinance/components/RefinancePortfolioBanner.tsx Added an entry for the LendingProtocol.Sky in the RefinancePortfolioBanner component.
features/refinance/constants.ts Added a key for the LendingProtocol.Sky in the refinanceCustomProductHubFiltersOptions object.
features/refinance/helpers/getProtocolNameByLendingProtocol.ts Added an entry for the LendingProtocol.Sky in the ProtocolNameByLendingProtocol record.
features/refinance/hooks/useInitializeRefinanceContextBase.ts Added an entry for the LendingProtocol.Sky in the useInitializeRefinanceContextBase function.
handlers/product-hub/update-handlers/index.ts Added a handler for the LendingProtocol.Sky in the PRODUCT_HUB_HANDLERS object.
helpers/lambda/yields/get-yields-config.ts Added a mapping entry for the LendingProtocol.Sky in the getYieldsConfig function.
server/database/migrations/041-sky-protocol.sql Added a new value 'sky' to the PostgreSQL enum type protocol.
server/database/schema.prisma Added a new value sky to the Protocol enum in the schema.prisma file.
theme/icons/usds.tsx Corrected SVG attribute names in the usds icon component to align with React standards.

Possibly related PRs

  • Sky swap + vault initial version #4024: Introduces an ABI for a smart contract related to token swaps, which is directly relevant to the staking functionalities described in the main PR.
  • Sky integration part 2 #4025: Includes enhancements to user interface components that promote the Sky Ecosystem, aligning with the staking functionalities introduced in the main PR.
  • Sky work part 3 #4026: Focuses on enhancing wallet handling and includes updates to token icons, relevant to the overall user experience when interacting with staking and token management features in the main PR.

Poem

In the meadow where tokens play,
A new staking contract leads the way.
With rewards to claim and stakes to grow,
The Sky ecosystem's set to glow!
Hopping along, we cheer with glee,
For a brighter blockchain, come stake with me! 🐇✨


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: 9

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

89-92: Clarify the purpose of the fixed parameter 1001 when staking.

The purpose of the fixed parameter 1001 when calling the stake method is not clear from the code. This magic number may cause confusion for future maintainers.

Consider adding a comment to explain the significance of this parameter or replace it with a named constant for better readability.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b203ef7 and ff53cca.

Files selected for processing (15)
  • blockchain/abi/sky-staking.json (1 hunks)
  • blockchain/better-calls/sky-swaps.ts (2 hunks)
  • blockchain/contracts/arbitrum.ts (1 hunks)
  • blockchain/contracts/base.ts (1 hunks)
  • blockchain/contracts/goerli.ts (1 hunks)
  • blockchain/contracts/mainnet.ts (2 hunks)
  • blockchain/contracts/optimism.ts (1 hunks)
  • blockchain/networks/networks-config.ts (1 hunks)
  • features/sky/components/SwapCard.tsx (3 hunks)
  • features/sky/components/stake/SkyStakePositionView.tsx (1 hunks)
  • features/sky/config.ts (1 hunks)
  • features/sky/hooks/useSky.ts (5 hunks)
  • helpers/context/ProductContext.ts (4 hunks)
  • pages/earn/sky/[wallet].tsx (1 hunks)
  • pages/earn/sky/index.tsx (1 hunks)
Files skipped from review due to trivial changes (2)
  • blockchain/contracts/goerli.ts
  • blockchain/networks/networks-config.ts
Additional context used
Biome
features/sky/components/stake/SkyStakePositionView.tsx

[error] 175-178: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 203-206: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

Additional comments not posted (42)
pages/earn/sky/index.tsx (4)

10-17: LGTM!

The getServerSideProps function correctly fetches the necessary translations and wallet address from the server-side context. It follows the expected signature and return type for Next.js.


19-33: LGTM!

The SkyProxyPage component correctly manages the wallet connection and routing based on the presence of a wallet address. It uses the necessary hooks and renders the appropriate components. The component structure and logic is clear and concise.


28-30: Verify the intended behavior of rendering null as children for the WithWalletConnection component.

Rendering null as children for the WithWalletConnection component seems unusual and may not provide any meaningful UI or functionality. Please confirm if this is the intended behavior.

If the component is not yet fully implemented or if the children are not needed, consider adding meaningful children or removing the component altogether to avoid confusion and improve code clarity.


35-35: LGTM!

The SkyProxyPage component is correctly exported as the default export, allowing it to be imported and used in other parts of the application.

features/sky/config.ts (2)

3-11: LGTM!

The new type definition SkySwapTokensConfigType is well-structured and enhances type safety for the skySwapTokensConfig array. It clearly defines the expected properties and their types for the configuration objects.


13-13: Verify the existing configuration matches the new type structure.

The type change from any[] to SkySwapTokensConfigType[] for skySwapTokensConfig is a good improvement. It enhances type safety and ensures the configuration objects adhere to the defined structure.

Run the following script to verify the existing configuration matches the new type structure:

Verification successful

Existing configuration matches the new type structure

The verification process confirms that the skySwapTokensConfig array is correctly typed as SkySwapTokensConfigType[] and the existing configuration objects match the expected structure. The type change has been successfully implemented without introducing any apparent issues.

Key points:

  • The array is explicitly typed as SkySwapTokensConfigType[].
  • Configuration objects contain expected properties such as primaryToken, secondaryToken, primaryTokenAddress, secondaryTokenAddress, contractAddress, stake, and description.
  • No type errors or inconsistencies are visible in the examined portion of the configuration.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existing configuration in `skySwapTokensConfig` matches the new `SkySwapTokensConfigType` structure.

# Test: Search for the `skySwapTokensConfig` array. Expect: No type errors.
rg --type typescript -A 20 $'skySwapTokensConfig'

Length of output: 83


Script:

#!/bin/bash
# Description: Find TypeScript files containing skySwapTokensConfig and display its structure

# Find .ts files and search for skySwapTokensConfig with context
fd -e ts -x rg -A 20 'export const skySwapTokensConfig'

Length of output: 882

blockchain/better-calls/sky-swaps.ts (2)

99-106: LGTM!

The function correctly retrieves the rewards by invoking the getReward method from the SkyStaking contract. The implementation looks good.


108-142: LGTM!

The function correctly retrieves the staking details for a given owner address by invoking the appropriate methods from the SkyStaking contract. The retrieved values are properly formatted into BigNumber instances for consistency. The use of Promise.all to retrieve the values in parallel is a good performance optimization. The defensive check for ownerAddress is also a good programming practice.

Overall, the implementation looks solid and well-structured.

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

Line range hint 17-29: LGTM!

The renaming of UseSkyTokenSwapType to useSkyType improves code readability and aligns with the naming convention for custom hook types in React.


Line range hint 30-42: LGTM!

The renaming of the exported function from useSkyTokenSwap to useSky improves code readability and maintainability by simplifying the function name while preserving its core functionality.


159-159: Verify the impact on user experience.

Moving the setReloadingTokenInfo(true) call to occur after the transaction initiation may improve the clarity of the transaction flow. However, it's important to validate through user testing that delaying the feedback to the user about reloading token information does not negatively impact the user experience.


264-264: LGTM!

Adding setTransactionTx to the return object of the useSky hook enhances its interface by providing more control over transaction handling to the consumers of the hook. This improves the flexibility and reusability of the hook.


265-265: LGTM!

Adding signer to the return object of the useSky hook enhances its interface by providing more context over transaction handling to the consumers of the hook. This improves the flexibility and reusability of the hook.

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

11-12: LGTM!

The import statements have been updated to use the useSky hook and its related types. This change suggests a consolidation or simplification of the logic related to handling token swaps.


117-117: LGTM!

The useSkyTokenSwap hook has been replaced with the useSky hook in the SwapCardWrapper component. This change is consistent with the updated import statement and the hook is being called with the same set of props.


295-295: LGTM!

The type assertion added to the address property in the balancesConfig array enhances type safety and clarity. It ensures that the config.primaryTokenAddress is treated as a string, which may prevent potential runtime errors related to type mismatches.


299-299: LGTM!

The type assertion added to the address property in the balancesConfig array enhances type safety and clarity. It ensures that the config.secondaryTokenAddress is treated as a string, which may prevent potential runtime errors related to type mismatches.

blockchain/contracts/base.ts (1)

219-219: Approve the addition of the 'staking' contract descriptor.

The inclusion of the 'staking' contract descriptor in the sky object within baseContracts is a valuable addition. It enables the integration of staking-related operations and interactions within the broader application context. This enhancement to the contract management system is crucial for supporting decentralized finance (DeFi) functionalities or other blockchain mechanisms that involve staking.

blockchain/contracts/arbitrum.ts (1)

229-229: New staking contract added for the Sky ecosystem.

The addition of the staking property to the sky object within arbitrumContracts suggests the introduction of a staking contract for the Sky ecosystem. The use of emptyContractDesc indicates that the contract is being defined without specific implementation details at this point.

blockchain/abi/sky-staking.json (18)

2-27: LGTM!

The constructor parameters are well-defined and serve clear purposes:

  • _owner: Address that will have ownership privileges.
  • _rewardsDistribution: Address responsible for distributing rewards.
  • _rewardsToken: Address of the token used for rewards.
  • _stakingToken: Address of the token to be staked.

28-46: LGTM!

The OwnerChanged event is emitted when the contract ownership is transferred and includes the relevant information:

  • oldOwner: Address of the previous owner.
  • newOwner: Address of the new owner.

47-59: LGTM!

The OwnerNominated event is emitted when a new owner is nominated and includes the relevant information:

  • newOwner: Address of the nominated owner.

60-72: LGTM!

The PauseChanged event is emitted when the paused state of the contract is changed and includes the relevant information:

  • isPaused: Indicates if the contract is paused.

73-91: LGTM!

The Recovered event is emitted when ERC20 tokens are recovered from the contract and includes the relevant information:

  • token: Address of the recovered ERC20 token.
  • amount: Amount of tokens recovered.

92-116: LGTM!

The Referral event is emitted when a referral is recorded during staking and includes the relevant information:

  • referral: ID of the referral.
  • user: Address of the user who staked with the referral.
  • amount: Amount staked by the user.

117-129: LGTM!

The RewardAdded event is emitted when rewards are added to the contract and includes the relevant information:

  • reward: Amount of rewards added.

130-148: LGTM!

The RewardPaid event is emitted when rewards are paid to a user and includes the relevant information:

  • user: Address of the user receiving the reward.
  • reward: Amount of reward paid to the user.

149-161: LGTM!

The RewardsDistributionUpdated event is emitted when the rewards distribution address is updated and includes the relevant information:

  • newRewardsDistribution: Address of the new rewards distribution.

162-174: LGTM!

The RewardsDurationUpdated event is emitted when the rewards duration is updated and includes the relevant information:

  • newDuration: New duration for rewards.

175-193: LGTM!

The Staked event is emitted when a user stakes tokens and includes the relevant information:

  • user: Address of the user staking tokens.
  • amount: Amount of tokens staked by the user.

194-212: LGTM!

The Withdrawn event is emitted when a user withdraws staked tokens and includes the relevant information:

  • user: Address of the user withdrawing tokens.
  • amount: Amount of tokens withdrawn by the user.

213-219: LGTM!

The acceptOwnership function allows the nominated owner to accept ownership of the contract. It provides a way to ensure the nominated owner consents to becoming the new owner.


220-238: LGTM!

The balanceOf function is a view function that returns the staked token balance of a given account. It allows querying the staked balance of any account without modifying the contract state.


239-257: LGTM!

The earned function is a view function that calculates the amount of rewards earned by a given account. It allows querying the earned rewards of any account without modifying the contract state.


258-264: LGTM!

The exit function allows a user to exit the staking contract by withdrawing their staked tokens and claiming any earned rewards in a single transaction.


265-271: LGTM!

The getReward function allows a user to claim their earned rewards without unstaking by transferring the rewards to their address.


272-284: LGTM!

The getRewardForDuration function is a view function that calculates the reward amount for a given

blockchain/contracts/optimism.ts (1)

254-254: LGTM!

The addition of the staking property to the sky object using emptyContractDesc is consistent with the existing pattern and suggests future expansion of staking-related functionalities. The change is localized and does not appear to impact other parts of the code.

blockchain/contracts/mainnet.ts (2)

49-49: LGTM!

The import statement for skyStaking ABI is syntactically correct and consistent with the existing import statements in the file.


287-287: Verify the contract address for the Sky staking contract.

The code change to add the staking entry to the sky object within the mainnetContracts object is syntactically correct and consistent with the existing code structure.

Please verify that the contract address 0x0650CAF159C5A49f711e8169D4336ECB9b950275 is the correct address for the Sky staking contract on the mainnet.

Run the following script to verify the contract address:

Verification successful

Contract address for Sky staking is correctly implemented

The verification process confirms that the contract address 0x0650CAF159C5A49f711e8169D4336ECB9b950275 for the Sky staking contract is correctly implemented in the blockchain/contracts/mainnet.ts file. This address is used only once in the entire codebase, specifically for the staking entry in the sky object within the mainnetContracts object.

The implementation is consistent with other contract definitions in the same file, such as mkrsky and susds.

As a final step, please manually verify that 0x0650CAF159C5A49f711e8169D4336ECB9b950275 is indeed the correct address for the Sky staking contract on the mainnet.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the contract address for the Sky staking contract on the mainnet.

# Test: Search for the contract address in the codebase. Expect: Only occurrences in the `mainnetContracts` object.
rg --type typescript $'0x0650CAF159C5A49f711e8169D4336ECB9b950275'

Length of output: 100


Script:

#!/bin/bash
# Description: Verify the contract address for the Sky staking contract on the mainnet.

# Search for the contract address in .ts and .js files
echo "Searching in TypeScript files:"
rg -C 2 '0x0650CAF159C5A49f711e8169D4336ECB9b950275' --glob '*.ts'

echo -e "\nSearching in JavaScript files:"
rg -C 2 '0x0650CAF159C5A49f711e8169D4336ECB9b950275' --glob '*.js'

Length of output: 697

helpers/context/ProductContext.ts (1)

689-690: LGTM!

The addition of the skyUsdsStakeDetails$ observable enhances the functionality of the product context by providing stake details for a specified owner address. The implementation leverages the onEveryBlock$ observable and the skyUsdsStakeDetails function to retrieve the stake details on every block. The resulting observable is made available in the return object of setupProductContext, allowing other parts of the application to access and react to changes in stake details.

The code changes are clear, consistent, and well-integrated with the existing codebase.

pages/earn/sky/[wallet].tsx (1)

25-119: Component Implementation Looks Good

The SkyStakeUsdsView component is well-structured and effectively handles data fetching, loading states, and error handling. It properly utilizes React hooks and context providers.

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: 3

Outside diff range and nitpick comments (2)
features/refinance/hooks/useInitializeRefinanceContextBase.ts (1)

78-78: Looks good! Remember to define the refinance steps for the Sky protocol.

The addition of the Sky lending protocol to the mapping is a step in the right direction. However, please ensure that you define the specific refinance steps for this protocol to avoid unexpected behavior or errors when attempting to use it for refinancing.

pages/earn/ssr/[wallet].tsx (1)

43-47: Refine dependencies in useEffect hook

Including tempSkyStakeData in the dependency array may cause unnecessary re-renders. Since setTempSkyStakeData updates tempSkyStakeData, which then triggers useEffect, consider removing tempSkyStakeData from the dependency array to prevent potential infinite loops.

Apply this diff to adjust the dependency array:

- }, [skyStakeData, tempSkyStakeData])
+ }, [skyStakeData])
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ff53cca and c3dcd03.

Files selected for processing (17)
  • features/omni-kit/constants.ts (1 hunks)
  • features/omni-kit/helpers/getOmniProtocolUrlMap.ts (1 hunks)
  • features/productHub/helpers/getGenericPositionUrl.ts (1 hunks)
  • features/refinance/components/RefinancePortfolioBanner.tsx (1 hunks)
  • features/refinance/constants.ts (1 hunks)
  • features/refinance/helpers/getProtocolNameByLendingProtocol.ts (1 hunks)
  • features/refinance/hooks/useInitializeRefinanceContextBase.ts (1 hunks)
  • features/sky/components/SwapCard.tsx (7 hunks)
  • features/sky/components/stake/SkyStakePositionView.tsx (1 hunks)
  • features/sky/hooks/useSky.ts (7 hunks)
  • handlers/product-hub/update-handlers/index.ts (1 hunks)
  • helpers/lambda/yields/get-yields-config.ts (1 hunks)
  • pages/earn/ssr/[wallet].tsx (1 hunks)
  • pages/earn/ssr/index.tsx (1 hunks)
  • server/database/migrations/041-sky-protocol.sql (1 hunks)
  • server/database/schema.prisma (1 hunks)
  • theme/icons/usds.tsx (2 hunks)
Files skipped from review due to trivial changes (3)
  • server/database/migrations/041-sky-protocol.sql
  • server/database/schema.prisma
  • theme/icons/usds.tsx
Files skipped from review as they are similar to previous changes (2)
  • features/sky/components/SwapCard.tsx
  • features/sky/hooks/useSky.ts
Additional context used
Biome
features/sky/components/stake/SkyStakePositionView.tsx

[error] 175-178: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 203-206: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

Additional comments not posted (21)
features/omni-kit/helpers/getOmniProtocolUrlMap.ts (1)

11-11: LGTM!

The addition of the LendingProtocol.Sky entry to the protocolUrlMap object is consistent with the existing pattern and expands the function's support for the Sky lending protocol. The change is necessary and well-implemented.

features/refinance/helpers/getProtocolNameByLendingProtocol.ts (1)

11-11: LGTM!

The addition of the new entry for the Sky lending protocol to the ProtocolNameByLendingProtocol record is consistent with the existing code and follows the established pattern. The type assertion as ProtocolName is correctly used to satisfy the record's value type.

This change expands the functionality to support the Sky lending protocol without introducing any breaking changes or negatively impacting the existing code.

handlers/product-hub/update-handlers/index.ts (1)

26-26: LGTM! This is a good foundational step.

Adding the Sky protocol to the PRODUCT_HUB_HANDLERS object with the emptyHandler as a placeholder is a solid approach. It allows the system to recognize and handle the Sky protocol gracefully, even if the specific handling logic is not yet implemented.

This change lays the groundwork for future enhancements and ensures that the system can support the Sky protocol without causing errors in the meantime. Nice work!

pages/earn/ssr/index.tsx (2)

10-17: LGTM!

The getServerSideProps function is correctly implemented. It fetches server-side translations and retrieves the wallet address from the query parameters as expected.


19-33: LGTM!

The SkyProxyPage component is well-structured and handles wallet connections and redirects as expected. It correctly integrates with the useAccount hook, AppLayout, and WithWalletConnection component.

helpers/lambda/yields/get-yields-config.ts (1)

28-28: LGTM! The addition of the Sky protocol mapping is a good precautionary measure.

The change expands the configuration options available within the getYieldsConfig function, potentially allowing for better handling of different lending protocols in the system.

As the comment suggests, the Sky protocol case is not expected to occur under normal circumstances. This indicates that the addition may serve as a placeholder for future functionality or as a precautionary measure to handle unexpected scenarios gracefully.

While the change itself may not have an immediate impact on the system's behavior, it demonstrates good foresight in preparing the codebase for potential future requirements related to the Sky protocol.

features/refinance/constants.ts (1)

102-102: LGTM!

The addition of [LendingProtocol.Sky]: undefined to the refinanceCustomProductHubFiltersOptions object is consistent with the existing structure and expands the options for lending protocols. As the value is set to undefined, there is no immediate impact on the existing logic or control flow. This change enables potential future configurations or functionalities associated with the Sky lending protocol.

features/omni-kit/constants.ts (1)

41-41: LGTM!

The addition of the sky protocol to the paybackAllAmountAllowanceMaxMultiplier mapping is consistent with the existing pattern and the multiplier value of one is appropriate.

features/productHub/helpers/getGenericPositionUrl.ts (1)

139-141: LGTM!

The new case statement for LendingProtocol.Sky looks good. It correctly handles the 'SSR' label by returning the appropriate URL path and provides a fallback root path for other labels.

features/refinance/components/RefinancePortfolioBanner.tsx (1)

179-179: LGTM!

The addition of the LendingProtocol.Sky entry in the content object is a preparatory step for future integration of the Sky lending protocol into the RefinancePortfolioBanner component.

Setting the value to null indicates that there is currently no specific UI representation or functionality associated with this protocol. This change expands the existing functionality of the component by preparing it to handle the Sky protocol, although no immediate visual or functional changes are introduced.

Consider adding a TODO comment to track the future implementation of the UI elements and functionality for the Sky protocol.

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

1-27: LGTM!

The import statements look good and are importing the necessary dependencies for the component.


28-42: LGTM!

The SkyStakeViewType type definition looks good and includes all the necessary props for the SkyStakePositionView component.


54-97: LGTM!

The state management and usage of the useSky hook look good. The component correctly uses the useTranslation and useConnectWallet hooks for internationalization and wallet connection, and the useState hook to manage the stakingAction state.


99-128: LGTM!

The claimAction function looks good. It correctly checks for the wallet connection and available rewards, uses the skyUsdsStakeGetRewards function to initiate the claim transaction, and handles the transaction success and error scenarios while updating the relevant states.


130-245: LGTM!

The sidebarSectionProps object looks good. It correctly defines the props for the SidebarSection component, including the title, content, and primary button properties. The content property renders the appropriate components based on the stakingAction state, and the primary button is configured to trigger the corresponding action.

Tools
Biome

[error] 175-178: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 203-206: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


246-311: LGTM!

The rendering logic using the TabBar component looks good. The component correctly renders the "Overview" and "FAQ" sections. The "Overview" section displays the staking details using the DetailsSection component and the SidebarSection component with the sidebarSectionProps object. The "FAQ" section renders a card with the FAQ content.


173-179: Typographical error in success message.

The past review comment suggesting the correction of typographical errors in the success message is still valid and applicable to the current code segment.

Apply this diff to correct the typo:

-         'Transaction successfull.',
+         'Transaction successful.',
Tools
Biome

[error] 175-178: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


201-207: Typographical error in success message.

The past review comment suggesting the correction of the typographical error in the success message is still valid and applicable to the current code segment.

Apply this diff to correct the typo:

-           View on etherscan.
+           View on Etherscan.
Tools
Biome

[error] 203-206: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


184-184: Remove incorrect type casting and adjust MessageCard component's messages prop.

The past review comment suggesting the removal of the incorrect type casting to string[] and adjusting the MessageCard component's messages prop to accept ReactNode[] is still valid and applicable to the current code segments.

Remove the type casting:

- ].filter(Boolean) as string[])
+ ].filter(Boolean))

Ensure the MessageCard component's messages prop is typed to accept ReactNode[] instead of string[].

Also applies to: 212-212

pages/earn/ssr/[wallet].tsx (2)

134-134: Verify network settings in WithConnection component

The WithConnection component sets includeTestNet={true}, but the application uses mainnet network IDs and contracts. Ensure that including test networks is intentional and won't cause unexpected behavior.


77-85: Confirm correct token symbols in allowance checks

In the allowance observables, tokens are referenced by their symbols 'USDS' and 'SKY'. Verify that these symbols match the expected tokens in the allowanceForAccountEthers$ function and that they correspond to the correct addresses.

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: 8

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c3dcd03 and 5011404.

Files selected for processing (10)
  • blockchain/better-calls/sky.ts (1 hunks)
  • components/context/PreloadAppDataContextProvider.tsx (1 hunks)
  • features/productHub/meta.ts (2 hunks)
  • features/sky/components/stake/SkyStakePositionView.tsx (1 hunks)
  • handlers/product-hub/update-handlers/index.ts (2 hunks)
  • handlers/product-hub/update-handlers/sky/skyHandler.ts (1 hunks)
  • handlers/product-hub/update-handlers/sky/skyProducts.ts (1 hunks)
  • helpers/context/ProductContext.ts (4 hunks)
  • pages/[networkOrProduct]/sky/upgrade.tsx (1 hunks)
  • pages/earn/ssr/[wallet].tsx (1 hunks)
Files skipped from review due to trivial changes (1)
  • pages/[networkOrProduct]/sky/upgrade.tsx
Files skipped from review as they are similar to previous changes (2)
  • handlers/product-hub/update-handlers/index.ts
  • helpers/context/ProductContext.ts
Additional context used
Biome
features/sky/components/stake/SkyStakePositionView.tsx

[error] 175-178: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 203-206: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

Additional comments not posted (15)
handlers/product-hub/update-handlers/sky/skyProducts.ts (2)

1-5: LGTM!

The imports are relevant and necessary for the code in this file. There are no unused imports.


6-18: LGTM!

The product item for the Sky lending protocol is structured correctly and the attributes are consistent. The use of 'USDS' token for all token-related attributes and the label 'SSR' with description 'Sky Savings Rate' clearly indicate that this is a single-token earning strategy.

components/context/PreloadAppDataContextProvider.tsx (1)

35-35: LGTM!

The addition of LendingProtocol.Sky to the array of lending protocols is a straightforward change that introduces support for fetching data related to the "Sky" lending protocol. This change expands the functionality of the PreloadAppDataContextProvider without affecting existing behavior.

pages/earn/ssr/[wallet].tsx (3)

25-127: LGTM!

The SkyStakeUsdsView component is well-structured and follows best practices. It effectively uses hooks, context providers, and observables to manage state, side effects, and data retrieval. The component also implements proper error handling and loading states, enhancing the user experience. The decomposition into sub-components promotes code reusability and maintainability.


129-145: LGTM!

The SkyStakeUsdsViewWrapper component effectively wraps the main view with necessary context providers, ensuring that essential data and functionality are accessible throughout the component tree. The inclusion of connection handling, gas estimation, and terms of service acceptance creates a comprehensive environment for users. The component composition is clean and readable, making it easy to understand the hierarchy of providers.


147-154: LGTM!

The getServerSideProps function correctly extracts the wallet address from the query parameters and prepares translations for internationalization. It returns an object with the necessary props, ensuring the page is ready for rendering with the appropriate context.

features/productHub/meta.ts (3)

97-99: LGTM!

The entry for the Sky lending protocol is correctly added to the productHubProtocolFilter array with all necessary properties.


106-111: LGTM!

The entry for the MorphoBlue lending protocol is correctly added to the productHubProtocolFilter array with all necessary properties, including the feature flag.


112-116: LGTM!

The entry for the SparkV3 lending protocol is correctly added to the productHubProtocolFilter array with all necessary properties.

The entry for the AaveV2 lending protocol is correctly moved to the end of the productHubProtocolFilter array.

Also applies to: 128-130

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

1-27: LGTM!

The import statements are well-organized and cover the necessary dependencies for the component. No issues found.


28-42: LGTM!

The SkyStakeViewType type definition is comprehensive and covers the necessary properties for the staking view. The property names are descriptive and follow a consistent naming convention. No issues found.


44-97: LGTM!

The SkyStakePositionView component is well-defined and receives the necessary props to handle staking functionality. The use of hooks such as useTranslation, useConnectWallet, and useSky is appropriate and follows best practices. No issues found.


99-128: LGTM!

The claimAction function correctly handles the claiming of rewards for the staked tokens. It checks for the presence of a wallet address and non-zero earned rewards before proceeding. The use of the skyUsdsStakeGetRewards function to interact with the staking contract is appropriate. The transaction status is updated based on the success or failure of the transaction, and the token information is reloaded after a successful transaction. No issues found.


130-245: LGTM!

The sidebarSectionProps object is well-structured and contains the necessary props for the SidebarSection component. The action pills provide a clear way to switch between staking, unstaking, and claiming actions. The VaultActionInput component allows users to input the staking/unstaking amount. The message cards provide informative feedback to the user regarding transaction status, allowance status, and insufficient allowance. No issues found.

Tools
Biome

[error] 175-178: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 203-206: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


246-310: LGTM!

The JSX structure of the SkyStakePositionView component is well-organized using the TabBar component. The "Overview" section displays the relevant staking details in a clear and concise manner, and the inclusion of the SidebarSection component ensures consistency with the sidebar section defined earlier. The "FAQ" section is currently a placeholder and may require further implementation. No issues found.

@marcinciarka marcinciarka merged commit 6cbd6b3 into dev Sep 19, 2024
13 checks passed
@marcinciarka marcinciarka deleted the marcinciarka/sky-staking-initial-view branch September 19, 2024 17:38
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.

1 participant