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

Deploy new stop loss contract on all networks #65

Conversation

yvesfracari
Copy link
Contributor

@yvesfracari yvesfracari commented Aug 19, 2024

Summary by CodeRabbit

  • New Features

    • Added support for the Arbitrum blockchain across various components and modules.
    • Enhanced token handling to include Arbitrum-specific token logos and price fetching.
    • Introduced comprehensive metadata for Arbitrum within the chain information structure.
  • Bug Fixes

    • Simplified validation checks for chainId, allowing for more flexible behavior on the OrderPage and Page components.
  • Chores

    • Removed deprecated constants and streamlined code for better maintainability.
    • Updated various components to improve readability and consistency without altering functionality.

Copy link

vercel bot commented Aug 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
composable-cow-hub-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 19, 2024 3:38pm
cow-stoploss ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 19, 2024 3:38pm

Copy link

linear bot commented Aug 19, 2024

Copy link

coderabbitai bot commented Aug 19, 2024

Walkthrough

The recent changes enhance the application's support for the Arbitrum blockchain by introducing flexibility in handling chain IDs, expanding token logo management, and improving API integrations. Key modifications involve removing strict validation checks and adding new functionalities, all while prioritizing code readability and maintainability. These updates aim to broaden interoperability and enrich the user experience across multiple blockchain networks.

Changes

Files Change Summary
src/app/[chainId]/[safeAddress]/[orderId]/page.tsx, src/app/[chainId]/[safeAddress]/page.tsx Removed strict validation for chainId, allowing any value. Simplified parameter naming.
src/components/TokenLogo.tsx Added Arbitrum to the supported chains and updated logo mapping.
src/lib/coingeckoApi.ts Entire file commented out, disabling functionality for fetching USD prices.
src/lib/contracts.ts Simplified STOP_LOSS_ADDRESS to a single constant; removed multiple chain addresses.
src/lib/cowApi/api.ts, src/lib/cowApi/fetchNativePrice.ts Added support for Arbitrum in API URL mappings and token management.
src/lib/cowExplorer.ts Enhanced explorer functionality by including Arbitrum URLs.
src/lib/oracleRouter.ts Introduced ArbitrumRouter to support fetching price feeds for Arbitrum.
src/lib/publicClients.ts Expanded support for Arbitrum in type definitions and client configurations.
src/lib/tokenUtils.ts Adjusted price fetching logic to remove Coingecko dependency.
src/lib/transactionFactory.ts Simplified handler assignments and code formatting for clarity.
src/lib/txQueue/fetchCreateQueuedOrders.ts Streamlined logic by removing redundant checks for STOP_LOSS_ADDRESS.
src/utils/index.ts Removed unnecessary constants and updated mappings for Arbitrum support.
src/utils/wagmi.ts Updated configurations to include Arbitrum in supported chains and transports.
src/lib/chainInfo.ts Added comprehensive Arbitrum chain information to the CHAIN_INFO object.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant API
    participant TokenService

    User->>App: Request token info
    App->>TokenService: Fetch token details
    TokenService->>API: Request price from Cow Protocol
    API-->>TokenService: Return token price
    TokenService-->>App: Send token price
    App-->>User: Display price info
Loading

🐇 In fields so wide and bright,
The code hops here with delight.
Arbitrum joins the merry crew,
More chains to play, more things to do!
With each tweak, the flow is clear,
A bouncy code, oh, what a cheer! 🎉


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

Outside diff range, codebase verification and nitpick comments (1)
src/lib/cowExplorer.ts (1)

35-35: Formatting Change in Error Message Construction

The formatting change in the error message construction improves readability. Ensure that similar formatting is applied consistently throughout the codebase.

-      "Unsupported Network. The operator API is not deployed in the Network " +
+      "Unsupported Network: The operator API is not deployed in the Network " +
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fb1e38b and ee4422b.

Files selected for processing (15)
  • src/app/[chainId]/[safeAddress]/[orderId]/page.tsx (1 hunks)
  • src/app/[chainId]/[safeAddress]/page.tsx (1 hunks)
  • src/components/TokenLogo.tsx (2 hunks)
  • src/lib/coingeckoApi.ts (1 hunks)
  • src/lib/contracts.ts (2 hunks)
  • src/lib/cowApi/api.ts (1 hunks)
  • src/lib/cowApi/fetchNativePrice.ts (4 hunks)
  • src/lib/cowExplorer.ts (4 hunks)
  • src/lib/oracleRouter.ts (4 hunks)
  • src/lib/publicClients.ts (2 hunks)
  • src/lib/tokenUtils.ts (5 hunks)
  • src/lib/transactionFactory.ts (4 hunks)
  • src/lib/txQueue/fetchCreateQueuedOrders.ts (2 hunks)
  • src/utils/index.ts (6 hunks)
  • src/utils/wagmi.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/lib/transactionFactory.ts
Additional comments not posted (28)
src/lib/cowApi/api.ts (1)

1-9: Support for Arbitrum added successfully.

