Skip to content

Commit

Permalink
feat: safety
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Nov 30, 2022
1 parent 5a62233 commit 2ce51e5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions contexts/useYearn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const YearnContextApp = ({children}: {children: ReactElement}): ReactElem
**************************************************************************/
const getYearnDataSync = useCallback(async (_chainID: number): Promise<void> => {
const [fromAPI, _ledgerSupport, _ledgerSupportFork, _exporterPartners, _metaVaultFiles, _metaProtocolFiles, _yDaemonPartners, strategies, tokens, protocols] = await Promise.all([
axios.get(`${web3Settings.yDaemonBaseURI}/${_chainID}/vaults/all?classification=any&strategiesRisk=withRisk`),
axios.get(`${web3Settings.yDaemonBaseURI}/${_chainID}/vaults/all?strategiesDetails=withDetails&strategiesRisk=withRisk&strategiesCondition=all`),
axios.get('https://raw.githubusercontent.com/LedgerHQ/app-plugin-yearn/develop/tests/yearn/b2c.json'),
axios.get('https://raw.githubusercontent.com/yearn/app-plugin-yearn/main/tests/yearn/b2c.json'),
axios.get('https://raw.githubusercontent.com/yearn/yearn-exporter/master/yearn/partners/partners.py'),
Expand Down Expand Up @@ -102,15 +102,15 @@ export const YearnContextApp = ({children}: {children: ReactElement}): ReactElem
**********************************************************************/
for (const data of fromAPI.data) {
if (!_allData.vaults[toAddress(data.address) as string]) {
const hasValidStrategiesDescriptions = data.strategies.every((strategy: appTypes.TStrategy): boolean => (
const hasValidStrategiesDescriptions = (data?.strategies || []).every((strategy: appTypes.TStrategy): boolean => (
strategy.description !== ''
));

const hasValidStrategiesRisk = data.strategies.every((strategy: appTypes.TStrategy): boolean => {
const hasValidStrategiesRisk = (data?.strategies || []).every((strategy: appTypes.TStrategy): boolean => {
return (strategy?.risk?.riskGroup || 'Others') !== 'Others';
});

const hasValidStrategiesRiskScore = data.strategies.every((strategy: appTypes.TStrategy): boolean => {
const hasValidStrategiesRiskScore = (data?.strategies || []).every((strategy: appTypes.TStrategy): boolean => {
const sum = (
(strategy?.risk?.TVLImpact || 0)
+ (strategy?.risk?.auditScore || 0)
Expand All @@ -126,7 +126,7 @@ export const YearnContextApp = ({children}: {children: ReactElement}): ReactElem

const hasYearnMetaFile = YEARN_META_VAULT_FILES.includes(data.address);
const missingTranslations: {[key: string]: string[]} = {};
const strategiesAddresses = data.strategies.map(({address}: appTypes.TStrategy): string => toAddress(address));
const strategiesAddresses = (data?.strategies || []).map(({address}: appTypes.TStrategy): string => toAddress(address));
for (const strategyAddress of strategiesAddresses) {
const localizations = STRATEGIES[strategyAddress]?.localization;
const english = localizations?.en;
Expand Down

0 comments on commit 2ce51e5

Please sign in to comment.