Sfoglia il codice sorgente

数量对接正确,v3swap第一步对接完成。

skyfffire 3 anni fa
parent
commit
fe55f48fc5
3 ha cambiato i file con 6 aggiunte e 9 eliminazioni
  1. 1 1
      config/contracts.ts
  2. 2 3
      contracts/Flash.sol
  3. 3 5
      test/FlashTest.ts

+ 1 - 1
config/contracts.ts

@@ -7,5 +7,5 @@ export default {
   QUOTER: '0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6',
   ZERO: '0x0000000000000000000000000000000000000000',
   CALC: '0x30c34b111121aCDb423eF2C0e39235Dc68a793A4',
-  FLASH: '0x1f05Ac6791e10E6667FED65B903d2b1DA7c30281'
+  FLASH: '0x672746E54B6FB7Bf6748De46271b68B112B79a66'
 }

+ 2 - 3
contracts/Flash.sol

@@ -54,8 +54,7 @@ contract Flash is IUniswapV3SwapCallback {
     struct FlashLoanParams {
         address pool;
         bool inToken0;
-        int256 outAmount;
-        uint256 inAmount;
+        int256 inAmount;
         uint160 sqrtPriceLimitX96;
         address inToken;
     }
@@ -72,7 +71,7 @@ contract Flash is IUniswapV3SwapCallback {
         return pool.swap(
             address(this),
             params.inToken0,
-            params.outAmount,
+            params.inAmount,
             params.sqrtPriceLimitX96 == 0
                 ? (params.inToken0 ? TickMath.MIN_SQRT_RATIO + 1 : TickMath.MAX_SQRT_RATIO - 1)
                 : params.sqrtPriceLimitX96,

+ 3 - 5
test/FlashTest.ts

@@ -1,10 +1,9 @@
-import {ethers, web3} from "hardhat";
+import { web3 } from "hardhat";
 import contracts from "../config/contracts";
 import deployer from "../.secret";
-import fee from "../config/fee";
 
 describe('Flash test', () => {
-  let inAmount = 1e15.toString()
+  let inAmount = 1e10.toString()
 
   it('Flash swap test', async () => {
     const FLASH_ABI = require('../artifacts/contracts/Flash.sol/Flash.json').abi
@@ -23,8 +22,7 @@ describe('Flash test', () => {
       .flashLoan({
         pool: WETH_USDT_POOL_CONTRACT,
         inToken0: true,
-        outAmount: 1,
-        inAmount: 1e10,
+        inAmount: inAmount,
         sqrtPriceLimitX96: 0,
         inToken: contracts.WETH
       })