-
Notifications
You must be signed in to change notification settings - Fork 69
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
Conversation
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 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. WalkthroughThis pull request introduces a new staking mechanism for the blockchain, encapsulated in the Changes
Possibly related PRs
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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"
andaria-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 creationThis change simplifies the code and improves efficiency by combining
useMemo
anduseObservable
. 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 managementWhile the current implementation works, there are several areas where state management could potentially be simplified:
The use of temporary state variables (
tempSkyStakeWalletData
,tempSkyStakeData
,tempBalancesData
) and their correspondinguseEffect
hooks adds complexity. Consider if these can be eliminated or simplified.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.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:
- 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] ) );
- 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 thesky
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 thesky
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 thesky
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 twostake
functions.There are two
stake
functions with different parameters. One includes areferral
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 thesky
object entries.The addition of
stakingCle
usingemptyContractDesc
is consistent with other entries in thesky
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':
coinGeckoTicker
: Used for fetching price data from CoinGecko.coinpaprikaTicker
: Used for fetching price data from Coinpaprika.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 functionalityThe 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 ClarityUsing 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 HandlingUsing
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 readabilityThe 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 languagesThe labels 'Stake' and 'Unstake' are hardcoded in the
ActionPills
. Consider using the translation functiont
fromuseTranslation()
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 inVaultActionInput
The action labels 'Stake' and 'Unstake' are hardcoded within the
VaultActionInput
. Use the translation functiont
to support multiple languages.Apply this diff:
action={ { stake: t('stake'), unstake: t('unstake'), }[stakingAction] }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 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 theviewBox
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:
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.
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
, anddepositToken
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/skyLength 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 suggestionReconsider the use of
void
withreplace
Using
void
withreplace
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 theSkyCLEUsdsViewWrapper
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 statesThe 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 hookThe 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 actionThe 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 valueThe 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 valueThe 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 valueThe 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 itemsThe 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 statesThe changes made to the
SkyStakePositionView
component significantly improve the user experience by implementing consistent loading states throughout the component. The addition of thestakingAction
prop enhances the component's flexibility, allowing for dynamic behavior based on the current staking action.Key improvements:
- Consistent use of SkeletonLine for loading placeholders
- Conditional rendering of values and units based on loading states
- 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 successfullyThe addition of the
stakingCle
entry to thesky
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 tostakingCle
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 tsxLength 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 thetheme/icons
directory, confirming that the exportexport { 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/iconsLength 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:
- The
recoverERC20
function needs additional checks to prevent potential misuse.- The two
stake
functions could be renamed for clarity.- 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:
- Conduct a thorough security audit by a reputable third-party.
- Implement comprehensive unit tests covering all functions and edge cases.
- Consider using established libraries like OpenZeppelin for standard functionalities to reduce the risk of implementation errors.
350-361
: Ensure proper access control fornotifyRewardAmount
.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 forskyCleStaking
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:
- New functionality for CLE token staking will be available in the application.
- 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: NewstakingCle
entry added correctly. Verify contract address.The new
stakingCle
entry in thesky
object is correctly structured and consistent with other entries. It uses theskyCleStaking
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 theskyUsdsWalletStakeCleDetails
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 bysetupProductContext
. 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):
- A new import for
skyUsdsWalletStakeCleDetails
is added.- A new observable
skyUsdsWalletStakeCleDetails$
is implemented, following existing patterns.- 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:
- The
precision
anddigits
values are consistent with most other tokens.- The
icon
andiconCircle
properties use thecle
icon, which should be imported at the top of the file.- The
color
andbackground
properties are set with unique values, which is good for distinguishing the token visually.- 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 suggestionAvoid 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 returningnull
orundefined
, making the intent clearer and potentially improving performance.Apply this diff to simplify the return statement:
- return {} + return nullLikely invalid or redundant comment.
1-1
: Verify thatskyUsdsStakeCleDetails
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 EnvironmentThe
fetch
API may not be available in all Node.js environments.Verify that your runtime environment supports
fetch
. If not, consider using a library likenode-fetch
oraxios
.features/sky/hooks/useSky.ts (6)
23-23
: Addition of 'stakingAction' parameter is appropriateThe
stakingAction
parameter is correctly added to theuseSkyType
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 parametersThe
stakingAction
parameter is properly destructured in theuseSky
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 arrayAdding
stakingAction
to the dependency array of theuseMemo
hook ensures that theaction
function updates correctly whenstakingAction
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 arrayBy adding
stakingAction
to the dependencies of theuseMemo
hook foractionLabel
, you ensure that the label updates appropriately whenstakingAction
changes.
Sky - Chronicle Points farming view, based on SRR.
Summary by CodeRabbit
Release Notes
New Features
SkyCleStaking
, allowing users to stake USDS tokens for Chronicle Points.SkyCLEPositionView
, for managing staking actions.Enhancements
Bug Fixes