Skip to content

Commit

Permalink
Add getPools/all endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
philippe-git committed Jun 14, 2023
1 parent b106273 commit 10ff41d
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

0 comments on commit 10ff41d

Please sign in to comment.