嗨,我正在努力让 swapExactTokensForTokens 在 pancakeswap 上工作我只是不明白为什么它一直失败我打电话给 giveAllowances() 并将 0.1 蛋糕发送到合同然后调用 sellCake() - 鸡蛋和蛋糕都具有 wbnb 的流动性所以我真的不明白怎么了,看看下面的部分代码希望有人能看到问题
address public egg = 0xF952Fc3ca7325Cc27D15885d37117676d25BfdA6;
address public cake = 0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82;
address public router = 0xF491e7B69E4244ad4002BC14e878a34207E38c29;
address public dead = 0x000000000000000000000000000000000000dEaD;
address public wbnb = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c;
address[] public route = [cake, wbnb, egg];
function giveAllowances() external onlyOwner {
IBEP20(cake).safeApprove(router, uint256(-1));
}
function sellCake() public onlyOwner {
uint256 _bal = IBEP20(cake).balanceOf(address(this));
if (_bal > 0) {
IUniswapV2Router02(router).swapExactTokensForTokens(_bal, 0, route, dead, now);
}
}