Skip to content

Commit

Permalink
Merge pull request #506 from HausDAO/fix/remove-safe-api-usd-balances
Browse files Browse the repository at this point in the history
Fix/remove safe api usd balances. see #507
  • Loading branch information
dekanbro authored May 21, 2024
2 parents b87b02b + 6a152b1 commit e750868
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 56 deletions.
10 changes: 5 additions & 5 deletions libs/moloch-v3-data/src/daos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const findDao = async ({

return {
...vault,
fiatTotal: vaultResMatch?.data?.fiatTotal,
// fiatTotal: vaultResMatch?.data?.fiatTotal,
tokenBalances: vaultResMatch?.data?.tokenBalances,
};
});
Expand All @@ -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),
},
},
};
Expand Down
4 changes: 3 additions & 1 deletion libs/moloch-v3-data/src/vaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const listTokenBalances = async ({
safeAddress: string;
}): Promise<IFindQueryResult<DaoTokenBalances>> => {
const url = ENDPOINTS['GNOSIS_API'][networkId];

if (!url) {
return {
error: formatFetchError({ type: 'INVALID_NETWORK_ERROR' }),
Expand All @@ -24,7 +25,8 @@ export const listTokenBalances = async ({

try {
const res = await fetch.get<TokenBalance[]>(
`${url}/safes/${getAddress(safeAddress)}/balances/usd/`
// `${url}/safes/${getAddress(safeAddress)}/balances/usd/` // dead link
`${url}/safes/${getAddress(safeAddress)}/balances/`
);

return { data: transformTokenBalances(res, safeAddress) };
Expand Down
48 changes: 26 additions & 22 deletions libs/moloch-v3-fields/src/fields/RagequitTokenList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<Field>) => {
Expand Down Expand Up @@ -139,26 +139,30 @@ export const RagequitTokenList = (props: Buildable<Field>) => {
</DataSm>,
];

acc.usdValue = [
...acc.usdValue,
<DataSm key={token.tokenAddress}>
{formatValueTo({
value: memberUsdValueShare(
token.fiatBalance,
dao.totalShares || 0,
dao.totalLoot || 0,
sharesToBurn || 0,
lootToBurn || 0
),
decimals: 2,
format: 'currency',
})}
</DataSm>,
];
// acc.usdValue = [
// ...acc.usdValue,
// <DataSm key={token.tokenAddress}>
// {formatValueTo({
// value: memberUsdValueShare(
// token.fiatBalance,
// dao.totalShares || 0,
// dao.totalLoot || 0,
// sharesToBurn || 0,
// lootToBurn || 0
// ),
// decimals: 2,
// format: 'currency',
// })}
// </DataSm>,
// ];

return acc;
},
{ tokenCheckboxes: [], amounts: [], usdValue: [] }
{
tokenCheckboxes: [],
amounts: [],
// usdValue: []
}
);
}, [
dao,
Expand Down Expand Up @@ -210,9 +214,9 @@ export const RagequitTokenList = (props: Buildable<Field>) => {
<Column>
<ParSm>Amount</ParSm>
</Column>
<Column>
{/* <Column>
<ParSm>USD Value</ParSm>
</Column>
</Column> */}
</TokenListContainer>
<TokenListContainer>
<Column>
Expand All @@ -223,7 +227,7 @@ export const RagequitTokenList = (props: Buildable<Field>) => {
/>
</Column>
<DataColumn>{tokenTable.amounts}</DataColumn>
<DataColumn>{tokenTable.usdValue}</DataColumn>
{/* <DataColumn>{tokenTable.usdValue}</DataColumn> */}
</TokenListContainer>
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -64,7 +66,7 @@ export const MemberProfileCard = ({
allowLinks={allowLinks}
allowMemberMenu={allowMemberMenu}
/>
<ValueRow>
{/* <ValueRow>
<DataIndicator
label="Total Exit Amount"
data={formatValueTo({
Expand All @@ -79,7 +81,7 @@ export const MemberProfileCard = ({
format: 'currency',
})}
/>
</ValueRow>
</ValueRow> */}
<MemberTokens daoChain={daoChain} dao={dao} member={member} />
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type TokenTableType = {
name: string | undefined;
};
balance: string;
fiatBalance: string;
// fiatBalance: string;
};

type MemberTokensProps = {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -108,15 +108,15 @@ export const MemberTokens = ({ daoChain, dao, member }: MemberTokensProps) => {
return <div>{value}</div>;
},
},
{
Header: () => {
return <div>USD Value</div>;
},
accessor: 'fiatBalance',
Cell: ({ value }: { value: string }) => {
return <div>{value}</div>;
},
},
// {
// Header: () => {
// return <div>USD Value</div>;
// },
// accessor: 'fiatBalance',
// Cell: ({ value }: { value: string }) => {
// return <div>{value}</div>;
// },
// },
],
[daoChain, networks]
);
Expand Down
4 changes: 2 additions & 2 deletions libs/moloch-v3-macro-ui/src/components/SafeCard/SafeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ export const SafeCard = ({
</div>
</SafeCardHeader>
<DataGrid>
<DataIndicator
{/* <DataIndicator
label="Balance"
data={formatValueTo({
value: safe.fiatTotal,
decimals: 2,
format: 'currencyShort',
})}
/>
/> */}
<DataIndicator label="Tokens" data={safe.tokenBalances.length} />
</DataGrid>
</SafeOverviewCard>
Expand Down

0 comments on commit e750868

Please sign in to comment.