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 - Chronicle Points farming #4031

Merged
merged 5 commits into from
Sep 25, 2024
Merged

Sky - Chronicle Points farming #4031

merged 5 commits into from
Sep 25, 2024

Conversation

marcinciarka
Copy link
Member

@marcinciarka marcinciarka commented Sep 25, 2024

Sky - Chronicle Points farming view, based on SRR.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new staking contract, SkyCleStaking, allowing users to stake USDS tokens for Chronicle Points.
    • Added a new React component, SkyCLEPositionView, for managing staking actions.
    • Implemented wallet-specific staking details and balances retrieval for the new staking mechanism.
  • Enhancements

    • Improved user experience with loading indicators and responsive UI elements during data fetching.
    • Added new token configuration for 'Chronicle Points' (CLE) with visual properties.
  • Bug Fixes

    • Streamlined data handling in various components to ensure accurate display of staking information.

Copy link
Contributor

coderabbitai bot commented Sep 25, 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 7 minutes and 12 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 ad32628 and 8d20bbc.

Walkthrough

This pull request introduces a new staking mechanism for the blockchain, encapsulated in the SkyCleStaking contract. It adds functionalities for staking, withdrawing, and claiming rewards, along with robust event logging. The changes extend to various files, integrating the new staking contract into the existing system, updating related components, and enhancing user interfaces for staking interactions. Additionally, new token configurations and icons for the 'CLE' token are introduced, enriching the overall ecosystem.

Changes

Files Change Summary
blockchain/abi/sky-cle-staking.json Added a new staking contract definition with events and functions for managing staking and rewards.
blockchain/better-calls/sky.ts Updated skyUsdsStake function to include a new parameter for selecting the staking contract and added functions to retrieve staking details for SkyCleStaking.
blockchain/contracts/arbitrum.ts, blockchain/contracts/base.ts, Added a new entry for stakingCle in multiple contract descriptor objects, initializing with emptyContractDesc.
blockchain/contracts/goerli.ts, blockchain/contracts/mainnet.ts, Introduced stakingCle in contract descriptors and imported the skyCleStaking ABI in the mainnet file.
blockchain/contracts/optimism.ts Added a new entry for stakingCle in the Optimism contracts object.
blockchain/token-metadata-list/token-configs.ts Added a new token configuration for 'CLE' (Chronicle Points) with specified properties.
features/productHub/helpers/getGenericPositionUrl.ts Enhanced the getGenericPositionUrl function to handle a new label 'CLE'.
features/sky/components/stake/SkyCLEPositionView.tsx Introduced a new React component for staking USDS tokens to earn Chronicle Points, featuring user interaction elements.
features/sky/components/stake/SkyStakePositionView.tsx Added loading states for UI elements to enhance user experience during asynchronous operations.
features/sky/hooks/useSky.ts Updated useSkyType to include an optional stakingAction property for better handling of staking actions.
handlers/portfolio/positions/handlers/sky/index.ts Added a new function to retrieve details related to the Chronicle Points stake, updating the positions array accordingly.
handlers/product-hub/update-handlers/sky/skyHandler.ts Updated getSkyData to include a call for skyUsdsStakeCleDetails, enhancing data retrieval for the 'CLE' label.
handlers/product-hub/update-handlers/sky/skyProducts.ts Introduced a new product entry for 'CLE' in the product hub.
helpers/context/ProductContext.ts Added a new observable function for retrieving wallet stake details related to 'CLE'.
pages/earn/cle/[wallet].tsx Created a new page component for displaying staking information for a specific wallet address.
pages/earn/cle/index.tsx Introduced a new page component to handle wallet address navigation and rendering.
pages/earn/srr/[wallet].tsx Simplified the observable creation process in the SkyStakeUsdsView component.
theme/icons/cle.tsx Added a new React component for the 'CLE' icon, defining its SVG path and viewBox.
theme/icons/index.ts Exported the new 'CLE' icon for accessibility in the icon module.

