Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

160
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda