Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!