Skip to content

Commit

Permalink
Merge pull request #311 from curvefi/fix/fixed-getBasePools
Browse files Browse the repository at this point in the history
fix: fixed getBasePools
  • Loading branch information
fedorovdg authored Apr 22, 2024
2 parents a237854 + 622ea50 commit 9bb1238
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 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.57.1",
"version": "2.57.2",
"description": "JavaScript library for curve.fi",
"main": "lib/index.js",
"author": "Macket",
Expand Down
20 changes: 18 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,24 @@ export const assetTypeNameHandler = (assetTypeName: string): REFERENCE_ASSET =>
}
}

export const getBasePools = (): IBasePoolShortItem[] => {
return Object.keys(curve.constants.BASE_POOLS).map((poolId) => {
export const getBasePools = async (): Promise<IBasePoolShortItem[]> => {
const factoryContract = curve.contracts[curve.constants.ALIASES['stable_ng_factory']].contract;
const factoryMulticallContract = curve.contracts[curve.constants.ALIASES['stable_ng_factory']].multicallContract;

const basePoolCount = Number(curve.formatUnits(await factoryContract.base_pool_count(curve.constantOptions), 0));

const calls = [];
for (let i = 0; i < basePoolCount; i++) {
calls.push(factoryMulticallContract.base_pool_list(i));
}

const basePoolList = (await curve.multicallProvider.all(calls) as string[]).map((item: string) => item.toLowerCase());

const pools = {...curve.constants.STABLE_NG_FACTORY_POOLS_DATA, ...curve.constants.FACTORY_POOLS_DATA, ...curve.constants.POOLS_DATA};

const basePoolIds = Object.keys(pools).filter((item: string) => basePoolList.includes(pools[item].swap_address));

return basePoolIds.map((poolId) => {
const pool = getPool(poolId);
return {
id: poolId,
Expand Down

0 comments on commit 9bb1238

Please sign in to comment.