[SOLVED] MoralisError [Moralis SDK Core Error]: [C0006] Request failed, Not Found(404): No pools found with enough liquidity, to calculate the price

Hello everyone.

Try to use this code:

import Moralis from 'moralis';
import { EvmChain } from '@moralisweb3/evm-utils';

const oMoralis = Moralis.default;
const sChain = EvmChain.BSC;
const address = '0x95c44070a160fee8a74ba4c594bf94154699fc76';

await oMoralis.start({apiKey: '...'});

const response = await oMoralis.EvmApi.token.getTokenPrice({address, sChain});

console.log(' ');
console.log('response.result');
console.log(response.result);
console.log(' ');

and got this error:

/../node_modules/@moralisweb3/core/lib/controllers/RequestController/RequestController.js:119
            return new Error_1.MoralisCoreError({
                   ^

MoralisError [Moralis SDK Core Error]: [C0006] Request failed, Not Found(404): No pools found with enough liquidity, to calculate the price
    at RequestController.makeError (/../node_modules/@moralisweb3/core/lib/controllers/RequestController/RequestController.js:119:20)
    at RequestController.<anonymous> (/../node_modules/@moralisweb3/core/lib/controllers/RequestController/RequestController.js:100:38)
    at step (/../node_modules/@moralisweb3/core/lib/controllers/RequestController/RequestController.js:44:23)
    at Object.throw (/../node_modules/@moralisweb3/core/lib/controllers/RequestController/RequestController.js:25:53)
    at rejected (/../node_modules/@moralisweb3/core/lib/controllers/RequestController/RequestController.js:17:65)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  isMoralisError: true,
  code: 'C0006',

Error answer is big. So if it needed I can provide a full answer.

How I can fix it?

Thanks.This text will be hidden

Short error:

MoralisError [Moralis SDK Core Error]: [C0006] Request failed, Not Found(404): No pools found with enough liquidity, to calculate the price
    at RequestController.makeError (/../node_modules/@moralisweb3/core/lib/controllers/RequestController/RequestController.js:119:20)
    at RequestController.<anonymous> (/../node_modules/@moralisweb3/core/lib/controllers/RequestController/RequestController.js:100:38)
    at step (/../node_modules/@moralisweb3/core/lib/controllers/RequestController/RequestController.js:44:23)
    at Object.throw (/../node_modules/@moralisweb3/core/lib/controllers/RequestController/RequestController.js:25:53)
    at rejected (/../node_modules/@moralisweb3/core/lib/controllers/RequestController/RequestController.js:17:65)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  isMoralisError: true,
  code: 'C0006',
  details: {
    status: 404,
    response: {
      status: 404,
      statusText: 'Not Found',
      headers: [Object],
      config: [Object],
      request: [ClientRequest],
      data: [Object]
    }
  },
  cause: [AxiosError: Request failed with status code 404] {
    code: 'ERR_BAD_REQUEST',
    config: {
      transitional: [Object],
      adapter: [Function: httpAdapter],
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 10000,
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      maxBodyLength: -1,
      env: [Object],
      validateStatus: [Function: validateStatus],
      headers: [Object],
      url: 'https://deep-index.moralis.io/api/v2/erc20/0x95c44070a160fee8a74ba4c594bf94154699fc76/price',
      params: [Object],
      method: 'get',
      data: undefined
    },
    request: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 7,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: false,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      _contentLength: 0,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      socket: [TLSSocket],
      _header: 'GET /api/v2/erc20/0x95c44070a160fee8a74ba4c594bf94154699fc76/price?chain=0x38 HTTP/1.1\r\n' +
        'Accept: application/json, text/plain, */*\r\n' +
        'x-moralis-platform: JS SDK\r\n' +
        'x-moralis-platform-version: 2.6.7\r\n' +
        'x-moralis-build-target: node\r\n' +
        'x-api-key: ...\r\n' +
        'User-Agent: axios/0.27.2\r\n' +
        'Host: deep-index.moralis.io\r\n' +
        'Connection: close\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: noopPendingOutput],
      agent: [Agent],
      socketPath: undefined,
      method: 'GET',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      path: '/api/v2/erc20/0x95c44070a160fee8a74ba4c594bf94154699fc76/price?chain=0x38',
      _ended: true,
      res: [IncomingMessage],
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: 'deep-index.moralis.io',
      protocol: 'https:',
      _redirectable: [Writable],
      [Symbol(kCapture)]: false,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype]
    },
    response: {
      status: 404,
      statusText: 'Not Found',
      headers: [Object],
      config: [Object],
      request: [ClientRequest],
      data: [Object]
    }
  }
}

You can try to specify an exact exchange name to see if it works. You will get this error also when there are no liquidity pools that we track for that token.

This function expects an object with property names like address, chain, etc. So you will need to do chain: sChain.

For that address you specified, it gets a result back if you add the exchange name.

const response = await oMoralis.EvmApi.token.getTokenPrice({
  address,
  chain: sChain,
  exchange: 'pancakeswap-v2',
});
1 Like

But how can I know that this is the pancakeswap-v2?

Thanks.

I searched that address on etherscan, it didn’t exist > it showed it existed on Binance > PancakeSwap is the main DEX on that Chain > tried using valid values of pancakeswap-v1 and pancakeswap-v2.

This is something you should find out beforehand. By default if you don’t specify the exchange, it will try to use a default e.g. Uniswap on Ethereum.

1 Like

Ouch … Now I see. But in this case I don’t understand for what I use:

const chain = EvmChain.BSC;

I already told that it Binance.

Thanks.

You use chain as mentioned. In your code sample, you used a variable called sChain which you tried to use directly in the options object for getTokenPrice - it didn’t apply the chain so it was defaulting to Ethereum.

1 Like

I didn’t know that I need use exactly var names. Got you. Thanks.

Hello.

Could u please give the actual list of exchanges? For example for this API.

I am asking because at this docs I see the pancakeswapv1 but above we talking about pancakeswap-v2.

So where is true?)

Thanks.

This is the full list for getTokenPrice:

eth

  • uniswapV3
  • sushiswapMainnet
  • uniswapV2

goerli (none)

sepolia (none)

polygon

  • quickswap
    polygon test (none)

bsc

  • pancakeswapV2
  • pancakeswapV1

bsc test (none)

avalanche

  • traderJoe
  • pangolin

avalanche test (none)

fantom

  • spookySwap

cronos

  • vvs

Please make a new topic for any new questions/issues you have.