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

Updates Metis Minichef contract #1533

Merged
merged 4 commits into from
Nov 7, 2023
Merged

Conversation

abtestingalpha
Copy link
Collaborator

@abtestingalpha abtestingalpha commented Nov 3, 2023

null
96e3b91e9cf892734deb3d180bbefb968a2ca34b: synapse-interface preview link
906ee2f88c4920d1f0d9d7a86ab7409537d3032a: synapse-interface preview link
5be7d3422190d8382022a35080ab1912fbfff190: synapse-interface preview link
8300571dfdc5c1359d25a194d970764977142940: synapse-interface preview link
81b98911dafbad04934ccf646bb39b425a33cd19: synapse-interface preview link
4bc7afbdd2dd343e2ae0149946e13c813ff51ee0: synapse-interface preview link
90d799961344b1a9ff315a0ba4391ea7cd882dbd: synapse-interface preview link
7a865969ea91fa5ed301ad0f46590325c5965aad: synapse-interface preview link
e9b713b59e092e35db807e288a9ebbda5e1e007a: synapse-interface preview link
010b6a8b70ed7bae91bd179a12a3181a845f1e59: synapse-interface preview link

Summary by CodeRabbit

  • New Features
    • Introduced a new search functionality for Metis price.
    • Added a new section to display migrated pools.
  • Bug Fixes
    • Optimized state management and data fetching within the PoolCard component.
    • Simplified the PoolCards component by removing unnecessary props and conditions related to price data.
  • Refactor
    • Updated the Token class to include customRewardToken and miniChefAddress properties.
    • Modified the getPoolApyData function to include a prices parameter.
  • Chores
    • Updated the address associated with the METIS chain in the MINICHEF_ADDRESSES mapping.
    • Changed the text displayed for an option button from "Claim SYN" to "Claim".

Copy link
Contributor

coderabbitai bot commented Nov 3, 2023

Walkthrough

The changes primarily revolve around the integration of the Metis chain into the Synapse Interface. This includes the addition of Metis price fetching, updating addresses for the Metis chain, and modifying various components and utility functions to accommodate the new chain. The changes also involve refactoring and optimization of state management and data fetching in several components.

Changes

File(s) Change Summary
.../Pools/PoolActionOptions.tsx, .../Pools/PoolHeader.tsx, .../pool/PoolBody.tsx, .../pools/PoolCard.tsx, .../pools/PoolCards.tsx, .../pools/index.tsx, .../stake/StakeCard.tsx, .../stake/StakeCardTitle.tsx Modifications to various components to accommodate the new Metis chain and optimize state management and data fetching.
.../constants/chainlink.ts, .../constants/minichef.ts, .../constants/tokens/poolMaster.ts Addition of new addresses for the Metis chain and updates to existing addresses.
.../contexts/UserProvider.tsx Addition of Metis price fetching operation.
.../slices/priceDataSlice.ts, .../utils/actions/getPrices.ts, .../utils/hasAllPrices.ts Introduction of new functions to fetch and manage Metis price data.
.../utils/actions/approveAndDeposit.tsx, .../utils/actions/approveAndStake.tsx, .../utils/actions/claimStake.tsx, .../utils/actions/getPoolApyData.ts, .../utils/actions/getStakedBalance.ts, .../utils/actions/withdrawStake.tsx Modifications to utility functions to accommodate the new Metis chain.
.../utils/types/index.tsx Addition of new properties to the Token class to support the Metis chain.

Poem

🍂 As autumn leaves gently fall, 🍁

In the world of code, we stand tall. 🌐

Metis chain joins the fray, 🎉

Brightening our digital day. 💻

With each commit, we weave a tale, 📜

Sailing forth, we never fail. ⛵

In the spirit of November Seven, 🗓️

We code from dawn to eleven. 🌙

Celebrating the joy of change, 🎊

In the vast code range. 🌌

So here's to the devs, working with zest, 🥂

Making Synapse Interface the very best! 🚀


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

Copy link

