FlashTest.ts 941 B

123456789101112131415161718192021222324252627282930313233
  1. import {ethers, web3} from "hardhat";
  2. import contracts from "../config/contracts";
  3. import deployer from "../.secret";
  4. import fee from "../config/fee";
  5. describe('Flash test', () => {
  6. let inAmount = 1e15.toString()
  7. it('Flash swap test', async () => {
  8. const FLASH_ABI = require('../artifacts/contracts/Flash.sol/Flash.json').abi
  9. let flash = new web3.eth.Contract(FLASH_ABI, contracts.FLASH)
  10. let rawTx = {
  11. from: deployer.address,
  12. nonce: await web3.eth.getTransactionCount(deployer.address),
  13. gasPrice: web3.utils.toWei('2', 'gwei'),
  14. gasLimit: 1e6
  15. }
  16. const WETH_USDT_POOL_CONTRACT = '0x4e68Ccd3E89f51C3074ca5072bbAC773960dFa36'
  17. await flash.methods
  18. .flashLoan({
  19. pool: WETH_USDT_POOL_CONTRACT,
  20. inToken0: true,
  21. outAmount: 1,
  22. inAmount: 1e10,
  23. sqrtPriceLimitX96: 0,
  24. inToken: contracts.WETH
  25. })
  26. .send(rawTx).then(console.log)
  27. })
  28. })