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

chore!: Remove PancakeSwap dependencies and related code #7

Merged
merged 4 commits into from
Sep 1, 2024

Conversation

shuhuiluo
Copy link
Owner

@shuhuiluo shuhuiluo commented Sep 1, 2024

Summary by CodeRabbit

  • New Features

    • Streamlined logic for handling different Automated Market Makers (AMMs) in the pool lens functionality.
    • Updated interfaces to align with the Uniswap V3 protocol for non-fungible position management.
  • Bug Fixes

    • Optimized gas usage across multiple test functions, enhancing performance.
  • Chores

    • Updated dependencies in the project to ensure compatibility with the latest tools and libraries.
    • Removed unnecessary PancakeSwap-related components to simplify the codebase.

Removed all references and dependencies on PancakeSwap from the project. This includes deleting PancakeSwap-specific import statements, contracts, and updating package.json and remappings.txt to exclude PancakeSwap modules.
Renamed INonfungiblePositionManager to IUniswapV3NonfungiblePositionManager across multiple files for clarity. Updated package dependencies and fixed Prettier commands for TypeScript files.
Copy link

coderabbitai bot commented Sep 1, 2024

Warning

Rate limit exceeded

@shuhuiluo has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 32 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 3a91457 and 794b733.

Walkthrough

The modifications encompass updates to performance metrics in various test classes, the removal of PancakeSwap-specific contracts, and adjustments to dependencies in the codebase. Notably, the workflow configuration has been streamlined by eliminating unnecessary components related to Binance Smart Chain. Additionally, changes in naming conventions and imports reflect a transition to Uniswap V3 protocols, enhancing clarity in contract interactions across the project.

Changes

Files Change Summary
src/pool_lens_test.py, src/position_lens_test.py, src/storage_lens_test.py Adjusted performance metrics, including reduced runs and gas consumption in various test functions.
.github/workflows/foundry.yml Removed BNB_RPC_URL and a job for BNB mainnet, streamlining the workflow.
contracts/EphemeralPoolPositions.sol, contracts/EphemeralPoolSlots.sol, contracts/EphemeralPoolTickBitmap.sol, contracts/EphemeralPoolTicks.sol Removed EphemeralPCSV3PoolPositions, EphemeralPCSV3PoolSlots, EphemeralPCSV3PoolTickBitmap, and EphemeralPCSV3PoolTicks contracts.
contracts/PositionUtils.sol Updated import for non-fungible position manager to IUniswapV3NonfungiblePositionManager.
package.json Updated scripts and dependencies, including @aperture_finance/uni-v3-lib and typescript.
remappings.txt Removed mapping for PancakeSwap library.
src/position_lens.rs Changed interface from INonfungiblePositionManagerInstance to IUniswapV3NonfungiblePositionManager.
src/viem/poolLens.ts Simplified logic by removing conditional checks for AMMs, focusing solely on Uniswap V3.
src/viem/storageLens.ts Modified getStorageAt function's overrides object with updated code.
test/foundry/Base.t.sol Updated imports and removed PancakeSwap callback interfaces, focusing on Uniswap V3.
test/hardhat/univ3_test.ts Renamed factory interface to IUniswapV3NonfungiblePositionManager__factory.

Sequence Diagram(s)

sequenceDiagram
    participant A as User
    participant B as Uniswap V3
    participant C as Contract
    participant D as PancakeSwap (removed)

    A->>C: Interact with Non-Fungible Position Manager
    C->>B: Call Uniswap V3 Functions
    B-->>C: Return Data
    C-->>A: Provide Results
Loading

In the realm of code, changes abound,
Contracts removed, new names are found.
Uniswap V3 takes center stage,
PancakeSwap's exit, a new page.
Performance metrics, refined and bright,
A streamlined workflow, a coder's delight!


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>.
    • 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 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

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

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 073ee03 and 3a91457.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (14)
  • .gas-snapshot (1 hunks)
  • .github/workflows/foundry.yml (2 hunks)
  • contracts/EphemeralPoolPositions.sol (1 hunks)
  • contracts/EphemeralPoolSlots.sol (2 hunks)
  • contracts/EphemeralPoolTickBitmap.sol (1 hunks)
  • contracts/EphemeralPoolTicks.sol (1 hunks)
  • contracts/PositionUtils.sol (1 hunks)
  • package.json (2 hunks)
  • remappings.txt (1 hunks)
  • src/position_lens.rs (2 hunks)
  • src/viem/poolLens.ts (5 hunks)
  • src/viem/storageLens.ts (1 hunks)
  • test/foundry/Base.t.sol (2 hunks)
  • test/hardhat/univ3_test.ts (2 hunks)
