Skip to content

Commit

Permalink
Merge pull request #251 from curvefi/fix/fixed-volumes-api
Browse files Browse the repository at this point in the history
fix: fixed _getFactoryAPYs
  • Loading branch information
fedorovdg authored Jan 9, 2024
2 parents fe67f81 + 2b93b8e commit 4006e6c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@curvefi/api",
"version": "2.53.8",
"version": "2.53.9",
"description": "JavaScript library for curve.fi",
"main": "lib/index.js",
"author": "Macket",
Expand Down
14 changes: 7 additions & 7 deletions src/external-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export const _getVolumes = memoize(

export const _getFactoryAPYs = memoize(
async (network: string): Promise<IVolumeAndAPYs> => {
const urlStable = `getFactoryAPYs/${network}/stable}`;
const urlCrypto = `getFactoryAPYs/${network}/crypto}`;
const urlStable = `https://api.curve.fi/api/getFactoryAPYs/${network}/stable`;
const urlCrypto = `https://api.curve.fi/api/getFactoryAPYs/${network}/crypto`;
const response = await Promise.all([
axios.get(urlStable, { validateStatus: () => true }),
axios.get(urlCrypto, { validateStatus: () => true }),
Expand All @@ -104,20 +104,20 @@ export const _getFactoryAPYs = memoize(
const stableVolume = response[0].data.data.totalVolumeUsd || response[0].data.data.totalVolume;
const cryptoVolume = response[1].data.data.totalVolumeUsd || response[1].data.data.totalVolume;

const poolsData = [...response[0].data.data.pools, ...response[1].data.data.pools].map((item) => {
const poolsData = [...response[0].data.data.poolDetails, ...response[1].data.data.poolDetails].map((item) => {
return {
address: item.poolAddress,
volumeUSD: item.totalVolumeUsd,
day: item.apy,
week: item.apy*7, //Because api does not return week apy
volumeUSD: item.totalVolumeUsd ?? 0,
day: item.apy ?? 0,
week: item.apy*7 ?? 0, //Because api does not return week apy
}
})

return {
poolsData: poolsData ?? [],
totalVolume: stableVolume + cryptoVolume ?? 0,
cryptoVolume: cryptoVolume ?? 0,
cryptoShare: 100*cryptoVolume/(stableVolume + cryptoVolume) ?? 0,
cryptoShare: 100*cryptoVolume/(stableVolume + cryptoVolume) || 0,
};
},
{
Expand Down

0 comments on commit 4006e6c

Please sign in to comment.