Skip to content

Commit

Permalink
build: bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Jan 17, 2024
1 parent 12c06e7 commit 9d20324
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
11 changes: 10 additions & 1 deletion src/contexts/useYearn.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -67,6 +68,7 @@ const YearnContext = createContext<TYearnContext>({
});

export const YearnContextApp = memo(function YearnContextApp({children}: {children: ReactElement}): ReactElement {
const {refresh} = useWallet();
const {value: maxLoss, set: set_maxLoss} = useLocalStorageValue<bigint>('yearn.fi/max-loss', {
defaultValue: DEFAULT_MAX_LOSS,
parse: (str: string, fallback: bigint): bigint => (str ? deserialize(str) : fallback),
Expand All @@ -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 (
<YearnContext.Provider
value={{
Expand Down
7 changes: 5 additions & 2 deletions src/hooks/useYearnTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ function useYearnTokens(): TYDaemonTokens {
return {};
}
const _tokens: TYDaemonTokens = {};
for (const [, tokensData] of Object.entries(tokens)) {
for (const [chainID, tokensData] of Object.entries(tokens)) {
for (const [tokenAddress, token] of Object.entries(tokensData)) {
if (token) {
_tokens[toAddress(tokenAddress)] = token;
_tokens[toAddress(tokenAddress)] = {
...token,
chainID: Number(chainID)
};
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/utils/schemas/yDaemonTokensSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export const yDaemonTokenSchema = z.object({
symbol: z.string(),
decimals: z.number(),
isVault: z.boolean(),
underlyingTokens: z.array(addressSchema).optional()
underlyingTokens: z.array(addressSchema).optional(),
chainID: z.number().optional()
});

export const yDaemonTokensSchema = z.record(addressSchema, yDaemonTokenSchema);
Expand Down

0 comments on commit 9d20324

Please sign in to comment.