Possibly related PRs

Poem

🐇 In the meadow where tokens play,
A new contract blooms today.
Chronicle Points, a treasure to earn,
With staking and rewards, it's your turn!
Hop along, don’t be late,
Join the fun, it's time to stake! 🌱✨


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

🧹 Outside diff range and nitpick comments (18)
theme/icons/cle.tsx (1)

2-9: Consider adding accessibility attributes to the SVG.

While the implementation is correct, it's a good practice to enhance accessibility for SVG icons. Consider adding role="img" and aria-label attributes to the SVG element.

Here's a suggested improvement:

 export const cle = {
   path: (
-    <>
+    <svg role="img" aria-label="CLE token icon">
       <circle cx="16" cy="16" fill="#2fd05b" r="16" />
       <path d="M12.25 7.25l-5 5v7.5h5v5h7.5l5-5V13.5h-5v6.25h-7.5v-7.5h6.25v-5zm0 0" fill="#fff" />
-    </>
+    </svg>
   ),
   viewBox: '0 0 32 32',
 }

This change will improve screen reader support for the icon.

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

141-141: LGTM! Consider a minor improvement for consistency.

The addition of the 'CLE' label handling for the Sky protocol is correct and follows the existing pattern. Good job on maintaining consistency with the 'SRR' label handling.

For improved readability and maintainability, consider extracting the label checks into a separate object or switch statement. This would make it easier to add more labels in the future. For example:

case LendingProtocol.Sky:
  const skyLabels = {
    SRR: '/earn/srr/',
    CLE: '/earn/cle/'
  };
  return skyLabels[label] || '/';

This approach would make it easier to add new labels in the future and reduce the number of if statements.

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

45-45: Improved efficiency in tokenPrices observable creation

This change simplifies the code and improves efficiency by combining useMemo and useObservable. It eliminates the need for an intermediate variable, reducing complexity while maintaining the same functionality.

Consider applying this pattern to other similar observable creations in the component for consistency, if any exist.


Line range hint 1-191: Consider simplifying state management

While the current implementation works, there are several areas where state management could potentially be simplified:

  1. The use of temporary state variables (tempSkyStakeWalletData, tempSkyStakeData, tempBalancesData) and their corresponding useEffect hooks adds complexity. Consider if these can be eliminated or simplified.

  2. The component uses multiple useObservable calls. It might be beneficial to combine some of these observables if they're closely related, reducing the number of subscriptions.

  3. The reloadingTokenInfo state is used in multiple observables. Consider moving this logic into a custom hook to encapsulate this behavior.

Here are some suggestions to improve the code:

  1. Combine related observables:
const [combinedData, combinedError] = useObservable(
  useMemo(() => 
    combineLatest({
      skyStakeWallet: skyUsdsWalletStakeDetails$(walletAddress),
      skyStake: skyUsdsStakeDetails$(tokenPrices?.MKR),
      balances: balancesFromAddressInfoArray$(...),
      allowances: combineLatest([...])
    }),
    [skyUsdsWalletStakeDetails$, skyUsdsStakeDetails$, balancesFromAddressInfoArray$, allowanceForAccountEthers$, walletAddress, tokenPrices?.MKR]
  )
);
  1. Create a custom hook for handling reloading state:
function useReloadableObservable(observable$, dependencies) {
  const [reloading, setReloading] = useState(false);
  const [data, error] = useObservable(
    useMemo(() => (reloading ? of(undefined) : observable$),
    [reloading, ...dependencies])
  );
  return [data, error, setReloading];
}

These changes could lead to more maintainable and easier to understand code.

blockchain/contracts/base.ts (1)

220-220: LGTM! Consider adding a comment for clarity.

The addition of stakingCle to the sky object is consistent with the existing structure and aligns with the PR objectives for introducing Chronicle Points farming.

Consider adding a brief comment above this line to explain the purpose of the stakingCle contract, e.g.:

