From 6e741ec85d8a687ca9706fe7d114634645c2cd15 Mon Sep 17 00:00:00 2001 From: Dekan Date: Mon, 20 May 2024 13:52:13 -0600 Subject: [PATCH 1/4] hot fix: remove safe api call for usd balances --- libs/moloch-v3-data/src/daos.ts | 10 ++-- libs/moloch-v3-data/src/vaults.ts | 5 +- .../src/fields/RagequitTokenList.tsx | 46 ++++++++++--------- .../MemberProfileCard/MemberTokens.tsx | 42 ++++++++--------- .../src/components/SafeCard/SafeCard.tsx | 4 +- 5 files changed, 57 insertions(+), 50 deletions(-) diff --git a/libs/moloch-v3-data/src/daos.ts b/libs/moloch-v3-data/src/daos.ts index 60c90f5f..f259a9d0 100644 --- a/libs/moloch-v3-data/src/daos.ts +++ b/libs/moloch-v3-data/src/daos.ts @@ -88,7 +88,7 @@ export const findDao = async ({ return { ...vault, - fiatTotal: vaultResMatch?.data?.fiatTotal, + // fiatTotal: vaultResMatch?.data?.fiatTotal, tokenBalances: vaultResMatch?.data?.tokenBalances, }; }); @@ -99,10 +99,10 @@ export const findDao = async ({ ...daoRes.data.dao, ...addDaoProfileFields(daoRes.data.dao), vaults: hydratedVaults, - fiatTotal: tokenData.reduce((sum, vault) => { - sum += Number(vault.data?.fiatTotal); - return sum; - }, 0), + // fiatTotal: tokenData.reduce((sum, vault) => { + // sum += Number(vault.data?.fiatTotal); + // return sum; + // }, 0), }, }, }; diff --git a/libs/moloch-v3-data/src/vaults.ts b/libs/moloch-v3-data/src/vaults.ts index 2f81b726..52e12a1f 100644 --- a/libs/moloch-v3-data/src/vaults.ts +++ b/libs/moloch-v3-data/src/vaults.ts @@ -16,6 +16,7 @@ export const listTokenBalances = async ({ safeAddress: string; }): Promise> => { const url = ENDPOINTS['GNOSIS_API'][networkId]; + if (!url) { return { error: formatFetchError({ type: 'INVALID_NETWORK_ERROR' }), @@ -24,7 +25,9 @@ export const listTokenBalances = async ({ try { const res = await fetch.get( - `${url}/safes/${getAddress(safeAddress)}/balances/usd/` + // `${url}/safes/${getAddress(safeAddress)}/balances/usd/` // dead link + `${url}/safes/${getAddress(safeAddress)}/balances/` + ); return { data: transformTokenBalances(res, safeAddress) }; diff --git a/libs/moloch-v3-fields/src/fields/RagequitTokenList.tsx b/libs/moloch-v3-fields/src/fields/RagequitTokenList.tsx index 07685bc0..7b0d34ab 100644 --- a/libs/moloch-v3-fields/src/fields/RagequitTokenList.tsx +++ b/libs/moloch-v3-fields/src/fields/RagequitTokenList.tsx @@ -48,7 +48,7 @@ const DataColumn = styled(Column)` type TokenTable = { tokenCheckboxes: CheckboxProps[]; amounts: React.ReactNode[]; - usdValue: React.ReactNode[]; + // usdValue: React.ReactNode[]; }; export const RagequitTokenList = (props: Buildable) => { @@ -139,26 +139,30 @@ export const RagequitTokenList = (props: Buildable) => { , ]; - acc.usdValue = [ - ...acc.usdValue, - - {formatValueTo({ - value: memberUsdValueShare( - token.fiatBalance, - dao.totalShares || 0, - dao.totalLoot || 0, - sharesToBurn || 0, - lootToBurn || 0 - ), - decimals: 2, - format: 'currency', - })} - , - ]; + // acc.usdValue = [ + // ...acc.usdValue, + // + // {formatValueTo({ + // value: memberUsdValueShare( + // token.fiatBalance, + // dao.totalShares || 0, + // dao.totalLoot || 0, + // sharesToBurn || 0, + // lootToBurn || 0 + // ), + // decimals: 2, + // format: 'currency', + // })} + // , + // ]; return acc; }, - { tokenCheckboxes: [], amounts: [], usdValue: [] } + { + tokenCheckboxes: [], + amounts: [], + // usdValue: [] + } ); }, [ dao, @@ -210,9 +214,9 @@ export const RagequitTokenList = (props: Buildable) => { Amount - + {/* USD Value - + */} @@ -223,7 +227,7 @@ export const RagequitTokenList = (props: Buildable) => { /> {tokenTable.amounts} - {tokenTable.usdValue} + {/* {tokenTable.usdValue} */} ); diff --git a/libs/moloch-v3-macro-ui/src/components/MemberProfileCard/MemberTokens.tsx b/libs/moloch-v3-macro-ui/src/components/MemberProfileCard/MemberTokens.tsx index 2abac896..68ecb6b8 100644 --- a/libs/moloch-v3-macro-ui/src/components/MemberProfileCard/MemberTokens.tsx +++ b/libs/moloch-v3-macro-ui/src/components/MemberProfileCard/MemberTokens.tsx @@ -21,7 +21,7 @@ type TokenTableType = { name: string | undefined; }; balance: string; - fiatBalance: string; + // fiatBalance: string; }; type MemberTokensProps = { @@ -53,17 +53,17 @@ export const MemberTokens = ({ daoChain, dao, member }: MemberTokensProps) => { address: bal.tokenAddress || NETWORK_TOKEN_ETH_ADDRESS, name: charLimit(bal.token?.name, 21), }, - fiatBalance: formatValueTo({ - value: memberUsdValueShare( - bal.fiatBalance, - dao.totalShares || 0, - dao.totalLoot || 0, - member.shares || 0, - member.loot || 0 - ), - decimals: 2, - format: 'currency', - }), + // fiatBalance: formatValueTo({ + // value: memberUsdValueShare( + // bal.fiatBalance, + // dao.totalShares || 0, + // dao.totalLoot || 0, + // member.shares || 0, + // member.loot || 0 + // ), + // decimals: 2, + // format: 'currency', + // }), balance: formatValueTo({ value: memberTokenBalanceShare( bal.balance, @@ -108,15 +108,15 @@ export const MemberTokens = ({ daoChain, dao, member }: MemberTokensProps) => { return
{value}
; }, }, - { - Header: () => { - return
USD Value
; - }, - accessor: 'fiatBalance', - Cell: ({ value }: { value: string }) => { - return
{value}
; - }, - }, + // { + // Header: () => { + // return
USD Value
; + // }, + // accessor: 'fiatBalance', + // Cell: ({ value }: { value: string }) => { + // return
{value}
; + // }, + // }, ], [daoChain, networks] ); diff --git a/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeCard.tsx b/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeCard.tsx index f856f796..8183f310 100644 --- a/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeCard.tsx +++ b/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeCard.tsx @@ -78,14 +78,14 @@ export const SafeCard = ({ - + /> */} From 6a152b1a26b7410b382220a55b0f504e04279a98 Mon Sep 17 00:00:00 2001 From: Dekan Date: Mon, 20 May 2024 13:59:48 -0600 Subject: [PATCH 2/4] remove total exit amount from member card --- libs/moloch-v3-data/src/vaults.ts | 1 - .../src/fields/RagequitTokenList.tsx | 10 +++++----- .../MemberProfileCard/MemberProfileCard.tsx | 12 +++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/libs/moloch-v3-data/src/vaults.ts b/libs/moloch-v3-data/src/vaults.ts index 52e12a1f..d7b9424e 100644 --- a/libs/moloch-v3-data/src/vaults.ts +++ b/libs/moloch-v3-data/src/vaults.ts @@ -27,7 +27,6 @@ export const listTokenBalances = async ({ const res = await fetch.get( // `${url}/safes/${getAddress(safeAddress)}/balances/usd/` // dead link `${url}/safes/${getAddress(safeAddress)}/balances/` - ); return { data: transformTokenBalances(res, safeAddress) }; diff --git a/libs/moloch-v3-fields/src/fields/RagequitTokenList.tsx b/libs/moloch-v3-fields/src/fields/RagequitTokenList.tsx index 7b0d34ab..f0454fe0 100644 --- a/libs/moloch-v3-fields/src/fields/RagequitTokenList.tsx +++ b/libs/moloch-v3-fields/src/fields/RagequitTokenList.tsx @@ -3,7 +3,7 @@ import { useFormContext } from 'react-hook-form'; import { formatValueTo, memberTokenBalanceShare, - memberUsdValueShare, + // memberUsdValueShare, NETWORK_TOKEN_ETH_ADDRESS, } from '@daohaus/utils'; import { getNetwork } from '@daohaus/keychain-utils'; @@ -158,10 +158,10 @@ export const RagequitTokenList = (props: Buildable) => { return acc; }, - { - tokenCheckboxes: [], - amounts: [], - // usdValue: [] + { + tokenCheckboxes: [], + amounts: [], + // usdValue: [] } ); }, [ diff --git a/libs/moloch-v3-macro-ui/src/components/MemberProfileCard/MemberProfileCard.tsx b/libs/moloch-v3-macro-ui/src/components/MemberProfileCard/MemberProfileCard.tsx index 665be4be..62c65924 100644 --- a/libs/moloch-v3-macro-ui/src/components/MemberProfileCard/MemberProfileCard.tsx +++ b/libs/moloch-v3-macro-ui/src/components/MemberProfileCard/MemberProfileCard.tsx @@ -1,14 +1,16 @@ import { ValidNetwork } from '@daohaus/keychain-utils'; import { MolochV3Member } from '@daohaus/moloch-v3-data'; import { useDaoData, useProfile } from '@daohaus/moloch-v3-hooks'; -import { DataIndicator, ParLg, Loading } from '@daohaus/ui'; -import { formatValueTo, memberUsdValueShare } from '@daohaus/utils'; +import { + // DataIndicator, + ParLg, Loading } from '@daohaus/ui'; +// import { formatValueTo, memberUsdValueShare } from '@daohaus/utils'; import { AlertContainer, LoadingContainer, MProfileCard, - ValueRow, + // ValueRow, } from './MemberProfileCard.styles'; import { MemberProfile } from './MemberProfile'; import { MemberTokens } from './MemberTokens'; @@ -64,7 +66,7 @@ export const MemberProfileCard = ({ allowLinks={allowLinks} allowMemberMenu={allowMemberMenu} /> - + {/* - + */} )} From 59c1c3b723800f54dbc7f83fe0455132291e035c Mon Sep 17 00:00:00 2001 From: Dekan Date: Tue, 21 May 2024 09:19:24 -0600 Subject: [PATCH 3/4] remove refs to usd and/or fiat totals --- apps/admin/src/components/DaoCard.tsx | 1 - apps/admin/src/components/DaoTable.tsx | 14 ----------- libs/moloch-v3-data/src/daos.ts | 5 ---- libs/moloch-v3-data/src/types/dao.types.ts | 2 -- libs/moloch-v3-data/src/utils/transformers.ts | 10 +------- libs/moloch-v3-data/src/vaults.ts | 1 - .../src/fields/RagequitTokenList.tsx | 24 ------------------ .../components/DaoOverview/DaoOverview.tsx | 8 ------ .../MemberProfileCard/MemberProfileCard.tsx | 25 +++---------------- .../MemberProfileCard/MemberTokens.tsx | 22 ---------------- .../src/components/SafeCard/SafeCard.tsx | 10 +------- libs/utils/src/types/query.ts | 2 -- libs/utils/src/utils/general.ts | 1 + 13 files changed, 7 insertions(+), 118 deletions(-) diff --git a/apps/admin/src/components/DaoCard.tsx b/apps/admin/src/components/DaoCard.tsx index 6f93edeb..bc4b6616 100644 --- a/apps/admin/src/components/DaoCard.tsx +++ b/apps/admin/src/components/DaoCard.tsx @@ -56,7 +56,6 @@ export const DaoCard = ({ dao, daoAvatarImg, activeMemberCount, - fiatTotal, activeProposalCount, totalProposalCount, votingPower, diff --git a/apps/admin/src/components/DaoTable.tsx b/apps/admin/src/components/DaoTable.tsx index 4d65c42d..84f577b4 100644 --- a/apps/admin/src/components/DaoTable.tsx +++ b/apps/admin/src/components/DaoTable.tsx @@ -76,7 +76,6 @@ export const DaoTable = ({ daoData }: IDaoTableData) => { networkId: dao.networkId, }, activeProposalCount: dao.activeProposalCount, - fiatTotal: dao.fiatTotal, activeMemberCount: dao.activeMemberCount, votingPower: dao.votingPower, networkId: dao.networkId, @@ -139,19 +138,6 @@ export const DaoTable = ({ daoData }: IDaoTableData) => { ); }, }, - { - Header: 'Vaults', - accessor: 'fiatTotal', - Cell: ({ value }: { value?: number }) => { - return ( - - {value != null - ? readableNumbers.toDollars({ value, separator: ' ' }) - : '--'} - - ); - }, - }, { Header: 'Members', accessor: 'activeMemberCount', diff --git a/libs/moloch-v3-data/src/daos.ts b/libs/moloch-v3-data/src/daos.ts index f259a9d0..65fa0326 100644 --- a/libs/moloch-v3-data/src/daos.ts +++ b/libs/moloch-v3-data/src/daos.ts @@ -88,7 +88,6 @@ export const findDao = async ({ return { ...vault, - // fiatTotal: vaultResMatch?.data?.fiatTotal, tokenBalances: vaultResMatch?.data?.tokenBalances, }; }); @@ -99,10 +98,6 @@ export const findDao = async ({ ...daoRes.data.dao, ...addDaoProfileFields(daoRes.data.dao), vaults: hydratedVaults, - // fiatTotal: tokenData.reduce((sum, vault) => { - // sum += Number(vault.data?.fiatTotal); - // return sum; - // }, 0), }, }, }; diff --git a/libs/moloch-v3-data/src/types/dao.types.ts b/libs/moloch-v3-data/src/types/dao.types.ts index 5323c244..bcc645fb 100644 --- a/libs/moloch-v3-data/src/types/dao.types.ts +++ b/libs/moloch-v3-data/src/types/dao.types.ts @@ -19,7 +19,6 @@ type DaoWithProfileQuery = { dao: DaoWithProfile | undefined; }; export type DaoSafe = DaoWithProfile['vaults'][number] & { - fiatTotal: number; tokenBalances: TokenBalance[]; }; type MolochV3DaoQuery = { @@ -27,7 +26,6 @@ type MolochV3DaoQuery = { }; export type MolochV3Dao = Omit & { vaults: DaoSafe[]; - fiatTotal: number; }; export type FindDaoQueryRes = | DaoWithProfileQuery diff --git a/libs/moloch-v3-data/src/utils/transformers.ts b/libs/moloch-v3-data/src/utils/transformers.ts index 00170e27..53aa4cf2 100644 --- a/libs/moloch-v3-data/src/utils/transformers.ts +++ b/libs/moloch-v3-data/src/utils/transformers.ts @@ -29,15 +29,7 @@ export const transformTokenBalances = ( tokenBalanceRes: TokenBalance[], safeAddress: string ): DaoTokenBalances => { - const fiatTotal = tokenBalanceRes.reduce( - (sum: number, balance: TokenBalance): number => { - sum += Number(balance.fiatBalance); - return sum; - }, - 0 - ); - - return { safeAddress, tokenBalances: tokenBalanceRes, fiatTotal }; + return { safeAddress, tokenBalances: tokenBalanceRes }; }; export const transformMembershipList = ( diff --git a/libs/moloch-v3-data/src/vaults.ts b/libs/moloch-v3-data/src/vaults.ts index d7b9424e..bcbb6cb6 100644 --- a/libs/moloch-v3-data/src/vaults.ts +++ b/libs/moloch-v3-data/src/vaults.ts @@ -25,7 +25,6 @@ export const listTokenBalances = async ({ try { const res = await fetch.get( - // `${url}/safes/${getAddress(safeAddress)}/balances/usd/` // dead link `${url}/safes/${getAddress(safeAddress)}/balances/` ); diff --git a/libs/moloch-v3-fields/src/fields/RagequitTokenList.tsx b/libs/moloch-v3-fields/src/fields/RagequitTokenList.tsx index f0454fe0..b4f4d341 100644 --- a/libs/moloch-v3-fields/src/fields/RagequitTokenList.tsx +++ b/libs/moloch-v3-fields/src/fields/RagequitTokenList.tsx @@ -3,7 +3,6 @@ import { useFormContext } from 'react-hook-form'; import { formatValueTo, memberTokenBalanceShare, - // memberUsdValueShare, NETWORK_TOKEN_ETH_ADDRESS, } from '@daohaus/utils'; import { getNetwork } from '@daohaus/keychain-utils'; @@ -48,7 +47,6 @@ const DataColumn = styled(Column)` type TokenTable = { tokenCheckboxes: CheckboxProps[]; amounts: React.ReactNode[]; - // usdValue: React.ReactNode[]; }; export const RagequitTokenList = (props: Buildable) => { @@ -139,29 +137,11 @@ export const RagequitTokenList = (props: Buildable) => { , ]; - // acc.usdValue = [ - // ...acc.usdValue, - // - // {formatValueTo({ - // value: memberUsdValueShare( - // token.fiatBalance, - // dao.totalShares || 0, - // dao.totalLoot || 0, - // sharesToBurn || 0, - // lootToBurn || 0 - // ), - // decimals: 2, - // format: 'currency', - // })} - // , - // ]; - return acc; }, { tokenCheckboxes: [], amounts: [], - // usdValue: [] } ); }, [ @@ -214,9 +194,6 @@ export const RagequitTokenList = (props: Buildable) => { Amount - {/* - USD Value - */} @@ -227,7 +204,6 @@ export const RagequitTokenList = (props: Buildable) => { /> {tokenTable.amounts} - {/* {tokenTable.usdValue} */} ); diff --git a/libs/moloch-v3-macro-ui/src/components/DaoOverview/DaoOverview.tsx b/libs/moloch-v3-macro-ui/src/components/DaoOverview/DaoOverview.tsx index 0c241511..e21b79d2 100644 --- a/libs/moloch-v3-macro-ui/src/components/DaoOverview/DaoOverview.tsx +++ b/libs/moloch-v3-macro-ui/src/components/DaoOverview/DaoOverview.tsx @@ -36,14 +36,6 @@ export const DaoOverview = ({ - - {/* - - */} )} diff --git a/libs/moloch-v3-macro-ui/src/components/MemberProfileCard/MemberTokens.tsx b/libs/moloch-v3-macro-ui/src/components/MemberProfileCard/MemberTokens.tsx index 68ecb6b8..b4188419 100644 --- a/libs/moloch-v3-macro-ui/src/components/MemberProfileCard/MemberTokens.tsx +++ b/libs/moloch-v3-macro-ui/src/components/MemberProfileCard/MemberTokens.tsx @@ -9,7 +9,6 @@ import { charLimit, formatValueTo, memberTokenBalanceShare, - memberUsdValueShare, NETWORK_TOKEN_ETH_ADDRESS, } from '@daohaus/utils'; @@ -21,7 +20,6 @@ type TokenTableType = { name: string | undefined; }; balance: string; - // fiatBalance: string; }; type MemberTokensProps = { @@ -53,17 +51,6 @@ export const MemberTokens = ({ daoChain, dao, member }: MemberTokensProps) => { address: bal.tokenAddress || NETWORK_TOKEN_ETH_ADDRESS, name: charLimit(bal.token?.name, 21), }, - // fiatBalance: formatValueTo({ - // value: memberUsdValueShare( - // bal.fiatBalance, - // dao.totalShares || 0, - // dao.totalLoot || 0, - // member.shares || 0, - // member.loot || 0 - // ), - // decimals: 2, - // format: 'currency', - // }), balance: formatValueTo({ value: memberTokenBalanceShare( bal.balance, @@ -108,15 +95,6 @@ export const MemberTokens = ({ daoChain, dao, member }: MemberTokensProps) => { return
{value}
; }, }, - // { - // Header: () => { - // return
USD Value
; - // }, - // accessor: 'fiatBalance', - // Cell: ({ value }: { value: string }) => { - // return
{value}
; - // }, - // }, ], [daoChain, networks] ); diff --git a/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeCard.tsx b/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeCard.tsx index 8183f310..97d1b964 100644 --- a/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeCard.tsx +++ b/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeCard.tsx @@ -10,7 +10,7 @@ import { ParXs, Tag, } from '@daohaus/ui'; -import { formatValueTo, generateGnosisUiLink } from '@daohaus/utils'; +import { generateGnosisUiLink } from '@daohaus/utils'; import { Keychain } from '@daohaus/keychain-utils'; import { DataGrid } from '../Layout'; import { @@ -78,14 +78,6 @@ export const SafeCard = ({ - {/* */} diff --git a/libs/utils/src/types/query.ts b/libs/utils/src/types/query.ts index 41c30846..14fffd0c 100644 --- a/libs/utils/src/types/query.ts +++ b/libs/utils/src/types/query.ts @@ -12,7 +12,6 @@ export interface MolochV3Membership { delegatingTo?: string; isDelegate: boolean; memberAddress: string; - fiatTotal?: number; totalProposalCount: string; contractType: string; tokenBalances?: TokenBalance[]; @@ -38,7 +37,6 @@ export type TokenBalance = { }; export type DaoTokenBalances = { safeAddress: string; - fiatTotal: number; tokenBalances: TokenBalance[]; }; export type AccountProfile = { diff --git a/libs/utils/src/utils/general.ts b/libs/utils/src/utils/general.ts index 9f692710..09423aa7 100644 --- a/libs/utils/src/utils/general.ts +++ b/libs/utils/src/utils/general.ts @@ -37,6 +37,7 @@ export const memberTokenBalanceShare = ( return memberSharesWei / 10 ** Number(decimals); }; +// if we have a usd value of the Safe, we can calculate the usd value of the member's shares export const memberUsdValueShare = ( usdValue: string | number, daoTotalShares: string | number, From 189fd095f678c4424790a6695eefefd21396aa99 Mon Sep 17 00:00:00 2001 From: Dekan Date: Tue, 21 May 2024 09:27:48 -0600 Subject: [PATCH 4/4] remove fiat stuff from TokenBalance type --- .../src/components/MemberProfileCard/MemberProfileCard.tsx | 5 +---- libs/utils/src/types/query.ts | 3 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/libs/moloch-v3-macro-ui/src/components/MemberProfileCard/MemberProfileCard.tsx b/libs/moloch-v3-macro-ui/src/components/MemberProfileCard/MemberProfileCard.tsx index c4f2586d..8d4aac62 100644 --- a/libs/moloch-v3-macro-ui/src/components/MemberProfileCard/MemberProfileCard.tsx +++ b/libs/moloch-v3-macro-ui/src/components/MemberProfileCard/MemberProfileCard.tsx @@ -1,10 +1,7 @@ import { ValidNetwork } from '@daohaus/keychain-utils'; import { MolochV3Member } from '@daohaus/moloch-v3-data'; import { useDaoData, useProfile } from '@daohaus/moloch-v3-hooks'; -import { - ParLg, - Loading, -} from '@daohaus/ui'; +import { ParLg, Loading } from '@daohaus/ui'; import { AlertContainer, diff --git a/libs/utils/src/types/query.ts b/libs/utils/src/types/query.ts index 14fffd0c..dd5249fa 100644 --- a/libs/utils/src/types/query.ts +++ b/libs/utils/src/types/query.ts @@ -31,9 +31,6 @@ export type TokenBalance = { balance: string; ethValue: string; timestamp: string; - fiatBalance: string; - fiatConversion: string; - fiatCode: string; }; export type DaoTokenBalances = { safeAddress: string;