Zerion clone problem: No pools found

I’m trying to follow this tutorial (https://github.com/IAmJaysWay/Moralis-Cross-Chain) but no token balances are displayed. Getting this error message in the log:
2021-11-10T02:53:40.812Z - Failed running cloud function getTokenPrice for user undefined with:
Input: {“chain”:“polygon”,“address”:“0x0ef2603cd156e1934e19d0b07cd64f415e1e7940”}
Error: {“message”:“No pools found with enough liquidity, to calculate the price”,“code”:141}
2021-11-10T02:53:40.755Z - Error: No pools found with enough liquidity, to calculate the price
at fetch (/moralis-server/lib/cloud-code/plugins/convenience/web3Api.js:128:11)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)

Would appreciate your help.

it looks like this works for me:

x = await Moralis.Web3API.token.getTokenPrice({address: “0x0ef2603cd156e1934e19d0b07cd64f415e1e7940”, chain: “polygon”})

Great to hear, but that’s not the code in the GitHub / video tutorial. I think the error comes from this line:

Can you get that code working?


I’m not familiar with that code, you could adapt it to debug on what parameters gives an error, somehow to handle an error when it happens

there may be addresses that may not work, that would give that error that you receive, in particular it looks that it wasn’t that address the case, but it may be another address

The code comes from a Moralis video tutorial, here:

Hoping someone on the Moralis team can support it.

x = await Moralis.Web3API.token.getTokenPrice({address: “0x0ef2603cd156e1934e19d0b07cd64f415e1e7940”, chain: “polygon”})

still works fine for me now

you get that error all the time for that specific address?

Can you get the code from the Moralis video tutorial working?

1 Like

Hi @jswift24

I guess the problem is because the Promise.all() fails in case if one of promises return error. So I suggest you use Promise.allSettled() instead

Promises can fail because of not enough liquidity to calculate the price of asked tokens :man_factory_worker:

If you make this change, can you get the tutorial code working?

If I use Promise.allSettled() as you suggest, some calls will succeed and others will fail/reject. Is there a way I can cycle through them after the last async call finishes to see which promises / tokens failed?

maybe you can change to code so that they don’t work all in parallel and you can check which one fails, or maybe you can check if it failed when it makes the request.

That is what I’m doing now, but it is slow. It takes ~1 min to value a wallet with ~50 tokens. Places like DeBank, Zerion and tin.network do it much faster.

After you make that query for those 50 tokens you can save the result in the database so that you can get it from database next time, it may work for historical data for example

I’m retrieving fresh prices each time, so that won’t help.