From 5516b27d7a067fda2244f91a2a129219d7322cd7 Mon Sep 17 00:00:00 2001 From: Chinmay Chougaonkar Date: Sun, 27 Feb 2022 09:32:51 +0530 Subject: [PATCH 01/20] add logic for compound import except flashloan related functions --- .../connectors/compound-import/events.sol | 5 + .../connectors/compound-import/helpers.sol | 41 ++ .../connectors/compound-import/interface.sol | 46 ++ .../connectors/compound-import/main.sol | 250 +++++++ yarn.lock | 685 +++++++++++++++--- 5 files changed, 941 insertions(+), 86 deletions(-) create mode 100644 contracts/mainnet/connectors/compound-import/events.sol create mode 100644 contracts/mainnet/connectors/compound-import/helpers.sol create mode 100644 contracts/mainnet/connectors/compound-import/interface.sol create mode 100644 contracts/mainnet/connectors/compound-import/main.sol diff --git a/contracts/mainnet/connectors/compound-import/events.sol b/contracts/mainnet/connectors/compound-import/events.sol new file mode 100644 index 00000000..cf2c0a6e --- /dev/null +++ b/contracts/mainnet/connectors/compound-import/events.sol @@ -0,0 +1,5 @@ +pragma solidity ^0.7.6; + +contract Events { + +} \ No newline at end of file diff --git a/contracts/mainnet/connectors/compound-import/helpers.sol b/contracts/mainnet/connectors/compound-import/helpers.sol new file mode 100644 index 00000000..c6042b9c --- /dev/null +++ b/contracts/mainnet/connectors/compound-import/helpers.sol @@ -0,0 +1,41 @@ +pragma solidity ^0.7.6; + +import { DSMath } from "../../common/math.sol"; +import { Basic } from "../../common/basic.sol"; +import { ComptrollerInterface, CompoundMappingInterface, CETHInterface } from "./interface.sol"; + +abstract contract Helpers is DSMath, Basic { + + /** + * @dev Compound CEth + */ + CETHInterface internal constant cEth = CETHInterface(0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5); + + /** + * @dev Compound Comptroller + */ + ComptrollerInterface internal constant troller = ComptrollerInterface(0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B); + + /** + * @dev Compound Mapping + */ + CompoundMappingInterface internal constant compMapping = CompoundMappingInterface(0xe7a85d0adDB972A4f0A4e57B698B37f171519e88); + + /** + * @dev enter compound market + */ + function enterMarket(address cToken) internal { + address[] memory markets = troller.getAssetsIn(address(this)); + bool isEntered = false; + for (uint i = 0; i < markets.length; i++) { + if (markets[i] == cToken) { + isEntered = true; + } + } + if (!isEntered) { + address[] memory toEnter = new address[](1); + toEnter[0] = cToken; + troller.enterMarkets(toEnter); + } + } +} \ No newline at end of file diff --git a/contracts/mainnet/connectors/compound-import/interface.sol b/contracts/mainnet/connectors/compound-import/interface.sol new file mode 100644 index 00000000..7a08c094 --- /dev/null +++ b/contracts/mainnet/connectors/compound-import/interface.sol @@ -0,0 +1,46 @@ +pragma solidity ^0.7.6; + +interface TokenInterface { + function balanceOf(address) external view returns (uint); + function allowance(address, address) external view returns (uint); + function approve(address, uint) external; + function transfer(address, uint) external returns (bool); + function transferFrom(address, address, uint) external returns (bool); +} + +interface CTokenInterface { + function mint(uint mintAmount) external returns (uint); + function redeem(uint redeemTokens) external returns (uint); + function borrow(uint borrowAmount) external returns (uint); + function repayBorrow(uint repayAmount) external returns (uint); + function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint); // For ERC20 + function liquidateBorrow(address borrower, uint repayAmount, address cTokenCollateral) external returns (uint); + + function borrowBalanceCurrent(address account) external returns (uint); + function redeemUnderlying(uint redeemAmount) external returns (uint); + function exchangeRateCurrent() external returns (uint); + + function balanceOf(address owner) external view returns (uint256 balance); + function transferFrom(address, address, uint) external returns (bool); + function allowance(address, address) external view returns (uint); + +} + +interface CETHInterface { + function mint() external payable; + function repayBorrow() external payable; + function repayBorrowBehalf(address borrower) external payable; + function liquidateBorrow(address borrower, address cTokenCollateral) external payable; +} + +interface ComptrollerInterface { + function enterMarkets(address[] calldata cTokens) external returns (uint[] memory); + function exitMarket(address cTokenAddress) external returns (uint); + function getAssetsIn(address account) external view returns (address[] memory); + function getAccountLiquidity(address account) external view returns (uint, uint, uint); +} + +interface CompoundMappingInterface { + function cTokenMapping(string calldata tokenId) external view returns (address); + function getMapping(string calldata tokenId) external view returns (address, address); +} diff --git a/contracts/mainnet/connectors/compound-import/main.sol b/contracts/mainnet/connectors/compound-import/main.sol new file mode 100644 index 00000000..456ed1f5 --- /dev/null +++ b/contracts/mainnet/connectors/compound-import/main.sol @@ -0,0 +1,250 @@ +pragma solidity ^0.7.6; +pragma experimental ABIEncoderV2; + +import { TokenInterface, AccountInterface } from "../../common/interfaces.sol"; +import { CTokenInterface } from "./interface.sol"; +import { Helpers } from "./helpers.sol"; +import { Events } from "./events.sol"; + +// 1. Get info for all the assets the user has supplied as collateral and the assets he borrowed. +// 2. Take the flash loan for all the borrowed assets. +// 3. Using this flash loan, pay back the user's debt in the EOA account. +// 4. After paying the debt, transfer the user's tokens from EOA to DSA. +// 5. Then borrow debt of same tokens but include flash loan fee in it. +// 6. Payback the flash loan for all the tokens. + +// fill logics in contract functions +contract FlashLoanHelper is Helpers, Events { + function _flashLoan( + address[] memory _tokens, + uint256[] memory _amts + ) internal { + // fill in logic for flash loans + } + + function _repayFlashLoan( + address[] memory _tokens, + uint256[] memory _amts + ) internal { + // fill in logic for flash loan repayment + } +} + +contract CompoundResolver is Helpers, Events { + function _repayUserDebt( + address _userAccount, + CTokenInterface[] memory _cTokenContracts, + uint[] memory _borrowAmts + ) internal { + for(uint i = 0; i < _cTokenContracts.length; i++){ + if(_borrowAmts[i] > 0){ + if(address(_cTokenContracts[i]) == address(cEth)){ + cEth.repayBorrowBehalf{value: _borrowAmts[i]}(_userAccount); + } + else{ + require(_cTokenContracts[i].repayBorrowBehalf(_userAccount, _borrowAmts[i]) == 0, "repayOnBehalf-failed"); + } + } + } + } + + function _transferTokensToDsa( + address _userAccount, + CTokenInterface[] memory _cTokenContracts, + uint[] memory _amts + ) internal { + for(uint i = 0; i < _cTokenContracts.length; i++) { + if(_amts[i] > 0) { + require(_cTokenContracts[i].transferFrom(_userAccount, address(this), _amts[i]), "ctoken-transfer-failed-allowance?"); + } + } + } + + function _borrowDebtPosition( + CTokenInterface[] memory _ctokenContracts, + uint[] memory _amts + ) internal { + for (uint i = 0; i < _ctokenContracts.length; i++) { + if (_amts[i] > 0) { + // add _amts flash loan fees to _amts[i] + require(_ctokenContracts[i].borrow(_amts[i]) == 0, "borrow-failed-collateral?"); + } + } + } +} + +contract CompoundHelpers is CompoundResolver { + struct ImportData { + address[] cTokens; // is the list of all tokens the user has interacted with (supply/borrow) -> used to enter markets + uint[] borrowAmts; + uint[] supplyAmts; + address[] borrowTokens; + address[] supplyTokens; + CTokenInterface[] borrowCtokens; + CTokenInterface[] supplyCtokens; + address[] supplyCtokensAddr; + address[] borrowCtokensAddr; + } + + struct ImportInputData { + address userAccount; + string[] supplyIds; + string[] borrowIds; + } + + function getBorrowAmounts ( + ImportInputData memory _importInputData, + ImportData memory data + ) internal returns(ImportData memory) { + if (_importInputData.borrowIds.length > 0) { + // initialize arrays for borrow data + data.borrowTokens = new address[](_importInputData.borrowIds.length); + data.borrowCtokens = new CTokenInterface[](_importInputData.borrowIds.length); + data.borrowCtokensAddr = new address[](_importInputData.borrowIds.length); + data.borrowAmts = new uint[](_importInputData.borrowIds.length); + + // check for repeated tokens + for (uint i = 0; i < _importInputData.borrowIds.length; i++) { + bytes32 i_hash = keccak256(abi.encode(_importInputData.borrowIds[i])); + for (uint j = i + 1; j < _importInputData.borrowIds.length; j++) { + bytes32 j_hash = keccak256(abi.encode(_importInputData.borrowIds[j])); + require(i_hash != j_hash, "token-repeated"); + } + } + + // populate the arrays with borrow tokens, cToken addresses and instances, and borrow amounts + for (uint i = 0; i < _importInputData.borrowIds.length; i++) { + (address _token, address _cToken) = compMapping.getMapping(_importInputData.borrowIds[i]); + + require(_token != address(0) && _cToken != address(0), "ctoken mapping not found"); + + data.cTokens[i] = _cToken; + + data.borrowTokens[i] = _token; + data.borrowCtokens[i] = CTokenInterface(_cToken); + data.borrowCtokensAddr[i] = _cToken; + data.borrowAmts[i] = data.borrowCtokens[i].borrowBalanceCurrent(_importInputData.userAccount); + + // give the resp. cToken address approval to spend tokens + if (_token != ethAddr && data.borrowAmts[i] > 0) { + // will be required when repaying the borrow amount on behalf of the user + TokenInterface(_token).approve(_cToken, data.borrowAmts[i]); + } + } + } + return data; + } + + function getSupplyAmounts ( + ImportInputData memory _importInputData, + ImportData memory data + ) internal view returns(ImportData memory) { + // initialize arrays for supply data + data.supplyTokens = new address[](_importInputData.supplyIds.length); + data.supplyCtokens = new CTokenInterface[](_importInputData.supplyIds.length); + data.supplyCtokensAddr = new address[](_importInputData.supplyIds.length); + data.supplyAmts = new uint[](_importInputData.supplyIds.length); + + // check for repeated tokens + for (uint i = 0; i < _importInputData.supplyIds.length; i++) { + bytes32 i_hash = keccak256(abi.encode(_importInputData.supplyIds[i])); + for (uint j = i + 1; j < _importInputData.supplyIds.length; j++) { + bytes32 j_hash = keccak256(abi.encode(_importInputData.supplyIds[j])); + require(i_hash != j_hash, "token-repeated"); + } + } + + // populate arrays with supply data (supply tokens address, cToken addresses, cToken instances and supply amounts) + for (uint i = 0; i < _importInputData.supplyIds.length; i++) { + (address _token, address _cToken) = compMapping.getMapping(_importInputData.supplyIds[i]); + + require(_token != address(0) && _cToken != address(0), "ctoken mapping not found"); + + uint _supplyIndex = add(i, _importInputData.borrowIds.length); + data.cTokens[_supplyIndex] = _cToken; + + data.supplyTokens[i] = _token; + data.supplyCtokens[i] = CTokenInterface(_cToken); + data.supplyCtokensAddr[i] = (_cToken); + data.supplyAmts[i] = data.supplyCtokens[i].balanceOf(_importInputData.userAccount); + } + return data; + } +} + +contract CompoundImportResolver is CompoundHelpers, FlashLoanHelper { + + // get info for all the assets the user has supplied as collateral and the assets borrowed + function _importCompound( + ImportInputData memory importInputData + ) internal returns (string memory _eventName, bytes memory _eventParam) { + require(AccountInterface(address(this)).isAuth(importInputData.userAccount), "user-account-not-auth"); + + require(importInputData.supplyIds.length > 0, "0-length-not-allowed"); + + ImportData memory data; + + uint _length = add(importInputData.supplyIds.length, importInputData.borrowIds.length); + data.cTokens = new address[](_length); + + data = getBorrowAmounts(importInputData, data); + data = getSupplyAmounts(importInputData, data); + + for(uint i = 0; i < data.cTokens.length; i++){ + enterMarket(data.cTokens[i]); + } + + // take flash loan for all the borrowed assets + // use the addresses of the borrowed tokens and their amounts to get the same flash loans + _flashLoan(data.borrowTokens, data.borrowAmts); + + // pay back user's debt using flash loan funds + _repayUserDebt(importInputData.userAccount, data.borrowCtokens, data.borrowAmts); + + // transfer user's tokens to DSA + _transferTokensToDsa(importInputData.userAccount, data.supplyCtokens, data.supplyAmts); + + // borrow the earlier position from Compound with flash loan fee added + _borrowDebtPosition(data.borrowCtokens, data.borrowAmts); + + // payback flash loan + _repayFlashLoan(data.borrowTokens, data.borrowAmts); // update borrowAmounts with flash loan fee + + _eventName = "LogCompoundImport(address,address[],string[],string[],uint256[],uint256[])"; + _eventParam = abi.encode( + importInputData.userAccount, + data.cTokens, + importInputData.supplyIds, + importInputData.borrowIds, + data.supplyAmts, + data.borrowAmts + ); + } + + function importCompound( + address userAccount, + string[] memory supplyIds, + string[] memory borrowIds + ) external payable returns (string memory _eventName, bytes memory _eventParam) { + ImportInputData memory inputData = ImportInputData({ + userAccount: userAccount, + supplyIds: supplyIds, + borrowIds: borrowIds + }); + + (_eventName, _eventParam) = _importCompound(inputData); + } + + function migrateCompound( + string[] memory supplyIds, + string[] memory borrowIds + ) external payable returns (string memory _eventName, bytes memory _eventParam) { + ImportInputData memory inputData = ImportInputData({ + userAccount: msg.sender, + supplyIds: supplyIds, + borrowIds: borrowIds + }); + + (_eventName, _eventParam) = _importCompound(inputData); + } +} diff --git a/yarn.lock b/yarn.lock index ecf0f61b..c636f51d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -30,6 +30,11 @@ dependencies: "regenerator-runtime" "^0.13.4" +"@bitauth/libauth@^1.17.1": + "integrity" "sha512-UtfCijrCcPCQdstlxiv29hBNuYs/1hqeDMgS6CPjxps7r7/y/0p9TRGDx65fczlO12Pa5rQdWO/GzwsXo03uIg==" + "resolved" "https://registry.npmjs.org/@bitauth/libauth/-/libauth-1.19.0.tgz" + "version" "1.19.0" + "@cspotcode/source-map-consumer@0.8.0": "integrity" "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==" "resolved" "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz" @@ -221,22 +226,7 @@ "rustbn.js" "~0.2.0" "util.promisify" "^1.0.1" -"@ethersproject/abi@^5.0.0", "@ethersproject/abi@^5.0.1", "@ethersproject/abi@^5.1.2", "@ethersproject/abi@^5.4.0": - "integrity" "sha512-9gU2H+/yK1j2eVMdzm6xvHSnMxk8waIHQGYCZg5uvAyH0rsAzxkModzBSpbAkAuhKFEovC2S9hM4nPuLym8IZw==" - "resolved" "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.4.0.tgz" - "version" "5.4.0" - dependencies: - "@ethersproject/address" "^5.4.0" - "@ethersproject/bignumber" "^5.4.0" - "@ethersproject/bytes" "^5.4.0" - "@ethersproject/constants" "^5.4.0" - "@ethersproject/hash" "^5.4.0" - "@ethersproject/keccak256" "^5.4.0" - "@ethersproject/logger" "^5.4.0" - "@ethersproject/properties" "^5.4.0" - "@ethersproject/strings" "^5.4.0" - -"@ethersproject/abi@^5.5.0": +"@ethersproject/abi@^5.0.0", "@ethersproject/abi@^5.0.1", "@ethersproject/abi@^5.0.12", "@ethersproject/abi@^5.1.2", "@ethersproject/abi@^5.4.0", "@ethersproject/abi@^5.5.0", "@ethersproject/abi@5.5.0": "integrity" "sha512-loW7I4AohP5KycATvc0MgujU6JyCHPqHdeoo9z3Nr9xEiNioxa65ccdm1+fsoJhkuhdRtfcL8cfyGamz2AxZ5w==" "resolved" "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.5.0.tgz" "version" "5.5.0" @@ -279,21 +269,6 @@ "@ethersproject/properties" "^5.0.3" "@ethersproject/strings" "^5.0.4" -"@ethersproject/abi@5.5.0": - "integrity" "sha512-loW7I4AohP5KycATvc0MgujU6JyCHPqHdeoo9z3Nr9xEiNioxa65ccdm1+fsoJhkuhdRtfcL8cfyGamz2AxZ5w==" - "resolved" "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.5.0.tgz" - "version" "5.5.0" - dependencies: - "@ethersproject/address" "^5.5.0" - "@ethersproject/bignumber" "^5.5.0" - "@ethersproject/bytes" "^5.5.0" - "@ethersproject/constants" "^5.5.0" - "@ethersproject/hash" "^5.5.0" - "@ethersproject/keccak256" "^5.5.0" - "@ethersproject/logger" "^5.5.0" - "@ethersproject/properties" "^5.5.0" - "@ethersproject/strings" "^5.5.0" - "@ethersproject/abstract-provider@^5.0.8": "version" "5.0.8" dependencies: @@ -338,7 +313,7 @@ "@ethersproject/logger" "^5.5.0" "@ethersproject/properties" "^5.5.0" -"@ethersproject/address@^5.0.2", "@ethersproject/address@^5.0.4", "@ethersproject/address@^5.4.0", "@ethersproject/address@^5.5.0", "@ethersproject/address@5.5.0": +"@ethersproject/address@^5.0.0", "@ethersproject/address@^5.0.2", "@ethersproject/address@^5.0.4", "@ethersproject/address@^5.4.0", "@ethersproject/address@^5.5.0", "@ethersproject/address@5.5.0": "integrity" "sha512-l4Nj0eWlTUh6ro5IbPTgbpT4wRbdH5l8CQf7icF7sb/SI3Nhd9Y9HzhonTSTi6CefI0necIw7LJqQPopPLZyWw==" "resolved" "https://registry.npmjs.org/@ethersproject/address/-/address-5.5.0.tgz" "version" "5.5.0" @@ -385,7 +360,7 @@ "@ethersproject/logger" "^5.0.8" "bn.js" "^4.4.0" -"@ethersproject/bignumber@^5.0.7", "@ethersproject/bignumber@^5.4.0", "@ethersproject/bignumber@^5.4.1", "@ethersproject/bignumber@^5.5.0", "@ethersproject/bignumber@5.5.0": +"@ethersproject/bignumber@^5.0.7", "@ethersproject/bignumber@^5.1.1", "@ethersproject/bignumber@^5.4.1", "@ethersproject/bignumber@^5.5.0", "@ethersproject/bignumber@5.5.0": "integrity" "sha512-6Xytlwvy6Rn3U3gKEc1vP7nR92frHkv6wtVr95LFR3jREXiCPzdWxKQ1cx4JGQBXxcguAwjA8murlYN2TSiEbg==" "resolved" "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.5.0.tgz" "version" "5.5.0" @@ -446,7 +421,7 @@ optionalDependencies: "@ledgerhq/hw-transport-node-hid" "5.26.0" -"@ethersproject/hash@^5.0.4", "@ethersproject/hash@^5.4.0", "@ethersproject/hash@^5.5.0", "@ethersproject/hash@5.5.0": +"@ethersproject/hash@^5.0.4", "@ethersproject/hash@^5.5.0", "@ethersproject/hash@5.5.0": "integrity" "sha512-dnGVpK1WtBjmnp3mUT0PlU2MpapnwWI0PibldQEq1408tQBAbZpPidkWoVVuNMOl/lISO3+4hXZWCL3YV7qzfg==" "resolved" "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.5.0.tgz" "version" "5.5.0" @@ -509,7 +484,7 @@ "aes-js" "3.0.0" "scrypt-js" "3.0.1" -"@ethersproject/keccak256@^5.0.3", "@ethersproject/keccak256@^5.4.0", "@ethersproject/keccak256@^5.5.0", "@ethersproject/keccak256@5.5.0": +"@ethersproject/keccak256@^5.0.3", "@ethersproject/keccak256@^5.5.0", "@ethersproject/keccak256@5.5.0": "integrity" "sha512-5VoFCTjo2rYbBe1l2f4mccaRFN/4VQEYFwwn04aJV2h7qf4ZvI2wFxUE1XOX+snbwCLRzIeikOqtAoPwMza9kg==" "resolved" "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.5.0.tgz" "version" "5.5.0" @@ -523,7 +498,7 @@ "@ethersproject/bytes" "^5.0.9" "js-sha3" "0.5.7" -"@ethersproject/logger@^5.0.5", "@ethersproject/logger@^5.4.0", "@ethersproject/logger@^5.5.0", "@ethersproject/logger@5.5.0": +"@ethersproject/logger@^5.0.5", "@ethersproject/logger@^5.5.0", "@ethersproject/logger@5.5.0": "integrity" "sha512-rIY/6WPm7T8n3qS2vuHTUBPdXHl+rGxWxW5okDfo9J4Z0+gRRZT0msvUdIJkE4/HS29GUMziwGaaKO2bWONBrg==" "resolved" "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.5.0.tgz" "version" "5.5.0" @@ -551,7 +526,7 @@ "@ethersproject/bytes" "^5.5.0" "@ethersproject/sha2" "^5.5.0" -"@ethersproject/properties@^5.0.3", "@ethersproject/properties@^5.4.0", "@ethersproject/properties@^5.5.0", "@ethersproject/properties@5.5.0": +"@ethersproject/properties@^5.0.3", "@ethersproject/properties@^5.5.0", "@ethersproject/properties@5.5.0": "integrity" "sha512-l3zRQg3JkD8EL3CPjNK5g7kMx4qSwiR60/uk5IVjd3oq1MZR5qUg40CNOoEJoX5wc3DyY5bt9EbMk86C7x0DNA==" "resolved" "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.5.0.tgz" "version" "5.5.0" @@ -639,7 +614,7 @@ "elliptic" "6.5.4" "hash.js" "1.1.7" -"@ethersproject/solidity@^5.4.0", "@ethersproject/solidity@5.5.0": +"@ethersproject/solidity@^5.0.0", "@ethersproject/solidity@^5.0.9", "@ethersproject/solidity@^5.4.0", "@ethersproject/solidity@5.5.0": "integrity" "sha512-9NgZs9LhGMj6aCtHXhtmFQ4AN4sth5HuFXVvAQtzmm0jpSCNOTGtrHZJAeYTh7MBjRR8brylWZxBZR9zDStXbw==" "resolved" "https://registry.npmjs.org/@ethersproject/solidity/-/solidity-5.5.0.tgz" "version" "5.5.0" @@ -651,7 +626,7 @@ "@ethersproject/sha2" "^5.5.0" "@ethersproject/strings" "^5.5.0" -"@ethersproject/strings@^5.0.4", "@ethersproject/strings@^5.4.0", "@ethersproject/strings@^5.5.0", "@ethersproject/strings@5.5.0": +"@ethersproject/strings@^5.0.4", "@ethersproject/strings@^5.5.0", "@ethersproject/strings@5.5.0": "integrity" "sha512-9fy3TtF5LrX/wTrBaT8FGE6TDJyVjOvXynXJz5MT5azq+E6D92zuKNx7i29sWW2FjVOaWjAsiZ1ZWznuduTIIQ==" "resolved" "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.5.0.tgz" "version" "5.5.0" @@ -901,6 +876,71 @@ dependencies: "@types/bignumber.js" "^5.0.0" +"@oclif/command@^1.8.0": + "integrity" "sha512-rmVKYEsKzurfRU0xJz+iHelbi1LGlihIWZ7Qvmb/CBz1EkhL7nOkW4SVXmG2dA5Ce0si2gr88i6q4eBOMRNJ1w==" + "resolved" "https://registry.npmjs.org/@oclif/command/-/command-1.8.16.tgz" + "version" "1.8.16" + dependencies: + "@oclif/config" "^1.18.2" + "@oclif/errors" "^1.3.5" + "@oclif/help" "^1.0.1" + "@oclif/parser" "^3.8.6" + "debug" "^4.1.1" + "semver" "^7.3.2" + +"@oclif/config@^1.18.2", "@oclif/config@1.18.2": + "integrity" "sha512-cE3qfHWv8hGRCP31j7fIS7BfCflm/BNZ2HNqHexH+fDrdF2f1D5S8VmXWLC77ffv3oDvWyvE9AZeR0RfmHCCaA==" + "resolved" "https://registry.npmjs.org/@oclif/config/-/config-1.18.2.tgz" + "version" "1.18.2" + dependencies: + "@oclif/errors" "^1.3.3" + "@oclif/parser" "^3.8.0" + "debug" "^4.1.1" + "globby" "^11.0.1" + "is-wsl" "^2.1.1" + "tslib" "^2.0.0" + +"@oclif/errors@^1.2.2", "@oclif/errors@^1.3.3", "@oclif/errors@^1.3.5", "@oclif/errors@1.3.5": + "integrity" "sha512-OivucXPH/eLLlOT7FkCMoZXiaVYf8I/w1eTAM1+gKzfhALwWTusxEx7wBmW0uzvkSg/9ovWLycPaBgJbM3LOCQ==" + "resolved" "https://registry.npmjs.org/@oclif/errors/-/errors-1.3.5.tgz" + "version" "1.3.5" + dependencies: + "clean-stack" "^3.0.0" + "fs-extra" "^8.1" + "indent-string" "^4.0.0" + "strip-ansi" "^6.0.0" + "wrap-ansi" "^7.0.0" + +"@oclif/help@^1.0.1": + "integrity" "sha512-8rsl4RHL5+vBUAKBL6PFI3mj58hjPCp2VYyXD4TAa7IMStikFfOH2gtWmqLzIlxAED2EpD0dfYwo9JJxYsH7Aw==" + "resolved" "https://registry.npmjs.org/@oclif/help/-/help-1.0.1.tgz" + "version" "1.0.1" + dependencies: + "@oclif/config" "1.18.2" + "@oclif/errors" "1.3.5" + "chalk" "^4.1.2" + "indent-string" "^4.0.0" + "lodash" "^4.17.21" + "string-width" "^4.2.0" + "strip-ansi" "^6.0.0" + "widest-line" "^3.1.0" + "wrap-ansi" "^6.2.0" + +"@oclif/linewrap@^1.0.0": + "integrity" "sha512-Ups2dShK52xXa8w6iBWLgcjPJWjais6KPJQq3gQ/88AY6BXoTX+MIGFPrWQO1KLMiQfoTpcLnUwloN4brrVUHw==" + "resolved" "https://registry.npmjs.org/@oclif/linewrap/-/linewrap-1.0.0.tgz" + "version" "1.0.0" + +"@oclif/parser@^3.8.0", "@oclif/parser@^3.8.6": + "integrity" "sha512-tXb0NKgSgNxmf6baN6naK+CCwOueaFk93FG9u202U7mTBHUKsioOUlw1SG/iPi9aJM3WE4pHLXmty59pci0OEw==" + "resolved" "https://registry.npmjs.org/@oclif/parser/-/parser-3.8.6.tgz" + "version" "3.8.6" + dependencies: + "@oclif/errors" "^1.2.2" + "@oclif/linewrap" "^1.0.0" + "chalk" "^4.1.0" + "tslib" "^2.0.0" + "@openzeppelin/contract-loader@^0.6.2": "integrity" "sha512-/P8v8ZFVwK+Z7rHQH2N3hqzEmTzLFjhMtvNK4FeIak6DEeONZ92vdFaFb10CCCQtp390Rp/Y57Rtfrm50bUdMQ==" "resolved" "https://registry.npmjs.org/@openzeppelin/contract-loader/-/contract-loader-0.6.2.tgz" @@ -1057,10 +1097,10 @@ dependencies: "type-detect" "4.0.8" -"@sinonjs/fake-timers@^7.0.4": - "integrity" "sha512-fUt6b15bjV/VW93UP5opNXJxdwZSbK1EdiwnhN7XrQrcpaOhMJpZ/CjwFpM3THpxwA+YviBUJKSuEqKlCK5alw==" - "resolved" "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-7.0.5.tgz" - "version" "7.0.5" +"@sinonjs/fake-timers@^7.1.0": + "integrity" "sha512-iQADsW4LBMISqZ6Ci1dupJL9pprqwcVFTcOsEmQOEhW+KLCVn/Y4Jrvg2k19fIHCp+iFprriYPTdRcQR8NbUPg==" + "resolved" "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-7.1.2.tgz" + "version" "7.1.2" dependencies: "@sinonjs/commons" "^1.7.0" @@ -1271,6 +1311,18 @@ "resolved" "https://registry.npmjs.org/@types/abstract-leveldown/-/abstract-leveldown-5.0.2.tgz" "version" "5.0.2" +"@types/async-retry@^1.4.2": + "integrity" "sha512-B3C9QmmNULVPL2uSJQ088eGWTNPIeUk35hca6CV8rRDJ8GXuQJP5CCVWA1ZUCrb9xYP7Js/RkLqnNNwKhe+Zsw==" + "resolved" "https://registry.npmjs.org/@types/async-retry/-/async-retry-1.4.3.tgz" + "version" "1.4.3" + dependencies: + "@types/retry" "*" + +"@types/await-timeout@^0.3.1": + "integrity" "sha512-H5PzROT4KuP7XQDua13Iw8did//OCKAZ/3TL15DjvMzDonrk4HvhH1+tLko96f2guU6XaD3AoqRa49ZOwbwNig==" + "resolved" "https://registry.npmjs.org/@types/await-timeout/-/await-timeout-0.3.1.tgz" + "version" "0.3.1" + "@types/bignumber.js@^5.0.0": "integrity" "sha512-0DH7aPGCClywOFaxxjE6UwpN2kQYe9LwuDQMv+zYA97j5GkOMo8e66LYT+a8JYU7jfmUFRZLa9KycxHDsKXJCA==" "resolved" "https://registry.npmjs.org/@types/bignumber.js/-/bignumber.js-5.0.0.tgz" @@ -1292,6 +1344,20 @@ dependencies: "@types/node" "*" +"@types/bunyan-blackhole@^0.2.2": + "integrity" "sha512-nbuxFn2FVw1AAT1h6shgluwz1cgpLKaMBYbEZcMU69Jb1UvSsXcwRiIg+FP4+/JjEUp/uPYLC+twWpfCAaVN1g==" + "resolved" "https://registry.npmjs.org/@types/bunyan-blackhole/-/bunyan-blackhole-0.2.2.tgz" + "version" "0.2.2" + dependencies: + "@types/bunyan" "*" + +"@types/bunyan@*", "@types/bunyan@^1.8.6": + "integrity" "sha512-Cblq+Yydg3u+sGiz2mjHjC5MPmdjY+No4qvHrF+BUhblsmSfMvsHLbOG62tPbonsqBj6sbWv1LHcsoe5Jw+/Ow==" + "resolved" "https://registry.npmjs.org/@types/bunyan/-/bunyan-1.8.8.tgz" + "version" "1.8.8" + dependencies: + "@types/node" "*" + "@types/chai-as-promised@^7.1.4": "integrity" "sha512-1y3L1cHePcIm5vXkh1DSGf/zQq5n5xDKG1fpCvf18+uOkpce0Z1ozNFPkyWsVswK7ntN1sZBw3oU6gmN+pDUcA==" "resolved" "https://registry.npmjs.org/@types/chai-as-promised/-/chai-as-promised-7.1.4.tgz" @@ -1334,6 +1400,11 @@ "@types/level-errors" "*" "@types/node" "*" +"@types/lodash@^4.14.168": + "integrity" "sha512-0d5Wd09ItQWH1qFbEyQ7oTQ3GZrMfth5JkbN3EvTKLXcHLRDSXeLnlvlOn0wvxVIwK5o2M8JzP/OWz7T3NRsbw==" + "resolved" "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.178.tgz" + "version" "4.14.178" + "@types/lru-cache@^5.1.0": "integrity" "sha512-RaE0B+14ToE4l6UqdarKPnXwVDuigfFv+5j9Dze/Nqr23yyuqdNvzcZi3xB+3Agvi5R4EOgAksfv3lXX4vBt9w==" "resolved" "https://registry.npmjs.org/@types/lru-cache/-/lru-cache-5.1.0.tgz" @@ -1374,6 +1445,11 @@ "resolved" "https://registry.npmjs.org/@types/node/-/node-12.20.36.tgz" "version" "12.20.36" +"@types/node@12.12.54": + "integrity" "sha512-ge4xZ3vSBornVYlDnk7yZ0gK6ChHf/CHB7Gl1I0Jhah8DDnEQqBzgohYG4FX4p81TNirSETOiSyn+y1r9/IR6w==" + "resolved" "https://registry.npmjs.org/@types/node/-/node-12.12.54.tgz" + "version" "12.12.54" + "@types/pbkdf2@^3.0.0": "integrity" "sha512-Cf63Rv7jCQ0LaL8tNXmEyqTHuIJxRdlS5vMh1mj5voN4+QFhVZnlZruezqpWYDiJ8UTzhP0VmeLXCmBk66YrMQ==" "resolved" "https://registry.npmjs.org/@types/pbkdf2/-/pbkdf2-3.1.0.tgz" @@ -1398,6 +1474,11 @@ dependencies: "@types/node" "*" +"@types/retry@*": + "integrity" "sha512-xoDlM2S4ortawSWORYqsdU+2rxdh4LRW9ytc3zmT37RIKQh6IHyKwwtKhKis9ah8ol07DCkZxPt8BBvPjC6v4g==" + "resolved" "https://registry.npmjs.org/@types/retry/-/retry-0.12.1.tgz" + "version" "0.12.1" + "@types/secp256k1@^4.0.1": "integrity" "sha512-+ZjSA8ELlOp8SlKi0YLB2tz9d5iPNEmOBd+8Rz21wTMdaXQIa9b6TEnD6l5qKOCypE7FSyPyck12qZJxSDNoog==" "resolved" "https://registry.npmjs.org/@types/secp256k1/-/secp256k1-4.0.1.tgz" @@ -1413,12 +1494,17 @@ "@types/chai" "*" "@types/sinon" "*" -"@types/sinon@*": - "integrity" "sha512-jDZ55oCKxqlDmoTBBbBBEx+N8ZraUVhggMZ9T5t+6/Dh8/4NiOjSUfpLrPiEwxQDlAe3wpAkoXhWvE6LibtsMQ==" - "resolved" "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.0.tgz" - "version" "10.0.0" +"@types/sinon@*", "@types/sinon@^10.0.2": + "integrity" "sha512-6EF+wzMWvBNeGrfP3Nx60hhx+FfwSg1JJBLAAP/IdIUq0EYkqCYf70VT3PhuhPX9eLD+Dp+lNdpb/ZeHG8Yezg==" + "resolved" "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.6.tgz" + "version" "10.0.6" dependencies: - "@sinonjs/fake-timers" "^7.0.4" + "@sinonjs/fake-timers" "^7.1.0" + +"@types/stats-lite@^2.2.0": + "integrity" "sha512-YV6SS4QC+pbzqjMIV8qVSTDOOazgKBLTVaN+7PfuxELjz/eyzc20KwDVGPrbHt2OcYMA7K2ezLB45Cp6DpNOSQ==" + "resolved" "https://registry.npmjs.org/@types/stats-lite/-/stats-lite-2.2.0.tgz" + "version" "2.2.0" "@types/through@*": "integrity" "sha512-FvnCJljyxhPM3gkRgWmxmDZyAQSiBQQWLI0A0VFL0K7W1oRUrPJSqNO0NvTnLkBcotdlp3lKvaT0JrnyRDkzOg==" @@ -1440,22 +1526,138 @@ "@types/bn.js" "*" "@types/underscore" "*" +"@uniswap/default-token-list@^2.0.0": + "integrity" "sha512-yfd4snv9K20tEbNwy9Vjym41RU3Yb2lN0seKxsgkr+m3f6oub2lWyXfTiNwgGFbOQPDvX4dxjMhA+M+S7mxqKg==" + "resolved" "https://registry.npmjs.org/@uniswap/default-token-list/-/default-token-list-2.3.0.tgz" + "version" "2.3.0" + "@uniswap/lib@^4.0.1-alpha": "integrity" "sha512-f6UIliwBbRsgVLxIaBANF6w09tYqc6Y/qXdsrbEmXHyFA7ILiKrIwRFXe1yOg8M3cksgVsO9N7yuL2DdCGQKBA==" "resolved" "https://registry.npmjs.org/@uniswap/lib/-/lib-4.0.1-alpha.tgz" "version" "4.0.1-alpha" -"@uniswap/v2-core@1.0.1": +"@uniswap/lib@1.1.1": + "integrity" "sha512-2yK7sLpKIT91TiS5sewHtOa7YuM8IuBXVl4GZv2jZFys4D2sY7K5vZh6MqD25TPA95Od+0YzCVq6cTF2IKrOmg==" + "resolved" "https://registry.npmjs.org/@uniswap/lib/-/lib-1.1.1.tgz" + "version" "1.1.1" + +"@uniswap/router-sdk@^1.0.5": + "integrity" "sha512-PA/0Ye9u3U5cm/LHrJuOgVSff6W4oFY3h+MUEzdp80SYIQdZZJ+BV06RL0h5KOSH+tuIX72n/qNusuRcf2Tc8Q==" + "resolved" "https://registry.npmjs.org/@uniswap/router-sdk/-/router-sdk-1.0.5.tgz" + "version" "1.0.5" + dependencies: + "@ethersproject/abi" "^5.5.0" + "@uniswap/sdk-core" "^3.0.1" + "@uniswap/swap-router-contracts" "1.1.0" + "@uniswap/v2-sdk" "^3.0.1" + "@uniswap/v3-sdk" "^3.7.1" + +"@uniswap/sdk-core@^3.0.0-alpha.3", "@uniswap/sdk-core@^3.0.1": + "integrity" "sha512-WbeDkhZ9myVR0VnHOdTrb8nHKKkqTFa5uE9RvUbG3eyDt2NWWDwhhqGHwAWJEHG405l30Fa1u3PogHDFsIOQlA==" + "resolved" "https://registry.npmjs.org/@uniswap/sdk-core/-/sdk-core-3.0.1.tgz" + "version" "3.0.1" + dependencies: + "@ethersproject/address" "^5.0.2" + "big.js" "^5.2.2" + "decimal.js-light" "^2.5.0" + "jsbi" "^3.1.4" + "tiny-invariant" "^1.1.0" + "toformat" "^2.0.0" + +"@uniswap/smart-order-router@^2.5.12": + "integrity" "sha512-4F0HzyT436XVxOyndBqZu9IK15+gCCg+rH5X80+XW/bdHrJrKN1WfN44NlnjPCee2fKjEiU2AAhEMqVdD2I2gw==" + "resolved" "https://registry.npmjs.org/@uniswap/smart-order-router/-/smart-order-router-2.5.12.tgz" + "version" "2.5.12" + dependencies: + "@bitauth/libauth" "^1.17.1" + "@ethersproject/bignumber" "^5.1.1" + "@oclif/command" "^1.8.0" + "@oclif/errors" "^1.3.5" + "@types/async-retry" "^1.4.2" + "@types/await-timeout" "^0.3.1" + "@types/bunyan" "^1.8.6" + "@types/bunyan-blackhole" "^0.2.2" + "@types/lodash" "^4.14.168" + "@types/sinon" "^10.0.2" + "@types/stats-lite" "^2.2.0" + "@uniswap/default-token-list" "^2.0.0" + "@uniswap/router-sdk" "^1.0.5" + "@uniswap/swap-router-contracts" "1.1.0" + "@uniswap/token-lists" "^1.0.0-beta.25" + "@uniswap/v2-core" "^1.0.1" + "@uniswap/v2-periphery" "^1.1.0-beta.0" + "@uniswap/v2-sdk" "^3.0.1" + "@uniswap/v3-periphery" "^1.1.1" + "@uniswap/v3-sdk" "^3.7.0" + "async-retry" "^1.3.1" + "await-timeout" "^1.1.1" + "axios" "^0.21.1" + "bunyan" "^1.8.15" + "bunyan-blackhole" "^1.1.1" + "bunyan-debug-stream" "^2.0.0" + "cli-logger" "^0.5.40" + "dotenv" "^10.0.0" + "ethereum-types" "^3.5.0" + "ethers" "^5.1.4" + "graphql" "^15.5.0" + "graphql-request" "^3.4.0" + "lodash" "^4.17.21" + "mnemonist" "^0.38.3" + "node-cache" "^5.1.2" + "stats-lite" "^2.2.0" + "tslib" "^1.14.1" + +"@uniswap/swap-router-contracts@1.1.0": + "integrity" "sha512-GPmpx1lvjXWloB95+YUabr3UHJYr3scnSS8EzaNXnNrIz9nYZ+XQcMaJxOKe85Yi7IfcUQpj0HzD2TW99dtolA==" + "resolved" "https://registry.npmjs.org/@uniswap/swap-router-contracts/-/swap-router-contracts-1.1.0.tgz" + "version" "1.1.0" + dependencies: + "@openzeppelin/contracts" "3.4.1-solc-0.7-2" + "@uniswap/v2-core" "1.0.1" + "@uniswap/v3-core" "1.0.0" + "@uniswap/v3-periphery" "1.3.0" + "hardhat-watcher" "^2.1.1" + +"@uniswap/token-lists@^1.0.0-beta.25": + "integrity" "sha512-x5hmIniQ9TGqOBCRqfWcmZi/U5kB0qrHMDQ9igs3nMbK0wwmYLraL4owbIwXFGR/co6/lJYJC4K/Gjn4wZY5mQ==" + "resolved" "https://registry.npmjs.org/@uniswap/token-lists/-/token-lists-1.0.0-beta.27.tgz" + "version" "1.0.0-beta.27" + +"@uniswap/v2-core@^1.0.1", "@uniswap/v2-core@1.0.1": "integrity" "sha512-MtybtkUPSyysqLY2U210NBDeCHX+ltHt3oADGdjqoThZaFRDKwM6k1Nb3F0A3hk5hwuQvytFWhrWHOEq6nVJ8Q==" "resolved" "https://registry.npmjs.org/@uniswap/v2-core/-/v2-core-1.0.1.tgz" "version" "1.0.1" +"@uniswap/v2-core@1.0.0": + "integrity" "sha512-BJiXrBGnN8mti7saW49MXwxDBRFiWemGetE58q8zgfnPPzQKq55ADltEILqOt6VFZ22kVeVKbF8gVd8aY3l7pA==" + "resolved" "https://registry.npmjs.org/@uniswap/v2-core/-/v2-core-1.0.0.tgz" + "version" "1.0.0" + +"@uniswap/v2-periphery@^1.1.0-beta.0": + "integrity" "sha512-6dkwAMKza8nzqYiXEr2D86dgW3TTavUvCR0w2Tu33bAbM8Ah43LKAzH7oKKPRT5VJQaMi1jtkGs1E8JPor1n5g==" + "resolved" "https://registry.npmjs.org/@uniswap/v2-periphery/-/v2-periphery-1.1.0-beta.0.tgz" + "version" "1.1.0-beta.0" + dependencies: + "@uniswap/lib" "1.1.1" + "@uniswap/v2-core" "1.0.0" + +"@uniswap/v2-sdk@^3.0.1": + "integrity" "sha512-eSpm2gjo2CZh9FACH5fq42str/oSNyWcDxB27o5k44bEew4sxb+pld4gGIf/byJndLBvArR9PtH8c0n/goNOTw==" + "resolved" "https://registry.npmjs.org/@uniswap/v2-sdk/-/v2-sdk-3.0.1.tgz" + "version" "3.0.1" + dependencies: + "@ethersproject/address" "^5.0.0" + "@ethersproject/solidity" "^5.0.0" + "@uniswap/sdk-core" "^3.0.0-alpha.3" + "tiny-invariant" "^1.1.0" + "tiny-warning" "^1.0.3" + "@uniswap/v3-core@^1.0.0", "@uniswap/v3-core@1.0.0": "integrity" "sha512-kSC4djMGKMHj7sLMYVnn61k9nu+lHjMIxgg9CDQT+s2QYLoA56GbSK9Oxr+qJXzzygbkrmuY6cwgP6cW2JXPFA==" "resolved" "https://registry.npmjs.org/@uniswap/v3-core/-/v3-core-1.0.0.tgz" "version" "1.0.0" -"@uniswap/v3-periphery@^1.3.0": +"@uniswap/v3-periphery@^1.0.1", "@uniswap/v3-periphery@^1.1.1", "@uniswap/v3-periphery@^1.3.0", "@uniswap/v3-periphery@1.3.0": "integrity" "sha512-HjHdI5RkjBl8zz3bqHShrbULFoZSrjbbrRHoO2vbzn+WRzTa6xY4PWphZv2Tlcb38YEKfKHp6NPl5hVedac8uw==" "resolved" "https://registry.npmjs.org/@uniswap/v3-periphery/-/v3-periphery-1.3.0.tgz" "version" "1.3.0" @@ -1467,6 +1669,28 @@ "base64-sol" "1.0.1" "hardhat-watcher" "^2.1.1" +"@uniswap/v3-sdk@^3.7.0", "@uniswap/v3-sdk@^3.7.1": + "integrity" "sha512-Fn+h9zNVzgX8DE0hTWqMyXNF1AhT1ovmzE2dpSsTZmJkxVbc70+DzENeuknTfA+nmemtB915mq4vHrJL3lZGjA==" + "resolved" "https://registry.npmjs.org/@uniswap/v3-sdk/-/v3-sdk-3.8.1.tgz" + "version" "3.8.1" + dependencies: + "@ethersproject/abi" "^5.0.12" + "@ethersproject/solidity" "^5.0.9" + "@uniswap/sdk-core" "^3.0.1" + "@uniswap/v3-periphery" "^1.1.1" + "@uniswap/v3-staker" "1.0.0" + "tiny-invariant" "^1.1.0" + "tiny-warning" "^1.0.3" + +"@uniswap/v3-staker@1.0.0": + "integrity" "sha512-JV0Qc46Px5alvg6YWd+UIaGH9lDuYG/Js7ngxPit1SPaIP30AlVer1UYB7BRYeUVVxE+byUyIeN5jeQ7LLDjIw==" + "resolved" "https://registry.npmjs.org/@uniswap/v3-staker/-/v3-staker-1.0.0.tgz" + "version" "1.0.0" + dependencies: + "@openzeppelin/contracts" "3.4.1-solc-0.7-2" + "@uniswap/v3-core" "1.0.0" + "@uniswap/v3-periphery" "^1.0.1" + "@vue/component-compiler-utils@^3.1.0": "integrity" "sha512-Mci9WJYLRjyJEBkGHMPxZ1ihJ9l6gOy2Gr6hpYZUNpQoe5+nbpeb3w00aP+PSHJygCF+fxJsqp7Af1zGDITzuw==" "resolved" "https://registry.npmjs.org/@vue/component-compiler-utils/-/component-compiler-utils-3.2.1.tgz" @@ -1878,6 +2102,13 @@ dependencies: "color-convert" "^1.9.0" +"ansi-styles@^4.0.0", "ansi-styles@^4.1.0": + "integrity" "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==" + "resolved" "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz" + "version" "4.3.0" + dependencies: + "color-convert" "^2.0.1" + "ansi-styles@^4.1.0": "integrity" "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==" "resolved" "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz" @@ -2064,6 +2295,13 @@ "resolved" "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz" "version" "1.0.1" +"async-retry@^1.3.1": + "integrity" "sha512-wfr/jstw9xNi/0teMHrRW7dsz3Lt5ARhYNZ2ewpadnhaIp5mbALhOAP+EAdsC7t4Z6wqsDVv9+W6gm1Dk9mEyw==" + "resolved" "https://registry.npmjs.org/async-retry/-/async-retry-1.3.3.tgz" + "version" "1.3.3" + dependencies: + "retry" "0.13.1" + "async@^1.4.2": "version" "1.5.2" @@ -2104,6 +2342,11 @@ "resolved" "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz" "version" "1.0.5" +"await-timeout@^1.1.1": + "integrity" "sha512-gsDXAS6XVc4Jt+7S92MPX6Noq69bdeXUPEaXd8dk3+yVr629LTDLxNt4j1ycBbrU+AStK2PhKIyNIM+xzWMVOQ==" + "resolved" "https://registry.npmjs.org/await-timeout/-/await-timeout-1.1.1.tgz" + "version" "1.1.1" + "aws-sign2@~0.7.0": "integrity" "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" "resolved" "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz" @@ -2614,6 +2857,11 @@ "resolved" "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.1.tgz" "version" "9.0.1" +"bignumber.js@~9.0.0": + "integrity" "sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw==" + "resolved" "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.2.tgz" + "version" "9.0.2" + "binary-extensions@^1.0.0": "integrity" "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==" "resolved" "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz" @@ -2907,6 +3155,31 @@ "resolved" "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz" "version" "3.0.0" +"bunyan-blackhole@^1.1.1": + "integrity" "sha1-uSCFhtwLTkf09xMhWxvd1l5PYlc=" + "resolved" "https://registry.npmjs.org/bunyan-blackhole/-/bunyan-blackhole-1.1.1.tgz" + "version" "1.1.1" + dependencies: + "stream-blackhole" "^1.0.3" + +"bunyan-debug-stream@^2.0.0": + "integrity" "sha512-MCEoqggU7NMt7f2O+PU8VkqfSkoQoa4lmN/OWhaRfqFRBF1Se2TOXQyLF6NxC+EtfrdthnquQe8jOe83fpEoGA==" + "resolved" "https://registry.npmjs.org/bunyan-debug-stream/-/bunyan-debug-stream-2.0.1.tgz" + "version" "2.0.1" + dependencies: + "colors" "1.4.0" + "exception-formatter" "^1.0.4" + +"bunyan@*", "bunyan@^1.8.15", "bunyan@~1.x.x": + "integrity" "sha512-0tECWShh6wUysgucJcBAoYegf3JJoZWibxdqhTm7OHPeT42qdjkZ29QCMcKwbgU1kiH+auSIasNRXMLWXafXig==" + "resolved" "https://registry.npmjs.org/bunyan/-/bunyan-1.8.15.tgz" + "version" "1.8.15" + optionalDependencies: + "dtrace-provider" "~0.8" + "moment" "^2.19.3" + "mv" "~2" + "safe-json-stringify" "~1" + "bytes@3.1.0": "integrity" "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" "resolved" "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz" @@ -3311,6 +3584,11 @@ "inherits" "^2.0.1" "safe-buffer" "^5.0.1" +"circular@^1.0.5": + "integrity" "sha1-fad6+Yu96c5LWzWM1Va13e0tMUk=" + "resolved" "https://registry.npmjs.org/circular/-/circular-1.0.5.tgz" + "version" "1.0.5" + "class-is@^1.1.0": "integrity" "sha512-rhjH9AG1fvabIDoGRVH587413LPjTZgmDF9fOFCbFJQV4yuocX1mHxxvXI4g3cGwbVY9wAYIoKlg1N79frJKQw==" "resolved" "https://registry.npmjs.org/class-is/-/class-is-1.1.0.tgz" @@ -3333,6 +3611,13 @@ dependencies: "source-map" "~0.6.0" +"clean-stack@^3.0.0": + "integrity" "sha512-lR9wNiMRcVQjSB3a7xXGLuz4cr4wJuuXlaAEbRutGowQTmlp7R72/DOgN21e8jdwblMWl9UOJMJXarX94pzKdg==" + "resolved" "https://registry.npmjs.org/clean-stack/-/clean-stack-3.0.1.tgz" + "version" "3.0.1" + dependencies: + "escape-string-regexp" "4.0.0" + "cli-cursor@^2.1.0": "integrity" "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=" "resolved" "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz" @@ -3347,11 +3632,31 @@ dependencies: "restore-cursor" "^3.1.0" +"cli-logger@^0.5.40": + "integrity" "sha1-CX8OEbByx8aYomxH9YiinCC0iws=" + "resolved" "https://registry.npmjs.org/cli-logger/-/cli-logger-0.5.40.tgz" + "version" "0.5.40" + dependencies: + "circular" "^1.0.5" + "cli-util" "~1.1.27" + +"cli-regexp@~0.1.0": + "integrity" "sha1-a82TsJ+y7RAl0woRVdWZeVSlNRI=" + "resolved" "https://registry.npmjs.org/cli-regexp/-/cli-regexp-0.1.2.tgz" + "version" "0.1.2" + "cli-spinners@^2.5.0": "integrity" "sha512-x/5fWmGMnbKQAaNwN+UZlV79qBLM9JFnJuJ03gIi5whrob0xV0ofNVHy9DhwGdsMJQc2OKv0oGmLzvaqvAVv+g==" "resolved" "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.6.1.tgz" "version" "2.6.1" +"cli-util@~1.1.27": + "integrity" "sha1-QtaeNqBAoyH8nPhRwVE8rcUJMFQ=" + "resolved" "https://registry.npmjs.org/cli-util/-/cli-util-1.1.27.tgz" + "version" "1.1.27" + dependencies: + "cli-regexp" "~0.1.0" + "cli-width@^2.0.0": "integrity" "sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw==" "resolved" "https://registry.npmjs.org/cli-width/-/cli-width-2.2.1.tgz" @@ -3404,6 +3709,11 @@ "clone@^2.0.0", "clone@2.1.2": "version" "2.1.2" +"clone@2.x": + "integrity" "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=" + "resolved" "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz" + "version" "2.1.2" + "code-point-at@^1.0.0": "integrity" "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" "resolved" "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz" @@ -3441,7 +3751,7 @@ "resolved" "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz" "version" "1.1.3" -"colors@^1.4.0": +"colors@^1.0.3", "colors@^1.4.0", "colors@1.4.0": "integrity" "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==" "resolved" "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz" "version" "1.4.0" @@ -3704,6 +4014,13 @@ "node-fetch" "2.1.2" "whatwg-fetch" "2.0.4" +"cross-fetch@^3.0.6": + "integrity" "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==" + "resolved" "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz" + "version" "3.1.4" + dependencies: + "node-fetch" "2.6.1" + "cross-spawn@^5.0.1": "integrity" "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=" "resolved" "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz" @@ -3904,6 +4221,11 @@ "resolved" "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz" "version" "1.2.0" +"decimal.js-light@^2.5.0": + "integrity" "sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg==" + "resolved" "https://registry.npmjs.org/decimal.js-light/-/decimal.js-light-2.5.1.tgz" + "version" "2.5.1" + "decode-uri-component@^0.2.0": "integrity" "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=" "resolved" "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz" @@ -4161,6 +4483,13 @@ dependencies: "minimatch" "^3.0.4" +"dtrace-provider@~0.8": + "integrity" "sha512-b7Z7cNtHPhH9EJhNNbbeqTcXB8LGFFZhq1PGgEvpeHlzd36bhbdTWoE/Ba/YguqpBSlAPKnARWhVlhunCMwfxg==" + "resolved" "https://registry.npmjs.org/dtrace-provider/-/dtrace-provider-0.8.8.tgz" + "version" "0.8.8" + dependencies: + "nan" "^2.14.0" + "duplexer3@^0.1.4": "integrity" "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=" "resolved" "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz" @@ -4480,6 +4809,11 @@ "resolved" "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz" "version" "4.0.0" +"escape-string-regexp@4.0.0": + "integrity" "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==" + "resolved" "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz" + "version" "4.0.0" + "escodegen@1.8.x": "integrity" "sha1-WltTr0aTEQvrsIZ6o0MN07cKEBg=" "resolved" "https://registry.npmjs.org/escodegen/-/escodegen-1.8.1.tgz" @@ -4779,6 +5113,14 @@ "secp256k1" "^4.0.1" "setimmediate" "^1.0.5" +"ethereum-types@^3.5.0": + "integrity" "sha512-iJX96C9W1elWhCZKUiSQfWn9fC+EO+xU2TvAE/p7QhMwcGibihKsxcG27B/4WZAudd8jNoeIhY4PH2qQPLuUfw==" + "resolved" "https://registry.npmjs.org/ethereum-types/-/ethereum-types-3.6.0.tgz" + "version" "3.6.0" + dependencies: + "@types/node" "12.12.54" + "bignumber.js" "~9.0.0" + "ethereum-waffle@^3.2.0", "ethereum-waffle@^3.4.0": "integrity" "sha512-ADBqZCkoSA5Isk486ntKJVjFEawIiC+3HxNqpJqONvh3YXBTNiRfXvJtGuAFLXPG91QaqkGqILEHANAo7j/olQ==" "resolved" "https://registry.npmjs.org/ethereum-waffle/-/ethereum-waffle-3.4.0.tgz" @@ -5095,7 +5437,7 @@ "uuid" "2.0.1" "xmlhttprequest" "1.8.0" -"ethers@^5.0.0", "ethers@^5.0.1", "ethers@^5.0.13", "ethers@^5.0.2", "ethers@^5.1.0", "ethers@^5.1.3", "ethers@^5.4.7", "ethers@^5.5.2": +"ethers@^5.0.0", "ethers@^5.0.1", "ethers@^5.0.13", "ethers@^5.0.2", "ethers@^5.1.0", "ethers@^5.1.3", "ethers@^5.1.4", "ethers@^5.4.7", "ethers@^5.5.2": "integrity" "sha512-EF5W+6Wwcu6BqVwpgmyR5U2+L4c1FQzlM/02dkZOugN3KF0cG9bzHZP+TDJglmPm2/IzCEJDT7KBxzayk7SAHw==" "resolved" "https://registry.npmjs.org/ethers/-/ethers-5.5.2.tgz" "version" "5.5.2" @@ -5187,6 +5529,13 @@ "md5.js" "^1.3.4" "safe-buffer" "^5.1.1" +"exception-formatter@^1.0.4": + "integrity" "sha512-zV45vEsjytJrwfGq6X9qd1Ll56cW4NC2mhCO6lqwMk4ZpA1fZ6C3UiaQM/X7if+7wZFmCgss3ahp9B/uVFuLRw==" + "resolved" "https://registry.npmjs.org/exception-formatter/-/exception-formatter-1.0.7.tgz" + "version" "1.0.7" + dependencies: + "colors" "^1.0.3" + "execa@^0.7.0": "integrity" "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=" "resolved" "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz" @@ -5322,6 +5671,11 @@ "snapdragon" "^0.8.1" "to-regex" "^3.0.1" +"extract-files@^9.0.0": + "integrity" "sha512-CvdFfHkC95B4bBBk36hcEmvdR2awOdhhVUYH6S/zrVj3477zven/fJMYg7121h4T1xHZC+tetUpubpAhxwI7hQ==" + "resolved" "https://registry.npmjs.org/extract-files/-/extract-files-9.0.0.tgz" + "version" "9.0.0" + "extsprintf@^1.2.0", "extsprintf@1.3.0": "integrity" "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" "resolved" "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz" @@ -5354,10 +5708,10 @@ "resolved" "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz" "version" "1.2.0" -"fast-glob@^3.0.3": - "integrity" "sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q==" - "resolved" "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.7.tgz" - "version" "3.2.7" +"fast-glob@^3.0.3", "fast-glob@^3.2.9": + "integrity" "sha512-s9nFhFnvR63wls6/kM88kQqDhMu0AfdjqouE2l5GVQPbqLgyFjjU5ry/r2yKsJxpb9Py1EYNqieFrmMaX4v++A==" + "resolved" "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.10.tgz" + "version" "3.2.10" dependencies: "@nodelib/fs.stat" "^2.0.2" "@nodelib/fs.walk" "^1.2.3" @@ -5700,6 +6054,15 @@ "jsonfile" "^4.0.0" "universalify" "^0.1.0" +"fs-extra@^8.1": + "integrity" "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==" + "resolved" "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz" + "version" "8.1.0" + dependencies: + "graceful-fs" "^4.2.0" + "jsonfile" "^4.0.0" + "universalify" "^0.1.0" + "fs-extra@^9.0.1": "integrity" "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==" "resolved" "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz" @@ -5747,19 +6110,6 @@ "resolved" "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" "version" "1.0.0" -"fsevents@^1.2.7", "fsevents@~2.1.1": - "integrity" "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==" - "resolved" "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz" - "version" "1.2.13" - dependencies: - "bindings" "^1.5.0" - "nan" "^2.12.1" - -"fsevents@~2.3.2": - "integrity" "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==" - "resolved" "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz" - "version" "2.3.2" - "function-bind@^1.1.1", "function-bind@~1.1.1": "integrity" "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" "resolved" "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz" @@ -5939,6 +6289,17 @@ "once" "^1.3.0" "path-is-absolute" "^1.0.0" +"glob@^6.0.1": + "integrity" "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=" + "resolved" "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz" + "version" "6.0.4" + dependencies: + "inflight" "^1.0.4" + "inherits" "2" + "minimatch" "2 || 3" + "once" "^1.3.0" + "path-is-absolute" "^1.0.0" + "glob@^7.0.0", "glob@^7.1.2", "glob@^7.1.3", "glob@^7.1.4", "glob@^7.1.6": "integrity" "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==" "resolved" "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz" @@ -6019,6 +6380,18 @@ "merge2" "^1.2.3" "slash" "^3.0.0" +"globby@^11.0.1": + "integrity" "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==" + "resolved" "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz" + "version" "11.1.0" + dependencies: + "array-union" "^2.1.0" + "dir-glob" "^3.0.1" + "fast-glob" "^3.2.9" + "ignore" "^5.2.0" + "merge2" "^1.4.1" + "slash" "^3.0.0" + "got@^7.1.0": "integrity" "sha512-Y5WMo7xKKq1muPsxD+KmrR8DH5auG7fBdDVueZwETwV6VytKyU9OX/ddpq2/1hp1vIPvVb4T81dKQz3BivkNLw==" "resolved" "https://registry.npmjs.org/got/-/got-7.1.0.tgz" @@ -6061,6 +6434,20 @@ "resolved" "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz" "version" "4.2.6" +"graphql-request@^3.4.0": + "integrity" "sha512-dw5PxHCgBneN2DDNqpWu8QkbbJ07oOziy8z+bK/TAXufsOLaETuVO4GkXrbs0WjhdKhBMN3BkpN/RIvUHkmNUQ==" + "resolved" "https://registry.npmjs.org/graphql-request/-/graphql-request-3.7.0.tgz" + "version" "3.7.0" + dependencies: + "cross-fetch" "^3.0.6" + "extract-files" "^9.0.0" + "form-data" "^3.0.0" + +"graphql@^15.5.0", "graphql@14 - 16": + "integrity" "sha512-5gghUc24tP9HRznNpV2+FIoq3xKkj5dTQqf4v0CpdPbFVwFkWoxOM+o+2OC9ZSvjEMTjfmG9QT+gcvggTwW1zw==" + "resolved" "https://registry.npmjs.org/graphql/-/graphql-15.8.0.tgz" + "version" "15.8.0" + "growl@1.10.5": "integrity" "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==" "resolved" "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz" @@ -6520,10 +6907,10 @@ "resolved" "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz" "version" "4.0.6" -"ignore@^5.1.1": - "integrity" "sha512-2zeMQpbKz5dhZ9IwL0gbxSW5w0NK/MSAMtNuhgIHEPmaU3vPdKPL0UdvUCXs5SS4JAwsBxysK5sFMW8ocFiVjQ==" - "resolved" "https://registry.npmjs.org/ignore/-/ignore-5.1.9.tgz" - "version" "5.1.9" +"ignore@^5.1.1", "ignore@^5.2.0": + "integrity" "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==" + "resolved" "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz" + "version" "5.2.0" "immediate@^3.2.3": "integrity" "sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q==" @@ -6566,6 +6953,11 @@ "resolved" "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz" "version" "0.1.4" +"indent-string@^4.0.0": + "integrity" "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==" + "resolved" "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz" + "version" "4.0.0" + "infer-owner@^1.0.3": "integrity" "sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A==" "resolved" "https://registry.npmjs.org/infer-owner/-/infer-owner-1.0.4.tgz" @@ -7061,6 +7453,11 @@ "resolved" "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz" "version" "2.0.0" +"isnumber@~1.0.0": + "integrity" "sha1-Dj+XWbWB2Z3YUIbw7Cp0kJz63QE=" + "resolved" "https://registry.npmjs.org/isnumber/-/isnumber-1.0.0.tgz" + "version" "1.0.0" + "isobject@^2.0.0": "integrity" "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=" "resolved" "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz" @@ -7130,6 +7527,11 @@ "argparse" "^1.0.7" "esprima" "^4.0.0" +"jsbi@^3.1.4": + "integrity" "sha512-aBE4n43IPvjaddScbvWRA2YlTzKEynHzu7MqOyTipdHucf/VxS63ViCjxYRg86M8Rxwbt/GfzHl1kKERkt45fQ==" + "resolved" "https://registry.npmjs.org/jsbi/-/jsbi-3.2.5.tgz" + "version" "3.2.5" + "jsbn@~0.1.0": "integrity" "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" "resolved" "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz" @@ -7861,7 +8263,7 @@ dependencies: "source-map" "^0.6.1" -"merge2@^1.2.3", "merge2@^1.3.0": +"merge2@^1.2.3", "merge2@^1.3.0", "merge2@^1.4.1": "integrity" "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==" "resolved" "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz" "version" "1.4.1" @@ -8085,7 +8487,7 @@ dependencies: "mkdirp" "*" -"mkdirp@*", "mkdirp@^0.5.0", "mkdirp@^0.5.1", "mkdirp@^0.5.3", "mkdirp@^0.5.5", "mkdirp@~0.5.0", "mkdirp@0.5.5", "mkdirp@0.5.x": +"mkdirp@*", "mkdirp@^0.5.0", "mkdirp@^0.5.1", "mkdirp@^0.5.3", "mkdirp@^0.5.5", "mkdirp@~0.5.0", "mkdirp@~0.5.1", "mkdirp@0.5.5", "mkdirp@0.5.x": "integrity" "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==" "resolved" "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz" "version" "0.5.5" @@ -8097,7 +8499,7 @@ "resolved" "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz" "version" "1.0.4" -"mnemonist@^0.38.0": +"mnemonist@^0.38.0", "mnemonist@^0.38.3": "integrity" "sha512-2K9QYubXx/NAjv4VLq1d1Ly8pWNC5L3BrixtdkyTegXWJIqY+zLNDhhX/A+ZwWt70tB1S8H4BE8FLYEFyNoOBw==" "resolved" "https://registry.npmjs.org/mnemonist/-/mnemonist-0.38.3.tgz" "version" "0.38.3" @@ -8139,6 +8541,11 @@ "resolved" "https://registry.npmjs.org/mock-fs/-/mock-fs-4.14.0.tgz" "version" "4.14.0" +"moment@^2.19.3": + "integrity" "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==" + "resolved" "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz" + "version" "2.29.1" + "move-concurrently@^1.0.1": "integrity" "sha1-viwAX9oy4LKa8fBdfEszIUxwH5I=" "resolved" "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz" @@ -8225,15 +8632,19 @@ "resolved" "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz" "version" "0.0.8" -"nan@^2.12.1": - "integrity" "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==" - "resolved" "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz" - "version" "2.13.2" +"mv@~2": + "integrity" "sha1-rmzg1vbV4KT32JN5jQPB6pVZtqI=" + "resolved" "https://registry.npmjs.org/mv/-/mv-2.1.1.tgz" + "version" "2.1.1" + dependencies: + "mkdirp" "~0.5.1" + "ncp" "~2.0.0" + "rimraf" "~2.4.0" "nan@^2.14.0": - "integrity" "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==" - "resolved" "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz" - "version" "2.14.2" + "integrity" "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==" + "resolved" "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz" + "version" "2.15.0" "nano-base32@^1.0.1": "integrity" "sha1-ulSMh578+5DaHE2eCX20pGySVe8=" @@ -8272,6 +8683,11 @@ "resolved" "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz" "version" "1.4.0" +"ncp@~2.0.0": + "integrity" "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=" + "resolved" "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz" + "version" "2.0.0" + "negotiator@0.6.2": "integrity" "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" "resolved" "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz" @@ -8321,6 +8737,13 @@ "resolved" "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.0.2.tgz" "version" "3.0.2" +"node-cache@^5.1.2": + "integrity" "sha512-t1QzWwnk4sjLWaQAS8CHgOJ+RAfmHpxFWmc36IWTiWHQfs0w5JDMBS1b1ZxQteo0vVVuWJvIUKHDkkeK7vIGCg==" + "resolved" "https://registry.npmjs.org/node-cache/-/node-cache-5.1.2.tgz" + "version" "5.1.2" + dependencies: + "clone" "2.x" + "node-emoji@^1.10.0": "integrity" "sha512-wo2DpQkQp7Sjm2A0cq+sN7EHKO6Sl0ctXeBdFZrL9T9+UywORbufTcTZxom8YqpLQt/FqNMUkOpkZrJVYSKD3A==" "resolved" "https://registry.npmjs.org/node-emoji/-/node-emoji-1.11.0.tgz" @@ -8336,7 +8759,7 @@ "object.getownpropertydescriptors" "^2.0.3" "semver" "^5.7.0" -"node-fetch@^2.6.0", "node-fetch@^2.6.1": +"node-fetch@^2.6.0", "node-fetch@^2.6.1", "node-fetch@2.6.1": "integrity" "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" "resolved" "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz" "version" "2.6.1" @@ -9800,6 +10223,11 @@ "resolved" "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz" "version" "0.1.15" +"retry@0.13.1": + "integrity" "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==" + "resolved" "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz" + "version" "0.13.1" + "reusify@^1.0.4": "integrity" "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==" "resolved" "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz" @@ -9819,6 +10247,13 @@ dependencies: "glob" "^7.1.3" +"rimraf@~2.4.0": + "integrity" "sha1-7nEM5dk6j9uFb7Xqj/Di11k0sto=" + "resolved" "https://registry.npmjs.org/rimraf/-/rimraf-2.4.5.tgz" + "version" "2.4.5" + dependencies: + "glob" "^6.0.1" + "rimraf@2.6.3": "integrity" "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==" "resolved" "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz" @@ -9909,6 +10344,11 @@ dependencies: "events" "^3.0.0" +"safe-json-stringify@~1": + "integrity" "sha512-gH8eh2nZudPQO6TytOvbxnuhYBOvDBBLW52tz5q6X58lJcd/tkmqFR+5Z9adS8aJtURSXWThWy/xJtJwixErvg==" + "resolved" "https://registry.npmjs.org/safe-json-stringify/-/safe-json-stringify-1.2.0.tgz" + "version" "1.2.0" + "safe-regex@^1.1.0": "integrity" "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=" "resolved" "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz" @@ -10015,6 +10455,13 @@ "resolved" "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz" "version" "6.3.0" +"semver@^7.3.2": + "integrity" "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==" + "resolved" "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz" + "version" "7.3.5" + dependencies: + "lru-cache" "^6.0.0" + "semver@^7.3.4": "integrity" "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==" "resolved" "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz" @@ -10496,11 +10943,23 @@ "define-property" "^0.2.5" "object-copy" "^0.1.0" +"stats-lite@^2.2.0": + "integrity" "sha512-/Kz55rgUIv2KP2MKphwYT/NCuSfAlbbMRv2ZWw7wyXayu230zdtzhxxuXXcvsc6EmmhS8bSJl3uS1wmMHFumbA==" + "resolved" "https://registry.npmjs.org/stats-lite/-/stats-lite-2.2.0.tgz" + "version" "2.2.0" + dependencies: + "isnumber" "~1.0.0" + "statuses@>= 1.5.0 < 2", "statuses@~1.5.0": "integrity" "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" "resolved" "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz" "version" "1.5.0" +"stream-blackhole@^1.0.3": + "integrity" "sha1-b8LiwunZ/ea+jGjT24jeCYAuTWM=" + "resolved" "https://registry.npmjs.org/stream-blackhole/-/stream-blackhole-1.0.3.tgz" + "version" "1.0.3" + "stream-browserify@^2.0.1": "integrity" "sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg==" "resolved" "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz" @@ -10580,7 +11039,16 @@ "is-fullwidth-code-point" "^2.0.0" "strip-ansi" "^5.1.0" -"string-width@^4.1.0": +"string-width@^4.0.0": + "integrity" "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==" + "resolved" "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz" + "version" "4.2.3" + dependencies: + "emoji-regex" "^8.0.0" + "is-fullwidth-code-point" "^3.0.0" + "strip-ansi" "^6.0.1" + +"string-width@^4.1.0", "string-width@^4.2.0": "integrity" "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==" "resolved" "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz" "version" "4.2.3" @@ -10919,6 +11387,16 @@ dependencies: "setimmediate" "^1.0.4" +"tiny-invariant@^1.1.0": + "integrity" "sha512-1Uhn/aqw5C6RI4KejVeTg6mIS7IqxnLJ8Mv2tV5rTc0qWobay7pDUz6Wi392Cnc8ak1H0F2cjoRzb2/AW4+Fvg==" + "resolved" "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.2.0.tgz" + "version" "1.2.0" + +"tiny-warning@^1.0.3": + "integrity" "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==" + "resolved" "https://registry.npmjs.org/tiny-warning/-/tiny-warning-1.0.3.tgz" + "version" "1.0.3" + "title-case@^2.1.0": "integrity" "sha1-PhJyFtpY0rxb7PE3q5Ha46fNj6o=" "resolved" "https://registry.npmjs.org/title-case/-/title-case-2.1.1.tgz" @@ -10984,6 +11462,11 @@ "regex-not" "^1.0.2" "safe-regex" "^1.1.0" +"toformat@^2.0.0": + "integrity" "sha512-03SWBVop6nU8bpyZCx7SodpYznbZF5R4ljwNLBcTQzKOD9xuihRo/psX58llS1BMFhhAI08H3luot5GoXJz2pQ==" + "resolved" "https://registry.npmjs.org/toformat/-/toformat-2.0.0.tgz" + "version" "2.0.0" + "toidentifier@1.0.0": "integrity" "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" "resolved" "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz" @@ -11058,11 +11541,16 @@ "make-error" "^1.1.1" "yn" "3.1.1" -"tslib@^1.9.0", "tslib@^1.9.3": +"tslib@^1.14.1", "tslib@^1.9.0", "tslib@^1.9.3": "integrity" "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" "resolved" "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz" "version" "1.14.1" +"tslib@^2.0.0": + "integrity" "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" + "resolved" "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz" + "version" "2.3.1" + "tslib@^2.2.0": "integrity" "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" "resolved" "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz" @@ -12420,6 +12908,13 @@ dependencies: "string-width" "^1.0.2 || 2" +"widest-line@^3.1.0": + "integrity" "sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg==" + "resolved" "https://registry.npmjs.org/widest-line/-/widest-line-3.1.0.tgz" + "version" "3.1.0" + dependencies: + "string-width" "^4.0.0" + "window-size@^0.2.0": "integrity" "sha1-tDFbtCFKPXBY6+7okuE/ok2YsHU=" "resolved" "https://registry.npmjs.org/window-size/-/window-size-0.2.0.tgz" @@ -12469,6 +12964,24 @@ "string-width" "^3.0.0" "strip-ansi" "^5.0.0" +"wrap-ansi@^6.2.0": + "integrity" "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==" + "resolved" "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz" + "version" "6.2.0" + dependencies: + "ansi-styles" "^4.0.0" + "string-width" "^4.1.0" + "strip-ansi" "^6.0.0" + +"wrap-ansi@^7.0.0": + "integrity" "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==" + "resolved" "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz" + "version" "7.0.0" + dependencies: + "ansi-styles" "^4.0.0" + "string-width" "^4.1.0" + "strip-ansi" "^6.0.0" + "wrappy@1": "integrity" "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" "resolved" "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" From 58c2d3cb6eb5d6da1d62ddb34faaa5208b446558 Mon Sep 17 00:00:00 2001 From: Chinmay Chougaonkar Date: Sun, 27 Feb 2022 09:40:25 +0530 Subject: [PATCH 02/20] added LogCompoundImport event --- .../mainnet/connectors/compound-import/events.sol | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/contracts/mainnet/connectors/compound-import/events.sol b/contracts/mainnet/connectors/compound-import/events.sol index cf2c0a6e..d3125959 100644 --- a/contracts/mainnet/connectors/compound-import/events.sol +++ b/contracts/mainnet/connectors/compound-import/events.sol @@ -1,5 +1,13 @@ pragma solidity ^0.7.6; +pragma experimental ABIEncoderV2; contract Events { - + event LogCompoundImport( + address indexed user, + address[] ctokens, + string[] supplyIds, + string[] borrowIds, + uint[] supplyAmts, + uint[] borrowAmts + ); } \ No newline at end of file From 7fd95fc81eb524ce2f94b403afcb6d271c8da6dc Mon Sep 17 00:00:00 2001 From: Chinmay Chougaonkar Date: Sun, 27 Feb 2022 21:58:52 +0530 Subject: [PATCH 03/20] added natspec comments, remove flashloan related function skeletons --- .../connectors/compound-import/main.sol | 145 +++++++++++------- 1 file changed, 87 insertions(+), 58 deletions(-) diff --git a/contracts/mainnet/connectors/compound-import/main.sol b/contracts/mainnet/connectors/compound-import/main.sol index 456ed1f5..63a44c94 100644 --- a/contracts/mainnet/connectors/compound-import/main.sol +++ b/contracts/mainnet/connectors/compound-import/main.sol @@ -7,30 +7,18 @@ import { Helpers } from "./helpers.sol"; import { Events } from "./events.sol"; // 1. Get info for all the assets the user has supplied as collateral and the assets he borrowed. -// 2. Take the flash loan for all the borrowed assets. -// 3. Using this flash loan, pay back the user's debt in the EOA account. -// 4. After paying the debt, transfer the user's tokens from EOA to DSA. -// 5. Then borrow debt of same tokens but include flash loan fee in it. -// 6. Payback the flash loan for all the tokens. +// 2. Using the flash loan funds, pay back the user's debt in the EOA account. +// 3. After paying the debt, transfer the user's tokens from EOA to DSA. +// 4. Then borrow debt of same tokens but include flash loan fee in it. -// fill logics in contract functions -contract FlashLoanHelper is Helpers, Events { - function _flashLoan( - address[] memory _tokens, - uint256[] memory _amts - ) internal { - // fill in logic for flash loans - } - - function _repayFlashLoan( - address[] memory _tokens, - uint256[] memory _amts - ) internal { - // fill in logic for flash loan repayment - } -} - -contract CompoundResolver is Helpers, Events { +contract CompoundHelper is Helpers, Events { + /** + * @notice repays the debt taken by user on Compound on its behalf to free its collateral for transfer + * @dev uses the cEth contract for ETH repays, otherwise the general cToken interface + * @param _userAccount the user address for which debt is to be repayed + * @param _cTokenContracts array containing all interfaces to the cToken contracts in which the user has debt positions + * @param _borrowAmts array containing the amount borrowed for each token + */ function _repayUserDebt( address _userAccount, CTokenInterface[] memory _cTokenContracts, @@ -48,6 +36,13 @@ contract CompoundResolver is Helpers, Events { } } + /** + * @notice used to transfer user's supply position on Compound to DSA + * @dev uses the transferFrom token in cToken contracts to transfer positions, requires approval from user first + * @param _userAccount address of the user account whose position is to be transferred + * @param _cTokenContracts array containing all interfaces to the cToken contracts in which the user has supply positions + * @param _amts array containing the amount supplied for each token + */ function _transferTokensToDsa( address _userAccount, CTokenInterface[] memory _cTokenContracts, @@ -60,20 +55,25 @@ contract CompoundResolver is Helpers, Events { } } + /** + * @notice borrows the user's debt positions from Compound via DSA, so that its debt positions get imported to DSA + * @dev actually borrow some extra amount than the original position to cover the flash loan fee + * @param _cTokenContracts array containing all interfaces to the cToken contracts in which the user has debt positions + * @param _amts array containing the amounts the user had borrowed originally from Compound plus the flash loan fee + */ function _borrowDebtPosition( - CTokenInterface[] memory _ctokenContracts, + CTokenInterface[] memory _cTokenContracts, uint[] memory _amts ) internal { - for (uint i = 0; i < _ctokenContracts.length; i++) { + for (uint i = 0; i < _cTokenContracts.length; i++) { if (_amts[i] > 0) { - // add _amts flash loan fees to _amts[i] - require(_ctokenContracts[i].borrow(_amts[i]) == 0, "borrow-failed-collateral?"); + require(_cTokenContracts[i].borrow(_amts[i]) == 0, "borrow-failed-collateral?"); } } } } -contract CompoundHelpers is CompoundResolver { +contract CompoundResolver is CompoundHelper { struct ImportData { address[] cTokens; // is the list of all tokens the user has interacted with (supply/borrow) -> used to enter markets uint[] borrowAmts; @@ -92,6 +92,13 @@ contract CompoundHelpers is CompoundResolver { string[] borrowIds; } + /** + * @notice fetch the borrow details of the user + * @dev approve the cToken to spend (borrowed amount of) tokens to allow for repaying later + * @param _importInputData the struct containing borrowIds of the users borrowed tokens + * @param data struct used to store the final data on which the CompoundHelper contract functions operate + * @return ImportData the final value of param data + */ function getBorrowAmounts ( ImportInputData memory _importInputData, ImportData memory data @@ -135,6 +142,13 @@ contract CompoundHelpers is CompoundResolver { return data; } + /** + * @notice fetch the supply details of the user + * @dev only reads data from blockchain hence view + * @param _importInputData the struct containing supplyIds of the users supplied tokens + * @param data struct used to store the final data on which the CompoundHelper contract functions operate + * @return ImportData the final value of param data + */ function getSupplyAmounts ( ImportInputData memory _importInputData, ImportData memory data @@ -172,79 +186,94 @@ contract CompoundHelpers is CompoundResolver { } } -contract CompoundImportResolver is CompoundHelpers, FlashLoanHelper { +contract CompoundImport is CompoundResolver { - // get info for all the assets the user has supplied as collateral and the assets borrowed + /** + * @notice this function performs the import of user's Compound positions into its DSA + * @dev called internally by the importCompound and migrateCompound functions + * @param _importInputData the struct containing borrowIds of the users borrowed tokens + */ function _importCompound( - ImportInputData memory importInputData + ImportInputData memory _importInputData ) internal returns (string memory _eventName, bytes memory _eventParam) { - require(AccountInterface(address(this)).isAuth(importInputData.userAccount), "user-account-not-auth"); + require(AccountInterface(address(this)).isAuth(_importInputData.userAccount), "user-account-not-auth"); - require(importInputData.supplyIds.length > 0, "0-length-not-allowed"); + require(_importInputData.supplyIds.length > 0, "0-length-not-allowed"); ImportData memory data; - uint _length = add(importInputData.supplyIds.length, importInputData.borrowIds.length); + uint _length = add(_importInputData.supplyIds.length, _importInputData.borrowIds.length); data.cTokens = new address[](_length); - data = getBorrowAmounts(importInputData, data); - data = getSupplyAmounts(importInputData, data); + // get info about all borrowings and lendings by the user on Compound + data = getBorrowAmounts(_importInputData, data); + data = getSupplyAmounts(_importInputData, data); for(uint i = 0; i < data.cTokens.length; i++){ enterMarket(data.cTokens[i]); } - // take flash loan for all the borrowed assets - // use the addresses of the borrowed tokens and their amounts to get the same flash loans - _flashLoan(data.borrowTokens, data.borrowAmts); - // pay back user's debt using flash loan funds - _repayUserDebt(importInputData.userAccount, data.borrowCtokens, data.borrowAmts); + _repayUserDebt(_importInputData.userAccount, data.borrowCtokens, data.borrowAmts); // transfer user's tokens to DSA - _transferTokensToDsa(importInputData.userAccount, data.supplyCtokens, data.supplyAmts); + _transferTokensToDsa(_importInputData.userAccount, data.supplyCtokens, data.supplyAmts); // borrow the earlier position from Compound with flash loan fee added _borrowDebtPosition(data.borrowCtokens, data.borrowAmts); - // payback flash loan - _repayFlashLoan(data.borrowTokens, data.borrowAmts); // update borrowAmounts with flash loan fee - _eventName = "LogCompoundImport(address,address[],string[],string[],uint256[],uint256[])"; _eventParam = abi.encode( - importInputData.userAccount, + _importInputData.userAccount, data.cTokens, - importInputData.supplyIds, - importInputData.borrowIds, + _importInputData.supplyIds, + _importInputData.borrowIds, data.supplyAmts, data.borrowAmts ); } + /** + * @notice import Compound position of the address passed in as userAccount + * @dev internally calls _importContract to perform the actual import + * @param _userAccount address of user whose position is to be imported to DSA + * @param _supplyIds Ids of all tokens the user has supplied to Compound + * @param _borrowIds Ids of all token borrowed by the user + */ function importCompound( - address userAccount, - string[] memory supplyIds, - string[] memory borrowIds + address _userAccount, + string[] memory _supplyIds, + string[] memory _borrowIds ) external payable returns (string memory _eventName, bytes memory _eventParam) { ImportInputData memory inputData = ImportInputData({ - userAccount: userAccount, - supplyIds: supplyIds, - borrowIds: borrowIds + userAccount: _userAccount, + supplyIds: _supplyIds, + borrowIds: _borrowIds }); (_eventName, _eventParam) = _importCompound(inputData); } + /** + * @notice import msg.sender's Compound position (which is the user since this is a delegateCall) + * @dev internally calls _importContract to perform the actual import + * @param _supplyIds Ids of all tokens the user has supplied to Compound + * @param _borrowIds Ids of all token borrowed by the user + */ function migrateCompound( - string[] memory supplyIds, - string[] memory borrowIds + string[] memory _supplyIds, + string[] memory _borrowIds ) external payable returns (string memory _eventName, bytes memory _eventParam) { ImportInputData memory inputData = ImportInputData({ userAccount: msg.sender, - supplyIds: supplyIds, - borrowIds: borrowIds + supplyIds: _supplyIds, + borrowIds: _borrowIds }); (_eventName, _eventParam) = _importCompound(inputData); } } + +contract ConnectV2CompoundImport is CompoundImport { + string public constant name = "Compound-Import-v2"; +} \ No newline at end of file From df59342790de3a9f8c0086c2c0ec89a5c0872ef6 Mon Sep 17 00:00:00 2001 From: Chinmay Chougaonkar Date: Mon, 28 Feb 2022 14:34:52 +0530 Subject: [PATCH 04/20] handled borrowing with flash loan fee --- .../connectors/compound-import/main.sol | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/contracts/mainnet/connectors/compound-import/main.sol b/contracts/mainnet/connectors/compound-import/main.sol index 63a44c94..43c51c70 100644 --- a/contracts/mainnet/connectors/compound-import/main.sol +++ b/contracts/mainnet/connectors/compound-import/main.sol @@ -60,14 +60,16 @@ contract CompoundHelper is Helpers, Events { * @dev actually borrow some extra amount than the original position to cover the flash loan fee * @param _cTokenContracts array containing all interfaces to the cToken contracts in which the user has debt positions * @param _amts array containing the amounts the user had borrowed originally from Compound plus the flash loan fee + * @param _flashLoanFee flash loan fee (in percentage and scaled up to 10**2) */ function _borrowDebtPosition( CTokenInterface[] memory _cTokenContracts, - uint[] memory _amts + uint256[] memory _amts, + uint256 _flashLoanFee ) internal { for (uint i = 0; i < _cTokenContracts.length; i++) { if (_amts[i] > 0) { - require(_cTokenContracts[i].borrow(_amts[i]) == 0, "borrow-failed-collateral?"); + require(_cTokenContracts[i].borrow(add(_amts[i], mul(_amts[i], mul(_flashLoanFee, 10**14)))) == 0, "borrow-failed-collateral?"); } } } @@ -192,9 +194,11 @@ contract CompoundImport is CompoundResolver { * @notice this function performs the import of user's Compound positions into its DSA * @dev called internally by the importCompound and migrateCompound functions * @param _importInputData the struct containing borrowIds of the users borrowed tokens + * @param _flashLoanFee flash loan fee */ function _importCompound( - ImportInputData memory _importInputData + ImportInputData memory _importInputData, + uint256 _flashLoanFee ) internal returns (string memory _eventName, bytes memory _eventParam) { require(AccountInterface(address(this)).isAuth(_importInputData.userAccount), "user-account-not-auth"); @@ -220,7 +224,7 @@ contract CompoundImport is CompoundResolver { _transferTokensToDsa(_importInputData.userAccount, data.supplyCtokens, data.supplyAmts); // borrow the earlier position from Compound with flash loan fee added - _borrowDebtPosition(data.borrowCtokens, data.borrowAmts); + _borrowDebtPosition(data.borrowCtokens, data.borrowAmts, _flashLoanFee); _eventName = "LogCompoundImport(address,address[],string[],string[],uint256[],uint256[])"; _eventParam = abi.encode( @@ -239,11 +243,13 @@ contract CompoundImport is CompoundResolver { * @param _userAccount address of user whose position is to be imported to DSA * @param _supplyIds Ids of all tokens the user has supplied to Compound * @param _borrowIds Ids of all token borrowed by the user + * @param _flashLoanFee flash loan fee (in percentage and scaled up to 10**2) */ function importCompound( address _userAccount, string[] memory _supplyIds, - string[] memory _borrowIds + string[] memory _borrowIds, + uint256 _flashLoanFee ) external payable returns (string memory _eventName, bytes memory _eventParam) { ImportInputData memory inputData = ImportInputData({ userAccount: _userAccount, @@ -251,7 +257,7 @@ contract CompoundImport is CompoundResolver { borrowIds: _borrowIds }); - (_eventName, _eventParam) = _importCompound(inputData); + (_eventName, _eventParam) = _importCompound(inputData, _flashLoanFee); } /** @@ -259,10 +265,12 @@ contract CompoundImport is CompoundResolver { * @dev internally calls _importContract to perform the actual import * @param _supplyIds Ids of all tokens the user has supplied to Compound * @param _borrowIds Ids of all token borrowed by the user + * @param _flashLoanFee flash loan fee (in percentage and scaled up to 10**2) */ function migrateCompound( string[] memory _supplyIds, - string[] memory _borrowIds + string[] memory _borrowIds, + uint256 _flashLoanFee ) external payable returns (string memory _eventName, bytes memory _eventParam) { ImportInputData memory inputData = ImportInputData({ userAccount: msg.sender, @@ -270,7 +278,7 @@ contract CompoundImport is CompoundResolver { borrowIds: _borrowIds }); - (_eventName, _eventParam) = _importCompound(inputData); + (_eventName, _eventParam) = _importCompound(inputData, _flashLoanFee); } } From ba847889d85ecf335df553b9f22aeeb08c86c937 Mon Sep 17 00:00:00 2001 From: Chinmay Chougaonkar Date: Thu, 3 Mar 2022 18:08:06 +0530 Subject: [PATCH 05/20] started writing tests --- test/mainnet/compound-import/ABIs/cDaiAbi.js | 1533 ++++++++++ test/mainnet/compound-import/ABIs/cEthAbi.js | 1184 ++++++++ .../compound-import/ABIs/comptrollerAbi.js | 2654 +++++++++++++++++ .../compound-import/compound-import.test.js | 124 + test/mainnet/compound-import/constants.js | 6 + 5 files changed, 5501 insertions(+) create mode 100644 test/mainnet/compound-import/ABIs/cDaiAbi.js create mode 100644 test/mainnet/compound-import/ABIs/cEthAbi.js create mode 100644 test/mainnet/compound-import/ABIs/comptrollerAbi.js create mode 100644 test/mainnet/compound-import/compound-import.test.js create mode 100644 test/mainnet/compound-import/constants.js diff --git a/test/mainnet/compound-import/ABIs/cDaiAbi.js b/test/mainnet/compound-import/ABIs/cDaiAbi.js new file mode 100644 index 00000000..ae494e6d --- /dev/null +++ b/test/mainnet/compound-import/ABIs/cDaiAbi.js @@ -0,0 +1,1533 @@ +const cDaiAbi = [ + { + "inputs": [ + { + "internalType": "address", + "name": "underlying_", + "type": "address" + }, + { + "internalType": "contract ComptrollerInterface", + "name": "comptroller_", + "type": "address" + }, + { + "internalType": "contract InterestRateModel", + "name": "interestRateModel_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "initialExchangeRateMantissa_", + "type": "uint256" + }, + { + "internalType": "string", + "name": "name_", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol_", + "type": "string" + }, + { + "internalType": "uint8", + "name": "decimals_", + "type": "uint8" + }, + { + "internalType": "address payable", + "name": "admin_", + "type": "address" + }, + { + "internalType": "address", + "name": "implementation_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "becomeImplementationData", + "type": "bytes" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor", + "signature": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "cashPrior", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "interestAccumulated", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "AccrueInterest", + "type": "event", + "signature": "0x4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc04" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event", + "signature": "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "accountBorrows", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "Borrow", + "type": "event", + "signature": "0x13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab80" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "error", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "info", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "detail", + "type": "uint256" + } + ], + "name": "Failure", + "type": "event", + "signature": "0x45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "LiquidateBorrow", + "type": "event", + "signature": "0x298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb52" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "mintTokens", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event", + "signature": "0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "NewAdmin", + "type": "event", + "signature": "0xf9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract ComptrollerInterface", + "name": "oldComptroller", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract ComptrollerInterface", + "name": "newComptroller", + "type": "address" + } + ], + "name": "NewComptroller", + "type": "event", + "signature": "0x7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldImplementation", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "NewImplementation", + "type": "event", + "signature": "0xd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract InterestRateModel", + "name": "oldInterestRateModel", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract InterestRateModel", + "name": "newInterestRateModel", + "type": "address" + } + ], + "name": "NewMarketInterestRateModel", + "type": "event", + "signature": "0xedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f926" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "NewPendingAdmin", + "type": "event", + "signature": "0xca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldReserveFactorMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newReserveFactorMantissa", + "type": "uint256" + } + ], + "name": "NewReserveFactor", + "type": "event", + "signature": "0xaaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f821460" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "redeemAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "Redeem", + "type": "event", + "signature": "0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "payer", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "accountBorrows", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "RepayBorrow", + "type": "event", + "signature": "0x1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "benefactor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "addAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newTotalReserves", + "type": "uint256" + } + ], + "name": "ReservesAdded", + "type": "event", + "signature": "0xa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc5" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "admin", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "reduceAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newTotalReserves", + "type": "uint256" + } + ], + "name": "ReservesReduced", + "type": "event", + "signature": "0x3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event", + "signature": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "constant": false, + "inputs": [], + "name": "_acceptAdmin", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xe9c714f2" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "addAmount", + "type": "uint256" + } + ], + "name": "_addReserves", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x3e941010" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "reduceAmount", + "type": "uint256" + } + ], + "name": "_reduceReserves", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x601a0bf1" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract ComptrollerInterface", + "name": "newComptroller", + "type": "address" + } + ], + "name": "_setComptroller", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x4576b5db" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + }, + { + "internalType": "bool", + "name": "allowResign", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "becomeImplementationData", + "type": "bytes" + } + ], + "name": "_setImplementation", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x555bcc40" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract InterestRateModel", + "name": "newInterestRateModel", + "type": "address" + } + ], + "name": "_setInterestRateModel", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xf2b3abbd" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address payable", + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "_setPendingAdmin", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xb71d1a0c" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "newReserveFactorMantissa", + "type": "uint256" + } + ], + "name": "_setReserveFactor", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xfca7820b" + }, + { + "constant": true, + "inputs": [], + "name": "accrualBlockNumber", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x6c540baf" + }, + { + "constant": false, + "inputs": [], + "name": "accrueInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xa6afed95" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xf851a440" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xdd62ed3e" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x095ea7b3" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x70a08231" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "balanceOfUnderlying", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x3af9e669" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + } + ], + "name": "borrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xc5ebeaec" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "borrowBalanceCurrent", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x17bfdfbc" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "borrowBalanceStored", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x95dd9193" + }, + { + "constant": true, + "inputs": [], + "name": "borrowIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xaa5af0fd" + }, + { + "constant": true, + "inputs": [], + "name": "borrowRatePerBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xf8f9da28" + }, + { + "constant": true, + "inputs": [], + "name": "comptroller", + "outputs": [ + { + "internalType": "contract ComptrollerInterface", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x5fe3b567" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x313ce567" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "delegateToImplementation", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x0933c1ed" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "delegateToViewImplementation", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x4487152f" + }, + { + "constant": false, + "inputs": [], + "name": "exchangeRateCurrent", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xbd6d894d" + }, + { + "constant": true, + "inputs": [], + "name": "exchangeRateStored", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x182df0f5" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getAccountSnapshot", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xc37f68e2" + }, + { + "constant": true, + "inputs": [], + "name": "getCash", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x3b1d21a2" + }, + { + "constant": true, + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x5c60da1b" + }, + { + "constant": true, + "inputs": [], + "name": "interestRateModel", + "outputs": [ + { + "internalType": "contract InterestRateModel", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xf3fdb15a" + }, + { + "constant": true, + "inputs": [], + "name": "isCToken", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xfe9c44ae" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "internalType": "contract CTokenInterface", + "name": "cTokenCollateral", + "type": "address" + } + ], + "name": "liquidateBorrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xf5e3c462" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xa0712d68" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x06fdde03" + }, + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x26782247" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "redeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xdb006a75" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "redeemAmount", + "type": "uint256" + } + ], + "name": "redeemUnderlying", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x852a12e3" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "repayBorrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x0e752702" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "repayBorrowBehalf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x2608f818" + }, + { + "constant": true, + "inputs": [], + "name": "reserveFactorMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x173b9904" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "seize", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xb2a02ff1" + }, + { + "constant": true, + "inputs": [], + "name": "supplyRatePerBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xae9d70b0" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x95d89b41" + }, + { + "constant": true, + "inputs": [], + "name": "totalBorrows", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x47bd3718" + }, + { + "constant": false, + "inputs": [], + "name": "totalBorrowsCurrent", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x73acee98" + }, + { + "constant": true, + "inputs": [], + "name": "totalReserves", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x8f840ddd" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x18160ddd" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xa9059cbb" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x23b872dd" + }, + { + "constant": true, + "inputs": [], + "name": "underlying", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x6f307dc3" + } +] +module.exports = cDaiAbi; \ No newline at end of file diff --git a/test/mainnet/compound-import/ABIs/cEthAbi.js b/test/mainnet/compound-import/ABIs/cEthAbi.js new file mode 100644 index 00000000..ce4ecec4 --- /dev/null +++ b/test/mainnet/compound-import/ABIs/cEthAbi.js @@ -0,0 +1,1184 @@ +const cEthAbi = [ + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x06fdde03" + }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x095ea7b3" + }, + { + "constant": false, + "inputs": [], + "name": "mint", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function", + "signature": "0x1249c58b" + }, + { + "constant": true, + "inputs": [], + "name": "reserveFactorMantissa", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x173b9904" + }, + { + "constant": false, + "inputs": [ + { + "name": "account", + "type": "address" + } + ], + "name": "borrowBalanceCurrent", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x17bfdfbc" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x18160ddd" + }, + { + "constant": true, + "inputs": [], + "name": "exchangeRateStored", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x182df0f5" + }, + { + "constant": false, + "inputs": [ + { + "name": "src", + "type": "address" + }, + { + "name": "dst", + "type": "address" + }, + { + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x23b872dd" + }, + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x26782247" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x313ce567" + }, + { + "constant": false, + "inputs": [ + { + "name": "owner", + "type": "address" + } + ], + "name": "balanceOfUnderlying", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x3af9e669" + }, + { + "constant": true, + "inputs": [], + "name": "getCash", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x3b1d21a2" + }, + { + "constant": false, + "inputs": [ + { + "name": "newComptroller", + "type": "address" + } + ], + "name": "_setComptroller", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x4576b5db" + }, + { + "constant": true, + "inputs": [], + "name": "totalBorrows", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x47bd3718" + }, + { + "constant": false, + "inputs": [], + "name": "repayBorrow", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function", + "signature": "0x4e4d9fea" + }, + { + "constant": true, + "inputs": [], + "name": "comptroller", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x5fe3b567" + }, + { + "constant": false, + "inputs": [ + { + "name": "reduceAmount", + "type": "uint256" + } + ], + "name": "_reduceReserves", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x601a0bf1" + }, + { + "constant": true, + "inputs": [], + "name": "initialExchangeRateMantissa", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x675d972c" + }, + { + "constant": true, + "inputs": [], + "name": "accrualBlockNumber", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x6c540baf" + }, + { + "constant": true, + "inputs": [ + { + "name": "owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x70a08231" + }, + { + "constant": false, + "inputs": [], + "name": "totalBorrowsCurrent", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x73acee98" + }, + { + "constant": false, + "inputs": [ + { + "name": "redeemAmount", + "type": "uint256" + } + ], + "name": "redeemUnderlying", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x852a12e3" + }, + { + "constant": true, + "inputs": [], + "name": "totalReserves", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x8f840ddd" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x95d89b41" + }, + { + "constant": true, + "inputs": [ + { + "name": "account", + "type": "address" + } + ], + "name": "borrowBalanceStored", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x95dd9193" + }, + { + "constant": false, + "inputs": [], + "name": "accrueInterest", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xa6afed95" + }, + { + "constant": false, + "inputs": [ + { + "name": "dst", + "type": "address" + }, + { + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xa9059cbb" + }, + { + "constant": true, + "inputs": [], + "name": "borrowIndex", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xaa5af0fd" + }, + { + "constant": false, + "inputs": [ + { + "name": "borrower", + "type": "address" + }, + { + "name": "cTokenCollateral", + "type": "address" + } + ], + "name": "liquidateBorrow", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function", + "signature": "0xaae40a2a" + }, + { + "constant": true, + "inputs": [], + "name": "supplyRatePerBlock", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xae9d70b0" + }, + { + "constant": false, + "inputs": [ + { + "name": "liquidator", + "type": "address" + }, + { + "name": "borrower", + "type": "address" + }, + { + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "seize", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xb2a02ff1" + }, + { + "constant": false, + "inputs": [ + { + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "_setPendingAdmin", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xb71d1a0c" + }, + { + "constant": false, + "inputs": [], + "name": "exchangeRateCurrent", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xbd6d894d" + }, + { + "constant": true, + "inputs": [ + { + "name": "account", + "type": "address" + } + ], + "name": "getAccountSnapshot", + "outputs": [ + { + "name": "", + "type": "uint256" + }, + { + "name": "", + "type": "uint256" + }, + { + "name": "", + "type": "uint256" + }, + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xc37f68e2" + }, + { + "constant": false, + "inputs": [ + { + "name": "borrowAmount", + "type": "uint256" + } + ], + "name": "borrow", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xc5ebeaec" + }, + { + "constant": false, + "inputs": [ + { + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "redeem", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xdb006a75" + }, + { + "constant": true, + "inputs": [ + { + "name": "owner", + "type": "address" + }, + { + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xdd62ed3e" + }, + { + "constant": false, + "inputs": [ + { + "name": "borrower", + "type": "address" + } + ], + "name": "repayBorrowBehalf", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function", + "signature": "0xe5974619" + }, + { + "constant": false, + "inputs": [], + "name": "_acceptAdmin", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xe9c714f2" + }, + { + "constant": false, + "inputs": [ + { + "name": "newInterestRateModel", + "type": "address" + } + ], + "name": "_setInterestRateModel", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xf2b3abbd" + }, + { + "constant": true, + "inputs": [], + "name": "interestRateModel", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xf3fdb15a" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xf851a440" + }, + { + "constant": true, + "inputs": [], + "name": "borrowRatePerBlock", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xf8f9da28" + }, + { + "constant": false, + "inputs": [ + { + "name": "newReserveFactorMantissa", + "type": "uint256" + } + ], + "name": "_setReserveFactor", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xfca7820b" + }, + { + "constant": true, + "inputs": [], + "name": "isCToken", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xfe9c44ae" + }, + { + "inputs": [ + { + "name": "comptroller_", + "type": "address" + }, + { + "name": "interestRateModel_", + "type": "address" + }, + { + "name": "initialExchangeRateMantissa_", + "type": "uint256" + }, + { + "name": "name_", + "type": "string" + }, + { + "name": "symbol_", + "type": "string" + }, + { + "name": "decimals_", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor", + "signature": "constructor" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "interestAccumulated", + "type": "uint256" + }, + { + "indexed": false, + "name": "borrowIndex", + "type": "uint256" + }, + { + "indexed": false, + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "AccrueInterest", + "type": "event", + "signature": "0x875352fb3fadeb8c0be7cbbe8ff761b308fa7033470cd0287f02f3436fd76cb9" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "minter", + "type": "address" + }, + { + "indexed": false, + "name": "mintAmount", + "type": "uint256" + }, + { + "indexed": false, + "name": "mintTokens", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event", + "signature": "0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "redeemer", + "type": "address" + }, + { + "indexed": false, + "name": "redeemAmount", + "type": "uint256" + }, + { + "indexed": false, + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "Redeem", + "type": "event", + "signature": "0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "name": "borrowAmount", + "type": "uint256" + }, + { + "indexed": false, + "name": "accountBorrows", + "type": "uint256" + }, + { + "indexed": false, + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "Borrow", + "type": "event", + "signature": "0x13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab80" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "payer", + "type": "address" + }, + { + "indexed": false, + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "name": "repayAmount", + "type": "uint256" + }, + { + "indexed": false, + "name": "accountBorrows", + "type": "uint256" + }, + { + "indexed": false, + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "RepayBorrow", + "type": "event", + "signature": "0x1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "liquidator", + "type": "address" + }, + { + "indexed": false, + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "name": "repayAmount", + "type": "uint256" + }, + { + "indexed": false, + "name": "cTokenCollateral", + "type": "address" + }, + { + "indexed": false, + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "LiquidateBorrow", + "type": "event", + "signature": "0x298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb52" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "oldPendingAdmin", + "type": "address" + }, + { + "indexed": false, + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "NewPendingAdmin", + "type": "event", + "signature": "0xca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "oldAdmin", + "type": "address" + }, + { + "indexed": false, + "name": "newAdmin", + "type": "address" + } + ], + "name": "NewAdmin", + "type": "event", + "signature": "0xf9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "oldComptroller", + "type": "address" + }, + { + "indexed": false, + "name": "newComptroller", + "type": "address" + } + ], + "name": "NewComptroller", + "type": "event", + "signature": "0x7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "oldInterestRateModel", + "type": "address" + }, + { + "indexed": false, + "name": "newInterestRateModel", + "type": "address" + } + ], + "name": "NewMarketInterestRateModel", + "type": "event", + "signature": "0xedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f926" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "oldReserveFactorMantissa", + "type": "uint256" + }, + { + "indexed": false, + "name": "newReserveFactorMantissa", + "type": "uint256" + } + ], + "name": "NewReserveFactor", + "type": "event", + "signature": "0xaaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f821460" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "admin", + "type": "address" + }, + { + "indexed": false, + "name": "reduceAmount", + "type": "uint256" + }, + { + "indexed": false, + "name": "newTotalReserves", + "type": "uint256" + } + ], + "name": "ReservesReduced", + "type": "event", + "signature": "0x3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "error", + "type": "uint256" + }, + { + "indexed": false, + "name": "info", + "type": "uint256" + }, + { + "indexed": false, + "name": "detail", + "type": "uint256" + } + ], + "name": "Failure", + "type": "event", + "signature": "0x45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "from", + "type": "address" + }, + { + "indexed": true, + "name": "to", + "type": "address" + }, + { + "indexed": false, + "name": "amount", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event", + "signature": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "name": "amount", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event", + "signature": "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925" + } +] +module.exports = cEthAbi; \ No newline at end of file diff --git a/test/mainnet/compound-import/ABIs/comptrollerAbi.js b/test/mainnet/compound-import/ABIs/comptrollerAbi.js new file mode 100644 index 00000000..c24070ca --- /dev/null +++ b/test/mainnet/compound-import/ABIs/comptrollerAbi.js @@ -0,0 +1,2654 @@ +const comptrollerAbi = [ + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x26782247" + }, + { + "constant": false, + "inputs": [ + { + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "_setPendingAdmin", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xb71d1a0c" + }, + { + "constant": true, + "inputs": [], + "name": "comptrollerImplementation", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xbb82aa5e" + }, + { + "constant": false, + "inputs": [], + "name": "_acceptImplementation", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xc1e80334" + }, + { + "constant": true, + "inputs": [], + "name": "pendingComptrollerImplementation", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xdcfbc0c7" + }, + { + "constant": false, + "inputs": [ + { + "name": "newPendingImplementation", + "type": "address" + } + ], + "name": "_setPendingImplementation", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xe992a041" + }, + { + "constant": false, + "inputs": [], + "name": "_acceptAdmin", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xe9c714f2" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xf851a440" + }, + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor", + "signature": "constructor" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "oldPendingImplementation", + "type": "address" + }, + { + "indexed": false, + "name": "newPendingImplementation", + "type": "address" + } + ], + "name": "NewPendingImplementation", + "type": "event", + "signature": "0xe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d815" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "oldImplementation", + "type": "address" + }, + { + "indexed": false, + "name": "newImplementation", + "type": "address" + } + ], + "name": "NewImplementation", + "type": "event", + "signature": "0xd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "oldPendingAdmin", + "type": "address" + }, + { + "indexed": false, + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "NewPendingAdmin", + "type": "event", + "signature": "0xca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "oldAdmin", + "type": "address" + }, + { + "indexed": false, + "name": "newAdmin", + "type": "address" + } + ], + "name": "NewAdmin", + "type": "event", + "signature": "0xf9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "error", + "type": "uint256" + }, + { + "indexed": false, + "name": "info", + "type": "uint256" + }, + { + "indexed": false, + "name": "detail", + "type": "uint256" + } + ], + "name": "Failure", + "type": "event", + "signature": "0x45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "contributor", + "type": "address" + } + ], + "name": "updateContributorRewards", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x741b2525" + }, + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor", + "signature": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "action", + "type": "string" + }, + { + "indexed": false, + "internalType": "bool", + "name": "pauseState", + "type": "bool" + } + ], + "name": "ActionPaused", + "type": "event", + "signature": "0xef159d9a32b2472e32b098f954f3ce62d232939f1c207070b584df1814de2de0" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "action", + "type": "string" + }, + { + "indexed": false, + "internalType": "bool", + "name": "pauseState", + "type": "bool" + } + ], + "name": "ActionPaused", + "type": "event", + "signature": "0x71aec636243f9709bb0007ae15e9afb8150ab01716d75fd7573be5cc096e03b0" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldCompAccrued", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newCompAccrued", + "type": "uint256" + } + ], + "name": "CompAccruedAdjusted", + "type": "event", + "signature": "0x4a5c134e28b537a76546993ea37f3b60d9190476df7356d3842aa40902e20f04" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "CompBorrowSpeedUpdated", + "type": "event", + "signature": "0x20af8e791cc98f74b2d7a391c80980ca8e5aebf3d4060bf581997b6acae2e537" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "CompGranted", + "type": "event", + "signature": "0x98b2f82a3a07f223a0be64b3d0f47711c64dccd1feafb94aa28156b38cd9695c" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldCompReceivable", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newCompReceivable", + "type": "uint256" + } + ], + "name": "CompReceivableUpdated", + "type": "event", + "signature": "0x17fea09d9a7ca41b2f9f9118f18f44848a62e9c70d55dd4385131eb2cf1b7e47" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "CompSupplySpeedUpdated", + "type": "event", + "signature": "0xdeafccd0c0b768b2529f7dcbbe58e155d6023059150b7490ed4535cc3744b92d" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "contributor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "ContributorCompSpeedUpdated", + "type": "event", + "signature": "0x386537fa92edc3319af95f1f904dcf1900021e4f3f4e08169a577a09076e66b3" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "compDelta", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "compBorrowIndex", + "type": "uint256" + } + ], + "name": "DistributedBorrowerComp", + "type": "event", + "signature": "0x1fc3ecc087d8d2d15e23d0032af5a47059c3892d003d8e139fdcb6bb327c99a6" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "supplier", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "compDelta", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "compSupplyIndex", + "type": "uint256" + } + ], + "name": "DistributedSupplierComp", + "type": "event", + "signature": "0x2caecd17d02f56fa897705dcc740da2d237c373f70686f4e0d9bd3bf0400ea7a" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "error", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "info", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "detail", + "type": "uint256" + } + ], + "name": "Failure", + "type": "event", + "signature": "0x45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "MarketEntered", + "type": "event", + "signature": "0x3ab23ab0d51cccc0c3085aec51f99228625aa1a922b3a8ca89a26b0f2027a1a5" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "MarketExited", + "type": "event", + "signature": "0xe699a64c18b07ac5b7301aa273f36a2287239eb9501d81950672794afba29a0d" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + } + ], + "name": "MarketListed", + "type": "event", + "signature": "0xcf583bb0c569eb967f806b11601c4cb93c10310485c67add5f8362c2f212321f" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBorrowCap", + "type": "uint256" + } + ], + "name": "NewBorrowCap", + "type": "event", + "signature": "0x6f1951b2aad10f3fc81b86d91105b413a5b3f847a34bbc5ce1904201b14438f6" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldBorrowCapGuardian", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newBorrowCapGuardian", + "type": "address" + } + ], + "name": "NewBorrowCapGuardian", + "type": "event", + "signature": "0xeda98690e518e9a05f8ec6837663e188211b2da8f4906648b323f2c1d4434e29" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldCloseFactorMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newCloseFactorMantissa", + "type": "uint256" + } + ], + "name": "NewCloseFactor", + "type": "event", + "signature": "0x3b9670cf975d26958e754b57098eaa2ac914d8d2a31b83257997b9f346110fd9" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldCollateralFactorMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newCollateralFactorMantissa", + "type": "uint256" + } + ], + "name": "NewCollateralFactor", + "type": "event", + "signature": "0x70483e6592cd5182d45ac970e05bc62cdcc90e9d8ef2c2dbe686cf383bcd7fc5" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldLiquidationIncentiveMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newLiquidationIncentiveMantissa", + "type": "uint256" + } + ], + "name": "NewLiquidationIncentive", + "type": "event", + "signature": "0xaeba5a6c40a8ac138134bff1aaa65debf25971188a58804bad717f82f0ec1316" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPauseGuardian", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPauseGuardian", + "type": "address" + } + ], + "name": "NewPauseGuardian", + "type": "event", + "signature": "0x0613b6ee6a04f0d09f390e4d9318894b9f6ac7fd83897cd8d18896ba579c401e" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract PriceOracle", + "name": "oldPriceOracle", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract PriceOracle", + "name": "newPriceOracle", + "type": "address" + } + ], + "name": "NewPriceOracle", + "type": "event", + "signature": "0xd52b2b9b7e9ee655fcb95d2e5b9e0c9f69e7ef2b8e9d2d0ea78402d576d22e22" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract Unitroller", + "name": "unitroller", + "type": "address" + } + ], + "name": "_become", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x1d504dc6" + }, + { + "constant": true, + "inputs": [], + "name": "_borrowGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xe6653f3d" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "_grantComp", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x27efe3cb" + }, + { + "constant": true, + "inputs": [], + "name": "_mintGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x3c94786f" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newBorrowCapGuardian", + "type": "address" + } + ], + "name": "_setBorrowCapGuardian", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x391957d7" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "state", + "type": "bool" + } + ], + "name": "_setBorrowPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x18c882a5" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "newCloseFactorMantissa", + "type": "uint256" + } + ], + "name": "_setCloseFactor", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x317b0b77" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "newCollateralFactorMantissa", + "type": "uint256" + } + ], + "name": "_setCollateralFactor", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xe4028eee" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "supplySpeeds", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "borrowSpeeds", + "type": "uint256[]" + } + ], + "name": "_setCompSpeeds", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xa8b43948" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "contributor", + "type": "address" + }, + { + "internalType": "uint256", + "name": "compSpeed", + "type": "uint256" + } + ], + "name": "_setContributorCompSpeed", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x598ee1cb" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "newLiquidationIncentiveMantissa", + "type": "uint256" + } + ], + "name": "_setLiquidationIncentive", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x4fd42e17" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "newBorrowCaps", + "type": "uint256[]" + } + ], + "name": "_setMarketBorrowCaps", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x607ef6c1" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "state", + "type": "bool" + } + ], + "name": "_setMintPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x3bcf7ec1" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newPauseGuardian", + "type": "address" + } + ], + "name": "_setPauseGuardian", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x5f5af1aa" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract PriceOracle", + "name": "newOracle", + "type": "address" + } + ], + "name": "_setPriceOracle", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x55ee1fe1" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "bool", + "name": "state", + "type": "bool" + } + ], + "name": "_setSeizePaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x2d70db78" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "bool", + "name": "state", + "type": "bool" + } + ], + "name": "_setTransferPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x8ebf6364" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + } + ], + "name": "_supportMarket", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xa76b3fda" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "accountAssets", + "outputs": [ + { + "internalType": "contract CToken", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xdce15449" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xf851a440" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "allMarkets", + "outputs": [ + { + "internalType": "contract CToken", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x52d84d1e" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + } + ], + "name": "borrowAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xda3d454c" + }, + { + "constant": true, + "inputs": [], + "name": "borrowCapGuardian", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x21af4569" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "borrowCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x4a584432" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "borrowGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x6d154ea5" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + } + ], + "name": "borrowVerify", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x5c778605" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + } + ], + "name": "checkMembership", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x929fe9a1" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "holder", + "type": "address" + }, + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + } + ], + "name": "claimComp", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x1c3db2e0" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address[]", + "name": "holders", + "type": "address[]" + }, + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + }, + { + "internalType": "bool", + "name": "borrowers", + "type": "bool" + }, + { + "internalType": "bool", + "name": "suppliers", + "type": "bool" + } + ], + "name": "claimComp", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x6810dfa6" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "holder", + "type": "address" + } + ], + "name": "claimComp", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xe9af0292" + }, + { + "constant": true, + "inputs": [], + "name": "closeFactorMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xe8755446" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "compAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xcc7ebdc4" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "compBorrowSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xf4a433c0" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "compBorrowState", + "outputs": [ + { + "internalType": "uint224", + "name": "index", + "type": "uint224" + }, + { + "internalType": "uint32", + "name": "block", + "type": "uint32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x8c57804e" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "compBorrowerIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xca0af043" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "compContributorSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x986ab838" + }, + { + "constant": true, + "inputs": [], + "name": "compInitialIndex", + "outputs": [ + { + "internalType": "uint224", + "name": "", + "type": "uint224" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xa7f0e231" + }, + { + "constant": true, + "inputs": [], + "name": "compRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xaa900754" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "compReceivable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x85b7beb8" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "compSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x1d7b33d7" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "compSupplierIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xb21be7fd" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "compSupplySpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x6aa875b5" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "compSupplyState", + "outputs": [ + { + "internalType": "uint224", + "name": "index", + "type": "uint224" + }, + { + "internalType": "uint32", + "name": "block", + "type": "uint32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x6b79c38d" + }, + { + "constant": true, + "inputs": [], + "name": "comptrollerImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xbb82aa5e" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address[]", + "name": "cTokens", + "type": "address[]" + } + ], + "name": "enterMarkets", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xc2998238" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "cTokenAddress", + "type": "address" + } + ], + "name": "exitMarket", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xede4edd0" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address[]", + "name": "affectedUsers", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "name": "fixBadAccruals", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x16b95e8f" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getAccountLiquidity", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x5ec88c79" + }, + { + "constant": true, + "inputs": [], + "name": "getAllMarkets", + "outputs": [ + { + "internalType": "contract CToken[]", + "name": "", + "type": "address[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xb0772d0b" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getAssetsIn", + "outputs": [ + { + "internalType": "contract CToken[]", + "name": "", + "type": "address[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xabfceffc" + }, + { + "constant": true, + "inputs": [], + "name": "getBlockNumber", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x42cbb15c" + }, + { + "constant": true, + "inputs": [], + "name": "getCompAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x9d1b5a0a" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "cTokenModify", + "type": "address" + }, + { + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + } + ], + "name": "getHypotheticalAccountLiquidity", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x4e79238f" + }, + { + "constant": true, + "inputs": [], + "name": "isComptroller", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x007e3dd2" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + } + ], + "name": "isDeprecated", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x94543c15" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "lastContributorBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xbea6b8b8" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "cTokenBorrowed", + "type": "address" + }, + { + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "liquidateBorrowAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x5fc7e71e" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "cTokenBorrowed", + "type": "address" + }, + { + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "actualRepayAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "liquidateBorrowVerify", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x47ef3b3b" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "cTokenBorrowed", + "type": "address" + }, + { + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "uint256", + "name": "actualRepayAmount", + "type": "uint256" + } + ], + "name": "liquidateCalculateSeizeTokens", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xc488847b" + }, + { + "constant": true, + "inputs": [], + "name": "liquidationIncentiveMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x4ada90af" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "markets", + "outputs": [ + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isComped", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x8e8f294b" + }, + { + "constant": true, + "inputs": [], + "name": "maxAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x94b2294b" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + } + ], + "name": "mintAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x4ef4c3e1" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "mintGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x731f0c2b" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "internalType": "uint256", + "name": "actualMintAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "mintTokens", + "type": "uint256" + } + ], + "name": "mintVerify", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x41c728b9" + }, + { + "constant": true, + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract PriceOracle", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x7dc0d1d0" + }, + { + "constant": true, + "inputs": [], + "name": "pauseGuardian", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x24a3d622" + }, + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x26782247" + }, + { + "constant": true, + "inputs": [], + "name": "pendingComptrollerImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xdcfbc0c7" + }, + { + "constant": true, + "inputs": [], + "name": "proposal65FixExecuted", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xf00a7a92" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "redeemAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xeabe7d91" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "redeemAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "redeemVerify", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x51dff989" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "payer", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "repayBorrowAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x24008a62" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "payer", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "actualRepayAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowerIndex", + "type": "uint256" + } + ], + "name": "repayBorrowVerify", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x1ededc91" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "cTokenBorrowed", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "seizeAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xd02f7351" + }, + { + "constant": true, + "inputs": [], + "name": "seizeGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0xac0b0bb7" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "cTokenBorrowed", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "seizeVerify", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x6d35bf91" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "transferTokens", + "type": "uint256" + } + ], + "name": "transferAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xbdcdc258" + }, + { + "constant": true, + "inputs": [], + "name": "transferGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x87f76303" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "transferTokens", + "type": "uint256" + } + ], + "name": "transferVerify", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x6a56947e" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "contributor", + "type": "address" + } + ], + "name": "updateContributorRewards", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x741b2525" + } +] +module.exports = comptrollerAbi; \ No newline at end of file diff --git a/test/mainnet/compound-import/compound-import.test.js b/test/mainnet/compound-import/compound-import.test.js new file mode 100644 index 00000000..8a97bac0 --- /dev/null +++ b/test/mainnet/compound-import/compound-import.test.js @@ -0,0 +1,124 @@ +const { expect, should } = require("chai"); +const { ethers } = require('hardhat'); +const { buildDSAv2 } = require("../../../scripts/tests/buildDSAv2"); +const { cEthAddress, cDaiAddress, daiAddress, comptrollerAddress } = require("./constants.js"); +const cEthAbi = require("./ABIs/cEthAbi"); +const cDaiAbi = require("./ABIs/cDaiAbi"); +const comptrollerAbi = require("./ABIs/comptrollerAbi"); +const { parseEther, parseUnits } = require("ethers/lib/utils"); +const { encodeSpells } = require("../../../scripts/tests/encodeSpells"); +const encodeFlashcastData = require("../../../scripts/tests/encodeFlashcastData").default; + + +describe('Import Compound', function () { + const connectorName = "IMPORT-COMPOUND-TEST-A" + let owner; // signers + let cEth, cDai, comptroller, Dai; // contracts + + before(async () => { + // create (reset) mainnet fork + await hre.network.provider.request({ + method: "hardhat_reset", + params: [ + { + forking: { + jsonRpcUrl: hre.config.networks.hardhat.forking.url, + blockNumber: 13300000, + }, + }, + ], + }); + + // get an account + await hre.network.provider.request({ + method: "hardhat_impersonateAccount", + params: ["0x10a25c6886AE02fde87C5561CDD331d941d0771a"], + }); + owner = await ethers.getSigner("0x10a25c6886AE02fde87C5561CDD331d941d0771a"); + + await hre.network.provider.send("hardhat_setBalance", [ + "0x10a25c6886AE02fde87C5561CDD331d941d0771a", + parseEther('100000').toHexString() + ]); + + // deploy connector contract + const contractConnectorFactory = await ethers.getContractFactory("ConnectV2CompoundImport"); + importCompoundConnector = await contractConnectorFactory.connect(owner).deploy(); + console.log("Connector address", importCompoundConnector.address); + + cEth = new ethers.Contract(cEthAddress, cEthAbi, ethers.provider); + cDai = new ethers.Contract(cDaiAddress, cDaiAbi, ethers.provider); + const tokenArtifact = await artifacts.readArtifact("@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20"); + Dai = new ethers.Contract(daiAddress, tokenArtifact.abi, ethers.provider); + comptroller = new ethers.Contract(comptrollerAddress, comptrollerAbi, ethers.provider); + + // deposit ether to Compound + await cEth.connect(owner).mint({ + value: parseEther('10') + }); + + // enter markets with deposits + const cTokens = [cEth.address]; + await comptroller.connect(owner).enterMarkets(cTokens); + + // borrow dai from Compound + await cDai.connect(owner).borrow(parseUnits('1000')); + }); + + describe('Deployment', async () => { + it('Should set correct name', async () => { + await expect(await importCompoundConnector.name()).to.eq('Compound-Import-v2'); + }); + }); + + describe("DSA wallet setup", async () => { + it("Should build DSA v2", async () => { + dsaWallet0 = await buildDSAv2(owner.address); + console.log(dsaWallet0.address); + expect(!!dsaWallet0.address).to.be.true; + }); + }); + + describe('Compound position migration', async () => { + it('Should migrate Compound position', async () => { + const flashSpells = [ + { + connector: 'INSTAPOOL-C', + method: 'flashPayback', + args: [Dai.address, parseUnits('1000.9'), 0, 0], + }] + + const spells = [ + { + connector: 'INSTAPOOL-A', + method: "flashBorrowAndCast", + args: [Dai.address, '1000', 1, encodeFlashcastData(flashSpells), bytes(0)] + } + ] + + const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) + const receipt = await tx.wait(); + }) + // it('DSA wallet should persist', async () => { + // console.log(dsaWallet0.address); + // }); + // take flash loan of dai through spell + // call contract function + // repay flash loan of dai + // check if import was successful + }) +}); + + +// deploy the connector on mainnet fork +// build a new dsa in tests + +// create a Compound position + // deposit some ether in Compound + // borrow some DAI + +// migrate the Compound position + // cast the migrate spell + +// check if migration was successful + // check the balance of DSA contract address in ERC20 tokens diff --git a/test/mainnet/compound-import/constants.js b/test/mainnet/compound-import/constants.js new file mode 100644 index 00000000..1648ec0c --- /dev/null +++ b/test/mainnet/compound-import/constants.js @@ -0,0 +1,6 @@ +const cEthAddress = "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5"; +const cDaiAddress = "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643"; +const daiAddress = "0x6B175474E89094C44Da98b954EedeAC495271d0F"; +const comptrollerAddress = "0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B"; +module.exports = { cEthAddress, cDaiAddress, daiAddress, comptrollerAddress }; + \ No newline at end of file From be278c62f5a5b6985b2594e50d0e7e3638aa8336 Mon Sep 17 00:00:00 2001 From: Chinmay Chougaonkar Date: Sat, 5 Mar 2022 12:27:30 +0530 Subject: [PATCH 06/20] added deployAndEnable for connector and instapool in test script --- .../compound-import/compound-import.test.js | 65 +++++++++++++------ 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/test/mainnet/compound-import/compound-import.test.js b/test/mainnet/compound-import/compound-import.test.js index 8a97bac0..902c39f8 100644 --- a/test/mainnet/compound-import/compound-import.test.js +++ b/test/mainnet/compound-import/compound-import.test.js @@ -1,19 +1,31 @@ const { expect, should } = require("chai"); const { ethers } = require('hardhat'); +const { Signer, Contract } = require("ethers"); + const { buildDSAv2 } = require("../../../scripts/tests/buildDSAv2"); const { cEthAddress, cDaiAddress, daiAddress, comptrollerAddress } = require("./constants.js"); const cEthAbi = require("./ABIs/cEthAbi"); const cDaiAbi = require("./ABIs/cDaiAbi"); const comptrollerAbi = require("./ABIs/comptrollerAbi"); +const { addresses } = require("../../../scripts/tests/mainnet/addresses"); +const { deployAndEnableConnector } = require("../../../scripts/tests/deployAndEnableConnector"); +const { abis } = require("../../../scripts/constant/abis"); +const { getMasterSigner } = require("../../../scripts/tests/getMasterSigner"); const { parseEther, parseUnits } = require("ethers/lib/utils"); const { encodeSpells } = require("../../../scripts/tests/encodeSpells"); const encodeFlashcastData = require("../../../scripts/tests/encodeFlashcastData").default; +const { ConnectV2CompoundImport__factory } = require("../../../typechain"); +const { ConnectV2InstaPoolV4__factory } = require("../../../typechain"); describe('Import Compound', function () { - const connectorName = "IMPORT-COMPOUND-TEST-A" + // const connectorName = "COMPOUND-IMPORT-ABC"; + const connectorName = "COMPOUND-IMPORT-C"; + const instapoolConnector = "INSTAPOOL-C"; let owner; // signers let cEth, cDai, comptroller, Dai; // contracts + let masterSigner = Signer; + let connector, connector2; before(async () => { // create (reset) mainnet fork @@ -28,8 +40,28 @@ describe('Import Compound', function () { }, ], }); + + // deploy and enable connector contract + masterSigner = await getMasterSigner() + instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2); - // get an account + connector = await deployAndEnableConnector({ + connectorName, + contractArtifact: ConnectV2CompoundImport__factory, + signer: masterSigner, + connectors: instaConnectorsV2 + }) + console.log("Connector address", connector.address); + + connector2 = await deployAndEnableConnector({ + connectorName: instapoolConnector, + contractArtifact: ConnectV2InstaPoolV4__factory, + signer: masterSigner, + connectors: instaConnectorsV2 + }) + console.log("Connector2 address", connector2.address); + + // // get an account await hre.network.provider.request({ method: "hardhat_impersonateAccount", params: ["0x10a25c6886AE02fde87C5561CDD331d941d0771a"], @@ -41,11 +73,6 @@ describe('Import Compound', function () { parseEther('100000').toHexString() ]); - // deploy connector contract - const contractConnectorFactory = await ethers.getContractFactory("ConnectV2CompoundImport"); - importCompoundConnector = await contractConnectorFactory.connect(owner).deploy(); - console.log("Connector address", importCompoundConnector.address); - cEth = new ethers.Contract(cEthAddress, cEthAbi, ethers.provider); cDai = new ethers.Contract(cDaiAddress, cDaiAbi, ethers.provider); const tokenArtifact = await artifacts.readArtifact("@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20"); @@ -67,7 +94,7 @@ describe('Import Compound', function () { describe('Deployment', async () => { it('Should set correct name', async () => { - await expect(await importCompoundConnector.name()).to.eq('Compound-Import-v2'); + await expect(await connector.name()).to.eq('Compound-Import-v2'); }); }); @@ -83,25 +110,23 @@ describe('Import Compound', function () { it('Should migrate Compound position', async () => { const flashSpells = [ { - connector: 'INSTAPOOL-C', + connector: instapoolConnector, method: 'flashPayback', args: [Dai.address, parseUnits('1000.9'), 0, 0], - }] - - const spells = [ - { - connector: 'INSTAPOOL-A', - method: "flashBorrowAndCast", - args: [Dai.address, '1000', 1, encodeFlashcastData(flashSpells), bytes(0)] } ] - const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) + const spells = [ + { + connector: instapoolConnector, + method: "flashBorrowAndCast", + args: [Dai.address, parseUnits('1000'), 0, encodeFlashcastData(flashSpells), "0x"] + } + ] + + const tx = await dsaWallet0.connect(owner).cast(...encodeSpells(spells), owner.address) const receipt = await tx.wait(); }) - // it('DSA wallet should persist', async () => { - // console.log(dsaWallet0.address); - // }); // take flash loan of dai through spell // call contract function // repay flash loan of dai From 5cd4eb192cd28afd423f99da6b762e56e29b2f46 Mon Sep 17 00:00:00 2001 From: Chinmay Chougaonkar Date: Sat, 5 Mar 2022 12:39:25 +0530 Subject: [PATCH 07/20] use wallets in tests --- .../compound-import/compound-import.test.js | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/test/mainnet/compound-import/compound-import.test.js b/test/mainnet/compound-import/compound-import.test.js index 902c39f8..2608f967 100644 --- a/test/mainnet/compound-import/compound-import.test.js +++ b/test/mainnet/compound-import/compound-import.test.js @@ -1,5 +1,6 @@ const { expect, should } = require("chai"); const { ethers } = require('hardhat'); +const { provider, deployContract} = waffle const { Signer, Contract } = require("ethers"); const { buildDSAv2 } = require("../../../scripts/tests/buildDSAv2"); @@ -22,10 +23,13 @@ describe('Import Compound', function () { // const connectorName = "COMPOUND-IMPORT-ABC"; const connectorName = "COMPOUND-IMPORT-C"; const instapoolConnector = "INSTAPOOL-C"; - let owner; // signers + let dsaWallet0; // signers let cEth, cDai, comptroller, Dai; // contracts let masterSigner = Signer; let connector, connector2; + let wallet0, wallet1, wallet2, wallet3; + const wallets = provider.getWallets() + before(async () => { // create (reset) mainnet fork @@ -61,12 +65,14 @@ describe('Import Compound', function () { }) console.log("Connector2 address", connector2.address); - // // get an account + [wallet0, wallet1, wallet2, wallet3] = wallets + + // get an account await hre.network.provider.request({ method: "hardhat_impersonateAccount", params: ["0x10a25c6886AE02fde87C5561CDD331d941d0771a"], }); - owner = await ethers.getSigner("0x10a25c6886AE02fde87C5561CDD331d941d0771a"); + wallet0 = await ethers.getSigner("0x10a25c6886AE02fde87C5561CDD331d941d0771a"); await hre.network.provider.send("hardhat_setBalance", [ "0x10a25c6886AE02fde87C5561CDD331d941d0771a", @@ -80,16 +86,16 @@ describe('Import Compound', function () { comptroller = new ethers.Contract(comptrollerAddress, comptrollerAbi, ethers.provider); // deposit ether to Compound - await cEth.connect(owner).mint({ + await cEth.connect(wallet0).mint({ value: parseEther('10') }); // enter markets with deposits const cTokens = [cEth.address]; - await comptroller.connect(owner).enterMarkets(cTokens); + await comptroller.connect(wallet0).enterMarkets(cTokens); // borrow dai from Compound - await cDai.connect(owner).borrow(parseUnits('1000')); + await cDai.connect(wallet0).borrow(parseUnits('1000')); }); describe('Deployment', async () => { @@ -100,10 +106,18 @@ describe('Import Compound', function () { describe("DSA wallet setup", async () => { it("Should build DSA v2", async () => { - dsaWallet0 = await buildDSAv2(owner.address); + dsaWallet0 = await buildDSAv2(wallet0.address); console.log(dsaWallet0.address); expect(!!dsaWallet0.address).to.be.true; }); + + it("Deposit ETH into DSA wallet", async function () { + await wallet0.sendTransaction({ + to: dsaWallet0.address, + value: ethers.utils.parseEther("10") + }); + expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("10")); + }); }); describe('Compound position migration', async () => { @@ -124,7 +138,7 @@ describe('Import Compound', function () { } ] - const tx = await dsaWallet0.connect(owner).cast(...encodeSpells(spells), owner.address) + const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) const receipt = await tx.wait(); }) // take flash loan of dai through spell From 9a8f20450899b4aa83636dc3f109356fa9b3142a Mon Sep 17 00:00:00 2001 From: Chinmay Chougaonkar Date: Sat, 5 Mar 2022 20:00:23 +0530 Subject: [PATCH 08/20] added Compound spells before flashPayback --- .../compound-import/compound-import.test.js | 61 +++++++++++++------ 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/test/mainnet/compound-import/compound-import.test.js b/test/mainnet/compound-import/compound-import.test.js index 2608f967..52301cf8 100644 --- a/test/mainnet/compound-import/compound-import.test.js +++ b/test/mainnet/compound-import/compound-import.test.js @@ -17,19 +17,20 @@ const { encodeSpells } = require("../../../scripts/tests/encodeSpells"); const encodeFlashcastData = require("../../../scripts/tests/encodeFlashcastData").default; const { ConnectV2CompoundImport__factory } = require("../../../typechain"); const { ConnectV2InstaPoolV4__factory } = require("../../../typechain"); +const { ConnectV2Compound__factory } = require("../../../typechain"); describe('Import Compound', function () { // const connectorName = "COMPOUND-IMPORT-ABC"; const connectorName = "COMPOUND-IMPORT-C"; const instapoolConnector = "INSTAPOOL-C"; - let dsaWallet0; // signers + const compoundConnector = "COMPOUND-C"; + let dsaWallet; // signers let cEth, cDai, comptroller, Dai; // contracts let masterSigner = Signer; - let connector, connector2; - let wallet0, wallet1, wallet2, wallet3; - const wallets = provider.getWallets() - + let connector, connector2, connector3; + let owner; + let wallets; before(async () => { // create (reset) mainnet fork @@ -49,6 +50,7 @@ describe('Import Compound', function () { masterSigner = await getMasterSigner() instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2); + // compound import connector connector = await deployAndEnableConnector({ connectorName, contractArtifact: ConnectV2CompoundImport__factory, @@ -56,7 +58,8 @@ describe('Import Compound', function () { connectors: instaConnectorsV2 }) console.log("Connector address", connector.address); - + + // flash loan connector connector2 = await deployAndEnableConnector({ connectorName: instapoolConnector, contractArtifact: ConnectV2InstaPoolV4__factory, @@ -65,14 +68,21 @@ describe('Import Compound', function () { }) console.log("Connector2 address", connector2.address); - [wallet0, wallet1, wallet2, wallet3] = wallets + // compound connector + connector3 = await deployAndEnableConnector({ + connectorName: compoundConnector, + contractArtifact: ConnectV2Compound__factory, + signer: masterSigner, + connectors: instaConnectorsV2 + }) + console.log("Connector3 address", connector3.address); // get an account await hre.network.provider.request({ method: "hardhat_impersonateAccount", params: ["0x10a25c6886AE02fde87C5561CDD331d941d0771a"], }); - wallet0 = await ethers.getSigner("0x10a25c6886AE02fde87C5561CDD331d941d0771a"); + owner = await ethers.getSigner("0x10a25c6886AE02fde87C5561CDD331d941d0771a"); await hre.network.provider.send("hardhat_setBalance", [ "0x10a25c6886AE02fde87C5561CDD331d941d0771a", @@ -86,16 +96,16 @@ describe('Import Compound', function () { comptroller = new ethers.Contract(comptrollerAddress, comptrollerAbi, ethers.provider); // deposit ether to Compound - await cEth.connect(wallet0).mint({ + await cEth.connect(owner).mint({ value: parseEther('10') }); // enter markets with deposits const cTokens = [cEth.address]; - await comptroller.connect(wallet0).enterMarkets(cTokens); + await comptroller.connect(owner).enterMarkets(cTokens); // borrow dai from Compound - await cDai.connect(wallet0).borrow(parseUnits('1000')); + await cDai.connect(owner).borrow(parseUnits('1000')); }); describe('Deployment', async () => { @@ -106,23 +116,36 @@ describe('Import Compound', function () { describe("DSA wallet setup", async () => { it("Should build DSA v2", async () => { - dsaWallet0 = await buildDSAv2(wallet0.address); - console.log(dsaWallet0.address); - expect(!!dsaWallet0.address).to.be.true; + dsaWallet = await buildDSAv2(owner.address); + console.log(dsaWallet.address); + expect(!!dsaWallet.address).to.be.true; }); it("Deposit ETH into DSA wallet", async function () { - await wallet0.sendTransaction({ - to: dsaWallet0.address, + await owner.sendTransaction({ + to: dsaWallet.address, value: ethers.utils.parseEther("10") }); - expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("10")); + expect(await ethers.provider.getBalance(dsaWallet.address)).to.be.gte(ethers.utils.parseEther("10")); }); }); describe('Compound position migration', async () => { it('Should migrate Compound position', async () => { + const amount = ethers.utils.parseEther("100") // 100 DAI + const setId = "83478237"; + const flashSpells = [ + { + connector: compoundConnector, + method: "borrow", + args: ["DAI-A", amount, 0, setId] + }, + { + connector: compoundConnector, + method: "payback", + args: ["DAI-A", 0, setId, 0] + }, { connector: instapoolConnector, method: 'flashPayback', @@ -137,8 +160,8 @@ describe('Import Compound', function () { args: [Dai.address, parseUnits('1000'), 0, encodeFlashcastData(flashSpells), "0x"] } ] - - const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) + console.log(owner.address); + const tx = await dsaWallet.connect(owner).cast(...encodeSpells(spells), owner.address) const receipt = await tx.wait(); }) // take flash loan of dai through spell From 8e74f758620dac39e0148020b127e97d62f3cd1a Mon Sep 17 00:00:00 2001 From: Chinmay Chougaonkar Date: Mon, 7 Mar 2022 20:10:17 +0530 Subject: [PATCH 09/20] refactored compound-import contracts --- .../connectors/compound-import/events.sol | 4 +- .../connectors/compound-import/helpers.sol | 179 ++++++++++++++++- .../connectors/compound-import/main.sol | 184 +----------------- 3 files changed, 183 insertions(+), 184 deletions(-) diff --git a/contracts/mainnet/connectors/compound-import/events.sol b/contracts/mainnet/connectors/compound-import/events.sol index d3125959..09e3e8f2 100644 --- a/contracts/mainnet/connectors/compound-import/events.sol +++ b/contracts/mainnet/connectors/compound-import/events.sol @@ -7,7 +7,7 @@ contract Events { address[] ctokens, string[] supplyIds, string[] borrowIds, - uint[] supplyAmts, - uint[] borrowAmts + uint256[] supplyAmts, + uint256[] borrowAmts ); } \ No newline at end of file diff --git a/contracts/mainnet/connectors/compound-import/helpers.sol b/contracts/mainnet/connectors/compound-import/helpers.sol index c6042b9c..78e600b1 100644 --- a/contracts/mainnet/connectors/compound-import/helpers.sol +++ b/contracts/mainnet/connectors/compound-import/helpers.sol @@ -2,7 +2,8 @@ pragma solidity ^0.7.6; import { DSMath } from "../../common/math.sol"; import { Basic } from "../../common/basic.sol"; -import { ComptrollerInterface, CompoundMappingInterface, CETHInterface } from "./interface.sol"; +import { TokenInterface, AccountInterface } from "../../common/interfaces.sol"; +import { ComptrollerInterface, CompoundMappingInterface, CETHInterface, CTokenInterface } from "./interface.sol"; abstract contract Helpers is DSMath, Basic { @@ -21,6 +22,24 @@ abstract contract Helpers is DSMath, Basic { */ CompoundMappingInterface internal constant compMapping = CompoundMappingInterface(0xe7a85d0adDB972A4f0A4e57B698B37f171519e88); + struct ImportData { + address[] cTokens; // is the list of all tokens the user has interacted with (supply/borrow) -> used to enter markets + uint[] borrowAmts; + uint[] supplyAmts; + address[] borrowTokens; + address[] supplyTokens; + CTokenInterface[] borrowCtokens; + CTokenInterface[] supplyCtokens; + address[] supplyCtokensAddr; + address[] borrowCtokensAddr; + } + + struct ImportInputData { + address userAccount; + string[] supplyIds; + string[] borrowIds; + } + /** * @dev enter compound market */ @@ -38,4 +57,162 @@ abstract contract Helpers is DSMath, Basic { troller.enterMarkets(toEnter); } } +} + +contract CompoundHelper is Helpers { + + /** + * @notice fetch the borrow details of the user + * @dev approve the cToken to spend (borrowed amount of) tokens to allow for repaying later + * @param _importInputData the struct containing borrowIds of the users borrowed tokens + * @param data struct used to store the final data on which the CompoundHelper contract functions operate + * @return ImportData the final value of param data + */ + function getBorrowAmounts ( + ImportInputData memory _importInputData, + ImportData memory data + ) internal returns(ImportData memory) { + if (_importInputData.borrowIds.length > 0) { + // initialize arrays for borrow data + data.borrowTokens = new address[](_importInputData.borrowIds.length); + data.borrowCtokens = new CTokenInterface[](_importInputData.borrowIds.length); + data.borrowCtokensAddr = new address[](_importInputData.borrowIds.length); + data.borrowAmts = new uint[](_importInputData.borrowIds.length); + + // check for repeated tokens + for (uint i = 0; i < _importInputData.borrowIds.length; i++) { + bytes32 i_hash = keccak256(abi.encode(_importInputData.borrowIds[i])); + for (uint j = i + 1; j < _importInputData.borrowIds.length; j++) { + bytes32 j_hash = keccak256(abi.encode(_importInputData.borrowIds[j])); + require(i_hash != j_hash, "token-repeated"); + } + } + + // populate the arrays with borrow tokens, cToken addresses and instances, and borrow amounts + for (uint i = 0; i < _importInputData.borrowIds.length; i++) { + (address _token, address _cToken) = compMapping.getMapping(_importInputData.borrowIds[i]); + + require(_token != address(0) && _cToken != address(0), "ctoken mapping not found"); + + data.cTokens[i] = _cToken; + + data.borrowTokens[i] = _token; + data.borrowCtokens[i] = CTokenInterface(_cToken); + data.borrowCtokensAddr[i] = _cToken; + data.borrowAmts[i] = data.borrowCtokens[i].borrowBalanceCurrent(_importInputData.userAccount); + + // give the resp. cToken address approval to spend tokens + if (_token != ethAddr && data.borrowAmts[i] > 0) { + // will be required when repaying the borrow amount on behalf of the user + TokenInterface(_token).approve(_cToken, data.borrowAmts[i]); + } + } + } + return data; + } + + /** + * @notice fetch the supply details of the user + * @dev only reads data from blockchain hence view + * @param _importInputData the struct containing supplyIds of the users supplied tokens + * @param data struct used to store the final data on which the CompoundHelper contract functions operate + * @return ImportData the final value of param data + */ + function getSupplyAmounts ( + ImportInputData memory _importInputData, + ImportData memory data + ) internal view returns(ImportData memory) { + // initialize arrays for supply data + data.supplyTokens = new address[](_importInputData.supplyIds.length); + data.supplyCtokens = new CTokenInterface[](_importInputData.supplyIds.length); + data.supplyCtokensAddr = new address[](_importInputData.supplyIds.length); + data.supplyAmts = new uint[](_importInputData.supplyIds.length); + + // check for repeated tokens + for (uint i = 0; i < _importInputData.supplyIds.length; i++) { + bytes32 i_hash = keccak256(abi.encode(_importInputData.supplyIds[i])); + for (uint j = i + 1; j < _importInputData.supplyIds.length; j++) { + bytes32 j_hash = keccak256(abi.encode(_importInputData.supplyIds[j])); + require(i_hash != j_hash, "token-repeated"); + } + } + + // populate arrays with supply data (supply tokens address, cToken addresses, cToken instances and supply amounts) + for (uint i = 0; i < _importInputData.supplyIds.length; i++) { + (address _token, address _cToken) = compMapping.getMapping(_importInputData.supplyIds[i]); + + require(_token != address(0) && _cToken != address(0), "ctoken mapping not found"); + + uint _supplyIndex = add(i, _importInputData.borrowIds.length); + data.cTokens[_supplyIndex] = _cToken; + + data.supplyTokens[i] = _token; + data.supplyCtokens[i] = CTokenInterface(_cToken); + data.supplyCtokensAddr[i] = (_cToken); + data.supplyAmts[i] = data.supplyCtokens[i].balanceOf(_importInputData.userAccount); + } + return data; + } + + /** + * @notice repays the debt taken by user on Compound on its behalf to free its collateral for transfer + * @dev uses the cEth contract for ETH repays, otherwise the general cToken interface + * @param _userAccount the user address for which debt is to be repayed + * @param _cTokenContracts array containing all interfaces to the cToken contracts in which the user has debt positions + * @param _borrowAmts array containing the amount borrowed for each token + */ + function _repayUserDebt( + address _userAccount, + CTokenInterface[] memory _cTokenContracts, + uint[] memory _borrowAmts + ) internal { + for(uint i = 0; i < _cTokenContracts.length; i++){ + if(_borrowAmts[i] > 0){ + if(address(_cTokenContracts[i]) == address(cEth)){ + cEth.repayBorrowBehalf{value: _borrowAmts[i]}(_userAccount); + } + else{ + require(_cTokenContracts[i].repayBorrowBehalf(_userAccount, _borrowAmts[i]) == 0, "repayOnBehalf-failed"); + } + } + } + } + + /** + * @notice used to transfer user's supply position on Compound to DSA + * @dev uses the transferFrom token in cToken contracts to transfer positions, requires approval from user first + * @param _userAccount address of the user account whose position is to be transferred + * @param _cTokenContracts array containing all interfaces to the cToken contracts in which the user has supply positions + * @param _amts array containing the amount supplied for each token + */ + function _transferTokensToDsa( + address _userAccount, + CTokenInterface[] memory _cTokenContracts, + uint[] memory _amts + ) internal { + for(uint i = 0; i < _cTokenContracts.length; i++) { + if(_amts[i] > 0) { + require(_cTokenContracts[i].transferFrom(_userAccount, address(this), _amts[i]), "ctoken-transfer-failed-allowance?"); + } + } + } + + /** + * @notice borrows the user's debt positions from Compound via DSA, so that its debt positions get imported to DSA + * @dev actually borrow some extra amount than the original position to cover the flash loan fee + * @param _cTokenContracts array containing all interfaces to the cToken contracts in which the user has debt positions + * @param _amts array containing the amounts the user had borrowed originally from Compound plus the flash loan fee + * @param _flashLoanFee flash loan fee (in percentage and scaled up to 10**2) + */ + function _borrowDebtPosition( + CTokenInterface[] memory _cTokenContracts, + uint256[] memory _amts, + uint256 _flashLoanFee + ) internal { + for (uint i = 0; i < _cTokenContracts.length; i++) { + if (_amts[i] > 0) { + require(_cTokenContracts[i].borrow(add(_amts[i], mul(_amts[i], mul(_flashLoanFee, 10**14)))) == 0, "borrow-failed-collateral?"); + } + } + } } \ No newline at end of file diff --git a/contracts/mainnet/connectors/compound-import/main.sol b/contracts/mainnet/connectors/compound-import/main.sol index 43c51c70..fbea89a3 100644 --- a/contracts/mainnet/connectors/compound-import/main.sol +++ b/contracts/mainnet/connectors/compound-import/main.sol @@ -2,8 +2,7 @@ pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; import { TokenInterface, AccountInterface } from "../../common/interfaces.sol"; -import { CTokenInterface } from "./interface.sol"; -import { Helpers } from "./helpers.sol"; +import { CompoundHelper } from "./helpers.sol"; import { Events } from "./events.sol"; // 1. Get info for all the assets the user has supplied as collateral and the assets he borrowed. @@ -11,184 +10,7 @@ import { Events } from "./events.sol"; // 3. After paying the debt, transfer the user's tokens from EOA to DSA. // 4. Then borrow debt of same tokens but include flash loan fee in it. -contract CompoundHelper is Helpers, Events { - /** - * @notice repays the debt taken by user on Compound on its behalf to free its collateral for transfer - * @dev uses the cEth contract for ETH repays, otherwise the general cToken interface - * @param _userAccount the user address for which debt is to be repayed - * @param _cTokenContracts array containing all interfaces to the cToken contracts in which the user has debt positions - * @param _borrowAmts array containing the amount borrowed for each token - */ - function _repayUserDebt( - address _userAccount, - CTokenInterface[] memory _cTokenContracts, - uint[] memory _borrowAmts - ) internal { - for(uint i = 0; i < _cTokenContracts.length; i++){ - if(_borrowAmts[i] > 0){ - if(address(_cTokenContracts[i]) == address(cEth)){ - cEth.repayBorrowBehalf{value: _borrowAmts[i]}(_userAccount); - } - else{ - require(_cTokenContracts[i].repayBorrowBehalf(_userAccount, _borrowAmts[i]) == 0, "repayOnBehalf-failed"); - } - } - } - } - - /** - * @notice used to transfer user's supply position on Compound to DSA - * @dev uses the transferFrom token in cToken contracts to transfer positions, requires approval from user first - * @param _userAccount address of the user account whose position is to be transferred - * @param _cTokenContracts array containing all interfaces to the cToken contracts in which the user has supply positions - * @param _amts array containing the amount supplied for each token - */ - function _transferTokensToDsa( - address _userAccount, - CTokenInterface[] memory _cTokenContracts, - uint[] memory _amts - ) internal { - for(uint i = 0; i < _cTokenContracts.length; i++) { - if(_amts[i] > 0) { - require(_cTokenContracts[i].transferFrom(_userAccount, address(this), _amts[i]), "ctoken-transfer-failed-allowance?"); - } - } - } - - /** - * @notice borrows the user's debt positions from Compound via DSA, so that its debt positions get imported to DSA - * @dev actually borrow some extra amount than the original position to cover the flash loan fee - * @param _cTokenContracts array containing all interfaces to the cToken contracts in which the user has debt positions - * @param _amts array containing the amounts the user had borrowed originally from Compound plus the flash loan fee - * @param _flashLoanFee flash loan fee (in percentage and scaled up to 10**2) - */ - function _borrowDebtPosition( - CTokenInterface[] memory _cTokenContracts, - uint256[] memory _amts, - uint256 _flashLoanFee - ) internal { - for (uint i = 0; i < _cTokenContracts.length; i++) { - if (_amts[i] > 0) { - require(_cTokenContracts[i].borrow(add(_amts[i], mul(_amts[i], mul(_flashLoanFee, 10**14)))) == 0, "borrow-failed-collateral?"); - } - } - } -} - -contract CompoundResolver is CompoundHelper { - struct ImportData { - address[] cTokens; // is the list of all tokens the user has interacted with (supply/borrow) -> used to enter markets - uint[] borrowAmts; - uint[] supplyAmts; - address[] borrowTokens; - address[] supplyTokens; - CTokenInterface[] borrowCtokens; - CTokenInterface[] supplyCtokens; - address[] supplyCtokensAddr; - address[] borrowCtokensAddr; - } - - struct ImportInputData { - address userAccount; - string[] supplyIds; - string[] borrowIds; - } - - /** - * @notice fetch the borrow details of the user - * @dev approve the cToken to spend (borrowed amount of) tokens to allow for repaying later - * @param _importInputData the struct containing borrowIds of the users borrowed tokens - * @param data struct used to store the final data on which the CompoundHelper contract functions operate - * @return ImportData the final value of param data - */ - function getBorrowAmounts ( - ImportInputData memory _importInputData, - ImportData memory data - ) internal returns(ImportData memory) { - if (_importInputData.borrowIds.length > 0) { - // initialize arrays for borrow data - data.borrowTokens = new address[](_importInputData.borrowIds.length); - data.borrowCtokens = new CTokenInterface[](_importInputData.borrowIds.length); - data.borrowCtokensAddr = new address[](_importInputData.borrowIds.length); - data.borrowAmts = new uint[](_importInputData.borrowIds.length); - - // check for repeated tokens - for (uint i = 0; i < _importInputData.borrowIds.length; i++) { - bytes32 i_hash = keccak256(abi.encode(_importInputData.borrowIds[i])); - for (uint j = i + 1; j < _importInputData.borrowIds.length; j++) { - bytes32 j_hash = keccak256(abi.encode(_importInputData.borrowIds[j])); - require(i_hash != j_hash, "token-repeated"); - } - } - - // populate the arrays with borrow tokens, cToken addresses and instances, and borrow amounts - for (uint i = 0; i < _importInputData.borrowIds.length; i++) { - (address _token, address _cToken) = compMapping.getMapping(_importInputData.borrowIds[i]); - - require(_token != address(0) && _cToken != address(0), "ctoken mapping not found"); - - data.cTokens[i] = _cToken; - - data.borrowTokens[i] = _token; - data.borrowCtokens[i] = CTokenInterface(_cToken); - data.borrowCtokensAddr[i] = _cToken; - data.borrowAmts[i] = data.borrowCtokens[i].borrowBalanceCurrent(_importInputData.userAccount); - - // give the resp. cToken address approval to spend tokens - if (_token != ethAddr && data.borrowAmts[i] > 0) { - // will be required when repaying the borrow amount on behalf of the user - TokenInterface(_token).approve(_cToken, data.borrowAmts[i]); - } - } - } - return data; - } - - /** - * @notice fetch the supply details of the user - * @dev only reads data from blockchain hence view - * @param _importInputData the struct containing supplyIds of the users supplied tokens - * @param data struct used to store the final data on which the CompoundHelper contract functions operate - * @return ImportData the final value of param data - */ - function getSupplyAmounts ( - ImportInputData memory _importInputData, - ImportData memory data - ) internal view returns(ImportData memory) { - // initialize arrays for supply data - data.supplyTokens = new address[](_importInputData.supplyIds.length); - data.supplyCtokens = new CTokenInterface[](_importInputData.supplyIds.length); - data.supplyCtokensAddr = new address[](_importInputData.supplyIds.length); - data.supplyAmts = new uint[](_importInputData.supplyIds.length); - - // check for repeated tokens - for (uint i = 0; i < _importInputData.supplyIds.length; i++) { - bytes32 i_hash = keccak256(abi.encode(_importInputData.supplyIds[i])); - for (uint j = i + 1; j < _importInputData.supplyIds.length; j++) { - bytes32 j_hash = keccak256(abi.encode(_importInputData.supplyIds[j])); - require(i_hash != j_hash, "token-repeated"); - } - } - - // populate arrays with supply data (supply tokens address, cToken addresses, cToken instances and supply amounts) - for (uint i = 0; i < _importInputData.supplyIds.length; i++) { - (address _token, address _cToken) = compMapping.getMapping(_importInputData.supplyIds[i]); - - require(_token != address(0) && _cToken != address(0), "ctoken mapping not found"); - - uint _supplyIndex = add(i, _importInputData.borrowIds.length); - data.cTokens[_supplyIndex] = _cToken; - - data.supplyTokens[i] = _token; - data.supplyCtokens[i] = CTokenInterface(_cToken); - data.supplyCtokensAddr[i] = (_cToken); - data.supplyAmts[i] = data.supplyCtokens[i].balanceOf(_importInputData.userAccount); - } - return data; - } -} - -contract CompoundImport is CompoundResolver { +contract CompoundImportResolver is CompoundHelper { /** * @notice this function performs the import of user's Compound positions into its DSA @@ -282,6 +104,6 @@ contract CompoundImport is CompoundResolver { } } -contract ConnectV2CompoundImport is CompoundImport { +contract ConnectV2CompoundImport is CompoundImportResolver { string public constant name = "Compound-Import-v2"; } \ No newline at end of file From b14f886365abef6fd2372f7174e10dfc4282debb Mon Sep 17 00:00:00 2001 From: Chinmay Chougaonkar Date: Mon, 21 Mar 2022 11:39:31 +0530 Subject: [PATCH 10/20] changed flashLoanFee to flashLoanFees[], removed migrateCompound function, removed checks for repeated tokens from getSupplyAmounts and getBorrowAmounts --- .../connectors/compound-import/helpers.sol | 39 ++++++++----------- .../connectors/compound-import/main.sol | 32 +++------------ 2 files changed, 22 insertions(+), 49 deletions(-) diff --git a/contracts/mainnet/connectors/compound-import/helpers.sol b/contracts/mainnet/connectors/compound-import/helpers.sol index 78e600b1..6e906ad7 100644 --- a/contracts/mainnet/connectors/compound-import/helpers.sol +++ b/contracts/mainnet/connectors/compound-import/helpers.sol @@ -79,15 +79,6 @@ contract CompoundHelper is Helpers { data.borrowCtokensAddr = new address[](_importInputData.borrowIds.length); data.borrowAmts = new uint[](_importInputData.borrowIds.length); - // check for repeated tokens - for (uint i = 0; i < _importInputData.borrowIds.length; i++) { - bytes32 i_hash = keccak256(abi.encode(_importInputData.borrowIds[i])); - for (uint j = i + 1; j < _importInputData.borrowIds.length; j++) { - bytes32 j_hash = keccak256(abi.encode(_importInputData.borrowIds[j])); - require(i_hash != j_hash, "token-repeated"); - } - } - // populate the arrays with borrow tokens, cToken addresses and instances, and borrow amounts for (uint i = 0; i < _importInputData.borrowIds.length; i++) { (address _token, address _cToken) = compMapping.getMapping(_importInputData.borrowIds[i]); @@ -128,15 +119,6 @@ contract CompoundHelper is Helpers { data.supplyCtokensAddr = new address[](_importInputData.supplyIds.length); data.supplyAmts = new uint[](_importInputData.supplyIds.length); - // check for repeated tokens - for (uint i = 0; i < _importInputData.supplyIds.length; i++) { - bytes32 i_hash = keccak256(abi.encode(_importInputData.supplyIds[i])); - for (uint j = i + 1; j < _importInputData.supplyIds.length; j++) { - bytes32 j_hash = keccak256(abi.encode(_importInputData.supplyIds[j])); - require(i_hash != j_hash, "token-repeated"); - } - } - // populate arrays with supply data (supply tokens address, cToken addresses, cToken instances and supply amounts) for (uint i = 0; i < _importInputData.supplyIds.length; i++) { (address _token, address _cToken) = compMapping.getMapping(_importInputData.supplyIds[i]); @@ -172,7 +154,10 @@ contract CompoundHelper is Helpers { cEth.repayBorrowBehalf{value: _borrowAmts[i]}(_userAccount); } else{ - require(_cTokenContracts[i].repayBorrowBehalf(_userAccount, _borrowAmts[i]) == 0, "repayOnBehalf-failed"); + require(_cTokenContracts[i].repayBorrowBehalf( + _userAccount, + _borrowAmts[i] + ) == 0, "repayOnBehalf-failed"); } } } @@ -192,7 +177,11 @@ contract CompoundHelper is Helpers { ) internal { for(uint i = 0; i < _cTokenContracts.length; i++) { if(_amts[i] > 0) { - require(_cTokenContracts[i].transferFrom(_userAccount, address(this), _amts[i]), "ctoken-transfer-failed-allowance?"); + require(_cTokenContracts[i].transferFrom( + _userAccount, + address(this), + _amts[i] + ), "ctoken-transfer-failed-allowance?"); } } } @@ -202,16 +191,20 @@ contract CompoundHelper is Helpers { * @dev actually borrow some extra amount than the original position to cover the flash loan fee * @param _cTokenContracts array containing all interfaces to the cToken contracts in which the user has debt positions * @param _amts array containing the amounts the user had borrowed originally from Compound plus the flash loan fee - * @param _flashLoanFee flash loan fee (in percentage and scaled up to 10**2) + * @param _flashLoanFees flash loan fee (in percentage and scaled up to 10**2) */ function _borrowDebtPosition( CTokenInterface[] memory _cTokenContracts, uint256[] memory _amts, - uint256 _flashLoanFee + uint256[] memory _flashLoanFees ) internal { for (uint i = 0; i < _cTokenContracts.length; i++) { if (_amts[i] > 0) { - require(_cTokenContracts[i].borrow(add(_amts[i], mul(_amts[i], mul(_flashLoanFee, 10**14)))) == 0, "borrow-failed-collateral?"); + require(_cTokenContracts[i].borrow( + add( + _amts[i], + _flashLoanFees[i] + )) == 0, "borrow-failed-collateral?"); } } } diff --git a/contracts/mainnet/connectors/compound-import/main.sol b/contracts/mainnet/connectors/compound-import/main.sol index fbea89a3..eda52e75 100644 --- a/contracts/mainnet/connectors/compound-import/main.sol +++ b/contracts/mainnet/connectors/compound-import/main.sol @@ -16,11 +16,11 @@ contract CompoundImportResolver is CompoundHelper { * @notice this function performs the import of user's Compound positions into its DSA * @dev called internally by the importCompound and migrateCompound functions * @param _importInputData the struct containing borrowIds of the users borrowed tokens - * @param _flashLoanFee flash loan fee + * @param _flashLoanFees list of flash loan fees */ function _importCompound( ImportInputData memory _importInputData, - uint256 _flashLoanFee + uint256[] memory _flashLoanFees ) internal returns (string memory _eventName, bytes memory _eventParam) { require(AccountInterface(address(this)).isAuth(_importInputData.userAccount), "user-account-not-auth"); @@ -46,7 +46,7 @@ contract CompoundImportResolver is CompoundHelper { _transferTokensToDsa(_importInputData.userAccount, data.supplyCtokens, data.supplyAmts); // borrow the earlier position from Compound with flash loan fee added - _borrowDebtPosition(data.borrowCtokens, data.borrowAmts, _flashLoanFee); + _borrowDebtPosition(data.borrowCtokens, data.borrowAmts, _flashLoanFees); _eventName = "LogCompoundImport(address,address[],string[],string[],uint256[],uint256[])"; _eventParam = abi.encode( @@ -65,13 +65,13 @@ contract CompoundImportResolver is CompoundHelper { * @param _userAccount address of user whose position is to be imported to DSA * @param _supplyIds Ids of all tokens the user has supplied to Compound * @param _borrowIds Ids of all token borrowed by the user - * @param _flashLoanFee flash loan fee (in percentage and scaled up to 10**2) + * @param _flashLoanFees list of flash loan fees */ function importCompound( address _userAccount, string[] memory _supplyIds, string[] memory _borrowIds, - uint256 _flashLoanFee + uint256[] memory _flashLoanFees ) external payable returns (string memory _eventName, bytes memory _eventParam) { ImportInputData memory inputData = ImportInputData({ userAccount: _userAccount, @@ -79,29 +79,9 @@ contract CompoundImportResolver is CompoundHelper { borrowIds: _borrowIds }); - (_eventName, _eventParam) = _importCompound(inputData, _flashLoanFee); + (_eventName, _eventParam) = _importCompound(inputData, _flashLoanFees); } - /** - * @notice import msg.sender's Compound position (which is the user since this is a delegateCall) - * @dev internally calls _importContract to perform the actual import - * @param _supplyIds Ids of all tokens the user has supplied to Compound - * @param _borrowIds Ids of all token borrowed by the user - * @param _flashLoanFee flash loan fee (in percentage and scaled up to 10**2) - */ - function migrateCompound( - string[] memory _supplyIds, - string[] memory _borrowIds, - uint256 _flashLoanFee - ) external payable returns (string memory _eventName, bytes memory _eventParam) { - ImportInputData memory inputData = ImportInputData({ - userAccount: msg.sender, - supplyIds: _supplyIds, - borrowIds: _borrowIds - }); - - (_eventName, _eventParam) = _importCompound(inputData, _flashLoanFee); - } } contract ConnectV2CompoundImport is CompoundImportResolver { From 95e390ddef9c6bc945f31e3cec54d7fcd2bab4e9 Mon Sep 17 00:00:00 2001 From: Chinmay Chougaonkar Date: Mon, 21 Mar 2022 15:50:11 +0530 Subject: [PATCH 11/20] changed logic for entering markets --- .../mainnet/connectors/compound-import/helpers.sol | 13 ++++--------- .../mainnet/connectors/compound-import/main.sol | 4 +--- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/contracts/mainnet/connectors/compound-import/helpers.sol b/contracts/mainnet/connectors/compound-import/helpers.sol index 6e906ad7..f1a9fac5 100644 --- a/contracts/mainnet/connectors/compound-import/helpers.sol +++ b/contracts/mainnet/connectors/compound-import/helpers.sol @@ -42,18 +42,13 @@ abstract contract Helpers is DSMath, Basic { /** * @dev enter compound market + * @param _userAccount address of the EOA's account to get the user's entered markets */ - function enterMarket(address cToken) internal { - address[] memory markets = troller.getAssetsIn(address(this)); - bool isEntered = false; + function _enterMarkets(address _userAccount) internal { + address[] memory markets = troller.getAssetsIn(_userAccount); for (uint i = 0; i < markets.length; i++) { - if (markets[i] == cToken) { - isEntered = true; - } - } - if (!isEntered) { address[] memory toEnter = new address[](1); - toEnter[0] = cToken; + toEnter[0] = markets[i]; troller.enterMarkets(toEnter); } } diff --git a/contracts/mainnet/connectors/compound-import/main.sol b/contracts/mainnet/connectors/compound-import/main.sol index eda52e75..8ab0ea52 100644 --- a/contracts/mainnet/connectors/compound-import/main.sol +++ b/contracts/mainnet/connectors/compound-import/main.sol @@ -35,9 +35,7 @@ contract CompoundImportResolver is CompoundHelper { data = getBorrowAmounts(_importInputData, data); data = getSupplyAmounts(_importInputData, data); - for(uint i = 0; i < data.cTokens.length; i++){ - enterMarket(data.cTokens[i]); - } + _enterMarkets(_importInputData.userAccount); // pay back user's debt using flash loan funds _repayUserDebt(_importInputData.userAccount, data.borrowCtokens, data.borrowAmts); From 98d9c158fc615181f346d629ea0a3ac0fbdcb51e Mon Sep 17 00:00:00 2001 From: Thrilok kumar Date: Tue, 22 Mar 2022 23:20:23 +0530 Subject: [PATCH 12/20] fixed compound enter market logic --- .../mainnet/connectors/compound-import/helpers.sol | 11 +++-------- contracts/mainnet/connectors/compound-import/main.sol | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/contracts/mainnet/connectors/compound-import/helpers.sol b/contracts/mainnet/connectors/compound-import/helpers.sol index f1a9fac5..b53347fd 100644 --- a/contracts/mainnet/connectors/compound-import/helpers.sol +++ b/contracts/mainnet/connectors/compound-import/helpers.sol @@ -42,15 +42,10 @@ abstract contract Helpers is DSMath, Basic { /** * @dev enter compound market - * @param _userAccount address of the EOA's account to get the user's entered markets + * @param _cotkens array of ctoken addresses to enter compound market */ - function _enterMarkets(address _userAccount) internal { - address[] memory markets = troller.getAssetsIn(_userAccount); - for (uint i = 0; i < markets.length; i++) { - address[] memory toEnter = new address[](1); - toEnter[0] = markets[i]; - troller.enterMarkets(toEnter); - } + function _enterMarkets(address[] memory _cotkens) internal { + troller.enterMarkets(_cotkens); } } diff --git a/contracts/mainnet/connectors/compound-import/main.sol b/contracts/mainnet/connectors/compound-import/main.sol index 8ab0ea52..e600033d 100644 --- a/contracts/mainnet/connectors/compound-import/main.sol +++ b/contracts/mainnet/connectors/compound-import/main.sol @@ -35,7 +35,7 @@ contract CompoundImportResolver is CompoundHelper { data = getBorrowAmounts(_importInputData, data); data = getSupplyAmounts(_importInputData, data); - _enterMarkets(_importInputData.userAccount); + _enterMarkets(_importInputData.cTokens); // pay back user's debt using flash loan funds _repayUserDebt(_importInputData.userAccount, data.borrowCtokens, data.borrowAmts); From 5ff4637b91d605961156b304a04c159e976915f6 Mon Sep 17 00:00:00 2001 From: pradyuman-verma Date: Wed, 23 Mar 2022 13:41:24 +0530 Subject: [PATCH 13/20] removed bugs and fixed lint --- .../connectors/compound-import/events.sol | 19 +- .../connectors/compound-import/helpers.sol | 365 +++++++++--------- .../connectors/compound-import/interface.sol | 108 ++++-- .../connectors/compound-import/main.sol | 143 ++++--- 4 files changed, 367 insertions(+), 268 deletions(-) diff --git a/contracts/mainnet/connectors/compound-import/events.sol b/contracts/mainnet/connectors/compound-import/events.sol index 09e3e8f2..79fd7d69 100644 --- a/contracts/mainnet/connectors/compound-import/events.sol +++ b/contracts/mainnet/connectors/compound-import/events.sol @@ -1,13 +1,14 @@ +// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; contract Events { - event LogCompoundImport( - address indexed user, - address[] ctokens, - string[] supplyIds, - string[] borrowIds, - uint256[] supplyAmts, - uint256[] borrowAmts - ); -} \ No newline at end of file + event LogCompoundImport( + address indexed user, + address[] ctokens, + string[] supplyIds, + string[] borrowIds, + uint256[] supplyAmts, + uint256[] borrowAmts + ); +} diff --git a/contracts/mainnet/connectors/compound-import/helpers.sol b/contracts/mainnet/connectors/compound-import/helpers.sol index b53347fd..93acc1fb 100644 --- a/contracts/mainnet/connectors/compound-import/helpers.sol +++ b/contracts/mainnet/connectors/compound-import/helpers.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import { DSMath } from "../../common/math.sol"; @@ -6,196 +7,216 @@ import { TokenInterface, AccountInterface } from "../../common/interfaces.sol"; import { ComptrollerInterface, CompoundMappingInterface, CETHInterface, CTokenInterface } from "./interface.sol"; abstract contract Helpers is DSMath, Basic { + /** + * @dev Compound CEth + */ + CETHInterface internal constant cEth = + CETHInterface(0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5); - /** - * @dev Compound CEth - */ - CETHInterface internal constant cEth = CETHInterface(0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5); + /** + * @dev Compound Comptroller + */ + ComptrollerInterface internal constant troller = + ComptrollerInterface(0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B); - /** - * @dev Compound Comptroller - */ - ComptrollerInterface internal constant troller = ComptrollerInterface(0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B); + /** + * @dev Compound Mapping + */ + CompoundMappingInterface internal constant compMapping = + CompoundMappingInterface(0xe7a85d0adDB972A4f0A4e57B698B37f171519e88); - /** - * @dev Compound Mapping - */ - CompoundMappingInterface internal constant compMapping = CompoundMappingInterface(0xe7a85d0adDB972A4f0A4e57B698B37f171519e88); + struct ImportData { + address[] cTokens; // is the list of all tokens the user has interacted with (supply/borrow) -> used to enter markets + uint256[] borrowAmts; + uint256[] supplyAmts; + address[] borrowTokens; + address[] supplyTokens; + CTokenInterface[] borrowCtokens; + CTokenInterface[] supplyCtokens; + address[] supplyCtokensAddr; + address[] borrowCtokensAddr; + } - struct ImportData { - address[] cTokens; // is the list of all tokens the user has interacted with (supply/borrow) -> used to enter markets - uint[] borrowAmts; - uint[] supplyAmts; - address[] borrowTokens; - address[] supplyTokens; - CTokenInterface[] borrowCtokens; - CTokenInterface[] supplyCtokens; - address[] supplyCtokensAddr; - address[] borrowCtokensAddr; - } + struct ImportInputData { + address userAccount; + string[] supplyIds; + string[] borrowIds; + } - struct ImportInputData { - address userAccount; - string[] supplyIds; - string[] borrowIds; - } - - /** - * @dev enter compound market - * @param _cotkens array of ctoken addresses to enter compound market - */ - function _enterMarkets(address[] memory _cotkens) internal { - troller.enterMarkets(_cotkens); - } + /** + * @dev enter compound market + * @param _cotkens array of ctoken addresses to enter compound market + */ + function _enterMarkets(address[] memory _cotkens) internal { + troller.enterMarkets(_cotkens); + } } contract CompoundHelper is Helpers { + /** + * @notice fetch the borrow details of the user + * @dev approve the cToken to spend (borrowed amount of) tokens to allow for repaying later + * @param _importInputData the struct containing borrowIds of the users borrowed tokens + * @param data struct used to store the final data on which the CompoundHelper contract functions operate + * @return ImportData the final value of param data + */ + function getBorrowAmounts( + ImportInputData memory _importInputData, + ImportData memory data + ) internal returns (ImportData memory) { + if (_importInputData.borrowIds.length > 0) { + // initialize arrays for borrow data + uint256 _length = _importInputData.borrowIds.length; + data.borrowTokens = new address[](_length); + data.borrowCtokens = new CTokenInterface[](_length); + data.borrowCtokensAddr = new address[](_length); + data.borrowAmts = new uint256[](_length); - /** - * @notice fetch the borrow details of the user - * @dev approve the cToken to spend (borrowed amount of) tokens to allow for repaying later - * @param _importInputData the struct containing borrowIds of the users borrowed tokens - * @param data struct used to store the final data on which the CompoundHelper contract functions operate - * @return ImportData the final value of param data - */ - function getBorrowAmounts ( - ImportInputData memory _importInputData, - ImportData memory data - ) internal returns(ImportData memory) { - if (_importInputData.borrowIds.length > 0) { - // initialize arrays for borrow data - data.borrowTokens = new address[](_importInputData.borrowIds.length); - data.borrowCtokens = new CTokenInterface[](_importInputData.borrowIds.length); - data.borrowCtokensAddr = new address[](_importInputData.borrowIds.length); - data.borrowAmts = new uint[](_importInputData.borrowIds.length); + // populate the arrays with borrow tokens, cToken addresses and instances, and borrow amounts + for (uint256 i; i < _length; i++) { + (address _token, address _cToken) = compMapping.getMapping( + _importInputData.borrowIds[i] + ); - // populate the arrays with borrow tokens, cToken addresses and instances, and borrow amounts - for (uint i = 0; i < _importInputData.borrowIds.length; i++) { - (address _token, address _cToken) = compMapping.getMapping(_importInputData.borrowIds[i]); + require( + _token != address(0) && _cToken != address(0), + "ctoken mapping not found" + ); - require(_token != address(0) && _cToken != address(0), "ctoken mapping not found"); + data.cTokens[i] = _cToken; - data.cTokens[i] = _cToken; + data.borrowTokens[i] = _token; + data.borrowCtokens[i] = CTokenInterface(_cToken); + data.borrowCtokensAddr[i] = _cToken; + data.borrowAmts[i] = data.borrowCtokens[i].borrowBalanceCurrent( + _importInputData.userAccount + ); - data.borrowTokens[i] = _token; - data.borrowCtokens[i] = CTokenInterface(_cToken); - data.borrowCtokensAddr[i] = _cToken; - data.borrowAmts[i] = data.borrowCtokens[i].borrowBalanceCurrent(_importInputData.userAccount); + // give the resp. cToken address approval to spend tokens + if (_token != ethAddr && data.borrowAmts[i] > 0) { + // will be required when repaying the borrow amount on behalf of the user + TokenInterface(_token).approve(_cToken, data.borrowAmts[i]); + } + } + } + return data; + } - // give the resp. cToken address approval to spend tokens - if (_token != ethAddr && data.borrowAmts[i] > 0) { - // will be required when repaying the borrow amount on behalf of the user - TokenInterface(_token).approve(_cToken, data.borrowAmts[i]); - } - } - } - return data; - } + /** + * @notice fetch the supply details of the user + * @dev only reads data from blockchain hence view + * @param _importInputData the struct containing supplyIds of the users supplied tokens + * @param data struct used to store the final data on which the CompoundHelper contract functions operate + * @return ImportData the final value of param data + */ + function getSupplyAmounts( + ImportInputData memory _importInputData, + ImportData memory data + ) internal view returns (ImportData memory) { + // initialize arrays for supply data + uint256 _length = _importInputData.supplyIds.length; + data.supplyTokens = new address[](_length); + data.supplyCtokens = new CTokenInterface[](_length); + data.supplyCtokensAddr = new address[](_length); + data.supplyAmts = new uint256[](_length); - /** - * @notice fetch the supply details of the user - * @dev only reads data from blockchain hence view - * @param _importInputData the struct containing supplyIds of the users supplied tokens - * @param data struct used to store the final data on which the CompoundHelper contract functions operate - * @return ImportData the final value of param data - */ - function getSupplyAmounts ( - ImportInputData memory _importInputData, - ImportData memory data - ) internal view returns(ImportData memory) { - // initialize arrays for supply data - data.supplyTokens = new address[](_importInputData.supplyIds.length); - data.supplyCtokens = new CTokenInterface[](_importInputData.supplyIds.length); - data.supplyCtokensAddr = new address[](_importInputData.supplyIds.length); - data.supplyAmts = new uint[](_importInputData.supplyIds.length); + // populate arrays with supply data (supply tokens address, cToken addresses, cToken instances and supply amounts) + for (uint256 i; i < _length; i++) { + (address _token, address _cToken) = compMapping.getMapping( + _importInputData.supplyIds[i] + ); - // populate arrays with supply data (supply tokens address, cToken addresses, cToken instances and supply amounts) - for (uint i = 0; i < _importInputData.supplyIds.length; i++) { - (address _token, address _cToken) = compMapping.getMapping(_importInputData.supplyIds[i]); - - require(_token != address(0) && _cToken != address(0), "ctoken mapping not found"); + require( + _token != address(0) && _cToken != address(0), + "ctoken mapping not found" + ); - uint _supplyIndex = add(i, _importInputData.borrowIds.length); - data.cTokens[_supplyIndex] = _cToken; + uint256 _supplyIndex = add(i, _importInputData.borrowIds.length); + data.cTokens[_supplyIndex] = _cToken; - data.supplyTokens[i] = _token; - data.supplyCtokens[i] = CTokenInterface(_cToken); - data.supplyCtokensAddr[i] = (_cToken); - data.supplyAmts[i] = data.supplyCtokens[i].balanceOf(_importInputData.userAccount); - } - return data; - } + data.supplyTokens[i] = _token; + data.supplyCtokens[i] = CTokenInterface(_cToken); + data.supplyCtokensAddr[i] = (_cToken); + data.supplyAmts[i] = data.supplyCtokens[i].balanceOf( + _importInputData.userAccount + ); + } + return data; + } - /** - * @notice repays the debt taken by user on Compound on its behalf to free its collateral for transfer - * @dev uses the cEth contract for ETH repays, otherwise the general cToken interface - * @param _userAccount the user address for which debt is to be repayed - * @param _cTokenContracts array containing all interfaces to the cToken contracts in which the user has debt positions - * @param _borrowAmts array containing the amount borrowed for each token - */ - function _repayUserDebt( - address _userAccount, - CTokenInterface[] memory _cTokenContracts, - uint[] memory _borrowAmts - ) internal { - for(uint i = 0; i < _cTokenContracts.length; i++){ - if(_borrowAmts[i] > 0){ - if(address(_cTokenContracts[i]) == address(cEth)){ - cEth.repayBorrowBehalf{value: _borrowAmts[i]}(_userAccount); - } - else{ - require(_cTokenContracts[i].repayBorrowBehalf( - _userAccount, - _borrowAmts[i] - ) == 0, "repayOnBehalf-failed"); - } - } - } - } + /** + * @notice repays the debt taken by user on Compound on its behalf to free its collateral for transfer + * @dev uses the cEth contract for ETH repays, otherwise the general cToken interface + * @param _userAccount the user address for which debt is to be repayed + * @param _cTokenContracts array containing all interfaces to the cToken contracts in which the user has debt positions + * @param _borrowAmts array containing the amount borrowed for each token + */ + function _repayUserDebt( + address _userAccount, + CTokenInterface[] memory _cTokenContracts, + uint256[] memory _borrowAmts + ) internal { + for (uint256 i; i < _cTokenContracts.length; i++) { + if (_borrowAmts[i] > 0) { + if (address(_cTokenContracts[i]) == address(cEth)) + cEth.repayBorrowBehalf{ value: _borrowAmts[i] }( + _userAccount + ); + else + require( + _cTokenContracts[i].repayBorrowBehalf( + _userAccount, + _borrowAmts[i] + ) == 0, + "repayOnBehalf-failed" + ); + } + } + } - /** - * @notice used to transfer user's supply position on Compound to DSA - * @dev uses the transferFrom token in cToken contracts to transfer positions, requires approval from user first - * @param _userAccount address of the user account whose position is to be transferred - * @param _cTokenContracts array containing all interfaces to the cToken contracts in which the user has supply positions - * @param _amts array containing the amount supplied for each token - */ - function _transferTokensToDsa( - address _userAccount, - CTokenInterface[] memory _cTokenContracts, - uint[] memory _amts - ) internal { - for(uint i = 0; i < _cTokenContracts.length; i++) { - if(_amts[i] > 0) { - require(_cTokenContracts[i].transferFrom( - _userAccount, - address(this), - _amts[i] - ), "ctoken-transfer-failed-allowance?"); - } - } - } + /** + * @notice used to transfer user's supply position on Compound to DSA + * @dev uses the transferFrom token in cToken contracts to transfer positions, requires approval from user first + * @param _userAccount address of the user account whose position is to be transferred + * @param _cTokenContracts array containing all interfaces to the cToken contracts in which the user has supply positions + * @param _amts array containing the amount supplied for each token + */ + function _transferTokensToDsa( + address _userAccount, + CTokenInterface[] memory _cTokenContracts, + uint256[] memory _amts + ) internal { + for (uint256 i; i < _cTokenContracts.length; i++) + if (_amts[i] > 0) + require( + _cTokenContracts[i].transferFrom( + _userAccount, + address(this), + _amts[i] + ), + "ctoken-transfer-failed-allowance?" + ); + } - /** - * @notice borrows the user's debt positions from Compound via DSA, so that its debt positions get imported to DSA - * @dev actually borrow some extra amount than the original position to cover the flash loan fee - * @param _cTokenContracts array containing all interfaces to the cToken contracts in which the user has debt positions - * @param _amts array containing the amounts the user had borrowed originally from Compound plus the flash loan fee - * @param _flashLoanFees flash loan fee (in percentage and scaled up to 10**2) - */ - function _borrowDebtPosition( - CTokenInterface[] memory _cTokenContracts, - uint256[] memory _amts, - uint256[] memory _flashLoanFees - ) internal { - for (uint i = 0; i < _cTokenContracts.length; i++) { - if (_amts[i] > 0) { - require(_cTokenContracts[i].borrow( - add( - _amts[i], - _flashLoanFees[i] - )) == 0, "borrow-failed-collateral?"); - } - } - } -} \ No newline at end of file + /** + * @notice borrows the user's debt positions from Compound via DSA, so that its debt positions get imported to DSA + * @dev actually borrow some extra amount than the original position to cover the flash loan fee + * @param _cTokenContracts array containing all interfaces to the cToken contracts in which the user has debt positions + * @param _amts array containing the amounts the user had borrowed originally from Compound plus the flash loan fee + * @param _flashLoanFees flash loan fee (in percentage and scaled up to 10**2) + */ + function _borrowDebtPosition( + CTokenInterface[] memory _cTokenContracts, + uint256[] memory _amts, + uint256[] memory _flashLoanFees + ) internal { + for (uint256 i; i < _cTokenContracts.length; i++) + if (_amts[i] > 0) + require( + _cTokenContracts[i].borrow( + add(_amts[i], _flashLoanFees[i]) + ) == 0, + "borrow-failed-collateral?" + ); + } +} diff --git a/contracts/mainnet/connectors/compound-import/interface.sol b/contracts/mainnet/connectors/compound-import/interface.sol index 7a08c094..5f9bf98d 100644 --- a/contracts/mainnet/connectors/compound-import/interface.sol +++ b/contracts/mainnet/connectors/compound-import/interface.sol @@ -1,46 +1,100 @@ +// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; interface TokenInterface { - function balanceOf(address) external view returns (uint); - function allowance(address, address) external view returns (uint); - function approve(address, uint) external; - function transfer(address, uint) external returns (bool); - function transferFrom(address, address, uint) external returns (bool); + function balanceOf(address) external view returns (uint256); + + function allowance(address, address) external view returns (uint256); + + function approve(address, uint256) external; + + function transfer(address, uint256) external returns (bool); + + function transferFrom( + address, + address, + uint256 + ) external returns (bool); } interface CTokenInterface { - function mint(uint mintAmount) external returns (uint); - function redeem(uint redeemTokens) external returns (uint); - function borrow(uint borrowAmount) external returns (uint); - function repayBorrow(uint repayAmount) external returns (uint); - function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint); // For ERC20 - function liquidateBorrow(address borrower, uint repayAmount, address cTokenCollateral) external returns (uint); + function mint(uint256 mintAmount) external returns (uint256); - function borrowBalanceCurrent(address account) external returns (uint); - function redeemUnderlying(uint redeemAmount) external returns (uint); - function exchangeRateCurrent() external returns (uint); + function redeem(uint256 redeemTokens) external returns (uint256); - function balanceOf(address owner) external view returns (uint256 balance); - function transferFrom(address, address, uint) external returns (bool); - function allowance(address, address) external view returns (uint); + function borrow(uint256 borrowAmount) external returns (uint256); + function repayBorrow(uint256 repayAmount) external returns (uint256); + + function repayBorrowBehalf(address borrower, uint256 repayAmount) + external + returns (uint256); // For ERC20 + + function liquidateBorrow( + address borrower, + uint256 repayAmount, + address cTokenCollateral + ) external returns (uint256); + + function borrowBalanceCurrent(address account) external returns (uint256); + + function redeemUnderlying(uint256 redeemAmount) external returns (uint256); + + function exchangeRateCurrent() external returns (uint256); + + function balanceOf(address owner) external view returns (uint256 balance); + + function transferFrom( + address, + address, + uint256 + ) external returns (bool); + + function allowance(address, address) external view returns (uint256); } interface CETHInterface { - function mint() external payable; - function repayBorrow() external payable; - function repayBorrowBehalf(address borrower) external payable; - function liquidateBorrow(address borrower, address cTokenCollateral) external payable; + function mint() external payable; + + function repayBorrow() external payable; + + function repayBorrowBehalf(address borrower) external payable; + + function liquidateBorrow(address borrower, address cTokenCollateral) + external + payable; } interface ComptrollerInterface { - function enterMarkets(address[] calldata cTokens) external returns (uint[] memory); - function exitMarket(address cTokenAddress) external returns (uint); - function getAssetsIn(address account) external view returns (address[] memory); - function getAccountLiquidity(address account) external view returns (uint, uint, uint); + function enterMarkets(address[] calldata cTokens) + external + returns (uint256[] memory); + + function exitMarket(address cTokenAddress) external returns (uint256); + + function getAssetsIn(address account) + external + view + returns (address[] memory); + + function getAccountLiquidity(address account) + external + view + returns ( + uint256, + uint256, + uint256 + ); } interface CompoundMappingInterface { - function cTokenMapping(string calldata tokenId) external view returns (address); - function getMapping(string calldata tokenId) external view returns (address, address); + function cTokenMapping(string calldata tokenId) + external + view + returns (address); + + function getMapping(string calldata tokenId) + external + view + returns (address, address); } diff --git a/contracts/mainnet/connectors/compound-import/main.sol b/contracts/mainnet/connectors/compound-import/main.sol index e600033d..62923ec5 100644 --- a/contracts/mainnet/connectors/compound-import/main.sol +++ b/contracts/mainnet/connectors/compound-import/main.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; @@ -11,77 +12,99 @@ import { Events } from "./events.sol"; // 4. Then borrow debt of same tokens but include flash loan fee in it. contract CompoundImportResolver is CompoundHelper { + /** + * @notice this function performs the import of user's Compound positions into its DSA + * @dev called internally by the importCompound and migrateCompound functions + * @param _importInputData the struct containing borrowIds of the users borrowed tokens + * @param _flashLoanFees list of flash loan fees + */ + function _importCompound( + ImportInputData memory _importInputData, + uint256[] memory _flashLoanFees + ) internal returns (string memory _eventName, bytes memory _eventParam) { + require( + AccountInterface(address(this)).isAuth( + _importInputData.userAccount + ), + "user-account-not-auth" + ); - /** - * @notice this function performs the import of user's Compound positions into its DSA - * @dev called internally by the importCompound and migrateCompound functions - * @param _importInputData the struct containing borrowIds of the users borrowed tokens - * @param _flashLoanFees list of flash loan fees - */ - function _importCompound( - ImportInputData memory _importInputData, - uint256[] memory _flashLoanFees - ) internal returns (string memory _eventName, bytes memory _eventParam) { - require(AccountInterface(address(this)).isAuth(_importInputData.userAccount), "user-account-not-auth"); + require(_importInputData.supplyIds.length > 0, "0-length-not-allowed"); - require(_importInputData.supplyIds.length > 0, "0-length-not-allowed"); + ImportData memory data; - ImportData memory data; + uint256 _length = add( + _importInputData.supplyIds.length, + _importInputData.borrowIds.length + ); + data.cTokens = new address[](_length); - uint _length = add(_importInputData.supplyIds.length, _importInputData.borrowIds.length); - data.cTokens = new address[](_length); + // get info about all borrowings and lendings by the user on Compound + data = getBorrowAmounts(_importInputData, data); + data = getSupplyAmounts(_importInputData, data); - // get info about all borrowings and lendings by the user on Compound - data = getBorrowAmounts(_importInputData, data); - data = getSupplyAmounts(_importInputData, data); + _enterMarkets(data.cTokens); - _enterMarkets(_importInputData.cTokens); + // pay back user's debt using flash loan funds + _repayUserDebt( + _importInputData.userAccount, + data.borrowCtokens, + data.borrowAmts + ); - // pay back user's debt using flash loan funds - _repayUserDebt(_importInputData.userAccount, data.borrowCtokens, data.borrowAmts); + // transfer user's tokens to DSA + _transferTokensToDsa( + _importInputData.userAccount, + data.supplyCtokens, + data.supplyAmts + ); - // transfer user's tokens to DSA - _transferTokensToDsa(_importInputData.userAccount, data.supplyCtokens, data.supplyAmts); + // borrow the earlier position from Compound with flash loan fee added + _borrowDebtPosition( + data.borrowCtokens, + data.borrowAmts, + _flashLoanFees + ); - // borrow the earlier position from Compound with flash loan fee added - _borrowDebtPosition(data.borrowCtokens, data.borrowAmts, _flashLoanFees); + _eventName = "LogCompoundImport(address,address[],string[],string[],uint256[],uint256[])"; + _eventParam = abi.encode( + _importInputData.userAccount, + data.cTokens, + _importInputData.supplyIds, + _importInputData.borrowIds, + data.supplyAmts, + data.borrowAmts + ); + } - _eventName = "LogCompoundImport(address,address[],string[],string[],uint256[],uint256[])"; - _eventParam = abi.encode( - _importInputData.userAccount, - data.cTokens, - _importInputData.supplyIds, - _importInputData.borrowIds, - data.supplyAmts, - data.borrowAmts - ); - } - - /** - * @notice import Compound position of the address passed in as userAccount - * @dev internally calls _importContract to perform the actual import - * @param _userAccount address of user whose position is to be imported to DSA - * @param _supplyIds Ids of all tokens the user has supplied to Compound - * @param _borrowIds Ids of all token borrowed by the user - * @param _flashLoanFees list of flash loan fees - */ - function importCompound( - address _userAccount, - string[] memory _supplyIds, - string[] memory _borrowIds, - uint256[] memory _flashLoanFees - ) external payable returns (string memory _eventName, bytes memory _eventParam) { - ImportInputData memory inputData = ImportInputData({ - userAccount: _userAccount, - supplyIds: _supplyIds, - borrowIds: _borrowIds - }); - - (_eventName, _eventParam) = _importCompound(inputData, _flashLoanFees); - } + /** + * @notice import Compound position of the address passed in as userAccount + * @dev internally calls _importContract to perform the actual import + * @param _userAccount address of user whose position is to be imported to DSA + * @param _supplyIds Ids of all tokens the user has supplied to Compound + * @param _borrowIds Ids of all token borrowed by the user + * @param _flashLoanFees list of flash loan fees + */ + function importCompound( + address _userAccount, + string[] memory _supplyIds, + string[] memory _borrowIds, + uint256[] memory _flashLoanFees + ) + external + payable + returns (string memory _eventName, bytes memory _eventParam) + { + ImportInputData memory inputData = ImportInputData({ + userAccount: _userAccount, + supplyIds: _supplyIds, + borrowIds: _borrowIds + }); + (_eventName, _eventParam) = _importCompound(inputData, _flashLoanFees); + } } contract ConnectV2CompoundImport is CompoundImportResolver { - string public constant name = "Compound-Import-v2"; -} \ No newline at end of file + string public constant name = "Compound-Import-v2"; +} From fc8aa786bd5103559e22b914a14fd515dfe313b6 Mon Sep 17 00:00:00 2001 From: pradyuman-verma Date: Wed, 23 Mar 2022 16:13:46 +0530 Subject: [PATCH 14/20] updated compound test --- test/mainnet/compound-import/ABIs/cDaiAbi.js | 1533 ---------- test/mainnet/compound-import/ABIs/cEthAbi.js | 1184 -------- .../compound-import/ABIs/comptrollerAbi.js | 2654 ----------------- .../compound-import/compound-import.test.js | 186 -- .../compound-import/compound-import.test.ts | 239 ++ test/mainnet/compound-import/constants.js | 6 - 6 files changed, 239 insertions(+), 5563 deletions(-) delete mode 100644 test/mainnet/compound-import/ABIs/cDaiAbi.js delete mode 100644 test/mainnet/compound-import/ABIs/cEthAbi.js delete mode 100644 test/mainnet/compound-import/ABIs/comptrollerAbi.js delete mode 100644 test/mainnet/compound-import/compound-import.test.js create mode 100644 test/mainnet/compound-import/compound-import.test.ts delete mode 100644 test/mainnet/compound-import/constants.js diff --git a/test/mainnet/compound-import/ABIs/cDaiAbi.js b/test/mainnet/compound-import/ABIs/cDaiAbi.js deleted file mode 100644 index ae494e6d..00000000 --- a/test/mainnet/compound-import/ABIs/cDaiAbi.js +++ /dev/null @@ -1,1533 +0,0 @@ -const cDaiAbi = [ - { - "inputs": [ - { - "internalType": "address", - "name": "underlying_", - "type": "address" - }, - { - "internalType": "contract ComptrollerInterface", - "name": "comptroller_", - "type": "address" - }, - { - "internalType": "contract InterestRateModel", - "name": "interestRateModel_", - "type": "address" - }, - { - "internalType": "uint256", - "name": "initialExchangeRateMantissa_", - "type": "uint256" - }, - { - "internalType": "string", - "name": "name_", - "type": "string" - }, - { - "internalType": "string", - "name": "symbol_", - "type": "string" - }, - { - "internalType": "uint8", - "name": "decimals_", - "type": "uint8" - }, - { - "internalType": "address payable", - "name": "admin_", - "type": "address" - }, - { - "internalType": "address", - "name": "implementation_", - "type": "address" - }, - { - "internalType": "bytes", - "name": "becomeImplementationData", - "type": "bytes" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor", - "signature": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "cashPrior", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "interestAccumulated", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "borrowIndex", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "totalBorrows", - "type": "uint256" - } - ], - "name": "AccrueInterest", - "type": "event", - "signature": "0x4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc04" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event", - "signature": "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "borrower", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "borrowAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "accountBorrows", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "totalBorrows", - "type": "uint256" - } - ], - "name": "Borrow", - "type": "event", - "signature": "0x13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab80" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "error", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "info", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "detail", - "type": "uint256" - } - ], - "name": "Failure", - "type": "event", - "signature": "0x45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "liquidator", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "borrower", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "repayAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "cTokenCollateral", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "seizeTokens", - "type": "uint256" - } - ], - "name": "LiquidateBorrow", - "type": "event", - "signature": "0x298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb52" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "minter", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "mintAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "mintTokens", - "type": "uint256" - } - ], - "name": "Mint", - "type": "event", - "signature": "0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "oldAdmin", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "NewAdmin", - "type": "event", - "signature": "0xf9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "contract ComptrollerInterface", - "name": "oldComptroller", - "type": "address" - }, - { - "indexed": false, - "internalType": "contract ComptrollerInterface", - "name": "newComptroller", - "type": "address" - } - ], - "name": "NewComptroller", - "type": "event", - "signature": "0x7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "oldImplementation", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newImplementation", - "type": "address" - } - ], - "name": "NewImplementation", - "type": "event", - "signature": "0xd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "contract InterestRateModel", - "name": "oldInterestRateModel", - "type": "address" - }, - { - "indexed": false, - "internalType": "contract InterestRateModel", - "name": "newInterestRateModel", - "type": "address" - } - ], - "name": "NewMarketInterestRateModel", - "type": "event", - "signature": "0xedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f926" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "oldPendingAdmin", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newPendingAdmin", - "type": "address" - } - ], - "name": "NewPendingAdmin", - "type": "event", - "signature": "0xca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "oldReserveFactorMantissa", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newReserveFactorMantissa", - "type": "uint256" - } - ], - "name": "NewReserveFactor", - "type": "event", - "signature": "0xaaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f821460" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "redeemer", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "redeemAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "redeemTokens", - "type": "uint256" - } - ], - "name": "Redeem", - "type": "event", - "signature": "0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "payer", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "borrower", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "repayAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "accountBorrows", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "totalBorrows", - "type": "uint256" - } - ], - "name": "RepayBorrow", - "type": "event", - "signature": "0x1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "benefactor", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "addAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newTotalReserves", - "type": "uint256" - } - ], - "name": "ReservesAdded", - "type": "event", - "signature": "0xa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc5" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "admin", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "reduceAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newTotalReserves", - "type": "uint256" - } - ], - "name": "ReservesReduced", - "type": "event", - "signature": "0x3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event", - "signature": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" - }, - { - "payable": true, - "stateMutability": "payable", - "type": "fallback" - }, - { - "constant": false, - "inputs": [], - "name": "_acceptAdmin", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xe9c714f2" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint256", - "name": "addAmount", - "type": "uint256" - } - ], - "name": "_addReserves", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x3e941010" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint256", - "name": "reduceAmount", - "type": "uint256" - } - ], - "name": "_reduceReserves", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x601a0bf1" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "contract ComptrollerInterface", - "name": "newComptroller", - "type": "address" - } - ], - "name": "_setComptroller", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x4576b5db" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "implementation_", - "type": "address" - }, - { - "internalType": "bool", - "name": "allowResign", - "type": "bool" - }, - { - "internalType": "bytes", - "name": "becomeImplementationData", - "type": "bytes" - } - ], - "name": "_setImplementation", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x555bcc40" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "contract InterestRateModel", - "name": "newInterestRateModel", - "type": "address" - } - ], - "name": "_setInterestRateModel", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xf2b3abbd" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address payable", - "name": "newPendingAdmin", - "type": "address" - } - ], - "name": "_setPendingAdmin", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xb71d1a0c" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint256", - "name": "newReserveFactorMantissa", - "type": "uint256" - } - ], - "name": "_setReserveFactor", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xfca7820b" - }, - { - "constant": true, - "inputs": [], - "name": "accrualBlockNumber", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x6c540baf" - }, - { - "constant": false, - "inputs": [], - "name": "accrueInterest", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xa6afed95" - }, - { - "constant": true, - "inputs": [], - "name": "admin", - "outputs": [ - { - "internalType": "address payable", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xf851a440" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xdd62ed3e" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x095ea7b3" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x70a08231" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "balanceOfUnderlying", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x3af9e669" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint256", - "name": "borrowAmount", - "type": "uint256" - } - ], - "name": "borrow", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xc5ebeaec" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "borrowBalanceCurrent", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x17bfdfbc" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "borrowBalanceStored", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x95dd9193" - }, - { - "constant": true, - "inputs": [], - "name": "borrowIndex", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xaa5af0fd" - }, - { - "constant": true, - "inputs": [], - "name": "borrowRatePerBlock", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xf8f9da28" - }, - { - "constant": true, - "inputs": [], - "name": "comptroller", - "outputs": [ - { - "internalType": "contract ComptrollerInterface", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x5fe3b567" - }, - { - "constant": true, - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x313ce567" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "delegateToImplementation", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x0933c1ed" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "delegateToViewImplementation", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x4487152f" - }, - { - "constant": false, - "inputs": [], - "name": "exchangeRateCurrent", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xbd6d894d" - }, - { - "constant": true, - "inputs": [], - "name": "exchangeRateStored", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x182df0f5" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "getAccountSnapshot", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xc37f68e2" - }, - { - "constant": true, - "inputs": [], - "name": "getCash", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x3b1d21a2" - }, - { - "constant": true, - "inputs": [], - "name": "implementation", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x5c60da1b" - }, - { - "constant": true, - "inputs": [], - "name": "interestRateModel", - "outputs": [ - { - "internalType": "contract InterestRateModel", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xf3fdb15a" - }, - { - "constant": true, - "inputs": [], - "name": "isCToken", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xfe9c44ae" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "borrower", - "type": "address" - }, - { - "internalType": "uint256", - "name": "repayAmount", - "type": "uint256" - }, - { - "internalType": "contract CTokenInterface", - "name": "cTokenCollateral", - "type": "address" - } - ], - "name": "liquidateBorrow", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xf5e3c462" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint256", - "name": "mintAmount", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xa0712d68" - }, - { - "constant": true, - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x06fdde03" - }, - { - "constant": true, - "inputs": [], - "name": "pendingAdmin", - "outputs": [ - { - "internalType": "address payable", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x26782247" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint256", - "name": "redeemTokens", - "type": "uint256" - } - ], - "name": "redeem", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xdb006a75" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint256", - "name": "redeemAmount", - "type": "uint256" - } - ], - "name": "redeemUnderlying", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x852a12e3" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint256", - "name": "repayAmount", - "type": "uint256" - } - ], - "name": "repayBorrow", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x0e752702" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "borrower", - "type": "address" - }, - { - "internalType": "uint256", - "name": "repayAmount", - "type": "uint256" - } - ], - "name": "repayBorrowBehalf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x2608f818" - }, - { - "constant": true, - "inputs": [], - "name": "reserveFactorMantissa", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x173b9904" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "liquidator", - "type": "address" - }, - { - "internalType": "address", - "name": "borrower", - "type": "address" - }, - { - "internalType": "uint256", - "name": "seizeTokens", - "type": "uint256" - } - ], - "name": "seize", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xb2a02ff1" - }, - { - "constant": true, - "inputs": [], - "name": "supplyRatePerBlock", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xae9d70b0" - }, - { - "constant": true, - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x95d89b41" - }, - { - "constant": true, - "inputs": [], - "name": "totalBorrows", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x47bd3718" - }, - { - "constant": false, - "inputs": [], - "name": "totalBorrowsCurrent", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x73acee98" - }, - { - "constant": true, - "inputs": [], - "name": "totalReserves", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x8f840ddd" - }, - { - "constant": true, - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x18160ddd" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "dst", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xa9059cbb" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "src", - "type": "address" - }, - { - "internalType": "address", - "name": "dst", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x23b872dd" - }, - { - "constant": true, - "inputs": [], - "name": "underlying", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x6f307dc3" - } -] -module.exports = cDaiAbi; \ No newline at end of file diff --git a/test/mainnet/compound-import/ABIs/cEthAbi.js b/test/mainnet/compound-import/ABIs/cEthAbi.js deleted file mode 100644 index ce4ecec4..00000000 --- a/test/mainnet/compound-import/ABIs/cEthAbi.js +++ /dev/null @@ -1,1184 +0,0 @@ -const cEthAbi = [ - { - "constant": true, - "inputs": [], - "name": "name", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x06fdde03" - }, - { - "constant": false, - "inputs": [ - { - "name": "spender", - "type": "address" - }, - { - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x095ea7b3" - }, - { - "constant": false, - "inputs": [], - "name": "mint", - "outputs": [], - "payable": true, - "stateMutability": "payable", - "type": "function", - "signature": "0x1249c58b" - }, - { - "constant": true, - "inputs": [], - "name": "reserveFactorMantissa", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x173b9904" - }, - { - "constant": false, - "inputs": [ - { - "name": "account", - "type": "address" - } - ], - "name": "borrowBalanceCurrent", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x17bfdfbc" - }, - { - "constant": true, - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x18160ddd" - }, - { - "constant": true, - "inputs": [], - "name": "exchangeRateStored", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x182df0f5" - }, - { - "constant": false, - "inputs": [ - { - "name": "src", - "type": "address" - }, - { - "name": "dst", - "type": "address" - }, - { - "name": "amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x23b872dd" - }, - { - "constant": true, - "inputs": [], - "name": "pendingAdmin", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x26782247" - }, - { - "constant": true, - "inputs": [], - "name": "decimals", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x313ce567" - }, - { - "constant": false, - "inputs": [ - { - "name": "owner", - "type": "address" - } - ], - "name": "balanceOfUnderlying", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x3af9e669" - }, - { - "constant": true, - "inputs": [], - "name": "getCash", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x3b1d21a2" - }, - { - "constant": false, - "inputs": [ - { - "name": "newComptroller", - "type": "address" - } - ], - "name": "_setComptroller", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x4576b5db" - }, - { - "constant": true, - "inputs": [], - "name": "totalBorrows", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x47bd3718" - }, - { - "constant": false, - "inputs": [], - "name": "repayBorrow", - "outputs": [], - "payable": true, - "stateMutability": "payable", - "type": "function", - "signature": "0x4e4d9fea" - }, - { - "constant": true, - "inputs": [], - "name": "comptroller", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x5fe3b567" - }, - { - "constant": false, - "inputs": [ - { - "name": "reduceAmount", - "type": "uint256" - } - ], - "name": "_reduceReserves", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x601a0bf1" - }, - { - "constant": true, - "inputs": [], - "name": "initialExchangeRateMantissa", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x675d972c" - }, - { - "constant": true, - "inputs": [], - "name": "accrualBlockNumber", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x6c540baf" - }, - { - "constant": true, - "inputs": [ - { - "name": "owner", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x70a08231" - }, - { - "constant": false, - "inputs": [], - "name": "totalBorrowsCurrent", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x73acee98" - }, - { - "constant": false, - "inputs": [ - { - "name": "redeemAmount", - "type": "uint256" - } - ], - "name": "redeemUnderlying", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x852a12e3" - }, - { - "constant": true, - "inputs": [], - "name": "totalReserves", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x8f840ddd" - }, - { - "constant": true, - "inputs": [], - "name": "symbol", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x95d89b41" - }, - { - "constant": true, - "inputs": [ - { - "name": "account", - "type": "address" - } - ], - "name": "borrowBalanceStored", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x95dd9193" - }, - { - "constant": false, - "inputs": [], - "name": "accrueInterest", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xa6afed95" - }, - { - "constant": false, - "inputs": [ - { - "name": "dst", - "type": "address" - }, - { - "name": "amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xa9059cbb" - }, - { - "constant": true, - "inputs": [], - "name": "borrowIndex", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xaa5af0fd" - }, - { - "constant": false, - "inputs": [ - { - "name": "borrower", - "type": "address" - }, - { - "name": "cTokenCollateral", - "type": "address" - } - ], - "name": "liquidateBorrow", - "outputs": [], - "payable": true, - "stateMutability": "payable", - "type": "function", - "signature": "0xaae40a2a" - }, - { - "constant": true, - "inputs": [], - "name": "supplyRatePerBlock", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xae9d70b0" - }, - { - "constant": false, - "inputs": [ - { - "name": "liquidator", - "type": "address" - }, - { - "name": "borrower", - "type": "address" - }, - { - "name": "seizeTokens", - "type": "uint256" - } - ], - "name": "seize", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xb2a02ff1" - }, - { - "constant": false, - "inputs": [ - { - "name": "newPendingAdmin", - "type": "address" - } - ], - "name": "_setPendingAdmin", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xb71d1a0c" - }, - { - "constant": false, - "inputs": [], - "name": "exchangeRateCurrent", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xbd6d894d" - }, - { - "constant": true, - "inputs": [ - { - "name": "account", - "type": "address" - } - ], - "name": "getAccountSnapshot", - "outputs": [ - { - "name": "", - "type": "uint256" - }, - { - "name": "", - "type": "uint256" - }, - { - "name": "", - "type": "uint256" - }, - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xc37f68e2" - }, - { - "constant": false, - "inputs": [ - { - "name": "borrowAmount", - "type": "uint256" - } - ], - "name": "borrow", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xc5ebeaec" - }, - { - "constant": false, - "inputs": [ - { - "name": "redeemTokens", - "type": "uint256" - } - ], - "name": "redeem", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xdb006a75" - }, - { - "constant": true, - "inputs": [ - { - "name": "owner", - "type": "address" - }, - { - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xdd62ed3e" - }, - { - "constant": false, - "inputs": [ - { - "name": "borrower", - "type": "address" - } - ], - "name": "repayBorrowBehalf", - "outputs": [], - "payable": true, - "stateMutability": "payable", - "type": "function", - "signature": "0xe5974619" - }, - { - "constant": false, - "inputs": [], - "name": "_acceptAdmin", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xe9c714f2" - }, - { - "constant": false, - "inputs": [ - { - "name": "newInterestRateModel", - "type": "address" - } - ], - "name": "_setInterestRateModel", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xf2b3abbd" - }, - { - "constant": true, - "inputs": [], - "name": "interestRateModel", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xf3fdb15a" - }, - { - "constant": true, - "inputs": [], - "name": "admin", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xf851a440" - }, - { - "constant": true, - "inputs": [], - "name": "borrowRatePerBlock", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xf8f9da28" - }, - { - "constant": false, - "inputs": [ - { - "name": "newReserveFactorMantissa", - "type": "uint256" - } - ], - "name": "_setReserveFactor", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xfca7820b" - }, - { - "constant": true, - "inputs": [], - "name": "isCToken", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xfe9c44ae" - }, - { - "inputs": [ - { - "name": "comptroller_", - "type": "address" - }, - { - "name": "interestRateModel_", - "type": "address" - }, - { - "name": "initialExchangeRateMantissa_", - "type": "uint256" - }, - { - "name": "name_", - "type": "string" - }, - { - "name": "symbol_", - "type": "string" - }, - { - "name": "decimals_", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor", - "signature": "constructor" - }, - { - "payable": true, - "stateMutability": "payable", - "type": "fallback" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "interestAccumulated", - "type": "uint256" - }, - { - "indexed": false, - "name": "borrowIndex", - "type": "uint256" - }, - { - "indexed": false, - "name": "totalBorrows", - "type": "uint256" - } - ], - "name": "AccrueInterest", - "type": "event", - "signature": "0x875352fb3fadeb8c0be7cbbe8ff761b308fa7033470cd0287f02f3436fd76cb9" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "minter", - "type": "address" - }, - { - "indexed": false, - "name": "mintAmount", - "type": "uint256" - }, - { - "indexed": false, - "name": "mintTokens", - "type": "uint256" - } - ], - "name": "Mint", - "type": "event", - "signature": "0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "redeemer", - "type": "address" - }, - { - "indexed": false, - "name": "redeemAmount", - "type": "uint256" - }, - { - "indexed": false, - "name": "redeemTokens", - "type": "uint256" - } - ], - "name": "Redeem", - "type": "event", - "signature": "0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "borrower", - "type": "address" - }, - { - "indexed": false, - "name": "borrowAmount", - "type": "uint256" - }, - { - "indexed": false, - "name": "accountBorrows", - "type": "uint256" - }, - { - "indexed": false, - "name": "totalBorrows", - "type": "uint256" - } - ], - "name": "Borrow", - "type": "event", - "signature": "0x13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab80" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "payer", - "type": "address" - }, - { - "indexed": false, - "name": "borrower", - "type": "address" - }, - { - "indexed": false, - "name": "repayAmount", - "type": "uint256" - }, - { - "indexed": false, - "name": "accountBorrows", - "type": "uint256" - }, - { - "indexed": false, - "name": "totalBorrows", - "type": "uint256" - } - ], - "name": "RepayBorrow", - "type": "event", - "signature": "0x1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "liquidator", - "type": "address" - }, - { - "indexed": false, - "name": "borrower", - "type": "address" - }, - { - "indexed": false, - "name": "repayAmount", - "type": "uint256" - }, - { - "indexed": false, - "name": "cTokenCollateral", - "type": "address" - }, - { - "indexed": false, - "name": "seizeTokens", - "type": "uint256" - } - ], - "name": "LiquidateBorrow", - "type": "event", - "signature": "0x298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb52" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "oldPendingAdmin", - "type": "address" - }, - { - "indexed": false, - "name": "newPendingAdmin", - "type": "address" - } - ], - "name": "NewPendingAdmin", - "type": "event", - "signature": "0xca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "oldAdmin", - "type": "address" - }, - { - "indexed": false, - "name": "newAdmin", - "type": "address" - } - ], - "name": "NewAdmin", - "type": "event", - "signature": "0xf9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "oldComptroller", - "type": "address" - }, - { - "indexed": false, - "name": "newComptroller", - "type": "address" - } - ], - "name": "NewComptroller", - "type": "event", - "signature": "0x7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "oldInterestRateModel", - "type": "address" - }, - { - "indexed": false, - "name": "newInterestRateModel", - "type": "address" - } - ], - "name": "NewMarketInterestRateModel", - "type": "event", - "signature": "0xedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f926" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "oldReserveFactorMantissa", - "type": "uint256" - }, - { - "indexed": false, - "name": "newReserveFactorMantissa", - "type": "uint256" - } - ], - "name": "NewReserveFactor", - "type": "event", - "signature": "0xaaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f821460" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "admin", - "type": "address" - }, - { - "indexed": false, - "name": "reduceAmount", - "type": "uint256" - }, - { - "indexed": false, - "name": "newTotalReserves", - "type": "uint256" - } - ], - "name": "ReservesReduced", - "type": "event", - "signature": "0x3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "error", - "type": "uint256" - }, - { - "indexed": false, - "name": "info", - "type": "uint256" - }, - { - "indexed": false, - "name": "detail", - "type": "uint256" - } - ], - "name": "Failure", - "type": "event", - "signature": "0x45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": true, - "name": "to", - "type": "address" - }, - { - "indexed": false, - "name": "amount", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event", - "signature": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "name": "amount", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event", - "signature": "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925" - } -] -module.exports = cEthAbi; \ No newline at end of file diff --git a/test/mainnet/compound-import/ABIs/comptrollerAbi.js b/test/mainnet/compound-import/ABIs/comptrollerAbi.js deleted file mode 100644 index c24070ca..00000000 --- a/test/mainnet/compound-import/ABIs/comptrollerAbi.js +++ /dev/null @@ -1,2654 +0,0 @@ -const comptrollerAbi = [ - { - "constant": true, - "inputs": [], - "name": "pendingAdmin", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x26782247" - }, - { - "constant": false, - "inputs": [ - { - "name": "newPendingAdmin", - "type": "address" - } - ], - "name": "_setPendingAdmin", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xb71d1a0c" - }, - { - "constant": true, - "inputs": [], - "name": "comptrollerImplementation", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xbb82aa5e" - }, - { - "constant": false, - "inputs": [], - "name": "_acceptImplementation", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xc1e80334" - }, - { - "constant": true, - "inputs": [], - "name": "pendingComptrollerImplementation", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xdcfbc0c7" - }, - { - "constant": false, - "inputs": [ - { - "name": "newPendingImplementation", - "type": "address" - } - ], - "name": "_setPendingImplementation", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xe992a041" - }, - { - "constant": false, - "inputs": [], - "name": "_acceptAdmin", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xe9c714f2" - }, - { - "constant": true, - "inputs": [], - "name": "admin", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xf851a440" - }, - { - "inputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor", - "signature": "constructor" - }, - { - "payable": true, - "stateMutability": "payable", - "type": "fallback" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "oldPendingImplementation", - "type": "address" - }, - { - "indexed": false, - "name": "newPendingImplementation", - "type": "address" - } - ], - "name": "NewPendingImplementation", - "type": "event", - "signature": "0xe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d815" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "oldImplementation", - "type": "address" - }, - { - "indexed": false, - "name": "newImplementation", - "type": "address" - } - ], - "name": "NewImplementation", - "type": "event", - "signature": "0xd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "oldPendingAdmin", - "type": "address" - }, - { - "indexed": false, - "name": "newPendingAdmin", - "type": "address" - } - ], - "name": "NewPendingAdmin", - "type": "event", - "signature": "0xca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "oldAdmin", - "type": "address" - }, - { - "indexed": false, - "name": "newAdmin", - "type": "address" - } - ], - "name": "NewAdmin", - "type": "event", - "signature": "0xf9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "error", - "type": "uint256" - }, - { - "indexed": false, - "name": "info", - "type": "uint256" - }, - { - "indexed": false, - "name": "detail", - "type": "uint256" - } - ], - "name": "Failure", - "type": "event", - "signature": "0x45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "contributor", - "type": "address" - } - ], - "name": "updateContributorRewards", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x741b2525" - }, - { - "inputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor", - "signature": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string", - "name": "action", - "type": "string" - }, - { - "indexed": false, - "internalType": "bool", - "name": "pauseState", - "type": "bool" - } - ], - "name": "ActionPaused", - "type": "event", - "signature": "0xef159d9a32b2472e32b098f954f3ce62d232939f1c207070b584df1814de2de0" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "contract CToken", - "name": "cToken", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "action", - "type": "string" - }, - { - "indexed": false, - "internalType": "bool", - "name": "pauseState", - "type": "bool" - } - ], - "name": "ActionPaused", - "type": "event", - "signature": "0x71aec636243f9709bb0007ae15e9afb8150ab01716d75fd7573be5cc096e03b0" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "oldCompAccrued", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newCompAccrued", - "type": "uint256" - } - ], - "name": "CompAccruedAdjusted", - "type": "event", - "signature": "0x4a5c134e28b537a76546993ea37f3b60d9190476df7356d3842aa40902e20f04" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract CToken", - "name": "cToken", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newSpeed", - "type": "uint256" - } - ], - "name": "CompBorrowSpeedUpdated", - "type": "event", - "signature": "0x20af8e791cc98f74b2d7a391c80980ca8e5aebf3d4060bf581997b6acae2e537" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "CompGranted", - "type": "event", - "signature": "0x98b2f82a3a07f223a0be64b3d0f47711c64dccd1feafb94aa28156b38cd9695c" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "oldCompReceivable", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newCompReceivable", - "type": "uint256" - } - ], - "name": "CompReceivableUpdated", - "type": "event", - "signature": "0x17fea09d9a7ca41b2f9f9118f18f44848a62e9c70d55dd4385131eb2cf1b7e47" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract CToken", - "name": "cToken", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newSpeed", - "type": "uint256" - } - ], - "name": "CompSupplySpeedUpdated", - "type": "event", - "signature": "0xdeafccd0c0b768b2529f7dcbbe58e155d6023059150b7490ed4535cc3744b92d" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "contributor", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newSpeed", - "type": "uint256" - } - ], - "name": "ContributorCompSpeedUpdated", - "type": "event", - "signature": "0x386537fa92edc3319af95f1f904dcf1900021e4f3f4e08169a577a09076e66b3" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract CToken", - "name": "cToken", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "borrower", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "compDelta", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "compBorrowIndex", - "type": "uint256" - } - ], - "name": "DistributedBorrowerComp", - "type": "event", - "signature": "0x1fc3ecc087d8d2d15e23d0032af5a47059c3892d003d8e139fdcb6bb327c99a6" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract CToken", - "name": "cToken", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "supplier", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "compDelta", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "compSupplyIndex", - "type": "uint256" - } - ], - "name": "DistributedSupplierComp", - "type": "event", - "signature": "0x2caecd17d02f56fa897705dcc740da2d237c373f70686f4e0d9bd3bf0400ea7a" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "error", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "info", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "detail", - "type": "uint256" - } - ], - "name": "Failure", - "type": "event", - "signature": "0x45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "contract CToken", - "name": "cToken", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "MarketEntered", - "type": "event", - "signature": "0x3ab23ab0d51cccc0c3085aec51f99228625aa1a922b3a8ca89a26b0f2027a1a5" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "contract CToken", - "name": "cToken", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "MarketExited", - "type": "event", - "signature": "0xe699a64c18b07ac5b7301aa273f36a2287239eb9501d81950672794afba29a0d" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "contract CToken", - "name": "cToken", - "type": "address" - } - ], - "name": "MarketListed", - "type": "event", - "signature": "0xcf583bb0c569eb967f806b11601c4cb93c10310485c67add5f8362c2f212321f" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract CToken", - "name": "cToken", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newBorrowCap", - "type": "uint256" - } - ], - "name": "NewBorrowCap", - "type": "event", - "signature": "0x6f1951b2aad10f3fc81b86d91105b413a5b3f847a34bbc5ce1904201b14438f6" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "oldBorrowCapGuardian", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newBorrowCapGuardian", - "type": "address" - } - ], - "name": "NewBorrowCapGuardian", - "type": "event", - "signature": "0xeda98690e518e9a05f8ec6837663e188211b2da8f4906648b323f2c1d4434e29" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "oldCloseFactorMantissa", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newCloseFactorMantissa", - "type": "uint256" - } - ], - "name": "NewCloseFactor", - "type": "event", - "signature": "0x3b9670cf975d26958e754b57098eaa2ac914d8d2a31b83257997b9f346110fd9" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "contract CToken", - "name": "cToken", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "oldCollateralFactorMantissa", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newCollateralFactorMantissa", - "type": "uint256" - } - ], - "name": "NewCollateralFactor", - "type": "event", - "signature": "0x70483e6592cd5182d45ac970e05bc62cdcc90e9d8ef2c2dbe686cf383bcd7fc5" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "oldLiquidationIncentiveMantissa", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newLiquidationIncentiveMantissa", - "type": "uint256" - } - ], - "name": "NewLiquidationIncentive", - "type": "event", - "signature": "0xaeba5a6c40a8ac138134bff1aaa65debf25971188a58804bad717f82f0ec1316" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "oldPauseGuardian", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newPauseGuardian", - "type": "address" - } - ], - "name": "NewPauseGuardian", - "type": "event", - "signature": "0x0613b6ee6a04f0d09f390e4d9318894b9f6ac7fd83897cd8d18896ba579c401e" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "contract PriceOracle", - "name": "oldPriceOracle", - "type": "address" - }, - { - "indexed": false, - "internalType": "contract PriceOracle", - "name": "newPriceOracle", - "type": "address" - } - ], - "name": "NewPriceOracle", - "type": "event", - "signature": "0xd52b2b9b7e9ee655fcb95d2e5b9e0c9f69e7ef2b8e9d2d0ea78402d576d22e22" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "contract Unitroller", - "name": "unitroller", - "type": "address" - } - ], - "name": "_become", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x1d504dc6" - }, - { - "constant": true, - "inputs": [], - "name": "_borrowGuardianPaused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xe6653f3d" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "_grantComp", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x27efe3cb" - }, - { - "constant": true, - "inputs": [], - "name": "_mintGuardianPaused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x3c94786f" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "newBorrowCapGuardian", - "type": "address" - } - ], - "name": "_setBorrowCapGuardian", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x391957d7" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "contract CToken", - "name": "cToken", - "type": "address" - }, - { - "internalType": "bool", - "name": "state", - "type": "bool" - } - ], - "name": "_setBorrowPaused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x18c882a5" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint256", - "name": "newCloseFactorMantissa", - "type": "uint256" - } - ], - "name": "_setCloseFactor", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x317b0b77" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "contract CToken", - "name": "cToken", - "type": "address" - }, - { - "internalType": "uint256", - "name": "newCollateralFactorMantissa", - "type": "uint256" - } - ], - "name": "_setCollateralFactor", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xe4028eee" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "contract CToken[]", - "name": "cTokens", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "supplySpeeds", - "type": "uint256[]" - }, - { - "internalType": "uint256[]", - "name": "borrowSpeeds", - "type": "uint256[]" - } - ], - "name": "_setCompSpeeds", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xa8b43948" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "contributor", - "type": "address" - }, - { - "internalType": "uint256", - "name": "compSpeed", - "type": "uint256" - } - ], - "name": "_setContributorCompSpeed", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x598ee1cb" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint256", - "name": "newLiquidationIncentiveMantissa", - "type": "uint256" - } - ], - "name": "_setLiquidationIncentive", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x4fd42e17" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "contract CToken[]", - "name": "cTokens", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "newBorrowCaps", - "type": "uint256[]" - } - ], - "name": "_setMarketBorrowCaps", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x607ef6c1" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "contract CToken", - "name": "cToken", - "type": "address" - }, - { - "internalType": "bool", - "name": "state", - "type": "bool" - } - ], - "name": "_setMintPaused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x3bcf7ec1" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "newPauseGuardian", - "type": "address" - } - ], - "name": "_setPauseGuardian", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x5f5af1aa" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "contract PriceOracle", - "name": "newOracle", - "type": "address" - } - ], - "name": "_setPriceOracle", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x55ee1fe1" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "bool", - "name": "state", - "type": "bool" - } - ], - "name": "_setSeizePaused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x2d70db78" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "bool", - "name": "state", - "type": "bool" - } - ], - "name": "_setTransferPaused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x8ebf6364" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "contract CToken", - "name": "cToken", - "type": "address" - } - ], - "name": "_supportMarket", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xa76b3fda" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "accountAssets", - "outputs": [ - { - "internalType": "contract CToken", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xdce15449" - }, - { - "constant": true, - "inputs": [], - "name": "admin", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xf851a440" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "allMarkets", - "outputs": [ - { - "internalType": "contract CToken", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x52d84d1e" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "cToken", - "type": "address" - }, - { - "internalType": "address", - "name": "borrower", - "type": "address" - }, - { - "internalType": "uint256", - "name": "borrowAmount", - "type": "uint256" - } - ], - "name": "borrowAllowed", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xda3d454c" - }, - { - "constant": true, - "inputs": [], - "name": "borrowCapGuardian", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x21af4569" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "borrowCaps", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x4a584432" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "borrowGuardianPaused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x6d154ea5" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "cToken", - "type": "address" - }, - { - "internalType": "address", - "name": "borrower", - "type": "address" - }, - { - "internalType": "uint256", - "name": "borrowAmount", - "type": "uint256" - } - ], - "name": "borrowVerify", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x5c778605" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract CToken", - "name": "cToken", - "type": "address" - } - ], - "name": "checkMembership", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x929fe9a1" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "holder", - "type": "address" - }, - { - "internalType": "contract CToken[]", - "name": "cTokens", - "type": "address[]" - } - ], - "name": "claimComp", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x1c3db2e0" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address[]", - "name": "holders", - "type": "address[]" - }, - { - "internalType": "contract CToken[]", - "name": "cTokens", - "type": "address[]" - }, - { - "internalType": "bool", - "name": "borrowers", - "type": "bool" - }, - { - "internalType": "bool", - "name": "suppliers", - "type": "bool" - } - ], - "name": "claimComp", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x6810dfa6" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "holder", - "type": "address" - } - ], - "name": "claimComp", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xe9af0292" - }, - { - "constant": true, - "inputs": [], - "name": "closeFactorMantissa", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xe8755446" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "compAccrued", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xcc7ebdc4" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "compBorrowSpeeds", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xf4a433c0" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "compBorrowState", - "outputs": [ - { - "internalType": "uint224", - "name": "index", - "type": "uint224" - }, - { - "internalType": "uint32", - "name": "block", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x8c57804e" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "compBorrowerIndex", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xca0af043" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "compContributorSpeeds", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x986ab838" - }, - { - "constant": true, - "inputs": [], - "name": "compInitialIndex", - "outputs": [ - { - "internalType": "uint224", - "name": "", - "type": "uint224" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xa7f0e231" - }, - { - "constant": true, - "inputs": [], - "name": "compRate", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xaa900754" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "compReceivable", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x85b7beb8" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "compSpeeds", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x1d7b33d7" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "compSupplierIndex", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xb21be7fd" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "compSupplySpeeds", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x6aa875b5" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "compSupplyState", - "outputs": [ - { - "internalType": "uint224", - "name": "index", - "type": "uint224" - }, - { - "internalType": "uint32", - "name": "block", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x6b79c38d" - }, - { - "constant": true, - "inputs": [], - "name": "comptrollerImplementation", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xbb82aa5e" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address[]", - "name": "cTokens", - "type": "address[]" - } - ], - "name": "enterMarkets", - "outputs": [ - { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xc2998238" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "cTokenAddress", - "type": "address" - } - ], - "name": "exitMarket", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xede4edd0" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address[]", - "name": "affectedUsers", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "amounts", - "type": "uint256[]" - } - ], - "name": "fixBadAccruals", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x16b95e8f" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "getAccountLiquidity", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x5ec88c79" - }, - { - "constant": true, - "inputs": [], - "name": "getAllMarkets", - "outputs": [ - { - "internalType": "contract CToken[]", - "name": "", - "type": "address[]" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xb0772d0b" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "getAssetsIn", - "outputs": [ - { - "internalType": "contract CToken[]", - "name": "", - "type": "address[]" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xabfceffc" - }, - { - "constant": true, - "inputs": [], - "name": "getBlockNumber", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x42cbb15c" - }, - { - "constant": true, - "inputs": [], - "name": "getCompAddress", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x9d1b5a0a" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "address", - "name": "cTokenModify", - "type": "address" - }, - { - "internalType": "uint256", - "name": "redeemTokens", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "borrowAmount", - "type": "uint256" - } - ], - "name": "getHypotheticalAccountLiquidity", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x4e79238f" - }, - { - "constant": true, - "inputs": [], - "name": "isComptroller", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x007e3dd2" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "contract CToken", - "name": "cToken", - "type": "address" - } - ], - "name": "isDeprecated", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x94543c15" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "lastContributorBlock", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xbea6b8b8" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "cTokenBorrowed", - "type": "address" - }, - { - "internalType": "address", - "name": "cTokenCollateral", - "type": "address" - }, - { - "internalType": "address", - "name": "liquidator", - "type": "address" - }, - { - "internalType": "address", - "name": "borrower", - "type": "address" - }, - { - "internalType": "uint256", - "name": "repayAmount", - "type": "uint256" - } - ], - "name": "liquidateBorrowAllowed", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x5fc7e71e" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "cTokenBorrowed", - "type": "address" - }, - { - "internalType": "address", - "name": "cTokenCollateral", - "type": "address" - }, - { - "internalType": "address", - "name": "liquidator", - "type": "address" - }, - { - "internalType": "address", - "name": "borrower", - "type": "address" - }, - { - "internalType": "uint256", - "name": "actualRepayAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "seizeTokens", - "type": "uint256" - } - ], - "name": "liquidateBorrowVerify", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x47ef3b3b" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "cTokenBorrowed", - "type": "address" - }, - { - "internalType": "address", - "name": "cTokenCollateral", - "type": "address" - }, - { - "internalType": "uint256", - "name": "actualRepayAmount", - "type": "uint256" - } - ], - "name": "liquidateCalculateSeizeTokens", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xc488847b" - }, - { - "constant": true, - "inputs": [], - "name": "liquidationIncentiveMantissa", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x4ada90af" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "markets", - "outputs": [ - { - "internalType": "bool", - "name": "isListed", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "collateralFactorMantissa", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "isComped", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x8e8f294b" - }, - { - "constant": true, - "inputs": [], - "name": "maxAssets", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x94b2294b" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "cToken", - "type": "address" - }, - { - "internalType": "address", - "name": "minter", - "type": "address" - }, - { - "internalType": "uint256", - "name": "mintAmount", - "type": "uint256" - } - ], - "name": "mintAllowed", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x4ef4c3e1" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "mintGuardianPaused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x731f0c2b" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "cToken", - "type": "address" - }, - { - "internalType": "address", - "name": "minter", - "type": "address" - }, - { - "internalType": "uint256", - "name": "actualMintAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "mintTokens", - "type": "uint256" - } - ], - "name": "mintVerify", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x41c728b9" - }, - { - "constant": true, - "inputs": [], - "name": "oracle", - "outputs": [ - { - "internalType": "contract PriceOracle", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x7dc0d1d0" - }, - { - "constant": true, - "inputs": [], - "name": "pauseGuardian", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x24a3d622" - }, - { - "constant": true, - "inputs": [], - "name": "pendingAdmin", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x26782247" - }, - { - "constant": true, - "inputs": [], - "name": "pendingComptrollerImplementation", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xdcfbc0c7" - }, - { - "constant": true, - "inputs": [], - "name": "proposal65FixExecuted", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xf00a7a92" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "cToken", - "type": "address" - }, - { - "internalType": "address", - "name": "redeemer", - "type": "address" - }, - { - "internalType": "uint256", - "name": "redeemTokens", - "type": "uint256" - } - ], - "name": "redeemAllowed", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xeabe7d91" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "cToken", - "type": "address" - }, - { - "internalType": "address", - "name": "redeemer", - "type": "address" - }, - { - "internalType": "uint256", - "name": "redeemAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "redeemTokens", - "type": "uint256" - } - ], - "name": "redeemVerify", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x51dff989" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "cToken", - "type": "address" - }, - { - "internalType": "address", - "name": "payer", - "type": "address" - }, - { - "internalType": "address", - "name": "borrower", - "type": "address" - }, - { - "internalType": "uint256", - "name": "repayAmount", - "type": "uint256" - } - ], - "name": "repayBorrowAllowed", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x24008a62" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "cToken", - "type": "address" - }, - { - "internalType": "address", - "name": "payer", - "type": "address" - }, - { - "internalType": "address", - "name": "borrower", - "type": "address" - }, - { - "internalType": "uint256", - "name": "actualRepayAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "borrowerIndex", - "type": "uint256" - } - ], - "name": "repayBorrowVerify", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x1ededc91" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "cTokenCollateral", - "type": "address" - }, - { - "internalType": "address", - "name": "cTokenBorrowed", - "type": "address" - }, - { - "internalType": "address", - "name": "liquidator", - "type": "address" - }, - { - "internalType": "address", - "name": "borrower", - "type": "address" - }, - { - "internalType": "uint256", - "name": "seizeTokens", - "type": "uint256" - } - ], - "name": "seizeAllowed", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xd02f7351" - }, - { - "constant": true, - "inputs": [], - "name": "seizeGuardianPaused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xac0b0bb7" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "cTokenCollateral", - "type": "address" - }, - { - "internalType": "address", - "name": "cTokenBorrowed", - "type": "address" - }, - { - "internalType": "address", - "name": "liquidator", - "type": "address" - }, - { - "internalType": "address", - "name": "borrower", - "type": "address" - }, - { - "internalType": "uint256", - "name": "seizeTokens", - "type": "uint256" - } - ], - "name": "seizeVerify", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x6d35bf91" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "cToken", - "type": "address" - }, - { - "internalType": "address", - "name": "src", - "type": "address" - }, - { - "internalType": "address", - "name": "dst", - "type": "address" - }, - { - "internalType": "uint256", - "name": "transferTokens", - "type": "uint256" - } - ], - "name": "transferAllowed", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xbdcdc258" - }, - { - "constant": true, - "inputs": [], - "name": "transferGuardianPaused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x87f76303" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "cToken", - "type": "address" - }, - { - "internalType": "address", - "name": "src", - "type": "address" - }, - { - "internalType": "address", - "name": "dst", - "type": "address" - }, - { - "internalType": "uint256", - "name": "transferTokens", - "type": "uint256" - } - ], - "name": "transferVerify", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x6a56947e" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "contributor", - "type": "address" - } - ], - "name": "updateContributorRewards", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x741b2525" - } -] -module.exports = comptrollerAbi; \ No newline at end of file diff --git a/test/mainnet/compound-import/compound-import.test.js b/test/mainnet/compound-import/compound-import.test.js deleted file mode 100644 index 52301cf8..00000000 --- a/test/mainnet/compound-import/compound-import.test.js +++ /dev/null @@ -1,186 +0,0 @@ -const { expect, should } = require("chai"); -const { ethers } = require('hardhat'); -const { provider, deployContract} = waffle -const { Signer, Contract } = require("ethers"); - -const { buildDSAv2 } = require("../../../scripts/tests/buildDSAv2"); -const { cEthAddress, cDaiAddress, daiAddress, comptrollerAddress } = require("./constants.js"); -const cEthAbi = require("./ABIs/cEthAbi"); -const cDaiAbi = require("./ABIs/cDaiAbi"); -const comptrollerAbi = require("./ABIs/comptrollerAbi"); -const { addresses } = require("../../../scripts/tests/mainnet/addresses"); -const { deployAndEnableConnector } = require("../../../scripts/tests/deployAndEnableConnector"); -const { abis } = require("../../../scripts/constant/abis"); -const { getMasterSigner } = require("../../../scripts/tests/getMasterSigner"); -const { parseEther, parseUnits } = require("ethers/lib/utils"); -const { encodeSpells } = require("../../../scripts/tests/encodeSpells"); -const encodeFlashcastData = require("../../../scripts/tests/encodeFlashcastData").default; -const { ConnectV2CompoundImport__factory } = require("../../../typechain"); -const { ConnectV2InstaPoolV4__factory } = require("../../../typechain"); -const { ConnectV2Compound__factory } = require("../../../typechain"); - - -describe('Import Compound', function () { - // const connectorName = "COMPOUND-IMPORT-ABC"; - const connectorName = "COMPOUND-IMPORT-C"; - const instapoolConnector = "INSTAPOOL-C"; - const compoundConnector = "COMPOUND-C"; - let dsaWallet; // signers - let cEth, cDai, comptroller, Dai; // contracts - let masterSigner = Signer; - let connector, connector2, connector3; - let owner; - let wallets; - - before(async () => { - // create (reset) mainnet fork - await hre.network.provider.request({ - method: "hardhat_reset", - params: [ - { - forking: { - jsonRpcUrl: hre.config.networks.hardhat.forking.url, - blockNumber: 13300000, - }, - }, - ], - }); - - // deploy and enable connector contract - masterSigner = await getMasterSigner() - instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2); - - // compound import connector - connector = await deployAndEnableConnector({ - connectorName, - contractArtifact: ConnectV2CompoundImport__factory, - signer: masterSigner, - connectors: instaConnectorsV2 - }) - console.log("Connector address", connector.address); - - // flash loan connector - connector2 = await deployAndEnableConnector({ - connectorName: instapoolConnector, - contractArtifact: ConnectV2InstaPoolV4__factory, - signer: masterSigner, - connectors: instaConnectorsV2 - }) - console.log("Connector2 address", connector2.address); - - // compound connector - connector3 = await deployAndEnableConnector({ - connectorName: compoundConnector, - contractArtifact: ConnectV2Compound__factory, - signer: masterSigner, - connectors: instaConnectorsV2 - }) - console.log("Connector3 address", connector3.address); - - // get an account - await hre.network.provider.request({ - method: "hardhat_impersonateAccount", - params: ["0x10a25c6886AE02fde87C5561CDD331d941d0771a"], - }); - owner = await ethers.getSigner("0x10a25c6886AE02fde87C5561CDD331d941d0771a"); - - await hre.network.provider.send("hardhat_setBalance", [ - "0x10a25c6886AE02fde87C5561CDD331d941d0771a", - parseEther('100000').toHexString() - ]); - - cEth = new ethers.Contract(cEthAddress, cEthAbi, ethers.provider); - cDai = new ethers.Contract(cDaiAddress, cDaiAbi, ethers.provider); - const tokenArtifact = await artifacts.readArtifact("@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20"); - Dai = new ethers.Contract(daiAddress, tokenArtifact.abi, ethers.provider); - comptroller = new ethers.Contract(comptrollerAddress, comptrollerAbi, ethers.provider); - - // deposit ether to Compound - await cEth.connect(owner).mint({ - value: parseEther('10') - }); - - // enter markets with deposits - const cTokens = [cEth.address]; - await comptroller.connect(owner).enterMarkets(cTokens); - - // borrow dai from Compound - await cDai.connect(owner).borrow(parseUnits('1000')); - }); - - describe('Deployment', async () => { - it('Should set correct name', async () => { - await expect(await connector.name()).to.eq('Compound-Import-v2'); - }); - }); - - describe("DSA wallet setup", async () => { - it("Should build DSA v2", async () => { - dsaWallet = await buildDSAv2(owner.address); - console.log(dsaWallet.address); - expect(!!dsaWallet.address).to.be.true; - }); - - it("Deposit ETH into DSA wallet", async function () { - await owner.sendTransaction({ - to: dsaWallet.address, - value: ethers.utils.parseEther("10") - }); - expect(await ethers.provider.getBalance(dsaWallet.address)).to.be.gte(ethers.utils.parseEther("10")); - }); - }); - - describe('Compound position migration', async () => { - it('Should migrate Compound position', async () => { - const amount = ethers.utils.parseEther("100") // 100 DAI - const setId = "83478237"; - - const flashSpells = [ - { - connector: compoundConnector, - method: "borrow", - args: ["DAI-A", amount, 0, setId] - }, - { - connector: compoundConnector, - method: "payback", - args: ["DAI-A", 0, setId, 0] - }, - { - connector: instapoolConnector, - method: 'flashPayback', - args: [Dai.address, parseUnits('1000.9'), 0, 0], - } - ] - - const spells = [ - { - connector: instapoolConnector, - method: "flashBorrowAndCast", - args: [Dai.address, parseUnits('1000'), 0, encodeFlashcastData(flashSpells), "0x"] - } - ] - console.log(owner.address); - const tx = await dsaWallet.connect(owner).cast(...encodeSpells(spells), owner.address) - const receipt = await tx.wait(); - }) - // take flash loan of dai through spell - // call contract function - // repay flash loan of dai - // check if import was successful - }) -}); - - -// deploy the connector on mainnet fork -// build a new dsa in tests - -// create a Compound position - // deposit some ether in Compound - // borrow some DAI - -// migrate the Compound position - // cast the migrate spell - -// check if migration was successful - // check the balance of DSA contract address in ERC20 tokens diff --git a/test/mainnet/compound-import/compound-import.test.ts b/test/mainnet/compound-import/compound-import.test.ts new file mode 100644 index 00000000..12b1aef4 --- /dev/null +++ b/test/mainnet/compound-import/compound-import.test.ts @@ -0,0 +1,239 @@ +import { expect, should } from "chai"; +import hre, { ethers, waffle } from "hardhat"; +import type { Signer, Contract } from "ethers"; +import { BigNumber } from "bignumber.js"; +import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"; +import { addresses } from "../../../scripts/tests/mainnet/addresses"; +import { deployAndEnableConnector, enableConnector } from "../../../scripts/tests/deployAndEnableConnector"; +import { abis } from "../../../scripts/constant/abis"; +import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; +import { parseEther, parseUnits } from "ethers/lib/utils"; +import { encodeSpells } from "../../../scripts/tests/encodeSpells"; + +import { ConnectV2CompoundImport__factory, ConnectV2InstaPoolV4__factory } from "../../../typechain"; +const { provider } = waffle; + +const encodeFlashcastData = require("../../../scripts/tests/encodeFlashcastData").default; +const cEthAddress = "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5"; +const cDaiAddress = "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643"; +const daiAddress = "0x6B175474E89094C44Da98b954EedeAC495271d0F"; +const comptrollerAddress = "0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B"; + +describe("Import Compound", function () { + const connectorName = "COMPOUND-IMPORT-C"; + const account = "0x26eD8119c45E3871df446a13F7Fdc9E2C527DaCD"; + + const cEthAbi = [ + { + constant: false, + inputs: [], + name: "mint", + outputs: [], + payable: true, + stateMutability: "payable", + type: "function", + signature: "0x1249c58b" + }, + { + constant: true, + inputs: [{ internalType: "address", name: "owner", type: "address" }], + name: "balanceOf", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: false, + inputs: [], + name: "exchangeRateCurrent", + outputs: [{ name: "", type: "uint256" }], + payable: false, + stateMutability: "nonpayable", + type: "function" + } + ]; + + const cDaiAbi = [ + { + constant: false, + inputs: [ + { + internalType: "uint256", + name: "borrowAmount", + type: "uint256" + } + ], + name: "borrow", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + payable: false, + stateMutability: "nonpayable", + type: "function", + signature: "0xc5ebeaec" + } + ]; + + const comptrollerAbi = [ + { + constant: false, + inputs: [ + { + internalType: "address[]", + name: "cTokens", + type: "address[]" + } + ], + name: "enterMarkets", + outputs: [ + { + internalType: "uint256[]", + name: "", + type: "uint256[]" + } + ], + payable: false, + stateMutability: "nonpayable", + type: "function", + signature: "0xc2998238" + } + ]; + + let connector2; + let cEth: Contract, cDai: Contract, comptroller, Dai: any; + let owner: any; + + let dsaWallet0: any; + let masterSigner: Signer; + let instaConnectorsV2: Contract; + let connector: any; + + const wallets = provider.getWallets(); + const [wallet0, wallet1, wallet2, wallet3] = wallets; + + before(async () => { + await hre.network.provider.request({ + method: "hardhat_reset", + params: [ + { + forking: { + // @ts-ignore + jsonRpcUrl: hre.config.networks.hardhat.forking.url, + blockNumber: 13300000 + } + } + ] + }); + + masterSigner = await getMasterSigner(); + instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2); + + connector = await deployAndEnableConnector({ + connectorName, + contractArtifact: ConnectV2CompoundImport__factory, + signer: masterSigner, + connectors: instaConnectorsV2 + }); + console.log("Connector address", connector.address); + + connector2 = await deployAndEnableConnector({ + connectorName: "INSTAPOOL-C", + contractArtifact: ConnectV2InstaPoolV4__factory, + signer: masterSigner, + connectors: instaConnectorsV2 + }); + console.log("Connector address", connector2.address); + + await hre.network.provider.request({ + method: "hardhat_impersonateAccount", + params: [account] + }); + + await hre.network.provider.send("hardhat_setBalance", [account, ethers.utils.parseEther("100000").toHexString()]); + + owner = await ethers.getSigner(account); + + cEth = new ethers.Contract(cEthAddress, cEthAbi); + cDai = new ethers.Contract(cDaiAddress, cDaiAbi); + Dai = new ethers.Contract(daiAddress, abis.basic.erc20); + comptroller = new ethers.Contract(comptrollerAddress, comptrollerAbi); + + // deposit ether to Compound: ETH-A + await cEth.connect(owner).mint({ + value: parseEther("9") + }); + + // enter markets with deposits + const cTokens = [cEth.address]; + await comptroller.connect(owner).enterMarkets(cTokens); + + // borrow dai from Compound: DAI-A + await cDai.connect(owner).borrow(parseUnits("100")); + }); + + describe("Deployment", async () => { + it("Should set correct name", async () => { + expect(await connector.name()).to.eq("Compound-Import-v2"); + }); + }); + + describe("checks", async () => { + it("Should check user COMPOUND position", async () => { + const ethExchangeRate = (await cEth.connect(owner).callStatic.exchangeRateCurrent()) / 1e28; + expect(new BigNumber(await cEth.connect(owner).balanceOf(owner.address)).dividedBy(1e8).toFixed(0)).to.eq( + new BigNumber(9).dividedBy(ethExchangeRate).toFixed(0) + ); + expect(await Dai.connect(owner).balanceOf(owner.address)).to.eq("100000000000000000000"); + }); + }); + + describe("DSA wallet setup", async () => { + it("Should build DSA v2", async () => { + dsaWallet0 = await buildDSAv2(owner.address); + console.log(dsaWallet0.address); + expect(!!dsaWallet0.address).to.be.true; + }); + + it("Deposit ETH into DSA wallet", async function () { + await owner.sendTransaction({ + to: dsaWallet0.address, + value: ethers.utils.parseEther("10") + }); + expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("10")); + }); + }); + + describe("Compound position migration", async () => { + it("Should migrate Compound position", async () => { + const amount = new BigNumber(ethers.utils.parseEther("100").toString()).multipliedBy(9).dividedBy(1e4); + + const flashSpells = [ + { + connector: "COMPOUND-IMPORT-C", + method: "importCompound", + args: [owner.address, ["ETH-A"], ["DAI-A"], [amount]] + }, + { + connector: "INSTAPOOL-C", + method: "flashPayback", + args: [daiAddress, amount, 0, 0] + } + ]; + + const spells = [ + { + connector: "INSTAPOOL-C", + method: "flashBorrowAndCast", + args: [daiAddress, ethers.utils.parseEther("100"), 0, encodeFlashcastData(flashSpells), "0x"] + } + ]; + const tx = await dsaWallet0.connect(owner).cast(...encodeSpells(spells), owner.address); + const receipt = await tx.wait(); + }); + }); +}); diff --git a/test/mainnet/compound-import/constants.js b/test/mainnet/compound-import/constants.js deleted file mode 100644 index 1648ec0c..00000000 --- a/test/mainnet/compound-import/constants.js +++ /dev/null @@ -1,6 +0,0 @@ -const cEthAddress = "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5"; -const cDaiAddress = "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643"; -const daiAddress = "0x6B175474E89094C44Da98b954EedeAC495271d0F"; -const comptrollerAddress = "0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B"; -module.exports = { cEthAddress, cDaiAddress, daiAddress, comptrollerAddress }; - \ No newline at end of file From 96573dc193c29e4c26b9641d4d6c93fa79d9b535 Mon Sep 17 00:00:00 2001 From: pradyuman-verma Date: Wed, 23 Mar 2022 16:21:56 +0530 Subject: [PATCH 15/20] minor fix --- test/mainnet/compound-import/compound-import.test.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/mainnet/compound-import/compound-import.test.ts b/test/mainnet/compound-import/compound-import.test.ts index 12b1aef4..3442709d 100644 --- a/test/mainnet/compound-import/compound-import.test.ts +++ b/test/mainnet/compound-import/compound-import.test.ts @@ -4,7 +4,7 @@ import type { Signer, Contract } from "ethers"; import { BigNumber } from "bignumber.js"; import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"; import { addresses } from "../../../scripts/tests/mainnet/addresses"; -import { deployAndEnableConnector, enableConnector } from "../../../scripts/tests/deployAndEnableConnector"; +import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector"; import { abis } from "../../../scripts/constant/abis"; import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; import { parseEther, parseUnits } from "ethers/lib/utils"; @@ -211,12 +211,11 @@ describe("Import Compound", function () { describe("Compound position migration", async () => { it("Should migrate Compound position", async () => { const amount = new BigNumber(ethers.utils.parseEther("100").toString()).multipliedBy(9).dividedBy(1e4); - const flashSpells = [ { connector: "COMPOUND-IMPORT-C", method: "importCompound", - args: [owner.address, ["ETH-A"], ["DAI-A"], [amount]] + args: [owner.address, ["ETH-A"], ["DAI-A"], [amount.toString()]] }, { connector: "INSTAPOOL-C", From 6a5784d067a5f0169643e7baa3af012d6a4ff40c Mon Sep 17 00:00:00 2001 From: pradyuman-verma Date: Thu, 24 Mar 2022 01:11:18 +0530 Subject: [PATCH 16/20] fixed test --- .../compound-import/compound-import.test.ts | 97 +++++++++++-------- 1 file changed, 56 insertions(+), 41 deletions(-) diff --git a/test/mainnet/compound-import/compound-import.test.ts b/test/mainnet/compound-import/compound-import.test.ts index 3442709d..10d082a8 100644 --- a/test/mainnet/compound-import/compound-import.test.ts +++ b/test/mainnet/compound-import/compound-import.test.ts @@ -9,19 +9,17 @@ import { abis } from "../../../scripts/constant/abis"; import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; import { parseEther, parseUnits } from "ethers/lib/utils"; import { encodeSpells } from "../../../scripts/tests/encodeSpells"; - -import { ConnectV2CompoundImport__factory, ConnectV2InstaPoolV4__factory } from "../../../typechain"; +import encodeFlashcastData from "../../../scripts/tests/encodeFlashcastData"; +import { ConnectV2CompoundImport__factory } from "../../../typechain"; const { provider } = waffle; -const encodeFlashcastData = require("../../../scripts/tests/encodeFlashcastData").default; const cEthAddress = "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5"; const cDaiAddress = "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643"; const daiAddress = "0x6B175474E89094C44Da98b954EedeAC495271d0F"; const comptrollerAddress = "0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B"; describe("Import Compound", function () { - const connectorName = "COMPOUND-IMPORT-C"; - const account = "0x26eD8119c45E3871df446a13F7Fdc9E2C527DaCD"; + const connectorName = "COMPOUND-IMPORT-X"; const cEthAbi = [ { @@ -51,6 +49,18 @@ describe("Import Compound", function () { payable: false, stateMutability: "nonpayable", type: "function" + }, + { + constant: false, + inputs: [ + { internalType: "address", name: "usr", type: "address" }, + { internalType: "uint256", name: "wad", type: "uint256" } + ], + name: "approve", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + payable: false, + stateMutability: "nonpayable", + type: "function" } ]; @@ -76,6 +86,15 @@ describe("Import Compound", function () { stateMutability: "nonpayable", type: "function", signature: "0xc5ebeaec" + }, + { + constant: false, + inputs: [{ internalType: "address", name: "account", type: "address" }], + name: "borrowBalanceCurrent", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + payable: false, + stateMutability: "nonpayable", + type: "function" } ]; @@ -104,9 +123,7 @@ describe("Import Compound", function () { } ]; - let connector2; let cEth: Contract, cDai: Contract, comptroller, Dai: any; - let owner: any; let dsaWallet0: any; let masterSigner: Signer; @@ -115,7 +132,13 @@ describe("Import Compound", function () { const wallets = provider.getWallets(); const [wallet0, wallet1, wallet2, wallet3] = wallets; - + let snapshot: any; + // this.beforeAll(async () => { + // snapshot = await ethers.provider.send("evm_snapshot", []); + // }); + // this.afterAll(async () => { + // snapshot = await ethers.provider.send("evm_revert", [snapshot]); + // }); before(async () => { await hre.network.provider.request({ method: "hardhat_reset", @@ -124,7 +147,7 @@ describe("Import Compound", function () { forking: { // @ts-ignore jsonRpcUrl: hre.config.networks.hardhat.forking.url, - blockNumber: 13300000 + blockNumber: 14441991 } } ] @@ -141,39 +164,22 @@ describe("Import Compound", function () { }); console.log("Connector address", connector.address); - connector2 = await deployAndEnableConnector({ - connectorName: "INSTAPOOL-C", - contractArtifact: ConnectV2InstaPoolV4__factory, - signer: masterSigner, - connectors: instaConnectorsV2 - }); - console.log("Connector address", connector2.address); - - await hre.network.provider.request({ - method: "hardhat_impersonateAccount", - params: [account] - }); - - await hre.network.provider.send("hardhat_setBalance", [account, ethers.utils.parseEther("100000").toHexString()]); - - owner = await ethers.getSigner(account); - cEth = new ethers.Contract(cEthAddress, cEthAbi); cDai = new ethers.Contract(cDaiAddress, cDaiAbi); Dai = new ethers.Contract(daiAddress, abis.basic.erc20); comptroller = new ethers.Contract(comptrollerAddress, comptrollerAbi); // deposit ether to Compound: ETH-A - await cEth.connect(owner).mint({ + await cEth.connect(wallet0).mint({ value: parseEther("9") }); // enter markets with deposits const cTokens = [cEth.address]; - await comptroller.connect(owner).enterMarkets(cTokens); + await comptroller.connect(wallet0).enterMarkets(cTokens); // borrow dai from Compound: DAI-A - await cDai.connect(owner).borrow(parseUnits("100")); + await cDai.connect(wallet0).borrow(parseUnits("100")); }); describe("Deployment", async () => { @@ -184,23 +190,22 @@ describe("Import Compound", function () { describe("checks", async () => { it("Should check user COMPOUND position", async () => { - const ethExchangeRate = (await cEth.connect(owner).callStatic.exchangeRateCurrent()) / 1e28; - expect(new BigNumber(await cEth.connect(owner).balanceOf(owner.address)).dividedBy(1e8).toFixed(0)).to.eq( + const ethExchangeRate = (await cEth.connect(wallet0).callStatic.exchangeRateCurrent()) / 1e28; + expect(new BigNumber(await cEth.connect(wallet0).balanceOf(wallet0.address)).dividedBy(1e8).toFixed(0)).to.eq( new BigNumber(9).dividedBy(ethExchangeRate).toFixed(0) ); - expect(await Dai.connect(owner).balanceOf(owner.address)).to.eq("100000000000000000000"); + expect(await Dai.connect(wallet0).balanceOf(wallet0.address)).to.eq("100000000000000000000"); }); }); describe("DSA wallet setup", async () => { it("Should build DSA v2", async () => { - dsaWallet0 = await buildDSAv2(owner.address); - console.log(dsaWallet0.address); + dsaWallet0 = await buildDSAv2(wallet0.address); expect(!!dsaWallet0.address).to.be.true; }); it("Deposit ETH into DSA wallet", async function () { - await owner.sendTransaction({ + await wallet0.sendTransaction({ to: dsaWallet0.address, value: ethers.utils.parseEther("10") }); @@ -210,17 +215,27 @@ describe("Import Compound", function () { describe("Compound position migration", async () => { it("Should migrate Compound position", async () => { - const amount = new BigNumber(ethers.utils.parseEther("100").toString()).multipliedBy(9).dividedBy(1e4); + const tx0 = await cEth + .connect(wallet0) + .approve(dsaWallet0.address, await cEth.connect(wallet0).balanceOf(wallet0.address)); + + await tx0.wait(); + + // const amount0 = await cDai.connect(wallet0).callStatic.borrowBalanceCurrent(wallet0.address); + const amount0 = new BigNumber("100000007061117456728"); + const amount = new BigNumber(amount0.toString()).multipliedBy(5).dividedBy(1e4); + + const amountWithFee = amount0.plus(amount); const flashSpells = [ { - connector: "COMPOUND-IMPORT-C", + connector: "COMPOUND-IMPORT-X", method: "importCompound", - args: [owner.address, ["ETH-A"], ["DAI-A"], [amount.toString()]] + args: [wallet0.address, ["ETH-A"], ["DAI-A"], [amount.toFixed(0)]] }, { connector: "INSTAPOOL-C", method: "flashPayback", - args: [daiAddress, amount, 0, 0] + args: [daiAddress, amountWithFee.toFixed(0), 0, 0] } ]; @@ -228,10 +243,10 @@ describe("Import Compound", function () { { connector: "INSTAPOOL-C", method: "flashBorrowAndCast", - args: [daiAddress, ethers.utils.parseEther("100"), 0, encodeFlashcastData(flashSpells), "0x"] + args: [daiAddress, amount0.toString(), 5, encodeFlashcastData(flashSpells), "0x"] } ]; - const tx = await dsaWallet0.connect(owner).cast(...encodeSpells(spells), owner.address); + const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet0.address); const receipt = await tx.wait(); }); }); From c07b4676f5c3d1500b160abe8e049bf68123c2ed Mon Sep 17 00:00:00 2001 From: pradyuman-verma Date: Thu, 24 Mar 2022 01:12:02 +0530 Subject: [PATCH 17/20] added instapool-c abis --- .../constant/abi/connectors/instapool-c.json | 114 ++++++++++++++++++ scripts/constant/abis.ts | 7 +- 2 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 scripts/constant/abi/connectors/instapool-c.json diff --git a/scripts/constant/abi/connectors/instapool-c.json b/scripts/constant/abi/connectors/instapool-c.json new file mode 100644 index 00000000..8102f825 --- /dev/null +++ b/scripts/constant/abi/connectors/instapool-c.json @@ -0,0 +1,114 @@ +[ + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "token", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "tokenAmt", "type": "uint256" } + ], + "name": "LogFlashBorrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address[]", "name": "token", "type": "address[]" }, + { "indexed": false, "internalType": "uint256[]", "name": "tokenAmts", "type": "uint256[]" } + ], + "name": "LogFlashMultiBorrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address[]", "name": "token", "type": "address[]" }, + { "indexed": false, "internalType": "uint256[]", "name": "tokenAmts", "type": "uint256[]" } + ], + "name": "LogFlashMultiPayback", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "token", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "tokenAmt", "type": "uint256" } + ], + "name": "LogFlashPayback", + "type": "event" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "amt", "type": "uint256" }, + { "internalType": "uint256", "name": "route", "type": "uint256" }, + { "internalType": "bytes", "name": "data", "type": "bytes" }, + { "internalType": "bytes", "name": "extraData", "type": "bytes" } + ], + "name": "flashBorrowAndCast", + "outputs": [ + { "internalType": "string", "name": "_eventName", "type": "string" }, + { "internalType": "bytes", "name": "_eventParam", "type": "bytes" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address[]", "name": "tokens_", "type": "address[]" }, + { "internalType": "uint256[]", "name": "amts_", "type": "uint256[]" }, + { "internalType": "uint256", "name": "route", "type": "uint256" }, + { "internalType": "bytes", "name": "data", "type": "bytes" }, + { "internalType": "bytes", "name": "extraData", "type": "bytes" } + ], + "name": "flashMultiBorrowAndCast", + "outputs": [ + { "internalType": "string", "name": "_eventName", "type": "string" }, + { "internalType": "bytes", "name": "_eventParam", "type": "bytes" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address[]", "name": "tokens_", "type": "address[]" }, + { "internalType": "uint256[]", "name": "amts_", "type": "uint256[]" }, + { "internalType": "uint256[]", "name": "getIds", "type": "uint256[]" }, + { "internalType": "uint256[]", "name": "setIds", "type": "uint256[]" } + ], + "name": "flashMultiPayback", + "outputs": [ + { "internalType": "string", "name": "_eventName", "type": "string" }, + { "internalType": "bytes", "name": "_eventParam", "type": "bytes" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "amt", "type": "uint256" }, + { "internalType": "uint256", "name": "getId", "type": "uint256" }, + { "internalType": "uint256", "name": "setId", "type": "uint256" } + ], + "name": "flashPayback", + "outputs": [ + { "internalType": "string", "name": "_eventName", "type": "string" }, + { "internalType": "bytes", "name": "_eventParam", "type": "bytes" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "instaPool", + "outputs": [{ "internalType": "contract InstaFlashV4Interface", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + } +] diff --git a/scripts/constant/abis.ts b/scripts/constant/abis.ts index 43097ba5..c2a70702 100644 --- a/scripts/constant/abis.ts +++ b/scripts/constant/abis.ts @@ -1,15 +1,16 @@ export const abis: Record = { core: { connectorsV2: require("./abi/core/connectorsV2.json"), - instaIndex: require("./abi/core/instaIndex.json"), + instaIndex: require("./abi/core/instaIndex.json") }, connectors: { "Basic-v1": require("./abi/connectors/basic.json"), basic: require("./abi/connectors/basic.json"), auth: require("./abi/connectors/auth.json"), "INSTAPOOL-A": require("./abi/connectors/instapool.json"), + "INSTAPOOL-C": require("./abi/connectors/instapool-c.json") }, basic: { - erc20: require("./abi/basics/erc20.json"), - }, + erc20: require("./abi/basics/erc20.json") + } }; From c54976945413ee59363ef4b353cc6270f90517da Mon Sep 17 00:00:00 2001 From: pradyuman-verma Date: Thu, 24 Mar 2022 01:13:10 +0530 Subject: [PATCH 18/20] minor fixes --- test/mainnet/compound-import/compound-import.test.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/test/mainnet/compound-import/compound-import.test.ts b/test/mainnet/compound-import/compound-import.test.ts index 10d082a8..3646de7a 100644 --- a/test/mainnet/compound-import/compound-import.test.ts +++ b/test/mainnet/compound-import/compound-import.test.ts @@ -132,13 +132,7 @@ describe("Import Compound", function () { const wallets = provider.getWallets(); const [wallet0, wallet1, wallet2, wallet3] = wallets; - let snapshot: any; - // this.beforeAll(async () => { - // snapshot = await ethers.provider.send("evm_snapshot", []); - // }); - // this.afterAll(async () => { - // snapshot = await ethers.provider.send("evm_revert", [snapshot]); - // }); + before(async () => { await hre.network.provider.request({ method: "hardhat_reset", From c704a26ef2385d4b102351a9f09df8495892453d Mon Sep 17 00:00:00 2001 From: pradyuman-verma Date: Thu, 24 Mar 2022 01:28:11 +0530 Subject: [PATCH 19/20] added comments --- contracts/mainnet/connectors/compound-import/main.sol | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contracts/mainnet/connectors/compound-import/main.sol b/contracts/mainnet/connectors/compound-import/main.sol index 62923ec5..9ae13f30 100644 --- a/contracts/mainnet/connectors/compound-import/main.sol +++ b/contracts/mainnet/connectors/compound-import/main.sol @@ -2,15 +2,15 @@ pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; +/** + * @title Compound-Import. + * @dev Lending & Borrowing. + */ + import { TokenInterface, AccountInterface } from "../../common/interfaces.sol"; import { CompoundHelper } from "./helpers.sol"; import { Events } from "./events.sol"; -// 1. Get info for all the assets the user has supplied as collateral and the assets he borrowed. -// 2. Using the flash loan funds, pay back the user's debt in the EOA account. -// 3. After paying the debt, transfer the user's tokens from EOA to DSA. -// 4. Then borrow debt of same tokens but include flash loan fee in it. - contract CompoundImportResolver is CompoundHelper { /** * @notice this function performs the import of user's Compound positions into its DSA From fe81e264281acb7a4da886abd338c11a4b2c172a Mon Sep 17 00:00:00 2001 From: pradyuman-verma Date: Thu, 24 Mar 2022 01:46:39 +0530 Subject: [PATCH 20/20] added DSA compound check --- test/mainnet/compound-import/compound-import.test.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/mainnet/compound-import/compound-import.test.ts b/test/mainnet/compound-import/compound-import.test.ts index 3646de7a..fb4585f5 100644 --- a/test/mainnet/compound-import/compound-import.test.ts +++ b/test/mainnet/compound-import/compound-import.test.ts @@ -243,5 +243,12 @@ describe("Import Compound", function () { const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet0.address); const receipt = await tx.wait(); }); + + it("Should check DSA COMPOUND position", async () => { + const ethExchangeRate = (await cEth.connect(wallet0).callStatic.exchangeRateCurrent()) / 1e28; + expect(new BigNumber(await cEth.connect(wallet0).balanceOf(dsaWallet0.address)).dividedBy(1e8).toFixed(0)).to.eq( + new BigNumber(9).dividedBy(ethExchangeRate).toFixed(0) + ); + }); }); });