Skip to content

Commit

Permalink
build: bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Feb 9, 2024
1 parent 798d5c9 commit b8082bb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"editor.wordWrap": "off",
"editor.autoIndent": "keep",
"editor.codeActionsOnSave": {
"source.fixAll": true
"source.fixAll": "explicit"
},
"editor.quickSuggestions": {
"strings": true
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yearn-finance/web-lib",
"version": "3.0.133",
"version": "3.0.134",
"main": "./dist/index.js",
"types": "./dist/index.d.js",
"files": [
Expand All @@ -25,7 +25,7 @@
"export": "tsc && next build && next export -o ipfs"
},
"dependencies": {
"@builtbymom/web3": "^0.0.20",
"@builtbymom/web3": "^0.0.37",
"@headlessui/react": "^1.7.18",
"@rainbow-me/rainbowkit": "^1.3.3",
"@react-hookz/web": "^24.0.2",
Expand Down
25 changes: 16 additions & 9 deletions src/contexts/useYearnWallet.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {createContext, memo, useCallback, useContext, useMemo, useState} from 'react';
import {useWeb3} from '@builtbymom/web3/contexts/useWeb3';
import {useBalances} from '@builtbymom/web3/hooks/useBalances.multichains';
import {toAddress, toNormalizedBN} from '@builtbymom/web3/utils';
import {isZeroAddress, toAddress, toNormalizedBN, zeroNormalizedBN} from '@builtbymom/web3/utils';
import {useDeepCompareMemo} from '@react-hookz/web';

import {
Expand Down Expand Up @@ -44,15 +45,15 @@ const defaultToken: TYToken = {
chainID: 1,
value: 0,
stakingValue: 0,
price: toNormalizedBN(0),
balance: toNormalizedBN(0),
price: zeroNormalizedBN,
balance: zeroNormalizedBN,
supportedZaps: []
};

const defaultProps = {
getToken: (): TYToken => defaultToken,
getBalance: (): TNormalizedBN => toNormalizedBN(0),
getPrice: (): TNormalizedBN => toNormalizedBN(0),
getBalance: (): TNormalizedBN => zeroNormalizedBN,
getPrice: (): TNormalizedBN => zeroNormalizedBN,
balances: {},
cumulatedValueInV2Vaults: 0,
cumulatedValueInV3Vaults: 0,
Expand Down Expand Up @@ -206,6 +207,7 @@ export const YearnWalletContextApp = memo(function YearnWalletContextApp({
}: {
children: ReactElement;
}): ReactElement {
const {address: userAddress} = useWeb3();
const {vaults, prices, vaultsMigrations} = useYearn();
const [shouldUseForknetBalances, set_shouldUseForknetBalances] = useState<boolean>(false);
const {tokens, isLoading, onRefresh} = useYearnBalances({shouldUseForknetBalances});
Expand Down Expand Up @@ -241,15 +243,20 @@ export const YearnWalletContextApp = memo(function YearnWalletContextApp({
[tokens]
);
const getBalance = useCallback(
({address, chainID}: TTokenAndChain): TNormalizedBN =>
tokens?.[chainID || 1]?.[address]?.balance || toNormalizedBN(0),
[tokens]
({address, chainID}: TTokenAndChain): TNormalizedBN => {
if (isZeroAddress(userAddress)) {
return zeroNormalizedBN;
}
return tokens?.[chainID || 1]?.[address]?.balance || zeroNormalizedBN;
},
[tokens, userAddress]
);

const getPrice = useCallback(
({address, chainID}: TTokenAndChain): TNormalizedBN => {
const price = tokens?.[chainID || 1]?.[address]?.price;
if (!price) {
return toNormalizedBN(prices?.[chainID]?.[address] || 0, 6) || toNormalizedBN(0);
return toNormalizedBN(prices?.[chainID]?.[address] || 0, 6) || zeroNormalizedBN;
}
return price;
},
Expand Down
9 changes: 4 additions & 5 deletions src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,12 @@ export const numberSort = ({a, b, sortDirection}: {a?: number; b?: number; sortD
sortDirection === 'desc' ? (b ?? 0) - (a ?? 0) : (a ?? 0) - (b ?? 0);

export const bigNumberSort = ({a, b, sortDirection}: {a: bigint; b: bigint; sortDirection: TSortDirection}): number =>
Number(toNormalizedBN(sortDirection === 'desc' ? b - a : a - b).normalized);

Number(toNormalizedBN(sortDirection === 'desc' ? b - a : a - b, 18).normalized);

/* 🔵 - Yearn Finance ******************************************************
** allowanceKey is used to access the unique allowance key matching one
** token with one spender
**************************************************************************/
** allowanceKey is used to access the unique allowance key matching one
** token with one spender
**************************************************************************/
export function allowanceKey(chainID: number, token: TAddress, spender: TAddress, owner: TAddress): string {
return `${chainID}_${token}_${spender}_${owner}`;
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,10 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@builtbymom/web3@^0.0.20":
version "0.0.20"
resolved "https://registry.yarnpkg.com/@builtbymom/web3/-/web3-0.0.20.tgz#5685e11f2b3a90c0a5d7b06692aaa9d500792fc5"
integrity sha512-no59LxzMChgZZd6XnJuh69go3PtD/3k1dTQ7KX3dpYhXZxLX2LdaDqnPVMsXmz6IovMpjAmKrkCEqEN6jlPRmA==
"@builtbymom/web3@^0.0.37":
version "0.0.37"
resolved "https://registry.yarnpkg.com/@builtbymom/web3/-/web3-0.0.37.tgz#0bc5aa08df38334266765282a3bb6da9c3dae83c"
integrity sha512-7eQLsrbR2k+mh0xBdBA1YV7m4e530CUnKl6EjYWMu7djTZkuMGGZTxQDVjwFIfAyYw6ktNrwv/3ZUlrMWVgAaQ==
dependencies:
"@rainbow-me/rainbowkit" "^1.3.0"
"@react-hookz/web" "^24.0.2"
Expand Down

0 comments on commit b8082bb

Please sign in to comment.