+  // Contract for staking CLE tokens (Chronicle Points)
   stakingCle: emptyContractDesc('stakingCle'),

This would improve code readability and provide context for future developers.

blockchain/contracts/arbitrum.ts (1)

230-230: LGTM. Consider adding a comment for clarity.

The addition of stakingCle to the sky object is consistent with the existing structure and aligns with the PR objectives for Chronicle Points farming.

Consider adding a brief comment above the sky object to explain its purpose and the significance of these contract descriptors, especially for new developers who might work on this file in the future. For example:

// Contract descriptors for Sky protocol-related contracts
sky: {
  // ... existing entries
  stakingCle: emptyContractDesc('stakingCle'),
},
blockchain/contracts/goerli.ts (1)

247-247: LGTM! Consider adding a comment for clarity.

The addition of stakingCle to the sky object is consistent with the existing structure and aligns with the PR objectives for introducing Chronicle Points farming.

Consider adding a brief comment above this line to explain the purpose of the stakingCle contract, e.g.:

// Contract for staking CLE tokens (Chronicle Points farming)
stakingCle: emptyContractDesc('stakingCle'),

This would improve code readability and provide context for future developers.

blockchain/abi/sky-cle-staking.json (2)

28-212: Events are well-defined and provide comprehensive logging.

The contract includes a wide range of events that cover all major state changes and user interactions. This is excellent for off-chain monitoring and analysis.

Consider adding a ReferralUpdated event to log changes to the referral system parameters if they are mutable. This would enhance transparency for any adjustments to the referral mechanism.


556-585: Clarify the purpose of two stake functions.

There are two stake functions with different parameters. One includes a referral parameter while the other doesn't. This could lead to confusion for users and integrators.

Consider renaming the function with the referral parameter to stakeWithReferral to clearly differentiate its purpose. Also, add comments in the contract code to explain the difference between these functions and when each should be used.

blockchain/contracts/optimism.ts (1)

255-255: LGTM! Consider alphabetizing the sky object entries.

The addition of stakingCle using emptyContractDesc is consistent with other entries in the sky object and aligns with the PR objectives for Chronicle Points farming.

For improved readability and maintainability, consider alphabetizing the entries in the sky object. This would result in the following order:

sky: {
  daiusds: emptyContractDesc('daiusds'),
  mkrsky: emptyContractDesc('mkrsky'),
  staking: emptyContractDesc('staking'),
  stakingCle: emptyContractDesc('stakingCle'),
  susds: emptyContractDesc('susds'),
},
blockchain/token-metadata-list/token-configs.ts (2)

147-158: Consider documenting the token ordering strategy.

The new 'CLE' token configuration has been placed before the 'USDS' token. While this placement doesn't disrupt any apparent ordering (as the list doesn't seem to follow strict alphabetical order), it would be helpful to understand and possibly document the strategy for adding new tokens to this list.

Is there a specific reason for placing 'CLE' in this position? Documenting the ordering strategy (if any) in a comment at the beginning of the tokenConfigs array would be beneficial for future maintainers.


147-158: Consider adding additional properties to the 'CLE' token configuration.

The 'CLE' token configuration is missing some properties that are common in other token configurations. Consider adding the following properties if they are applicable to 'CLE':

  1. coinGeckoTicker: Used for fetching price data from CoinGecko.
  2. coinpaprikaTicker: Used for fetching price data from Coinpaprika.
  3. rootToken: If 'CLE' is derived from or pegged to another token.

Adding these properties, if relevant, would make the 'CLE' configuration more consistent with other tokens and potentially more useful for integrations with price feeds or other systems.

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

52-77: Add unit tests for the new Chronicle Points staking functionality

The new logic for handling Chronicle Points staking lacks unit tests. It's important to ensure this functionality is tested to prevent future regressions and maintain code quality.

Would you like me to help create unit tests for this new functionality or open a GitHub issue to track this task?

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

