19
votes
Understand price impact and liquidity in pancakeswap
Disclaimer: I don't think this is the correct method to calculate the price impact but it's almost 100% accurate for price impacts of less than 1%. This calculation method assumes that multi-hop is ...
9
votes
Accepted
Fail with error 'TransferHelper: TRANSFER_FROM_FAILED' even approved in contract
The issue is that you need to approve the pair and not the router. Looking at the transaction you linked you can see that it revert on the transfer from 0xa89C6f52Ce3Ce1BFF6CAac1E1c98b4f9b3AA5f63 (...
7
votes
Accepted
Finding a Pair Contract on PancakeSwap
you're looking at the different PancakeSwap contracts versions. Example:
PancakeRouter V1 - 0x05ff2b0db69458a0750badebc4f9e13add608c7f
PancakeFactory V1 - 0xbcfccbde45ce874adcb698cc183debcf17952812
...
6
votes
Accepted
understanding the Swap function in pancakeSwap Pair contract
balance0 and balance1 are local variables of functions mint, burn and swap while reserve0 and reserve1 are globally declared variables.
why there is a need for computing balance and reserve?
As ...
5
votes
Accepted
Token Price from pancakeswap
You do not need to go through this hassle, you can use getAmountsOut on the PancakeSwap router contract to make this a lot simpler. You provide a path&amount of the first token in the path to use, ...
5
votes
Call swapExactETHForTokens from contract and pay with contract balance
You should be able to achieve that if you send the ether along the function call. In solc v0.8 you achieve that using the function call options {value: amount}.
The resulting function should look like ...
5
votes
Accepted
How to create a liquidity pool by code?
Since the you (the contract) are adding ETH/Token as liquidity, your function needs to be marked as internal/private. Additionally, you need to give the PancakeRouter02an allowance to spend at least ...
5
votes
Accepted
Testing Token with Uniswap liquidity provisioning using hardhat
It sounds like you're facing one of two problems - either you're using a local dev chain and haven't deployed Uniswap to it, or you're using a testing fork of a chain, and haven't told your test suite ...
4
votes
Accepted
where can i find the addresses of the pancakeswap coin pairs smart contracts
The factory contract - PancakeFactory - is here:
https://bscscan.com/address/0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73
If you read the contract, you'll see that allPairsLength gives you 14,690 pairs. ...
4
votes
understanding the Swap function in pancakeSwap Pair contract
Here is the TL;DR version.
Q1 balance0 and balance1 vs reserve0 and reserve1
reserve0 and reserve1 are the balances of each tokens in the pair contract just before the swap transaction is processed.
...
3
votes
Accepted
An unlocked wallet is holding 100% of <PAIR> LP
It means the owner can rug pull(remove liquidity, steal everyone's investment, and make the token valueless) any time. That is why that prompt exists. Locks are commonly done on DxSale and Poocoin ...
3
votes
What are the Pancakeswap "*SupportingFeeOnTransfer" methods for?
For anything like this, it's always best to refer to the original documentation... which exists on Uniswap site. PancakeSwap didn't seem bothered about copying the actual documentation, unlike ...
3
votes
Getting the balance of a token in wallet - decimal issue
ethers.utils.formatEther uses decimals as 18. Though most of popular ERC20 tokens out there use 18 decimals, there are some ERC20s that can use a different decimal value, like in your case it appears ...
3
votes
Check valid slippage before sending transaction using web3
Currently, ERC-20 tokens do not expose interface expose transaction fees. Only thing you can find these out is by checking them by hand.
Also, taking fee on transfer() does not fit to ERC-20 token ...
3
votes
How to conduct a flash loan on PancakeSwap?
PancakeSwap is a fork of Uniswap V2, which allows flashswaps. An example of flashswap using Uniswap V2 can be found here: https://github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/examples/...
3
votes
Accepted
How To Read LP Tokens Held By Address After Being Staked On Pancakeswap
After spending some time looking into other projects that show this information I discovered the way to find it is by executing a function called userInfo on the main PancakeSwap Staking contract: ...
3
votes
Accepted
Solidity function can't sell with slippage on Pancakeswap
That's because for these tokens you need to call swapExactTokensForETHSupportingFeeOnTransferTokens or swapExactETHForTokensSupportingFeeOnTransferTokens.
You can always use these method instead of ...
2
votes
Unable to understand master-chef contract in pancake-swap
Dev Address - Some percentage of cake minted is sent to the dev address. For every 100 cake, 10 is sent to dev address. The dev address will then burn it.
Update pool fn - Straight forward, it is ...
2
votes
Understanding front running. Why did my transaction fail? (PancakeSwap V2)
There's no predefined order for transactions in a block. The only requirement is for transactions from the same address to be sorted by the transaction's nonce but transactions from different ...
2
votes
Failing to add liquidity to pancakeswap on bsc testnet
Yes, I believe this problem is due to the deadline parameter of the addLiquidity method.
In your tx you have submitted a deadline of 7741799 which corresponds (https://www.epochconverter.com/) to ...
2
votes
An unlocked wallet is holding 100% of <PAIR> LP
If it says: An unlocked wallet is holding 100% of the lp. This means that the owner of the token can at any time get his liquidity and devalue the token. Therefore, you need to block liquidity, for ...
2
votes
Accepted
swapExactTokensForTokens ignore amountOutMin parameter
The AMM is only checking that it is sending you the amountOutMin, not that you are receiving it. In other words, it calls a transfer for that token for an amount greater than or equal amountOutMin.
...
2
votes
Accepted
How to understand the constant product formula?
The product k would actually be constant, if the swap fee was 0%. Since AMMs usually have a fee, the product of the reserves is not really a constant in practice.
The name ‘constant product market’ ...
2
votes
What's the relationship between LP reserves and Swap rate?
amount_in=14067900000000
amount_out=393017164305296368
reserve0=95594454080845
reserve1=3070347989941780637
amount_in_with_fee=amount_in*998-14067900000000*0.5
numerator=amount_in_with_fee*reserve1
...
2
votes
What does a Swap event describe when amount0In and amount0Out are non-0, but amount1In and amount1Out are zero?
After analyzing the contract interactions and the account history it isn't a regular trade. It appears to be a bot farming rewards then interacting with other pools.
It initially get 0.1046 WBNB as ...
2
votes
Accepted
Is this smart contract code malicious?
TL;DR Yes, it's a scam.
The functions used are hidden in the Manager object imported with this line import "ipfs://Qmf5Ua79ZT8ERFa9q32fQtGuWkqk1eZXxnzRdeTi6wvzUy". I cannot see that code, ...
2
votes
Is there a way to convert Binance pegged tokens into Ethereum based tokens?
I think the main "problem" here is that BSC is derived from Ethereum - they use the same EVM code (Ethereum Virtual Machine) in the background. Therefore they also have the same underlying ...
2
votes
Accepted
Retrieving APY from PancakeSwap CAKE auto-compounding pool
https://github.com/gaijinjoe/cake-liquidity/blob/7ae59f159d09dc3560b294ce8d19955a56f401e5/borrow-limit-status.js#L233
Here you go.
Call it like this:
const autoAPY = compoundInterest(1, ...
2
votes
How can we fetch the current market price to our DEX?
You can get price of BNB/BUSD using getAmountsOut method
//one WBNB in Wei
const oneWBNB = '1000000000000000000';
const WBNB = '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c';
const BUSD = '...
2
votes
What happens when disconnect my wallet from Pancakeswap
Just by connecting your wallet, most websites will just see your wallet address and require your permission before signing a transaction. Unless you connect to a shady site which asks for transaction ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
pancakeswap × 312uniswap × 97
solidity × 88
bsc × 63
web3js × 45
web3.py × 37
tokens × 32
liquidity-provider × 29
swaps × 21
contract-development × 19
ethers.js × 19
decentralized-exchange × 19
python × 18
binance-smart-chain × 17
blockchain × 16
binance × 14
defi × 12
transactions × 11
erc-20 × 10
nodejs × 10
bscscan × 10
metamask × 8
contract-invocation × 8
etherscan × 7
flash-loans × 7