The addition of the Arbitrum network to COW_API_URL_BY_CHAIN_ID is consistent with existing entries and correctly imports arbitrum from the viem/chains module.

src/utils/wagmi.ts (1)

2-12: Arbitrum network support added to wagmiConfig.

The inclusion of Arbitrum in both the chains array and transports object is correctly implemented, ensuring consistent support across the configuration.

src/app/[chainId]/[safeAddress]/[orderId]/page.tsx (1)

Line range hint 1-19: Validation removal for chainId simplifies control flow.

The removal of the chainId validation allows the function to handle multiple chain IDs, enhancing flexibility. Ensure that this change does not introduce unintended behaviors in the OrderPage function.

Verification successful

No unintended behaviors from chainId validation removal in OrderPage. The removal of chainId validation does not affect other parts of the codebase, as OrderPage is not referenced elsewhere. The change simplifies control flow without introducing issues.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of removing the `chainId` validation on `OrderPage`.

# Test: Search for usages of `OrderPage` and ensure no assumptions are made about `chainId`.
rg --type tsx -A 5 $'OrderPage'

Length of output: 58


Script:

#!/bin/bash
# Description: Verify the impact of removing the `chainId` validation on `OrderPage`.

# Test: Search for usages of `OrderPage` and ensure no assumptions are made about `chainId`.
rg --glob '**/*.tsx' -A 5 'OrderPage'

Length of output: 454


Script:

#!/bin/bash
# Description: Search for any imports or references to `OrderPage` in the codebase.

# Find all occurrences of `OrderPage` to ensure there are no assumptions about `chainId`.
rg 'OrderPage' --glob '**/*.tsx' --glob '**/*.ts' --glob '**/*.js' --glob '**/*.jsx'

Length of output: 3259

src/app/[chainId]/[safeAddress]/page.tsx (1)

6-8: Parameter renaming and validation removal enhance flexibility.

Renaming params to _params indicates potential non-use within the function. The removal of chainId validation increases input flexibility. Verify that _params is not used elsewhere in the component.

Verification successful

Parameter _params is not used within the component.

The _params parameter is defined but not utilized in the function body, confirming its non-use within the component. This aligns with the review comment regarding its renaming and potential non-use.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `_params` in the `Page` component.

# Test: Search for `_params` usage within the file to ensure it's not needed.
rg --type tsx -A 5 $'_params' src/app/[chainId]/[safeAddress]/page.tsx

Length of output: 99


Script:

#!/bin/bash
# Description: Verify the usage of `_params` in the `Page` component.

# Test: Search for `_params` usage within the file to ensure it's not needed.
rg -A 5 '_params' src/app/[chainId]/[safeAddress]/page.tsx

Length of output: 156

src/lib/contracts.ts (1)

Line range hint 1-15: STOP_LOSS_ADDRESS simplification is effective.

The change to a single constant address for STOP_LOSS_ADDRESS simplifies address management and aligns with the goal of streamlining the code. The removal of unused imports is also appropriate.

src/lib/publicClients.ts (4)

2-6: Addition of Arbitrum to Chain Imports and Type Definitions

The addition of arbitrum to the chain imports and type definitions is correct and necessary for supporting the new blockchain. Ensure that the arbitrum import is used consistently throughout the codebase.


10-17: Expansion of Supported Chains and Chain IDs

The supportedChains and supportedChainIds arrays now include arbitrum. This change is consistent with the goal of supporting the Arbitrum blockchain. Verify that all usages of these arrays accommodate the additional chain.


23-23: Addition of Arbitrum to RPC Providers

The RPC_PROVIDERS object now includes an entry for arbitrum, which is necessary for connecting to the Arbitrum network. Ensure that the environment variable NEXT_PUBLIC_RPC_URL_ARBITRUM is correctly configured.


38-38: Addition of Arbitrum to Public Clients

The publicClientsFromNames and publicClientsFromIds objects now include entries for arbitrum, allowing for client creation for this chain. This is consistent with the intended support for Arbitrum.

src/lib/coingeckoApi.ts (1)

1-54: Impact of Commenting Out CoinGecko API Integration

The entire CoinGecko API integration has been commented out. This will disable any functionality relying on getCoingeckoUsdPrice. Ensure that all dependent modules or functions are updated accordingly, and verify that this change does not introduce any runtime errors.

Verification successful

No Active Usages of getCoingeckoUsdPrice Found

The function getCoingeckoUsdPrice is only referenced in comments, indicating no active dependencies in the codebase. This suggests that commenting out the CoinGecko API integration should not introduce runtime errors.

  • src/lib/tokenUtils.ts: Contains commented-out references to getCoingeckoUsdPrice.
  • src/lib/coingeckoApi.ts: Contains the commented-out function definition.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that no runtime errors occur due to the removal of CoinGecko API integration.

# Test: Search for usages of `getCoingeckoUsdPrice`. Expect: No usages remain.
rg --type javascript 'getCoingeckoUsdPrice'

Length of output: 78


Script:

#!/bin/bash
# Description: Verify that no runtime errors occur due to the removal of CoinGecko API integration.