90-91: Refactor Contract Selection for Clarity

Using a ternary operator directly within the ethers.Contract instantiation can reduce readability.

Assign the contract address and ABI to variables before creating the contract instance:

+ const contractAddress = stakeForCle
+   ? mainnetContracts.sky.stakingCle.address
+   : mainnetContracts.sky.staking.address
+ const contractABI = stakeForCle
+   ? SkyCleStaking__factory.abi
+   : SkyStaking__factory.abi
  const skyStakingContract = new ethers.Contract(
-   stakeForCle ? mainnetContracts.sky.stakingCle.address : mainnetContracts.sky.staking.address,
-   stakeForCle ? SkyCleStaking__factory.abi : SkyStaking__factory.abi,
+   contractAddress,
+   contractABI,
    signer,
  )

180-184: Simplify Promise Handling

Using Promise.all for a single promise adds unnecessary complexity.

Await the promise directly for cleaner code:

- const [totalUSDSLocked] = await Promise.all([
-   skyStakingCleContract['totalSupply']().then(
-     (USDSLocked: ethers.BigNumber) => new BigNumber(ethers.utils.formatUnits(USDSLocked, 18)),
-   ),
- ])
+ const totalUSDSLocked = await skyStakingCleContract['totalSupply']().then(
+   (USDSLocked: ethers.BigNumber) => new BigNumber(ethers.utils.formatUnits(USDSLocked, 18)),
+ )
features/sky/hooks/useSky.ts (1)

267-273: Simplify nested ternary operators for better readability

The nested ternary operators in the actionLabel computation can be hard to read and maintain. Consider refactoring for clarity.

Suggested refactor:

-return stake
-  ? isTokenSwapped || stakingAction !== 'stake'
-    ? `Unstake`
-    : `Stake`
-  : isTokenSwapped
-    ? `Downgrade`
-    : `Upgrade`
+if (stake) {
+  if (isTokenSwapped || stakingAction !== 'stake') {
+    return 'Unstake'
+  } else {
+    return 'Stake'
+  }
+} else {
+  if (isTokenSwapped) {
+    return 'Downgrade'
+  } else {
+    return 'Upgrade'
+  }
+}
features/sky/components/stake/SkyCLEPositionView.tsx (2)

107-108: Internationalize hardcoded labels to support multiple languages

The labels 'Stake' and 'Unstake' are hardcoded in the ActionPills. Consider using the translation function t from useTranslation() to internationalize these labels.

Apply this diff:

{
  id: 'stake',
- label: 'Stake',
+ label: t('stake'),
  action: () => setStakingAction('stake'),
  disabled: isLoading || !isOwner,
},
{
  id: 'unstake',
- label: 'Unstake',
+ label: t('unstake'),
  action: () => setStakingAction('unstake'),
  disabled: isLoading || !isOwner,
},

131-132: Internationalize action labels in VaultActionInput

The action labels 'Stake' and 'Unstake' are hardcoded within the VaultActionInput. Use the translation function t to support multiple languages.

Apply this diff:

action={
  {
    stake: t('stake'),
    unstake: t('unstake'),
  }[stakingAction]
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ae7bd93 and ad32628.

📒 Files selected for processing (21)
  • blockchain/abi/sky-cle-staking.json (1 hunks)
  • blockchain/better-calls/sky.ts (3 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/token-metadata-list/token-configs.ts (2 hunks)
  • features/productHub/helpers/getGenericPositionUrl.ts (1 hunks)
  • features/sky/components/stake/SkyCLEPositionView.tsx (1 hunks)
  • features/sky/components/stake/SkyStakePositionView.tsx (4 hunks)
  • features/sky/hooks/useSky.ts (5 hunks)
  • handlers/portfolio/positions/handlers/sky/index.ts (2 hunks)
  • handlers/product-hub/update-handlers/sky/skyHandler.ts (3 hunks)
  • handlers/product-hub/update-handlers/sky/skyProducts.ts (1 hunks)
  • helpers/context/ProductContext.ts (3 hunks)
  • pages/earn/cle/[wallet].tsx (1 hunks)
  • pages/earn/cle/index.tsx (1 hunks)
  • pages/earn/srr/[wallet].tsx (1 hunks)
  • theme/icons/cle.tsx (1 hunks)
  • theme/icons/index.ts (1 hunks)
🧰 Additional context used
Biome
features/sky/components/stake/SkyCLEPositionView.tsx

[error] 146-149: 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] 174-177: 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)

