Skip to content

Commit

Permalink
fix osmosis
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Dec 10, 2024
1 parent b0f2982 commit d1d9795
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions projects/helper/chain/cosmos.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const sdk = require("@defillama/sdk");
const { transformBalances } = require("../portedTokens");
const { get, post } = require("../http");
const { PromisePool } = require("@supercharge/promise-pool");
const { log } = require("../utils");
const { log, sleep } = require("../utils");
const ADDRESSES = require('../coreAssets.json')

// where to find chain info
Expand All @@ -11,7 +11,7 @@ const ADDRESSES = require('../coreAssets.json')
// https://cosmos-chain.directory/chains
const endPoints = {
crescent: "https://mainnet.crescent.network:1317",
osmosis: "https://rest.cosmos.directory/osmosis",
osmosis: "https://lcd.osmosis.zone",
cosmos: "https://cosmoshub-lcd.stakely.io",
kujira: "https://kuji-api.kleomedes.network",
comdex: "https://rest.comdex.one",
Expand Down Expand Up @@ -304,10 +304,15 @@ async function sumTokens({ balances, owners = [], chain, owner, tokens, blacklis
if (owner) owners = [owner]
log(chain, "fetching balances for ", owners.length);
let parallelLimit = 25;
if (chain === 'osmosis') parallelLimit = 5;

const { errors } = await PromisePool.withConcurrency(parallelLimit)
.for(owners)
.process(async (owner) => getBalance2({ balances, owner, chain, tokens, blacklistedTokens, api, }));
.process(async (owner, i) => {
await getBalance2({ balances, owner, chain, tokens, blacklistedTokens, api, })
if (chain === 'osmosis' && owners.length > 100)
await sleep(3000)
});

if (errors && errors.length) throw errors[0];
return transformBalances(chain, balances);
Expand Down

0 comments on commit d1d9795

Please sign in to comment.