Why do you use this address? What is this adress? “0x10ed43c718714eb63d5aa57b78b54704e256024e”
Because I can’t find anything about it in internet.
Is it just a random router from pancakeswap that everyone can use?
Why do you use this address? What is this adress? “0x10ed43c718714eb63d5aa57b78b54704e256024e”
Because I can’t find anything about it in internet.
Is it just a random router from pancakeswap that everyone can use?
It is the address of pancakeswap router v2 contract
thank you for your awnser
If the contract already has a tax every transaction that goes to liquidity, is this necessary? Can we just remove numTokensSellToAddToLiquidity and/or set swapAndLiquifyEnabled to false?
Hi tuto, welcome to Open Zeppelin.
The tax for liquidity goes into the liquidity by using numTokensSellToAddToLiquidity and swapAndLiquify functions.
Please read the safemoon code and read through the forums about SafeMoon before asking questions about it. Please direct questions into this topic or another topic that has a mountain of posts about SafeMoon.
Thank you.
when i try to transfer tokens ,i am getting the below error
“Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
Internal JSON-RPC error. { “code”: 3, “message”: “execution reverted: TransferHelper: TRANSFER_FROM_FAILED”, “data”: “0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000245472616e7366657248656c7065723a205452414e534645525f46524f4d5f4641494c454400000000000000000000000000000000000000000000000000000000” }”
when i force send the transaction i am getting the below error
“false Transaction mined but the execution failed”
Below is my code. Any help in this regard is much appreciated.
function swapAndLiquify(uint256 liquidityBalanceWithContract) private lockTheSwap {
// split the contract balance into halves
uint256 half = liquidityBalanceWithContract.div(2);
uint256 otherHalf = liquidityBalanceWithContract.sub(half);
// capture the contract's current BNB balance.
// this is so that we can capture exactly the amount of BNB that the
// swap creates, and not make the liquidity event include any BNB that
// has been manually sent to the contract
uint256 initialBalance = address(this).balance;
// swap tokens for BNB
swapTokensForBNB(half); // <- this breaks the BNB -> HATE swap when swap+liquify is triggered
// how much BNB did we just swap into?
uint256 newBalance = address(this).balance.sub(initialBalance);
// add liquidity to uniswap
addLiquidity(otherHalf, newBalance);
emit SwapAndLiquify(half, newBalance, otherHalf);
}
function swapTokensForBNB(uint256 tokenAmount) private {
// generate the uniswap pair path of token -> wBNB
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of BNB
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
// approve token transfer to cover all possible scenarios
_approve(address(this), address(uniswapV2Router), tokenAmount);
// add the liquidity
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
owner(),
block.timestamp
);
}
It is likely because you don’t have enough liquidity in your LP.
It needs that in order to swap and liquify.
Thanks for your response @Yoshiko .But what is the minimum amount required in Lp token to make swap and liquify.
I’m not exactly sure the precise minimum. You at least need something like 0.001 BNB to sell to. Otherwise if the amount is so small, it can’t work because of math issues I think.
Feel free to correct me if I’m wrong about what is the minimum BNB.
Thanks, @Tsushima_Yoshiko.But I have 0.001000028125554541 BNB in my cake Lp. whether I want to change MxTxAmount or numTokensSellToAddToLiquidity value.
That is very small amount. IT would be better if there is more.
ok @Yoshiko .If i reduce the numTokensSellToAddToLiquidity value,whether i can get the same error?
Reducing the numTokensSellToAddToLiquidity will just cause it to Swap and Liquify more often. You need to have enough liquidity in the pool for it to Swap and Liquify, or just turn it off.
Hi @Tsushima_Yoshiko.I have another doubt. we have a total supply of 1billion, for that how much BNB need to be in cakePL.
It’s up to you on how much you put in. Adjust the price as you want in an AMM. https://uniswap.org/docs/v2/protocol-overview/how-uniswap-works/
You just need enough BNB in order to handle the Swap and Liquify. If you don’t then it won’t work and the token transfers will stop.
Thanks @Yoshiko .can you please give some example.
I have 1 BNB, I have 100 token.
In the pool 1 Token is equivalent to 0.01 BNB at that current liquidity ratio. This ratio (price) changes as liquidity is changed. Please read about AMM.
Thanks @Yoshiko .I will check it out.
@Yoshiko is there way find a translation is a buy or sell in safemoon code. raised a separate thread https://forum.openzeppelin.com/t/how-to-tax-only-on-selling-tokens-using-safemoon-fork/9978 it will be great you can help me on this.