pages/earn/cle/[wallet].tsx

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

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments not posted (34)
theme/icons/cle.tsx (1)

1-10: LGTM! Well-structured SVG icon component.

The implementation of the cle icon component is clean and follows React best practices. The SVG path is correctly defined within a JSX fragment, and the viewBox property is appropriately set.

handlers/product-hub/update-handlers/sky/skyProducts.ts (1)

18-28: LGTM! Please verify token usage and consider adding a clarifying comment.

The new product entry for Chronicle Points farming looks good and aligns with the PR objectives. A few points to consider:

  1. Can you verify that 'USDS' is the correct token to use for primaryToken, secondaryToken, and depositToken? It's unusual to see the same token used for all three, so it would be good to confirm this is intentional.

  2. Consider adding a brief comment to explain that 'CLE' stands for Chronicle Points. This would improve code readability for future developers.

To verify the token usage, please run the following script:

✅ Verification successful

Since the previous search command resulted in an error, please use the following script to verify the token usage:


Verification Successful: 'USDS' Token Usage Confirmed

The usage of 'USDS' as primaryToken, secondaryToken, and depositToken has been verified and is consistent within the Sky protocol configurations.

Additionally, please consider adding a brief comment explaining that 'CLE' stands for Chronicle Points to improve code readability for future developers.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other occurrences of 'USDS' token in Sky protocol configurations

# Test: Search for 'USDS' token usage in Sky protocol files
rg --type typescript 'USDS.*Sky' ./handlers/product-hub/update-handlers/sky

Length of output: 112


Script:

#!/bin/bash
# Description: Check for other occurrences of 'USDS' token in Sky protocol configurations

# Test: Search for 'USDS' token usage in Sky protocol TypeScript files
rg 'USDS.*Sky' ./handlers/product-hub/update-handlers/sky --glob '*.ts' --glob '*.tsx'

Length of output: 88

pages/earn/cle/index.tsx (1)

17-25: 🛠️ Refactor suggestion

Reconsider the use of void with replace

Using void with replace suppresses any potential errors that might occur during navigation. Consider handling potential errors for better debugging and user experience.

Replace line 21 with:

replace(`/earn/cle/${walletContextAddress}`).catch(console.error);

This allows you to log any navigation errors that might occur.

Verify if walletAddress should be passed to SkyCLEUsdsViewWrapper

The walletAddress prop is not being passed to the SkyCLEUsdsViewWrapper component. If this component requires the wallet address, make sure to pass it as a prop.

If SkyCLEUsdsViewWrapper needs the wallet address, update line 24 to:

return <SkyCLEUsdsViewWrapper walletAddress={walletAddress || walletContextAddress} />

To verify this, let's check the SkyCLEUsdsViewWrapper component:

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

20-20: LGTM: SkeletonLine import added for loading states

The addition of the SkeletonLine import is appropriate for implementing loading state placeholders in the component.


99-99: LGTM: stakingAction prop added and used in useSky hook

The addition of the stakingAction prop and its inclusion in the useSky hook parameters is a good approach. This allows for dynamic behavior based on the current staking action, enhancing the component's flexibility.


174-182: LGTM: Loading state added for claim action

The addition of a loading state for the claim action is a good improvement. It enhances user experience by providing visual feedback during data fetching, and the use of SkeletonLine is consistent with other loading state implementations in the component.


