0

我尝试使用标准 aave v2 flashloan 智能合约测试松露项目(没有任何套利操作)。这是来自 aave github https://github.com/aave/code-examples-protocol/tree/main/V2/Flash%20Loan%20-%20Batch的标准示例

    using SafeMath for uint256;
    constructor(ILendingPoolAddressesProvider _addressProvider)
        FlashLoanReceiverBase(_addressProvider)
    {}
    function executeOperation(
        address[] calldata assets,
        uint256[] calldata amounts,
        uint256[] calldata premiums,
        address initiator,
        bytes calldata params
    ) external override returns (bool) {
        for (uint256 i = 0; i < assets.length; i++) {
            uint256 amountOwing = amounts[i].add(premiums[i]);
            IERC20(assets[i]).approve(address(LENDING_POOL), amountOwing);
        }
        return true;
    }
    function myFlashLoanCall() public {
        address receiverAddress = address(this);
        address[] memory assets = new address[](7);
        uint256[] memory amounts = new uint256[](7); 
        uint256[] memory modes = new uint256[](7);
        address onBehalfOf = address(this);
        bytes memory params = "";
        uint16 referralCode = 0;

        LENDING_POOL.flashLoan(
            receiverAddress,
            assets,
            amounts,
            modes,
            onBehalfOf,
            params,
            referralCode
        );
    }
}

但是有一个错误:
“after each” hook: after test: ProviderError: json: cannot unmarshal number into Go struct field params.fromBlock of string 有什么问题?

这是 package.json

  "name": "120122",
  "version": "1.0.0",
  "description": "",
  "main": "truffle-config.js",
  "directories": {
    "test": "test"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@openzeppelin/contracts": "^4.4.2",
    "@truffle/hdwallet-provider": "^2.0.0",
    "web3": "^1.6.1"
  }
}

...这是松露配置

module.exports = {
  networks: {
    kovan: {
     networkCheckTimeout: 100000, 
      provider: function() {
        return new provider1('da2387a9631a8e188732dd4af90eb25293c93241a81fad3df02e419768abc330', "wss://kovan.infura.io/ws/v3/0d7018fd130743889a0f1ce2c46d9bb3");
      },
      network_id: 42
    }
  },
  mocha: {
  },
  compilers: {
    solc: {
      version: "^0.8.10",    // Fetch exact version from solc-bin (default: truffle's version)
      docker: false,        // Use "0.5.1" you've installed locally with docker (default: false)
  
    }
  },
  db: {
    enabled: false
  }
};
4

0 回答 0