Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

159
Visualizações
Pancakeswap - getAmountsOut getting strange results

I'm making first steps in web3, that's why question can be silly.

I can't figure out, why results from getAmountsOut method of Pancakeswap's v2 router differs a lot from swap results I see on a frontend of Pancakeswap.

BAKE decimals should be everywhere 18 automatically, so I don't understand the reason of such different results.

Example BUSD-BAKE swap

  1. My code (results in 20000 BUSD -> 163 BAKE) 👇

const Web3 = require('web3');
const abis = require('./abis');
const web3 = new Web3('wss://bsc-ws-node.nariox.org:443');

const amountInBUSD = web3.utils.toBN(web3.utils.toWei('20000'));
const busdTokenAddress = "0xE02dF9e3e622DeBdD69fb838bB799E3F168902c5";
const bakeTokenAddress = "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56";

const init = async () => {
  const pancakeSwap = new web3.eth.Contract(
    abis.pancakeSwap.router,
    "0x10ED43C718714eb63d5aA57B78B54704E256024E"
  );

  web3.eth.subscribe('newBlockHeaders')
    .on('data', async block => {
      const bakeOutput = await pancakeSwap.methods.getAmountsOut(amountInBUSD, [busdTokenAddress, bakeTokenAddress]).call();
      console.log(`PancakeSwap BUSD-BAKE: ${web3.utils.fromWei(amountInBUSD.toString())} -> ${web3.utils.fromWei(bakeOutput[1].toString())}`);
    })
    .on('error', error => {
      console.log(error);
    });
}
init();

  1. Call of getAmountsOut method on router contract in bscscan (results in 20000 BUSD -> 163 BAKE) 👇

enter image description here

  1. Screenshot from PancakeSwap UI (results in 20000 BUSD -> 12100 BAKE) 👇

screenshot from PancakeSwap UI

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you compare the path/route on the pcs screenshot to the path on bsc, you should notice that it doesn't use the same path.

You will get a different price if you Trade on pair BUSD -> BAKE vs. BUSD -> BNB -> BAKE

Also please notice the price impact on the pool.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda