-
Notifications
You must be signed in to change notification settings - Fork 33
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
Conversation
WalkthroughThe 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
Poem
TipsChat with CodeRabbit Bot (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
18cbd7d
to
472f5db
Compare
Deploying with Cloudflare Pages
|
dcc4e48
to
1c182c8
Compare
* Updates minichef address * Fetches Metis price through chainlink aggregator * Updates APY calcs cased on Metis price
1c182c8
to
a0f1b75
Compare
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.
LGTM
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.
Review Status
Actionable comments generated: 4
Configuration used: CodeRabbit UI
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 frompriceDataSlice
.51-54: The new function call
fetchMetisPrice
is correctly added to the list of dispatched actions whenisClient
is true. Ensure that thefetchMetisPrice
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 thepool
object.packages/synapse-interface/utils/actions/getPrices.ts (2)
12-18: The
getEthPrice
function has been updated to useCHAINLINK_ETH_PRICE_ADDRESSES
directly. Ensure that theCHAINLINK_ETH_PRICE_ADDRESSES
mapping contains the correct address for theETH
chain.48-64: The
getMetisPrice
function has been added to retrieve the Metis price from Chainlink. Ensure that theCHAINLINK_METIS_PRICE_ADDRESSES
mapping contains the correct address for theMETIS
chain.packages/synapse-interface/pages/pool/PoolBody.tsx (2)
55-62: Ensure that the
getStakedBalance
function has been updated to accept the newpool
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 thePoolActionOptions
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
anduseAppSelector
should be verified to ensure they are correct and accessible.46-61: The
useEffect
hook has been updated to usetoken.chainId
instead ofconnectedChainId
andhasAllPrices(prices)
. Ensure that thetoken
object andhasAllPrices(prices)
are always available when this effect runs.63-69: The
useMemo
hook has been updated to removeconnectedChainId
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 thepool
object. Ensure that thepool
object is always populated with theminiChefAddress
property before this function is called.33-38: The
approveErc20Token
function now usesminiChefAddress
from thepool
object instead of theMINICHEF_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 thepool
object. Ensure that thepool
object is always populated with theminiChefAddress
property before this function is called.94-98: The
stakeLpToken
function now usesminiChefAddress
from thepool
object instead of theMINICHEF_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 includemetisPrice
andisLoadingMetisPrice
. Ensure that these new fields are used correctly throughout the codebase.32-40: The initial state has been updated to include
metisPrice
andisLoadingMetisPrice
. This is consistent with the changes to thePriceDataState
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 theharvestLpPool
function call has been changed fromMINICHEF_ADDRESSES[chainId]
tominiChefAddress
. Ensure that this change does not affect the functionality of theharvestLpPool
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 thepool
object. Ensure that thepool
object always has theminiChefAddress
property and it is notnull
orundefined
.30-30: The
lpAddress
is now being set tominiChefAddress
from thepool
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 withcustomRewardToken
andminiChefAddress
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 acceptcustomRewardToken
andminiChefAddress
properties. Ensure that all instances of theToken
class are being created with the updated constructor.252-259: The type of the constructor argument has been updated to include
customRewardToken
andminiChefAddress
properties. Ensure that the types are being used correctly throughout the codebase.307-314: The constructor of the
Token
class has been updated to initializecustomRewardToken
andminiChefAddress
properties. Ensure that these properties are being initialized correctly in all instances of theToken
class.packages/synapse-interface/pages/pools/index.tsx (4)
19-25: New imports for
METIS_POOL_SWAP_TOKEN_MIGRATED
andMETIS_WETH_SWAP_TOKEN_MIGRATED
have been added. Ensure these constants are correctly defined and exported in thepoolMaster
file.35-37: A new
migratedPools
object has been introduced. Ensure that the key1088
correctly represents the chain ID for the Metis network.47-51: The
unIncentivizedPools
object has been modified to filter outMETIS_POOL_SWAP_TOKEN_MIGRATED
andMETIS_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 thePoolCards
component can handle themigratedPools
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 parameterpool: 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 thepool
parameter instead of theMINICHEF_ADDRESSES
mapping. This change provides more flexibility as the address can now be dynamically determined based on thepool
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 thereadContracts
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
andgetPoolApyData
functions are called within auseEffect
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 additionalpool
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 theToken
class is used here. Ensure that this property is correctly set for all instances of theToken
class.packages/synapse-interface/constants/tokens/poolMaster.ts (3)
37-37: Ensure that the
MINICHEF_ADDRESSES
constant is correctly defined and exported in theminichef
module.922-922: Ensure that the
MINICHEF_ADDRESSES
constant includes the correct addresses for each chain ID.900-922: Ensure that the new
Token
objectsMETIS_WETH_SWAP_TOKEN_MIGRATED
andMETIS_POOL_SWAP_TOKEN_MIGRATED
are correctly defined and that all properties are correctly set. Also, verify that theminiChefAddress
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 usinguseMemo
which is a good practice as it prevents unnecessary recalculations. The calculation now depends on thebalancesAndAllowances
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 aprices
parameter of typePrices
. 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 thepoolToken.miniChefAddress
. Ensure that thepoolToken
object has theminiChefAddress
property and it is of typeAddress
.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
andmetisPrice
are fetched either from theprices
parameter or by calling thegetSynPrices
andgetMetisPrice
functions respectively. Ensure that thegetSynPrices
andgetMetisPrice
functions return the expected data structure.136-140: The
usePrice
is assigned based on thechainId
of thepoolToken
. This logic seems fine. Ensure that theMETIS.id
is correctly defined and matches the expectedchainId
for Metis.142-145: The calculations for
usdPerWeek
,weeklyAPR
, andyearlyAPR
look fine. Ensure that thestakedTvl
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 thegetStakedBalance
function is updated to accept the newpool
parameter.
82-94: The
useEffect
hook is used to fetch the token allowance and the staked balance. Ensure that thegetTokenAllowance
andgetStakedBalance
functions are updated to accept the newpool
parameter.102-108: The
useEffect
hook is used to fetch the token allowance. Ensure that thegetTokenAllowance
function is updated to accept the newpool
parameter.148-157: The "SYN Earned" text and the token symbol are now dynamic based on the
customRewardToken
property of thepool
object. Ensure that thecustomRewardToken
property is correctly set in thepool
object.171-187: The "Claim SYN" button text is now dynamic based on the
customRewardToken
property of thepool
object. Ensure that thecustomRewardToken
property is correctly set in thepool
object.303-309: The
stake
function now receives thepool
object as an additional parameter. Ensure that thestake
function is updated to accept this new parameter.327-333: The
withdrawStake
function now receives thepool
object as an additional parameter. Ensure that thewithdrawStake
function is updated to accept this new parameter.
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
PoolCard
component.PoolCards
component by removing unnecessary props and conditions related to price data.Token
class to includecustomRewardToken
andminiChefAddress
properties.getPoolApyData
function to include aprices
parameter.METIS
chain in theMINICHEF_ADDRESSES
mapping.