Skip to content

Commit

Permalink
Merge pull request #307 from curvefi/get-all-pools
Browse files Browse the repository at this point in the history
Add getPools/all endpoint
  • Loading branch information
philippe-git authored Jun 14, 2023
2 parents 94b13e5 + 10ff41d commit 11a5258
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ GET /api/getPools/<blockchainId>/<registryId>
- https://api.curve.fi/api/getPools/xdai/crypto
- https://api.curve.fi/api/getPools/xdai/factory

This endpoint returns *all* pools from all these registries, in exactly the same shape, except for the fact that each pool object will also contain a `blockchainId` prop.
For each pool object in the endpoints above, the `id` prop is unique. For each pool object in this single "all pools" endpoint, the combination of props `blockchainId` and `id` is unique.

### getETHprice
```
GET /api/getETHprice
Expand Down
13 changes: 13 additions & 0 deletions pages/api/getPools/all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import configs from 'constants/configs';
import getAllCurvePoolsData from 'utils/data/curve-pools-data';
import { fn } from 'utils/api';

const allBlockchainIds = Array.from(Object.keys(configs));
console.log({ allBlockchainIds })

export default fn(async () => (
getAllCurvePoolsData(allBlockchainIds)
), {
maxAge: 5 * 60,
name: 'getAllPools',
});
2 changes: 1 addition & 1 deletion pages/api/getPools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ const getPools = async ({ blockchainId, registryId, preventQueryingFactoData })
registryId === 'factory-eywa' ? await getFactoryEywaRegistryAddress() :
undefined
);
if (registryAddress === ZERO_ADDRESS) return { poolData: [], tvlAll: 0 };
if (registryAddress === ZERO_ADDRESS || !registryAddress) return { poolData: [], tvlAll: 0 };

const getIdForPool = (id) => (
registryId === 'factory' ? `factory-v2-${id}` :
Expand Down

1 comment on commit 11a5258

@vercel
Copy link

@vercel vercel bot commented on 11a5258 Jun 14, 2023

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.