Open jurgenBE opened 2 years ago
@jurgenBE Sorry I don't see any error message in the post. Can you share what exactly you ran and what you got on your machine or on your console? Please note that the article and this repository were created for entertaining and educational purpose only it does not guarantee that all codes are workable all the time. Thanks.
@jurgenBE Hey so I think the issue here is that UniswapV2Library.pairFor(fromApeFactory, token0, token1)
does not work for V2 pairs. IUniswapV2Factory(fromApeFactory).getPair(token0, token1)
will calculate the right pair address. When the require is called the two pairs don't match and thats why the execution stops at that point
@benedictmc If you've got a tweaked code in hands, please raise a PR in the repository. I'll look into that and merge it into main branch. Thanks.
@benedictmc thanks for that. were you able to execute the function after making this edit? I still get the same 'execution revert' error.
@0xPlask @benedictmc Please confirm the revised code and let me know if it works. I did some online research and updated the contract and the script.
I have a question, if i use the code 'as is' it does not work, i always get 'Fail' but don't know if it's a failure in the contract or not, so i tried to add en event, but that's also not shown. Did your code work on mainnet like that, don't you have to sign the transaction or something. Do i have to hex the data first? I am getting desprerate, i've tried so many things...
this is the code, i do a reversal from apefactory to pancakerouter, and added 1 required to see if i see the message and added in the last try this emit event :
I already found out that it is in the pancakeCall function : i found that the error is showed here :
require(msg.sender == UniswapV2Library.pairFor(fromApeFactory, token0, token1), 'message fail 1');
// SPDX-License-Identifier: MIT pragma solidity >=0.6.6 <0.8.0;
import './utils/SafeMath.sol'; import './UniswapV2Library.sol'; import './interfaces/IERC20.sol'; import './interfaces/IUniswapV2Pair.sol'; import './interfaces/IUniswapV2Factory.sol'; import './interfaces/IUniswapV2Router02.sol'; import './interfaces/IPancakeCallee.sol'; import './interfaces/IApeCallee.sol';
contract EventExample { using SafeMath for uint;
}