Skip to content

Commit 3b5c300

Browse files
committed
update staking pool enpoint
1 parent cb6f126 commit 3b5c300

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/utils/lib.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,23 @@ export async function getUserStakeBalances(
318318
}
319319
);
320320

321-
const stakedPools = (data?.pools ?? [])?.map((i: any) => i.pool_id);
321+
const { data: stakingData } = await axios.get(
322+
`https://staking-pools-api.neartreasury.com/v1/account/${account_id}/staking`,
323+
324+
);
325+
326+
// Combine pools from both API calls and get unique pool IDs
327+
const fastnearPools = (data?.pools ?? []).map((i: any) => i.pool_id);
328+
const treasuryPools = (stakingData?.pools ?? []).map((i: any) => i.pool_id);
329+
330+
const uniqueStakedPools = [...new Set([...fastnearPools, ...treasuryPools])];
331+
322332
const results: number[] = new Array(blockHeights.length).fill(0); // Store total balance per blockHeight
323333

324334
await Promise.all(
325335
blockHeights.map(async (block_id, index) => {
326336
const balances = await Promise.all(
327-
stakedPools.map(async (pool: string) => {
337+
uniqueStakedPools.map(async (pool: string) => {
328338
const cacheKey = `${account_id}-${block_id}-${pool}`;
329339

330340
const cachedBalance = cache.get(cacheKey);

0 commit comments

Comments
 (0)