codecov bot commented Nov 3, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (413a921) 51.23324% compared to head (9c7c784) 51.23324%.
Report is 3 commits behind head on master.

Additional details and impacted files
@@              Coverage Diff              @@
##              master       #1533   +/-   ##
=============================================
  Coverage   51.23324%   51.23324%           
=============================================
  Files            362         362           
  Lines          24691       24691           
  Branches         283         283           
=============================================
  Hits           12650       12650           
  Misses         10813       10813           
  Partials        1228        1228           
Flag Coverage Δ
packages 91.00610% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@abtestingalpha abtestingalpha force-pushed the fe/metis-minichef-update branch from 18cbd7d to 472f5db Compare November 3, 2023 23:50
Copy link

cloudflare-workers-and-pages bot commented Nov 3, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9c7c784
Status: ✅  Deploy successful!
Preview URL: https://c2263bc4.sanguine.pages.dev
Branch Preview URL: https://fe-metis-minichef-update.sanguine.pages.dev

View logs

@abtestingalpha abtestingalpha force-pushed the fe/metis-minichef-update branch 4 times, most recently from dcc4e48 to 1c182c8 Compare November 7, 2023 15:33
* Updates minichef address
* Fetches Metis price through chainlink aggregator
* Updates APY calcs cased on Metis price
@abtestingalpha abtestingalpha force-pushed the fe/metis-minichef-update branch from 1c182c8 to a0f1b75 Compare November 7, 2023 16:20
@abtestingalpha abtestingalpha changed the title [WIP] Updates Metis Minichef contract Updates Metis Minichef contract Nov 7, 2023
Copy link
Collaborator

@ChiTimesChi ChiTimesChi left a comment

Choose a reason for hiding this comment

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

LGTM

@abtestingalpha abtestingalpha marked this pull request as ready for review November 7, 2023 18:02
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.

Review Status

Actionable comments generated: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3864694 and 9c7c784.
Files selected for processing (22)
  • packages/synapse-interface/components/Pools/PoolActionOptions.tsx (1 hunks)
  • packages/synapse-interface/components/Pools/PoolHeader.tsx (3 hunks)
  • packages/synapse-interface/constants/chainlink.ts (1 hunks)
  • packages/synapse-interface/constants/minichef.ts (1 hunks)
  • packages/synapse-interface/constants/tokens/poolMaster.ts (32 hunks)
  • packages/synapse-interface/contexts/UserProvider.tsx (2 hunks)
  • packages/synapse-interface/pages/pool/PoolBody.tsx (2 hunks)
  • packages/synapse-interface/pages/pools/PoolCard.tsx (4 hunks)
  • packages/synapse-interface/pages/pools/PoolCards.tsx (1 hunks)
  • packages/synapse-interface/pages/pools/index.tsx (3 hunks)
  • packages/synapse-interface/pages/stake/StakeCard.tsx (12 hunks)
  • packages/synapse-interface/pages/stake/StakeCardTitle.tsx (2 hunks)
  • packages/synapse-interface/slices/priceDataSlice.ts (5 hunks)
  • packages/synapse-interface/utils/actions/approveAndDeposit.tsx (1 hunks)
  • packages/synapse-interface/utils/actions/approveAndStake.tsx (6 hunks)
  • packages/synapse-interface/utils/actions/claimStake.tsx (3 hunks)
  • packages/synapse-interface/utils/actions/getPoolApyData.ts (4 hunks)
  • packages/synapse-interface/utils/actions/getPrices.ts (2 hunks)
  • packages/synapse-interface/utils/actions/getStakedBalance.ts (2 hunks)
  • packages/synapse-interface/utils/actions/withdrawStake.tsx (3 hunks)
  • packages/synapse-interface/utils/hasAllPrices.ts (1 hunks)
  • packages/synapse-interface/utils/types/index.tsx (4 hunks)
Files skipped from review due to trivial changes (3)
  • packages/synapse-interface/components/Pools/PoolActionOptions.tsx
  • packages/synapse-interface/constants/minichef.ts
  • packages/synapse-interface/pages/pools/PoolCards.tsx
