diff --git a/package.json b/package.json index 59ac1876..d37e7786 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@yearn-finance/web-lib", - "version": "3.0.115", + "version": "3.0.116", "main": "./dist/index.js", "types": "./dist/index.d.js", "files": [ diff --git a/src/contexts/useYearn.tsx b/src/contexts/useYearn.tsx index 32a7f312..d354ec31 100755 --- a/src/contexts/useYearn.tsx +++ b/src/contexts/useYearn.tsx @@ -1,5 +1,6 @@ -import {createContext, memo, useContext} from 'react'; +import {createContext, memo, useContext, useEffect} from 'react'; import {deserialize, serialize} from 'wagmi'; +import useWallet from '@builtbymom/web3/contexts/useWallet'; import {useLocalStorageValue} from '@react-hookz/web'; import {toAddress} from '@yearn-finance/web-lib/utils/address'; @@ -67,6 +68,7 @@ const YearnContext = createContext({ }); export const YearnContextApp = memo(function YearnContextApp({children}: {children: ReactElement}): ReactElement { + const {refresh} = useWallet(); const {value: maxLoss, set: set_maxLoss} = useLocalStorageValue('yearn.fi/max-loss', { defaultValue: DEFAULT_MAX_LOSS, parse: (str: string, fallback: bigint): bigint => (str ? deserialize(str) : fallback), @@ -90,6 +92,13 @@ export const YearnContextApp = memo(function YearnContextApp({children}: {childr const earned = useYearnEarned(); const {vaults, vaultsMigrations, vaultsRetired, isLoading, mutate} = useYearnVaults(); + useEffect(() => { + const tokensToRefresh = Object.values(tokens).map(token => { + return {token: toAddress(token?.address)}; + }); + refresh(tokensToRefresh); + }, [tokens, refresh]); + return (