0

I am trying to follow along with a youtube tutorial that teaches you how to make a basic uniswap flash loan application. I have copied every piece of code, line by line, from the video as instructed.

I have an issue with repaying the flashloan. All other lines of code work.I can take the loan, and make swaps with the borrowed money, but when I try to repay the loan ("TransferHelper.safeTransfer(address(token1), address(pool), decoded.amount1 + fee1);") , the npx hardhat test will timeout, and the code never finishes executing. If I comment this code out, the swaps go through and I get the F1 error message that means I did not pay back the flash loan.

I suspect this has something to do with my provider. The URL I used, "bsc-dataseed.bnbchain.org", was not the exact same one used in the video but the closest name to it I could find on chainlist. Using this url with the test returns an error saying "missing trie node" unless I specify what block number I am looking at in the hardhat.config file. When I specify a more recent block in that config file, that error will go away until about 3-5 min later and I will have to put a more up to date block in the settings folder to get back to testing. When we have a test that runs, the flash loan never gets repaid and I get a timeout error in the terminal.

If I change the block number and the test successfully borrows using the flash loan, shoudn't it also be able to successfully repay the flashloan to the same pool? What is going wrong here? I know I have sufficient funds because I send a bunch of money in using a fake whale wallet to simulate profitable trades on the forked mainnet I am using for testing.

Any help is greatly appreciated!!

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.