Additional comments not posted (31)
remappings.txt (1)

Line range hint 1-6: Verify the impact of removing the PancakeSwap dependency.

The removal of the PancakeSwap dependency mapping is a non-trivial change that could have far-reaching implications. It is imperative that we conduct a thorough review of the codebase to ensure that no critical functionality is compromised by this alteration.

To verify the impact, I propose the following course of action:

The expected results are that no occurrences of PancakeSwap imports or references are found. If any are discovered, further investigation will be necessary to determine if the removal of the PancakeSwap dependency has introduced any breaking changes.

.gas-snapshot (1)

1-13: The changes to the performance metrics are approved.

Upon meticulous examination, I have determined that the modifications to the performance metrics of the various test functions are indeed optimizations. The reduction in the number of runs and the minor adjustments to gas consumption suggest a commendable effort to enhance the efficiency and performance of the testing framework.

I hereby grant my approval for these changes, as they align with the principles of continuous improvement and do not introduce any discernible risks or concerns.

.github/workflows/foundry.yml (1)

Line range hint 1-45: The removal of BNB-related components from the workflow is approved.

I have thoroughly scrutinized the modifications to the GitHub Actions workflow configuration file and have concluded that the removal of the BNB_RPC_URL environment variable and the job that executed tests on the BNB mainnet is a logical and appropriate simplification of the workflow.

By eliminating these unnecessary components, the workflow has been streamlined to focus solely on the critical task of running tests on the mainnet. This change aligns with the principle of Occam's razor, which states that the simplest solution is often the correct one.

Therefore, I wholeheartedly approve these changes, as they serve to optimize the workflow without introducing any discernible risks or complications.

contracts/EphemeralPoolTickBitmap.sol (1)

Line range hint 1-58: The removal of the EphemeralPCSV3PoolTickBitmap contract is approved.

The changes simplify the codebase by eliminating PancakeSwap-specific functionality. The removal does not introduce any new issues.

package.json (13)

45-45: The change to the prettier script is approved.

Specifying {src,test}/**/*.ts instead of ./**/*.ts improves clarity and potentially performance by narrowing the scope of the files being processed.


46-46: The change to the prettier:fix script is approved.

Specifying {src,test}/**/*.ts instead of ./**/*.ts improves clarity and potentially performance by narrowing the scope of the files being processed.


59-59: The update to the @nomicfoundation/hardhat-foundry dependency is approved.

The minor version bump from ^1.1.1 to ^1.1.2 suggests improvements or bug fixes. The change is unlikely to introduce any issues.


63-63: The update to the @types/chai dependency is approved.

The minor version bump from ^4.3.14 to ^4.3.19 suggests improvements or bug fixes. The change is unlikely to introduce any issues.


64-64: The update to the @types/mocha dependency is approved.

The patch version bump from ^10.0.6 to ^10.0.7 suggests bug fixes. The change is unlikely to introduce any issues.


66-66: The update to the @uniswap/v3-sdk dependency is approved.

The minor version bump from ^3.11.0 to ^3.13.1 suggests improvements or new features. The change is unlikely to introduce any issues.


68-68: The update to the hardhat dependency is approved.

The patch version bump from ^2.22.2 to ^2.22.9 suggests bug fixes. The change is unlikely to introduce any issues.


69-69: The update to the mocha dependency is approved.

The minor version bump from ^10.4.0 to ^10.7.3 suggests improvements or new features. The change is unlikely to introduce any issues.


70-70: The update to the prettier dependency is approved.

The minor version bump from ^3.2.5 to ^3.3.3 suggests improvements or new features. The change is unlikely to introduce any issues.