Additional comments: 62
packages/synapse-interface/constants/chainlink.ts (1)
  • 7-13: The new CHAINLINK_METIS_PRICE_ADDRESSES export follows the existing pattern for price addresses for different chains. Ensure that the address '0xd4a5bb03b5d66d9bf81507379302ac2c2dfdfa6d' is correct and that it has been deployed on the METIS chain.
packages/synapse-interface/contexts/UserProvider.tsx (2)
  • 10-15: The new import fetchMetisPrice is correctly added to the list of imports from priceDataSlice.

  • 51-54: The new function call fetchMetisPrice is correctly added to the list of dispatched actions when isClient is true. Ensure that the fetchMetisPrice function is implemented correctly and handles potential errors.

packages/synapse-interface/utils/actions/approveAndDeposit.tsx (1)
  • 46-52: The condition token.addresses[pool.chainId] === zeroAddress is used to check if the token address is the zero address. If it is, the function returns early. This change seems to be a part of the logic modification related to token addresses. Ensure that this change doesn't break any existing functionality and that all token addresses are correctly set in the pool object.
packages/synapse-interface/utils/actions/getPrices.ts (2)
  • 12-18: The getEthPrice function has been updated to use CHAINLINK_ETH_PRICE_ADDRESSES directly. Ensure that the CHAINLINK_ETH_PRICE_ADDRESSES mapping contains the correct address for the ETH chain.

  • 48-64: The getMetisPrice function has been added to retrieve the Metis price from Chainlink. Ensure that the CHAINLINK_METIS_PRICE_ADDRESSES mapping contains the correct address for the METIS chain.

packages/synapse-interface/pages/pool/PoolBody.tsx (2)
  • 55-62: Ensure that the getStakedBalance function has been updated to accept the new pool argument and that all calls to this function throughout the codebase have been updated to match the new signature.

  • 96-96: The options in the PoolActionOptions component have been modified from ['Stake', 'Unstake', 'Claim SYN'] to ['Stake', 'Unstake', 'Claim']. Ensure that this change is reflected in the logic of the PoolActionOptions component and that it doesn't break any existing functionality.

packages/synapse-interface/pages/stake/StakeCardTitle.tsx (3)
  • 5-9: The new import paths for hasAllPrices and useAppSelector should be verified to ensure they are correct and accessible.

  • 46-61: The useEffect hook has been updated to use token.chainId instead of connectedChainId and hasAllPrices(prices). Ensure that the token object and hasAllPrices(prices) are always available when this effect runs.

  • 63-69: The useMemo hook has been updated to remove connectedChainId from its dependency array. Ensure that this change does not introduce any unintended side effects.

packages/synapse-interface/utils/actions/approveAndStake.tsx (4)
  • 16-22: The miniChefAddress is now being fetched from the pool object. Ensure that the pool object is always populated with the miniChefAddress property before this function is called.

  • 33-38: The approveErc20Token function now uses miniChefAddress from the pool object instead of the MINICHEF_ADDRESSES constant. This change should be verified across the codebase to ensure that all calls to this function are updated accordingly.

  • 68-78: The miniChefAddress is now being fetched from the pool object. Ensure that the pool object is always populated with the miniChefAddress property before this function is called.

  • 94-98: The stakeLpToken function now uses miniChefAddress from the pool object instead of the MINICHEF_ADDRESSES constant. This change should be verified across the codebase to ensure that all calls to this function are updated accordingly.

packages/synapse-interface/slices/priceDataSlice.ts (5)
  • 4-8: The new getMetisPrice function is imported correctly.

  • 16-24: The PriceDataState interface has been updated to include metisPrice and isLoadingMetisPrice. Ensure that these new fields are used correctly throughout the codebase.

  • 32-40: The initial state has been updated to include metisPrice and isLoadingMetisPrice. This is consistent with the changes to the PriceDataState interface.

  • 63-72: A new async thunk fetchMetisPrice has been added to fetch and update the Metis price in the state. Ensure that this function is called at the appropriate times to keep the Metis price up-to-date.

  • 112-125: The reducer logic has been updated to handle the new Metis price fetching actions. This includes setting the loading state and updating the Metis price in the state. Ensure that errors are handled appropriately in the application when the fetchMetisPrice action is rejected.

