I am new to blockchain dev. so the first learning I fork sushiswap from github, so the code very not clear for me

The difficulty understanding is how to get price tokens to exchange? example 1BNB will be 157.902SUSHI, I checked the network tab in chrome, and not showing any request.

So how to exchange the price from Token A - to Token B is there using API, Service, Smartconrtact, or any provider? I would appreciate it if someone could explain this more deeply so that I can understand

![enter image description here


  • You need to understand liquidity pool. Simplified not accurate example: When you create a pool you must send 50% tokenA and 50% token B. If you send 100 Sushi and 1 BNB then the price of 1 sushi is equal 0.01 BNB … YOU decide the price. After that traders see that you are selling sushi for cheap price and they come and buy it from the pool to sell it in another exchange and win some money.. and that will make the price of sushi go high in your pool because there is now less sushi and more BNB. This apply also in the other direction. Summary no they do not use api to get price
    – Majd TL
    May 1, 2022 at 8:55
  • The price is calculated inside the smart contract based on how much of tokenA and TokenB are inside the contract
    – Majd TL
    May 1, 2022 at 9:00

1 Answer 1


The price is calculated inside the smart contract using x * y= k where x and y are the reserve of the pair token.

This Video explain it very well with examples: https://www.youtube.com/watch?v=IL7cRj5vzEU&list=PLO5VPQH6OWdX-Rh7RonjZhOd9pb9zOnHW&index=2

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.