71-71: The update to the prettier-plugin-solidity dependency is approved.

The minor version bump from ^1.3.1 to ^1.4.1 suggests improvements or new features. The change is unlikely to introduce any issues.


74-74: The update to the typescript dependency is approved.

The minor version bump from ^5.4.3 to ^5.5.4 suggests improvements or new features. The change is unlikely to introduce any issues.


50-50: The update to the @aperture_finance/uni-v3-lib dependency is approved, but compatibility must be verified.

The version bump from ^2.0.1 to ^3.0.3 may include new features or breaking changes. Ensure that the codebase is compatible with the new version.

Run the following script to verify the dependency usage:


65-65: The update to the @types/node dependency is approved, but compatibility must be verified.

The major version bump from ^20.11.30 to ^22.5.1 may include breaking changes. Ensure that the codebase is compatible with the new version.

Run the following script to verify the dependency usage:

contracts/EphemeralPoolPositions.sol (1)

Line range hint 1-58: The removal of the EphemeralPCSV3PoolPositions contract is approved.

The changes simplify the codebase by eliminating PancakeSwap-specific functionality. The removal does not introduce any new issues.

src/viem/storageLens.ts (1)

60-60: Verify the impact of the change in the code property on the getStorageAt function.

The hexadecimal string representing the code in the overrides object has been modified. This change suggests an update to the underlying logic or functionality of the code, which could impact how the getStorageAt function retrieves or interacts with the storage at the specified address.

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

Please ensure that the change in the code property aligns with the expected behavior of the getStorageAt function and does not introduce any unintended side effects.

src/viem/poolLens.ts (5)

13-13: Bazinga! The formatting change is acceptable.

The update to the AutomatedMarketMakerEnum declaration using a more concise array syntax is a minor formatting change that enhances readability without impacting the functionality.


51-55: The removal of the conditional logic is a commendable simplification.

The elimination of the conditional checks for different AMMs in the getStaticSlots function streamlines the code without compromising the functionality. By directly using the EphemeralPoolSlots__factory for all cases, the implementation becomes cleaner and more efficient.


70-74: The removal of the AMM-specific logic is a laudable enhancement.

The getTicksSlots function has been improved by eliminating the conditional checks for different AMMs and directly utilizing the EphemeralPoolTicks__factory. This change simplifies the code structure while preserving the intended functionality, resulting in a more maintainable and efficient implementation.


87-91: The simplification of the getTickBitmapSlots function is a welcome improvement.

By removing the conditional logic for handling different AMMs and directly using the EphemeralPoolTickBitmap__factory, the getTickBitmapSlots function has been streamlined. This change enhances code readability and maintainability without altering the core functionality, resulting in a more efficient implementation.


110-114: The refactoring of the getPositionsSlots function is a delightful enhancement.

The getPositionsSlots function has undergone a beneficial simplification by eliminating the conditional logic for handling different AMMs. By directly utilizing the EphemeralPoolPositions__factory, the code becomes more concise and maintainable while preserving its intended behavior. This change is a commendable improvement to the codebase.

contracts/EphemeralPoolSlots.sol (1)

1-1: The removal of the EphemeralPCSV3PoolSlots contract warrants further clarification.

The EphemeralPCSV3PoolSlots contract, which served as a lens for fetching static state variables from a PancakeSwap v3 pool, has been completely removed from the codebase. While this change simplifies the contract structure and reduces the complexity of managing multiple contracts for similar purposes, it raises questions about the rationale behind the removal and its potential impact on the overall functionality.

To better understand the implications of this change, please provide insights into the following:

  1. What motivated the decision to remove the EphemeralPCSV3PoolSlots contract?
  2. How does the removal affect the system's ability to interact with PancakeSwap v3 pools?
  3. Are there any alternative mechanisms or contracts in place to handle PancakeSwap-specific functionality?

Clarifying these aspects will help ensure that the removal of the contract aligns with the project's goals and does not introduce any unintended limitations or compatibility issues.

contracts/EphemeralPoolTicks.sol (1)

Line range hint 1-1: The removal of the EphemeralPCSV3PoolTicks contract is approved, but I recommend verifying that the removed functionality is no longer required or has been properly refactored.