307-314: LGTM: Loading state added for USDS Deposited value

The addition of a loading state for the USDS Deposited value is a good improvement. It enhances user experience by providing visual feedback during data fetching. The conditional rendering of the unit based on the loading state is also a nice touch, preventing the display of the unit when the value is not yet available.


318-325: LGTM: Loading state added for SKY Reward Rate value

The addition of a loading state for the SKY Reward Rate value is a good improvement. It enhances user experience by providing visual feedback during data fetching. The conditional rendering of the unit based on the loading state is also appropriate, preventing the display of the unit when the value is not yet available.


329-336: LGTM: Loading state added for SKY Earned value

The addition of a loading state for the SKY Earned value is a good improvement. It enhances user experience by providing visual feedback during data fetching. The conditional rendering of the unit based on the loading state is also appropriate, preventing the display of the unit when the value is not yet available.


344-350: LGTM: Loading states added for footer items

The addition of loading states for the "Total USDS Locked" and "Total SKY Earned" footer items is a good improvement. It enhances user experience by providing visual feedback during data fetching and maintains consistency with the loading state handling in other parts of the component.

Also applies to: 354-360


Line range hint 1-377: Overall assessment: Excellent implementation of loading states

The changes made to the SkyStakePositionView component significantly improve the user experience by implementing consistent loading states throughout the component. The addition of the stakingAction prop enhances the component's flexibility, allowing for dynamic behavior based on the current staking action.

Key improvements:

  1. Consistent use of SkeletonLine for loading placeholders
  2. Conditional rendering of values and units based on loading states
  3. Implementation of loading states for all major data points (USDS Deposited, SKY Reward Rate, SKY Earned, and footer items)

These changes provide better visual feedback during data fetching and enhance the overall responsiveness of the UI. The implementation is well-integrated into the existing component structure and maintains code consistency.

blockchain/contracts/base.ts (1)

Line range hint 1-265: File review summary: New staking contract added successfully

The addition of the stakingCle entry to the sky object is the only change in this file. It's consistent with the existing structure and supports the PR objective of introducing Chronicle Points farming.

To ensure this change is properly integrated, please run the following script to check for any references to the new stakingCle contract throughout the codebase:

This will help verify that the new contract is properly utilized and that there are no pending tasks related to its implementation.

✅ Verification successful

File review summary: New stakingCle contract integrated successfully

The stakingCle contract has been added and referenced appropriately across multiple files, ensuring consistent integration with the existing codebase. No pending TODOs related to stakingCle were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for references to the new stakingCle contract

# Search for stakingCle references
echo "Searching for stakingCle references:"
rg "stakingCle" --type ts --type tsx

# Check for any TODO comments related to stakingCle
echo "\nChecking for related TODO comments:"
rg "TODO.*stakingCle" --type ts --type tsx

Length of output: 305


Script:

#!/bin/bash
# Description: Check for references to the new stakingCle contract

# Search for stakingCle references in .ts and .tsx files
echo "Searching for stakingCle references:"
rg "stakingCle" --glob "*.ts" --glob "*.tsx"

# Check for any TODO comments related to stakingCle in .ts and .tsx files
echo "\nChecking for related TODO comments:"
rg "TODO.*stakingCle" --glob "*.ts" --glob "*.tsx"

Length of output: 1360

theme/icons/index.ts (1)

65-65: LGTM: New icon export added consistently.

The addition of the 'cle' icon export is consistent with the existing structure and maintains the alphabetical order. This new icon likely relates to the Chronicle Points farming feature mentioned in the PR objectives.

To ensure the validity of this export, please run the following command to verify the existence of the 'cle.ts' or 'cle.tsx' file:

If the file exists, the export is valid. If not, please ensure the 'cle' icon file has been created.

✅ Verification successful

Verification Successful: 'cle.tsx' icon file exists.

The cle.tsx file has been found in the theme/icons directory, confirming that the export export { cle } from './cle' is valid and correctly references the existing icon file.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the existence of the 'cle' icon file
fd -e ts -e tsx cle.* theme/icons