packages/synapse-interface/utils/actions/claimStake.tsx (2)
  • 10-15: Ensure that all calls to claimStake function throughout the codebase have been updated to match the new signature.

  • 34-34: The lpAddress parameter in the harvestLpPool function call has been changed from MINICHEF_ADDRESSES[chainId] to miniChefAddress. Ensure that this change does not affect the functionality of the harvestLpPool function.

packages/synapse-interface/utils/actions/withdrawStake.tsx (3)
  • 10-16: Ensure that all calls to withdrawStake function throughout the codebase have been updated to match the new signature.

  • 17-17: The miniChefAddress is being extracted from the pool object. Ensure that the pool object always has the miniChefAddress property and it is not null or undefined.

  • 30-30: The lpAddress is now being set to miniChefAddress from the pool object. Ensure that this change does not break any functionality and is consistent with the rest of the codebase.

packages/synapse-interface/utils/types/index.tsx (4)
  • 159-166: The Token class has been extended with customRewardToken and miniChefAddress properties. Ensure that these new properties are being used correctly throughout the codebase.

  • 211-218: The constructor of the Token class has been updated to accept customRewardToken and miniChefAddress properties. Ensure that all instances of the Token class are being created with the updated constructor.

  • 252-259: The type of the constructor argument has been updated to include customRewardToken and miniChefAddress properties. Ensure that the types are being used correctly throughout the codebase.

  • 307-314: The constructor of the Token class has been updated to initialize customRewardToken and miniChefAddress properties. Ensure that these properties are being initialized correctly in all instances of the Token class.

packages/synapse-interface/pages/pools/index.tsx (4)
  • 19-25: New imports for METIS_POOL_SWAP_TOKEN_MIGRATED and METIS_WETH_SWAP_TOKEN_MIGRATED have been added. Ensure these constants are correctly defined and exported in the poolMaster file.

  • 35-37: A new migratedPools object has been introduced. Ensure that the key 1088 correctly represents the chain ID for the Metis network.

  • 47-51: The unIncentivizedPools object has been modified to filter out METIS_POOL_SWAP_TOKEN_MIGRATED and METIS_WETH_SWAP_TOKEN_MIGRATED. This logic seems correct as migrated pools should not be included in the list of unincentivized pools.

  • 89-100: A new section has been added to display migrated pools using PoolCards. Ensure that the PoolCards component can handle the migratedPools object correctly.

packages/synapse-interface/utils/actions/getStakedBalance.ts (4)
  • 1-3: Imports have been updated to reflect the changes in the function signature and the usage of the Token type.

  • 15-20: The function signature of getStakedBalance has been updated to include an additional parameter pool: Token. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 21-21: The miniChefContractAddress is now derived from the pool parameter instead of the MINICHEF_ADDRESSES mapping. This change provides more flexibility as the address can now be dynamically determined based on the pool argument.

  • 15-24: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [22-37]

The error handling in the getStakedBalance function is appropriate. It catches any errors that occur during the execution of the readContracts function and logs the error message. It also provides a default return value in case of an error.

packages/synapse-interface/pages/pools/PoolCard.tsx (4)
  • 39-57: The getSinglePoolData and getPoolApyData functions are called within a useEffect hook. Ensure that these functions handle potential errors properly and that the state updates are safe. Consider using a state machine or a similar pattern to handle the loading, success, and error states.

  • 59-76: The getStakedBalance function now accepts an additional pool parameter. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 171-174: The ManageLp component's action options now include "Claim" instead of "Claim SYN". This change should be reflected in the UI. Ensure that the UI updates correctly and that the user experience is not negatively affected.

  • 240-246: The customRewardToken property of the Token class is used here. Ensure that this property is correctly set for all instances of the Token class.

