一、说明
在合约开发过程中直接在合约创建本币和WETH(BNB)的交易对时,在合约部署完成,BNB的资金池对创建完成后,会被脚本程序恶意向BNB对资金池地址打入0.000000000000000001个WBNB,也就是最小数量的WBNB。这样当用户在pancakeswapV2上添加BNB交易对的流动性时,资金池中本币的数量为0,但是又存在wbnb,这样无法计算添加流动性的价格。因为按照当前代币的比例为0.000000000000000001 : 0 ,本币的价格为0,bnb的价格为无穷大。因此,无法添加bnb交易对的流动性。
在pancakeswapV2 操作界面上直接提示无法添加BNB的交易对,需要修复该lp资金池对,并给出了官网的解决方案。
二、官方解决方案
针对该bug,官方给出了标准的解决方案:
Why can’t I add liquidity to a pair I just created?
Due to a bug from the legacy Exchange V2 (present in every UniSwap V2 forks), you will not be able to add liquidity to a pair using the normal PancakeSwap liquidity UI and its contract calls if a pair is:
- Created by calling createPair on FactoryV2 without depositing initial liquidity and minting the initial LP tokens
- Then, one of the tokens in the pair has been manually transferred into the pool contract while calling sync
Recently, an increase amount of such attacks were spotted on PancakeSwap Exchange V2 on BNB Chain.
We strongly recommend using our UI to create the trading pair for your token by adding the initial liquidity with the pair creation.
While Chefs are working hard on a solution to resolve this issue, here is a step-by-step guide to resolve this using BscScan:
Locate the pool address and its BscScan page
If your pair is affected, you will see the link to the BscScan page for the trading pair/pool in the error prompt.
Alternatively, you can head to Factory V2 (Bsc), go to “Read Contract”, “6. getPair”, enter the address of the two tokens in your trading pair, and click “Query”. You should see the pair address in the return field.
Check which token has been deposited and transfer the other token into the pair manually
From the token balance field on BscScan, you can check which token has been deposited into the pool. Usually, it should be the paired token. (Like WBNB, USDT, etc…)
Once confirmed, you must manually transfer the other asset into the pool contract. You may do that in the wallet app you prefer by entering the pool address as the receiver.
You can transfer any amount but since this is effectively “donating” assets to a pool. You will be transfering your assets into a liquidity without minting liquidity tokens. So we recommend keeping this amount minimal.
IMPORTANT: Once you’ve transferred the token, you must call sync()immediately on the pool.
You can do so by heading to the BscScan page for the trading pair, going to “Write Contract”, “8. Sync”, and clicking the “Write” button. You will need to connect your wallet before performing the transaction.
Once the transaction is confirmed, you can add the subsequent liquidity on PancakeSwap UI.
What if I want to define the launch price?
You must adjust the pool to the launch price while transferring the token and fixing the pool.
The amount to transfer can be calculated using:
- tokenInside: the token that is already transferred into the pool. Usually it should be the paired token. (Like WBNB, USDT, etc…)
- tokenToSend: the token that is about to be sent to the pool. Usually it should be your project token
- tokenInside.price: the USD price of tokenInside
- tokenToSend.price: the USD price of tokenToSend (the launch price)
- pool: the V2 pool
With the following formula:
amountToSend = tokenInside.balanceOf(pool) / tokenInside.decimal() * tokenInside.price / tokenToSend.price * tokenToSend.decimal()
If the result is smaller than 0 (usually happens when the launch price is very large. You may need to first deposit more tokenInside into the pool)
pdf+视频币安智能链BSC发币教程及多模式组合合约源代码下载:
币安智能链BSC发币(合约部署、开源、锁仓、LP、参数配置、开发、故障处理、工具使用)教程下载:
多模式(燃烧、回流指定营销地址、分红本币及任意币种,邀请推广八代收益,LP加池分红、交易分红、复利分红、NFT分红、自动筑池、动态手续费、定时开盘、回购)组合合约源代码下载:
pdf+视频币安智能链BSC发币教程及多模式组合合约源代码下载地址:
此内容仅供注册用户可见,请登录!
添加VX或者telegram获取全程线上免费指导
评论前必须登录!
注册