The complete removal of the EphemeralPCSV3PoolTicks contract suggests a significant shift in the architecture and a simplification of the codebase. It is important to ensure that the functionality previously provided by this contract is either no longer necessary or has been appropriately refactored into another component to maintain the integrity of the system.

To verify that the removed functionality is no longer required or has been properly refactored, I propose the following steps:

  1. Review the codebase to identify any references to the EphemeralPCSV3PoolTicks contract or its specific functionality.
  2. If references are found, investigate whether the functionality has been refactored into another component or if it is no longer required.
  3. If the functionality has been refactored, ensure that the new implementation maintains the expected behavior and does not introduce any regressions.
  4. If the functionality is no longer required, confirm that its removal does not impact the overall system's correctness and performance.

By thoroughly verifying the impact of removing the EphemeralPCSV3PoolTicks contract, we can ensure that the codebase remains coherent, maintainable, and free of any unintended consequences.

test/hardhat/univ3_test.ts (1)

19-19: The change in the import statement and the instantiation of the contract using the new factory is approved.

The transition from INonfungiblePositionManager__factory to IUniswapV3NonfungiblePositionManager__factory improves the semantic clarity of the code and ensures that the correct factory is referenced. This change enhances the readability and maintainability of the codebase by explicitly indicating that the factory is tailored for the Uniswap V3 implementation.

By updating the import statement and the instantiation of the contract within the test suite, the code maintains its integrity and functionality, allowing for accurate contract interactions during testing. This change promotes a more precise and self-explanatory codebase, reducing the likelihood of confusion or errors related to factory usage.

Also applies to: 53-53

test/foundry/Base.t.sol (1)

4-4: Bazinga! The import statement change is logically sound.

The updated import statement aligns with the objective of transitioning to Uniswap V3 and removing PancakeSwap dependencies. The new interface IUniswapV3NonfungiblePositionManager is imported from the correct path, ensuring compatibility with the Uniswap V3 ecosystem.

src/position_lens.rs (3)

131-131: Intriguing! The import statement change is a logical progression.

The updated import statement, which brings in the IUniswapV3NonfungiblePositionManager interface from the iuniswapv3nonfungiblepositionmanager module, aligns perfectly with the goal of transitioning to Uniswap V3 and eliminating PancakeSwap dependencies. This change ensures that the code is utilizing the appropriate interface for managing non-fungible positions within the Uniswap V3 framework.


283-283: Remarkable! The instantiation change is a logical step forward.

The updated instantiation of the non-fungible position manager using IUniswapV3NonfungiblePositionManager::new aligns seamlessly with the goal of transitioning to Uniswap V3 and eliminating PancakeSwap dependencies. This change ensures that the code is utilizing the correct interface for managing non-fungible positions within the Uniswap V3 framework, thereby enhancing compatibility and consistency.


291-291: Fascinating! The instantiation change is a logical progression.

The updated instantiation of the non-fungible position manager using IUniswapV3NonfungiblePositionManager::new aligns perfectly with the goal of transitioning to Uniswap V3 and eliminating PancakeSwap dependencies. This change ensures that the code is utilizing the correct interface for managing non-fungible positions within the Uniswap V3 framework, thereby enhancing compatibility and consistency across the codebase.

contracts/PositionUtils.sol Show resolved Hide resolved
test/foundry/Base.t.sol Show resolved Hide resolved
Replaced INFURA_API_KEY with MAINNET_RPC_URL for consistency and clarity. Updated the test setup to use the new MAINNET_RPC_URL for fetching the RPC URL from the environment variables.
Adjusted gas usage metrics in multiple test cases to reflect new performance measurements. These changes help ensure the accuracy and relevance of benchmarking data in our testing suite.
@shuhuiluo shuhuiluo changed the title chore: Remove PancakeSwap dependencies and related code chore!: Remove PancakeSwap dependencies and related code Sep 1, 2024
@shuhuiluo shuhuiluo merged commit b728ef0 into main Sep 1, 2024
4 checks passed
@shuhuiluo shuhuiluo deleted the fuck-pcs branch September 1, 2024 05:43
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