FlashTest.ts 884 B

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