Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
fix missing tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
tonzgao committed Mar 26, 2023
1 parent 87427af commit c2e4712
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,29 @@ type Pool = {
};
};

const dataSources = {
[Network.ARBITRUM_MAINNET]: ['/arbitrum', '/zyberswap/arbitrum'],
[Network.ETHEREUM_MAINNET]: [''],
[Network.OPTIMISM_MAINNET]: ['/optimism'],
[Network.POLYGON_MAINNET]: ['/polygon', '/quickswap/polygon'],
[Network.CELO_MAINNET]: ['/celo'],
};

@Injectable()
export class GammaStrategiesDefinitionResolver {
@Cache({
key: (network: Network) => `studio:gamma:${network}:vaults`,
ttl: 30 * 60, // 30 min
})
async getPoolDefinitionsData(network: Network) {
const url =
network == Network.ETHEREUM_MAINNET
? 'https://wire2.gamma.xyz/hypervisors/allData'
: `https://gammawire.net/${network}/hypervisors/allData`;
const urls = dataSources[network];
const data = await Promise.all(
urls.map((path: string) => this._getPoolDefinitionsData(`https://wire2.gamma.xyz${path}/hypervisors/allData`)),
);
return Object.assign({}, ...data) as GammaApiTokensResponse;
}

async _getPoolDefinitionsData(url: string) {
const { data } = await Axios.get<GammaApiTokensResponse>(url);
return data;
}
Expand All @@ -39,7 +50,6 @@ export class GammaStrategiesDefinitionResolver {
const defintionsRaw = definitionsDataRaw.map(([key, value]) => {
return Number(value.returns.allTime.feeApy) > 0 ? { address: key.toLowerCase() } : null;
});

return _.compact(defintionsRaw);
}
}

0 comments on commit c2e4712

Please sign in to comment.