Length of output: 3161

blockchain/abi/sky-cle-staking.json (3)

1-27: Constructor looks well-defined and comprehensive.

The constructor initializes the contract with essential addresses: owner, rewards distribution, rewards token, and staking token. This setup provides a good foundation for the staking mechanism.


1-645: Overall, the SkyCleStaking contract ABI is well-structured and comprehensive.

The ABI defines a robust staking mechanism with reward distribution, covering essential functions such as staking, withdrawing, and claiming rewards. It also includes administrative functions for contract management and a good set of events for logging important state changes.

However, there are a few areas that require attention:

  1. The recoverERC20 function needs additional checks to prevent potential misuse.
  2. The two stake functions could be renamed for clarity.
  3. Ensure proper access control is implemented for critical functions like notifyRewardAmount.

Addressing these points will enhance the contract's security and usability. Additionally, consider adding more detailed comments in the actual contract implementation to explain the purpose and usage of each function, especially for complex operations like reward calculations.

To ensure the contract's robustness, it's recommended to:

  1. Conduct a thorough security audit by a reputable third-party.
  2. Implement comprehensive unit tests covering all functions and edge cases.
  3. Consider using established libraries like OpenZeppelin for standard functionalities to reduce the risk of implementation errors.

350-361: Ensure proper access control for notifyRewardAmount.

The notifyRewardAmount function is crucial for updating the reward amount, but the ABI doesn't specify any access control.

Ensure that this function has appropriate access control in the contract implementation. It should typically only be callable by the rewards distribution address or the contract owner. For example:

require(msg.sender == rewardsDistribution, "Caller is not RewardsDistribution contract");

Run the following script to verify the implementation:

blockchain/contracts/mainnet.ts (3)

47-47: LGTM: New import for skyCleStaking ABI added correctly.

The import statement for the skyCleStaking ABI is correctly placed and follows the existing pattern in the file.


47-47: Summary: Sky CLE Staking contract integration looks good.

The changes in this file successfully integrate the Sky CLE Staking contract into the mainnet contracts configuration. This addition enables interaction with the new staking mechanism for CLE tokens within the Sky ecosystem. The changes are minimal, focused, and consistent with the existing code structure.

Potential impact:

  1. New functionality for CLE token staking will be available in the application.
  2. Other parts of the codebase that interact with the mainnetContracts object may need to be updated to utilize this new contract.

Also applies to: 289-289


289-289: LGTM: New stakingCle entry added correctly. Verify contract address.

The new stakingCle entry in the sky object is correctly structured and consistent with other entries. It uses the skyCleStaking ABI imported earlier.

Please verify the correctness of the contract address 0x10ab606B067C9C461d8893c47C7512472E19e2Ce. Run the following script to check if the contract at this address is indeed the Sky CLE Staking contract:

This script searches for key functions typically present in staking contracts. If these functions are found, it increases our confidence that the address is correct.

helpers/context/ProductContext.ts (4)

3-7: LGTM: New import added correctly.

The new import for skyUsdsWalletStakeCleDetails is added correctly to the existing import statement from the 'blockchain/better-calls/sky' module. This follows the established pattern in the file.


697-699: LGTM: New observable function implemented correctly.

The skyUsdsWalletStakeCleDetails$ function is implemented correctly:

  • It follows the pattern of similar functions in the file.
  • It uses onEveryBlock$ to ensure updates on each new block.
  • It correctly passes the optional ownerAddress parameter to the skyUsdsWalletStakeCleDetails function.

This implementation allows for real-time updates of the CLE staking details for a given wallet address.


744-744: LGTM: New observable added to the returned object.

The skyUsdsWalletStakeCleDetails$ function is correctly added to the object returned by setupProductContext. This makes the new observable available for use in other parts of the application that consume this context.


