Skip to content

Commit

Permalink
fix: registry with kind
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Oct 27, 2023
1 parent f833cc3 commit 58dd54c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 20 deletions.
1 change: 1 addition & 0 deletions apps/common/schemas/yDaemonVaultsSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const yDaemonVaultSchema = z.object({
.or(z.literal('Experimental Yearn Vault'))
.or(z.literal('Standard'))
.or(z.literal('Yearn Vault')),
kind: z.literal('Legacy').or(z.literal('Multi Strategies')).or(z.literal('Single Strategy')),
symbol: z.string(),
name: z.string(),
category: z
Expand Down
2 changes: 1 addition & 1 deletion apps/vaults-v3/components/Filters.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useMemo} from 'react';
import {VaultListOptions} from '@vaults/components/list/VaultListOptions';
import {ALL_CATEGORIES} from '@vaults/constants';
import {ALL_CATEGORIES} from '@vaults-v3/constants';
import {MultiSelectDropdown} from '@common/components/MultiSelectDropdown';
import {SearchBar} from '@common/components/SearchBar';
import {useChainOptions} from '@common/hooks/useChains';
Expand Down
35 changes: 25 additions & 10 deletions apps/vaults-v3/components/details/tabs/VaultDetailsStrategies.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {useMemo, useState} from 'react';
import {findLatestApr} from '@vaults/components/details/tabs/findLatestApr';
import {yDaemonReportsSchema} from '@vaults/schemas/reportsSchema';
import {VaultsV3ListRow} from '@vaults-v3/components/list/VaultsV3ListRow';
import {IconCopy} from '@yearn-finance/web-lib/icons/IconCopy';
import {toAddress} from '@yearn-finance/web-lib/utils/address';
import {formatToNormalizedValue, toBigInt} from '@yearn-finance/web-lib/utils/format.bigNumber';
Expand All @@ -9,6 +10,7 @@ import {formatDuration} from '@yearn-finance/web-lib/utils/format.time';
import {copyToClipboard, parseMarkdown} from '@yearn-finance/web-lib/utils/helpers';
import {SearchBar} from '@common/components/SearchBar';
import {Switch} from '@common/components/Switch';
import {useYearn} from '@common/contexts/useYearn';
import {useFetch} from '@common/hooks/useFetch';
import {IconChevron} from '@common/icons/IconChevron';
import {useYDaemonBaseURI} from '@common/utils/getYDaemonBaseURI';
Expand Down Expand Up @@ -187,6 +189,8 @@ function isExceptionStrategy(strategy: TYDaemonVaultStrategy): boolean {
}

export function VaultDetailsStrategies({currentVault}: {currentVault: TYDaemonVault}): ReactElement {
const {vaults} = useYearn();

const [searchValue, set_searchValue] = useState<string>('');
const [shouldHide0DebtStrategies, set_shouldHide0DebtStrategies] = useState(true);

Expand Down Expand Up @@ -229,16 +233,27 @@ export function VaultDetailsStrategies({currentVault}: {currentVault: TYDaemonVa
</div>
</div>
</div>
<div className={'col-span-1 w-full'}>
{filteredStrategies.map(
(strategy): ReactElement => (
<VaultDetailsStrategy
currentVault={currentVault}
strategy={strategy}
key={strategy.address}
/>
)
)}
<div className={'col-span-1 w-full px-6 pb-6'}>
<div className={'grid gap-4'}>
{filteredStrategies.map((strategy): ReactElement => {
const strategyAsVault = vaults[strategy.address];
if (!strategyAsVault) {
return (
<VaultDetailsStrategy
currentVault={currentVault}
strategy={strategy}
key={strategy.address}
/>
);
}
return (
<VaultsV3ListRow
key={strategy.address}
currentVault={strategyAsVault}
/>
);
})}
</div>
</div>
</div>
);
Expand Down
10 changes: 2 additions & 8 deletions apps/vaults-v3/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
export const ALL_CATEGORIES = {
holdings: 'Holdings',
crypto: 'Crypto Vaults',
stables: 'Stables Vaults',
curve: 'Curve Vaults',
// balancer: 'Balancer Vaults',
boosted: 'Boosted Vaults',
velodrome: 'Velodrome Vaults',
aerodrome: 'Aerodrome Vaults'
multi: 'Multi Strategies',
single: 'Single Strategy'
};
export const ALL_CATEGORIES_KEYS = Object.keys(ALL_CATEGORIES);
19 changes: 18 additions & 1 deletion apps/vaults/hooks/useFilteredVaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,18 @@ export function useVaultFilter(
[getToken]
);

// V3 Filtered Vaults
const v3Vaults = useFilteredVaults(vaults, ({version}): boolean => (version || '')?.split('.')?.[0] === '3');
const singleVault = useFilteredVaults(
vaults,
({version, kind}): boolean => (version || '')?.split('.')?.[0] === '3' && kind === 'Single Strategy'
);
const MultiVault = useFilteredVaults(
vaults,
({version, kind}): boolean => (version || '')?.split('.')?.[0] === '3' && kind === 'Multi Strategies'
);

//V2 Filtered Vaults
const boostedVaults = useFilteredVaults(vaults, ({apr}): boolean => apr.extra.stakingRewardsAPR > 0);
const curveVaults = useFilteredVaults(vaults, ({category}): boolean => category === 'Curve');
const velodromeVaults = useFilteredVaults(vaults, ({category}): boolean => category === 'Velodrome');
Expand All @@ -99,7 +110,13 @@ export function useVaultFilter(
const activeVaults = useDeepCompareMemo((): TYDaemonVault[] => {
let _vaultList: TYDaemonVault[] = [];
if (v3) {
return v3Vaults;
if (categories.includes('single')) {
_vaultList = [..._vaultList, ...singleVault];
}
if (categories.includes('multi')) {
_vaultList = [..._vaultList, ...MultiVault];
}
return _vaultList;
}

if (categories.includes('featured')) {
Expand Down

0 comments on commit 58dd54c

Please sign in to comment.