Skip to content

Commit

Permalink
feat: Only show current strategies (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
karelianpie authored Oct 20, 2022
1 parent 7c7edf6 commit d1e5a38
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pages/api/vaults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ STABLE_UNDERLYING[10] = [ // optimism
STABLE_UNDERLYING[42161] = [ // arbitrum
];


async function getVaultStrategies(vaultStrategies: TVaultStrategy[]): Promise<TVaultStrategies> {
const strategies = [];
let hasMissingStrategiesDescriptions = false;
Expand All @@ -36,11 +35,13 @@ async function getVaultStrategies(vaultStrategies: TVaultStrategy[]): Promise<TV
strategies.push(strategy);
}
}

return ([strategies, hasMissingStrategiesDescriptions]);
}

async function getStrategies(network: number, isCurve: boolean, isRetired: boolean, isAll: boolean, isStable: boolean, isDefi: boolean): Promise<TVaultWithStrats[]> {
let vaults: TVault[] = (await (await fetch(`https://ydaemon.yearn.finance/${network}/vaults/all?strategiesDetails=withDetails`)).json());
let vaults: TVault[] = (await (await fetch(`https://ydaemon.yearn.finance/${network}/vaults/all?strategiesCondition=absolute&strategiesDetails=withDetails`)).json());

if (isRetired) {
vaults = vaults.filter((e): boolean => e?.migration?.available || false);
} else {
Expand Down Expand Up @@ -69,14 +70,18 @@ async function getStrategies(network: number, isCurve: boolean, isRetired: boole
vault.strategies
);

if (!strategies.length) {
continue;
}

vaultsWithStrats.push({
address: vault.address || '',
symbol: vault.token.symbol || '',
underlying: vault.token.address || '',
name: vault.name || '',
display_name: vault.display_name || '',
icon: vault.icon || '',
hasBoost: vault?.apy?.composite?.boost ? true : false,
hasBoost: !!vault?.apy?.composite?.boost,
strategies
});
}
Expand Down

1 comment on commit d1e5a38

@vercel
Copy link

@vercel vercel bot commented on d1e5a38 Oct 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.