3-7: Summary: New Sky USDS wallet staking for CLE feature added successfully.

These changes introduce support for Sky USDS wallet staking for CLE (Chronicle Points):

  1. A new import for skyUsdsWalletStakeCleDetails is added.
  2. A new observable skyUsdsWalletStakeCleDetails$ is implemented, following existing patterns.
  3. The new observable is made available in the product context.

The implementation is clean, consistent with the existing codebase, and should integrate well with the rest of the application. These additions enable real-time tracking of CLE staking details for user wallets, enhancing the functionality related to Chronicle Points farming.

Also applies to: 697-699, 744-744

blockchain/token-metadata-list/token-configs.ts (2)

Line range hint 1-158: LGTM! The addition of the 'CLE' token configuration is approved.

The new 'CLE' (Chronicle Points) token has been successfully added to the tokenConfigs array. The configuration follows the established structure and provides the necessary information for integration into the system.

A few minor suggestions have been made to enhance consistency and documentation, but overall, the changes look good and are ready for integration.


147-158: New token configuration for 'CLE' looks good.

The new token configuration for 'Chronicle Points' (CLE) has been added correctly. It follows the structure and conventions used for other tokens in the list. A few observations:

  1. The precision and digits values are consistent with most other tokens.
  2. The icon and iconCircle properties use the cle icon, which should be imported at the top of the file.
  3. The color and background properties are set with unique values, which is good for distinguishing the token visually.
  4. The tags array is empty, which is fine if there are no specific tags for this token.

To ensure the cle icon is properly imported, let's run this script:

handlers/product-hub/update-handlers/sky/skyHandler.ts (2)

48-48: 🛠️ Refactor suggestion

Avoid returning empty objects in the map function.

Returning {} when the label doesn't match 'SRR' or 'CLE' adds unnecessary placeholders that are later filtered out. This can be optimized by returning null or undefined, making the intent clearer and potentially improving performance.

Apply this diff to simplify the return statement:

-  return {}
+  return null

Likely invalid or redundant comment.


1-1: Verify that skyUsdsStakeCleDetails is correctly imported.

Ensure that skyUsdsStakeCleDetails is exported from 'blockchain/better-calls/sky' and that the import path is correct to prevent any import errors.

Run the following script to confirm the export exists:

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

200-212: Ensure Fetch API Availability in Node.js Environment

The fetch API may not be available in all Node.js environments.

Verify that your runtime environment supports fetch. If not, consider using a library like node-fetch or axios.

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

23-23: Addition of 'stakingAction' parameter is appropriate

The stakingAction parameter is correctly added to the useSkyType interface with the appropriate union type, allowing for 'stake', 'unstake', or 'claim' actions. This enhances the function's flexibility.


49-49: Including 'stakingAction' in function parameters

The stakingAction parameter is properly destructured in the useSky function, ensuring it can be utilized within the function logic as intended.


227-230: Conditional logic updated to handle 'stakingAction'

The condition now checks if stakingAction === 'stake' before requiring approval. This ensures that the allowance prompt is only shown when staking, which aligns with the expected behavior.


242-242: Including 'stakingAction' in dependencies array

Adding stakingAction to the dependency array of the useMemo hook ensures that the action function updates correctly when stakingAction changes, preventing potential stale closures.


259-266: Updating action labels based on 'stakingAction'

The action label logic now considers stakingAction, correctly adjusting the label based on the current action (e.g., 'Set allowance' when staking). This improves user feedback and interface clarity.


277-277: Including 'stakingAction' in dependencies array

By adding stakingAction to the dependencies of the useMemo hook for actionLabel, you ensure that the label updates appropriately when stakingAction changes.

@marcinciarka marcinciarka merged commit 74e27d2 into dev Sep 25, 2024
13 checks passed
@marcinciarka marcinciarka deleted the marcinciarka/sky-cle branch September 25, 2024 14:20
@coderabbitai coderabbitai bot mentioned this pull request Sep 26, 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