packages/synapse-interface/constants/tokens/poolMaster.ts (3)
  • 37-37: Ensure that the MINICHEF_ADDRESSES constant is correctly defined and exported in the minichef module.

  • 922-922: Ensure that the MINICHEF_ADDRESSES constant includes the correct addresses for each chain ID.

  • 900-922: Ensure that the new Token objects METIS_WETH_SWAP_TOKEN_MIGRATED and METIS_POOL_SWAP_TOKEN_MIGRATED are correctly defined and that all properties are correctly set. Also, verify that the miniChefAddress is correct for the migrated pools.

packages/synapse-interface/components/Pools/PoolHeader.tsx (2)
  • 51-53: The ConnectedIndicator is rendered only if the component is mounted and the connected chain's id matches the pool's chain id. This is a good practice as it ensures that the indicator is only shown when the user is connected to the correct chain for the pool.

  • 11-24: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [22-46]

The canDeposit calculation is done using useMemo which is a good practice as it prevents unnecessary recalculations. The calculation now depends on the balancesAndAllowances from the portfolio state which seems to be a more accurate way of determining if a deposit can be made.

packages/synapse-interface/utils/actions/getPoolApyData.ts (8)
  • 1-10: The import statements look fine. Ensure that the imported modules and constants are being used in the code.

  • 17-27: The Prices type is well defined and covers all the necessary fields.

  • 29-33: The function signature of getPoolApyData has been updated to include a prices parameter of type Prices. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 42-44: The minichefAddress is now assigned from the poolToken.miniChefAddress. Ensure that the poolToken object has the miniChefAddress property and it is of type Address.

  • 83-94: The data fetching and assignment operations look fine. The fallback values are correctly assigned in case of null or undefined results.

  • 89-90: The synPriceData and metisPrice are fetched either from the prices parameter or by calling the getSynPrices and getMetisPrice functions respectively. Ensure that the getSynPrices and getMetisPrice functions return the expected data structure.

  • 136-140: The usePrice is assigned based on the chainId of the poolToken. This logic seems fine. Ensure that the METIS.id is correctly defined and matches the expected chainId for Metis.

  • 142-145: The calculations for usdPerWeek, weeklyAPR, and yearlyAPR look fine. Ensure that the stakedTvl is correctly calculated and is not zero to avoid division by zero errors.

packages/synapse-interface/pages/stake/StakeCard.tsx (8)
  • 40-45: The useState hook is used to manage the state of deposit, withdraw, and showStake. Ensure that these states are updated correctly throughout the component.

  • 53-59: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [53-69]

The useEffect hook is used to fetch the staked balance. Ensure that the getStakedBalance function is updated to accept the new pool parameter.

  • 82-94: The useEffect hook is used to fetch the token allowance and the staked balance. Ensure that the getTokenAllowance and getStakedBalance functions are updated to accept the new pool parameter.

  • 102-108: The useEffect hook is used to fetch the token allowance. Ensure that the getTokenAllowance function is updated to accept the new pool parameter.

  • 148-157: The "SYN Earned" text and the token symbol are now dynamic based on the customRewardToken property of the pool object. Ensure that the customRewardToken property is correctly set in the pool object.

  • 171-187: The "Claim SYN" button text is now dynamic based on the customRewardToken property of the pool object. Ensure that the customRewardToken property is correctly set in the pool object.

  • 303-309: The stake function now receives the pool object as an additional parameter. Ensure that the stake function is updated to accept this new parameter.

  • 327-333: The withdrawStake function now receives the pool object as an additional parameter. Ensure that the withdrawStake function is updated to accept this new parameter.

@abtestingalpha abtestingalpha merged commit 392ee1f into master Nov 7, 2023
43 checks passed
@abtestingalpha abtestingalpha deleted the fe/metis-minichef-update branch November 7, 2023 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants