Skip to content

Commit

Permalink
Merge pull request #411 from curvefi/fix/fix-fetch-pools
Browse files Browse the repository at this point in the history
fix: fixed fetch pools for lite
  • Loading branch information
fedorovdg authored Nov 14, 2024
2 parents f1137f2 + 5c7484c commit 407e29f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 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.65.4",
"version": "2.65.5",
"description": "JavaScript library for curve.fi",
"main": "lib/index.js",
"author": "Macket",
Expand Down
4 changes: 4 additions & 0 deletions src/curve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,10 @@ class Curve implements ICurve {
getNetworkConstants = (): INetworkConstants => {
return this.constants
}

getIsLiteChain = (): boolean => {
return this.isLiteChain
}
}

export const curve = new Curve();
30 changes: 19 additions & 11 deletions src/external-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,25 @@ export const _getPoolsFromApi = memoize(
)

export const _getAllPoolsFromApi = async (network: INetworkName, isLiteChain = false): Promise<IExtendedPoolDataFromApi[]> => {
return await Promise.all([
_getPoolsFromApi(network, "main", isLiteChain),
_getPoolsFromApi(network, "crypto", isLiteChain),
_getPoolsFromApi(network, "factory", isLiteChain),
_getPoolsFromApi(network, "factory-crvusd", isLiteChain),
_getPoolsFromApi(network, "factory-eywa", isLiteChain),
_getPoolsFromApi(network, "factory-crypto", isLiteChain),
_getPoolsFromApi(network, "factory-twocrypto", isLiteChain),
_getPoolsFromApi(network, "factory-tricrypto", isLiteChain),
_getPoolsFromApi(network, "factory-stable-ng", isLiteChain),
]);
if(isLiteChain) {
return await Promise.all([
_getPoolsFromApi(network, "factory-twocrypto", isLiteChain),
_getPoolsFromApi(network, "factory-tricrypto", isLiteChain),
_getPoolsFromApi(network, "factory-stable-ng", isLiteChain),
]);
} else {
return await Promise.all([
_getPoolsFromApi(network, "main", isLiteChain),
_getPoolsFromApi(network, "crypto", isLiteChain),
_getPoolsFromApi(network, "factory", isLiteChain),
_getPoolsFromApi(network, "factory-crvusd", isLiteChain),
_getPoolsFromApi(network, "factory-eywa", isLiteChain),
_getPoolsFromApi(network, "factory-crypto", isLiteChain),
_getPoolsFromApi(network, "factory-twocrypto", isLiteChain),
_getPoolsFromApi(network, "factory-tricrypto", isLiteChain),
_getPoolsFromApi(network, "factory-stable-ng", isLiteChain),
]);
}
}

export const _getSubgraphData = memoize(
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ const curve = {
hasRouter,
getCurveLiteNetworks,
getNetworkConstants: _curve.getNetworkConstants,
getIsLiteChain: _curve.getIsLiteChain,
factory: {
fetchPools: _curve.fetchFactoryPools,
fetchNewPools: _curve.fetchNewFactoryPools,
Expand Down

0 comments on commit 407e29f

Please sign in to comment.