Anyone know any Api or something similar to get the price of an LP in pancakeswap with Js

Of Pancakeswap

Mar 20, 2021, 4:21 AM
getReserves from lp, gettotalsupply, do some division to find token/lp ratio, divide your lp by that number, use pancakeswap api to get price
what's cheaper on gas fees
1. storing a function return as a variable and calling it multiple times
2. calling the function over and over again
Mar 20, 2021, 6:17 AM
2.
Mar 20, 2021, 6:18 AM
any edge cases to that?
Mar 20, 2021, 6:18 AM
You have to be precise how you are going to write it
Mar 20, 2021, 6:18 AM
ah yes, very helpful, thanks.
so far my conclusion from testnet using both internal and external functions is 1
Mar 20, 2021, 6:46 AM
1
That's even true for every programming language based on computation required
There might be some exceptions if the function body is really really small
Mar 20, 2021, 6:51 AM
true, but since i'm pretty new to solidity i can't ever be too sure. it's possible creating a variable in a function costs more gas than i expect
Mar 20, 2021, 6:54 AM
If a single variable costs more than an entire function call, then that's the worst programming language I've ever seen😅
Mar 20, 2021, 6:56 AM

© 2024 Draquery.com All rights reserved.