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

feat: configure rewards controller && update init params #64

Open
wants to merge 6 commits into
base: staging
Choose a base branch
from

Conversation

royvardhan
Copy link
Member

@royvardhan royvardhan commented Apr 18, 2024

Summary by CodeRabbit

  • New Features

    • Introduced setRewardControllerAddress and getUnlockDiscountForStratosphereMember functions in DiamondManagerFacet.
    • Added a new IRewardsController interface for retrieving member tiers.
  • Enhancements

    • Updated AppStorage struct with rewardsControllerAddress for better rewards management.
    • Enhanced DiamondInit struct with new rewardsController field and updated discount arrays.
  • Tests

    • Implemented RewardsControllerMock for extensive testing.
    • Updated BoostFacetTest, FeeCollectorFacetTest, and UnlockFacetTest to integrate rewards controller logic.
  • Refactor

    • Refined logic in LStratosphere to interact with the new rewards controller for tier fetching.

Copy link

swarmia bot commented Apr 18, 2024

✅  Linked to Story DEV-585 · VPND LM - Unlocking period
➡️  Part of Epic DEV-697 · Stratosphere

Copy link

coderabbitai bot commented Apr 18, 2024

Walkthrough

The changes involve updating various facets and utilities within a Solidity-based smart contract system. The most significant inclusions are the setRewardControllerAddress and getUnlockDiscountForStratosphereMember functions in the DiamondManagerFacet contract. Other updates involve restructuring interfaces, modifying a mock rewards controller for testing, and consolidating new functionalities for better rewards control based on member tiers.

Changes

File Path Change Summary
lib/forge-std Updated the subproject commit hash.
src/facets/DiamondManagerFacet.sol Added setRewardControllerAddress and getUnlockDiscountForStratosphereMember functions.
src/interfaces/IRewardsController.sol Introduced IRewardsController interface with tierOf function.
src/interfaces/IStratosphere.sol Removed tierOf function.
src/libraries/AppStorage.sol Added rewardsControllerAddress field to AppStorage struct.
src/libraries/LStratosphere.sol Imported IRewardsController and updated logic to fetch member tier.
src/upgradeInitializers/DiamondInit.sol Added rewardsController to InitDiamondState and updated rewards control initializations.
test/foundry/Facets/BoostFacet.t.sol, test/foundry/Facets/FeeCollectorFacet.t.sol, test/foundry/Facets/UnlockFacet.t.sol Added/Imported RewardsControllerMock, updated test setup with rewardsControllerMock.
test/foundry/mocks/RewardsControllerMock.sol Introduced RewardsControllerMock contract for testing purposes.
test/foundry/utils/DiamondTest.sol Increased functionSelectors array size and added new function selectors.

Poem

In code so bright, a diamond gleams,
With facets sharp, fulfilling dreams,
Rewards now stacked in tiers so high,
As Stratosphere members reach the sky.
Address set and functions grow,
Solidity's brilliance starts to show.
🐇✨ Shine on, dear bytes, through the Ethereum glow. ✨💎


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@royvardhan royvardhan changed the title feat: add rewards controller feat: configure rewards controller && update init params May 2, 2024
@royvardhan royvardhan marked this pull request as ready for review May 3, 2024 08:07
@royvardhan
Copy link
Member Author

@mejiasd3v We Need to discuss about Tier setup and update the contracts.

@mejiasd3v
Copy link
Member

@royvardhan could you please fix the CI? I think it was broken before but please have a look if its an easy fix

@royvardhan royvardhan marked this pull request as draft May 6, 2024 11:17
@royvardhan royvardhan marked this pull request as ready for review May 14, 2024 07:16
Copy link

@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: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 6bcd965 and 086c171.
Files selected for processing (1)
  • src/upgradeInitializers/DiamondInit.sol (3 hunks)
Additional comments not posted (3)
src/upgradeInitializers/DiamondInit.sol (3)

39-39: Addition of rewardsController parameter to Args struct looks good.


155-155: Initialization of rewardsControllerAddress looks good.