# Test: Search for usages of `getCoingeckoUsdPrice`. Expect: No usages remain.
rg 'getCoingeckoUsdPrice'

Length of output: 258

src/lib/cowExplorer.ts (2)

Line range hint 3-21: Addition of Arbitrum to Explorer URL Configuration

The addition of arbitrum to the _getExplorerUrlByEnvironment function allows for proper URL configuration for the Arbitrum network. This change is consistent with the goal of supporting Arbitrum. Ensure that the base URL for Arbitrum is correctly configured.


50-52: Formatting Change in Parameter Declaration

The formatting change in the getExplorerAddressLink function improves consistency. Ensure that similar formatting is applied consistently throughout the codebase.

src/lib/cowApi/fetchNativePrice.ts (3)

3-3: Addition of Arbitrum to Chain Imports

The addition of arbitrum to the chain imports is necessary for supporting the Arbitrum network. Ensure that this import is utilized correctly throughout the codebase.


43-47: Addition of Arbitrum to USDC Configuration

The USDC constant now includes an entry for the Arbitrum chain. This addition is consistent with the goal of supporting USDC on Arbitrum. Verify that this configuration is used correctly in related functions.


68-72: Formatting Change in Parameter Declaration

The formatting change in the getCowProtocolUsdPrice function improves readability. Ensure that similar formatting is applied consistently throughout the codebase.

src/components/TokenLogo.tsx (2)

6-6: Addition of Arbitrum to Chain Imports

The addition of arbitrum to the chain imports is necessary for supporting token logos from the Arbitrum network. Ensure that this import is utilized correctly throughout the component.


40-40: Addition of Arbitrum to Chain ID to Name Mapping

The chainIdToName mapping now includes an entry for arbitrum. This change is consistent with the goal of supporting Arbitrum. Verify that this mapping is used correctly in related functions.

src/lib/txQueue/fetchCreateQueuedOrders.ts (3)

26-26: Simplified condition improves readability.

The removal of redundant comparison enhances clarity without affecting functionality.


40-40: Formatting adjustments enhance readability.

The changes improve the consistency of the code style without altering its logic.


47-47: Consistent formatting for decodedArgsList.

The formatting change aligns with the overall code style, enhancing readability.

src/lib/tokenUtils.ts (3)

51-65: Simplified error handling in fetchTokenUsdPrice.

The function now exclusively uses the Cow Protocol API for price data, simplifying error handling. Ensure the Cow Protocol API is reliable for your use case.


90-90: Stylistic change: Removed trailing commas.

The removal of trailing commas aligns with common style guides and does not impact functionality.

Also applies to: 114-114


3-3: Commented out Coingecko import.

The import for getCoingeckoUsdPrice is commented out, indicating a temporary shift in logic. Ensure this change is documented or tracked for future reference.

src/utils/index.ts (3)

2-2: Arbitrum chain added to imports.

The addition of the Arbitrum chain supports the PR objective of expanding network compatibility.


175-176: Reformatted filtering logic for clarity.

The changes improve readability while maintaining the original functionality.


208-208: Arbitrum support added to cowExplorerUrl.

The addition of Arbitrum-specific URLs enhances network support, aligning with the PR objectives.

src/lib/oracleRouter.ts (2)

5-5: ArbitrumRouter class introduced.

The new ArbitrumRouter class extends support for the Arbitrum network, aligning with the PR objectives. The implementation is consistent with existing routers.

Also applies to: 194-200


220-220: ArbitrumRouter added to router factory.

The inclusion of ArbitrumRouter in the factory integrates Arbitrum support into the existing routing framework.

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 ee4422b and 2df84f1.

Files selected for processing (1)
  • src/app/[chainId]/[safeAddress]/page.tsx (1 hunks)
Additional comments not posted (2)
src/app/[chainId]/[safeAddress]/page.tsx (2)

6-6: Parameter Renaming to _params is Appropriate.

Renaming params to _params is a common practice to indicate that the parameter is intentionally unused, which helps suppress warnings. This change is appropriate if the parameter is not needed within the function.


6-6: Verify the Impact of Removing chainId Validation.

The removal of strict validation for chainId could lead to unexpected behavior if the component depends on specific chainId values. Ensure that the broader range of chainId values is handled correctly in the application.

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 2df84f1 and 434338b.

Files selected for processing (1)
  • src/lib/chainInfo.ts (2 hunks)
Additional comments not posted (2)
src/lib/chainInfo.ts (2)

1-1: Import statement update approved.

The addition of arbitrum to the import statement is correct and aligns with the new entry in CHAIN_INFO.


58-68: Addition of Arbitrum network entry approved.

The new entry for arbitrum.id is consistent with the existing entries in CHAIN_INFO and includes all necessary properties.

@yvesfracari yvesfracari merged commit 14cb931 into main Aug 19, 2024
4 of 5 checks passed
@yvesfracari yvesfracari deleted the pedro/cow-327-deploy-new-contract-on-all-networks-and-merge-pr-on branch August 19, 2024 15: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