153-155: The overall structure and logic of the init function, including the new rewardsControllerAddress, are sound.

@mejiasd3v mejiasd3v requested a review from parth-15 May 29, 2024 13:59
src/facets/DiamondManagerFacet.sol Outdated Show resolved Hide resolved
src/libraries/LStratosphere.sol Show resolved Hide resolved
test/foundry/Facets/UnlockFacet.t.sol Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 086c171 and cbc74ae.

Files selected for processing (4)
  • src/facets/DiamondManagerFacet.sol (2 hunks)
  • src/libraries/LStratosphere.sol (2 hunks)
  • test/foundry/Facets/UnlockFacet.t.sol (3 hunks)
  • test/foundry/utils/DiamondTest.sol (2 hunks)
Additional comments not posted (8)
src/libraries/LStratosphere.sol (1)

6-6: Refactor: Import statement for IRewardsController.

Ensure that the imported interface is used properly within the library. This import is crucial for the updated logic in the getDetails function.

test/foundry/Facets/UnlockFacet.t.sol (4)

11-12: Code Cleanup: Import statement for RewardsControllerMock.

The import is correctly placed and necessary for the mock's usage in tests. This setup is essential for simulating the behavior of the rewards controller in a test environment.


19-19: Initialization of RewardsControllerMock.

The mock is properly initialized, ensuring that the rewards controller behavior can be simulated during tests. This is crucial for testing the integration of the rewards controller with the UnlockFacet.


34-34: Correctness: Constant declaration for COOLDOWN_PERIOD.

The constant is defined correctly and used in subsequent test logic to simulate time-based conditions. This is a good practice for making tests readable and maintainable.


56-56: Ensure proper usage of setRewardControllerAddress.

This line sets the mock address for the rewards controller, which is crucial for ensuring that the facet interacts correctly with the controller in the test environment. Verify that this setup is consistent with the intended test scenarios.

test/foundry/utils/DiamondTest.sol (1)

Line range hint 181-212: Refactor: Updated function selectors for DiamondManagerFacet.

The addition of new function selectors to handle the increased functionality of the DiamondManagerFacet is crucial for ensuring that all facet functions are correctly registered in the diamond. This change is necessary due to the introduction of new functions in the facet.

src/facets/DiamondManagerFacet.sol (2)

240-246: Enhancement: Addition of setRewardControllerAddress function.

This function is a critical addition, allowing for dynamic configuration of the rewards controller address. It includes a check for a zero address, which is a good practice to prevent misconfiguration. Ensure thorough testing of this function to confirm it behaves as expected under various conditions.


376-378: Correctness: Implementation of getUnlockDiscount.

This getter function provides access to unlock discounts based on tiers. It's a straightforward implementation that should function correctly provided that the state variable unlockTimestampDiscountForStratosphereMembers is properly managed elsewhere in the contract.

Comment on lines +29 to +30
IRewardsController _rewardsController = IRewardsController(s.rewardsControllerAddress);
tier = _rewardsController.tierOf(_tokenId); // Revert if rewardsControllerAddress is not set
Copy link

Choose a reason for hiding this comment

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

Potential Issue: Ensure rewardsControllerAddress is correctly initialized.

The code now depends on rewardsControllerAddress being properly set. If this address is not correctly initialized, the call to tierOf will fail and revert the transaction. Consider adding a check to ensure that rewardsControllerAddress is not zero before making the call.

- tier = _rewardsController.tierOf(_tokenId); // Revert if rewardsControllerAddress is not set
+ if (s.rewardsControllerAddress == address(0)) revert("RewardsController address not set");
+ tier = _rewardsController.tierOf(_tokenId);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
IRewardsController _rewardsController = IRewardsController(s.rewardsControllerAddress);
tier = _rewardsController.tierOf(_tokenId); // Revert if rewardsControllerAddress is not set
IRewardsController _rewardsController = IRewardsController(s.rewardsControllerAddress);
if (s.rewardsControllerAddress == address(0)) revert("RewardsController address not set");
tier = _rewardsController.tierOf(_tokenId);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants