From 303b73d2154796901192a90b17a95d02a518f2ba Mon Sep 17 00:00:00 2001 From: Geoffrey Hayes Date: Fri, 3 Apr 2020 14:42:10 -0700 Subject: [PATCH] Add Comp and Gov to Compund Lens This patch adds to the `CompoundLens` and begins to build functions to read data for Comp and Gov. We add scenarios and tests for the Lens as well to verify its view of the data. The new Lens has been deployed to all test-nets. --- contracts/Lens/CompoundLens.sol | 122 +++ contracts/SimplePriceOracle.sol | 10 +- networks/goerli-abi.json | 658 +++++++++++++- networks/goerli.json | 12 +- networks/kovan-abi.json | 1135 ++++++++++++++----------- networks/kovan.json | 10 +- networks/mainnet-abi.json | 656 ++++++++++++++ networks/mainnet.json | 10 +- networks/rinkeby-abi.json | 656 ++++++++++++++ networks/rinkeby.json | 10 +- networks/ropsten-abi.json | 656 ++++++++++++++ networks/ropsten.json | 10 +- package.json | 4 +- scenario/src/Contract/CompoundLens.ts | 18 + scenario/src/Contract/builder.js | 63 ++ scenario/src/CoreEvent.ts | 2 + scenario/src/CoreValue.ts | 3 +- scenario/src/EventBuilder.ts | 19 +- tests/Lens/CompoundLensTest.js | 346 ++++++++ tests/Utils/Compound.js | 2 +- 20 files changed, 3905 insertions(+), 497 deletions(-) create mode 100644 scenario/src/Contract/CompoundLens.ts create mode 100644 scenario/src/Contract/builder.js create mode 100644 tests/Lens/CompoundLensTest.js diff --git a/contracts/Lens/CompoundLens.sol b/contracts/Lens/CompoundLens.sol index 6cbf03ca0..d09a781e1 100644 --- a/contracts/Lens/CompoundLens.sol +++ b/contracts/Lens/CompoundLens.sol @@ -5,6 +5,8 @@ import "../CErc20.sol"; import "../CToken.sol"; import "../Comptroller.sol"; import "../EIP20Interface.sol"; +import "../Governance/GovernorAlpha.sol"; +import "../Governance/Comp.sol"; contract CompoundLens { struct CTokenMetadata { @@ -153,6 +155,126 @@ contract CompoundLens { }); } + struct GovReceipt { + uint proposalId; + bool hasVoted; + bool support; + uint96 votes; + } + + function getGovReceipts(GovernorAlpha governor, address voter, uint[] memory proposalIds) public view returns (GovReceipt[] memory) { + uint proposalCount = proposalIds.length; + GovReceipt[] memory res = new GovReceipt[](proposalCount); + for (uint i = 0; i < proposalCount; i++) { + GovernorAlpha.Receipt memory receipt = governor.getReceipt(proposalIds[i], voter); + res[i] = GovReceipt({ + proposalId: proposalIds[i], + hasVoted: receipt.hasVoted, + support: receipt.support, + votes: receipt.votes + }); + } + return res; + } + + struct GovProposal { + uint proposalId; + address proposer; + uint eta; + address[] targets; + uint[] values; + string[] signatures; + bytes[] calldatas; + uint startBlock; + uint endBlock; + uint forVotes; + uint againstVotes; + bool canceled; + bool executed; + } + + function setProposal(GovProposal memory res, GovernorAlpha governor, uint proposalId) internal view { + ( + , + address proposer, + uint eta, + uint startBlock, + uint endBlock, + uint forVotes, + uint againstVotes, + bool canceled, + bool executed + ) = governor.proposals(proposalId); + res.proposalId = proposalId; + res.proposer = proposer; + res.eta = eta; + res.startBlock = startBlock; + res.endBlock = endBlock; + res.forVotes = forVotes; + res.againstVotes = againstVotes; + res.canceled = canceled; + res.executed = executed; + } + + function getGovProposals(GovernorAlpha governor, uint[] calldata proposalIds) external view returns (GovProposal[] memory) { + GovProposal[] memory res = new GovProposal[](proposalIds.length); + for (uint i = 0; i < proposalIds.length; i++) { + ( + address[] memory targets, + uint[] memory values, + string[] memory signatures, + bytes[] memory calldatas + ) = governor.getActions(proposalIds[i]); + res[i] = GovProposal({ + proposalId: 0, + proposer: address(0), + eta: 0, + targets: targets, + values: values, + signatures: signatures, + calldatas: calldatas, + startBlock: 0, + endBlock: 0, + forVotes: 0, + againstVotes: 0, + canceled: false, + executed: false + }); + setProposal(res[i], governor, proposalIds[i]); + } + return res; + } + + struct CompBalanceMetadata { + uint balance; + uint votes; + address delegate; + } + + function getCompBalanceMetadata(Comp comp, address account) external view returns (CompBalanceMetadata memory) { + return CompBalanceMetadata({ + balance: comp.balanceOf(account), + votes: uint256(comp.getCurrentVotes(account)), + delegate: comp.delegates(account) + }); + } + + struct CompVotes { + uint blockNumber; + uint votes; + } + + function getCompVotes(Comp comp, address account, uint32[] calldata blockNumbers) external view returns (CompVotes[] memory) { + CompVotes[] memory res = new CompVotes[](blockNumbers.length); + for (uint i = 0; i < blockNumbers.length; i++) { + res[i] = CompVotes({ + blockNumber: uint256(blockNumbers[i]), + votes: uint256(comp.getPriorVotes(account, blockNumbers[i])) + }); + } + return res; + } + function compareStrings(string memory a, string memory b) internal pure returns (bool) { return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b)))); } diff --git a/contracts/SimplePriceOracle.sol b/contracts/SimplePriceOracle.sol index 3843165a7..ea16be13f 100644 --- a/contracts/SimplePriceOracle.sol +++ b/contracts/SimplePriceOracle.sol @@ -10,7 +10,11 @@ contract SimplePriceOracle is PriceOracle { function getUnderlyingPrice(CToken cToken) public view returns (uint) { - return prices[address(CErc20(address(cToken)).underlying())]; + if (compareStrings(cToken.symbol(), "cETH")) { + return 1e18; + } else { + return prices[address(CErc20(address(cToken)).underlying())]; + } } function setUnderlyingPrice(CToken cToken, uint underlyingPriceMantissa) public { @@ -28,4 +32,8 @@ contract SimplePriceOracle is PriceOracle { function assetPrices(address asset) external view returns (uint) { return prices[asset]; } + + function compareStrings(string memory a, string memory b) internal pure returns (bool) { + return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b)))); + } } diff --git a/networks/goerli-abi.json b/networks/goerli-abi.json index 4d1913741..7d3ee4089 100644 --- a/networks/goerli-abi.json +++ b/networks/goerli-abi.json @@ -4583,6 +4583,662 @@ "signature": "0x6f307dc3" } ], + "CompoundLens": [ + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address payable", + "name": "account", + "type": "address" + } + ], + "name": "cTokenBalances", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balanceOf", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowBalanceCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceOfUnderlying", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAllowance", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenBalances", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xbdf950c9" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + }, + { + "internalType": "address payable", + "name": "account", + "type": "address" + } + ], + "name": "cTokenBalancesAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balanceOf", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowBalanceCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceOfUnderlying", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAllowance", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenBalances[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x0972bf8b" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + } + ], + "name": "cTokenMetadata", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "exchangeRateCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactorMantissa", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalReserves", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalCash", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + }, + { + "internalType": "address", + "name": "underlyingAssetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "cTokenDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingDecimals", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenMetadata", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x158eca8b" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + } + ], + "name": "cTokenMetadataAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "exchangeRateCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactorMantissa", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalReserves", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalCash", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + }, + { + "internalType": "address", + "name": "underlyingAssetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "cTokenDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingDecimals", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenMetadata[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x4b70d84b" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + } + ], + "name": "cTokenUnderlyingPrice", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenUnderlyingPrice", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xc5ae5934" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + } + ], + "name": "cTokenUnderlyingPriceAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenUnderlyingPrice[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x2b2d5ed6" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract Comptroller", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getAccountLimits", + "outputs": [ + { + "components": [ + { + "internalType": "contract CToken[]", + "name": "markets", + "type": "address[]" + }, + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "shortfall", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.AccountLimits", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x7dd8f6d9" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract Comp", + "name": "comp", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getCompBalanceMetadata", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votes", + "type": "uint256" + }, + { + "internalType": "address", + "name": "delegate", + "type": "address" + } + ], + "internalType": "struct CompoundLens.CompBalanceMetadata", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x416405d7" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract Comp", + "name": "comp", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint32[]", + "name": "blockNumbers", + "type": "uint32[]" + } + ], + "name": "getCompVotes", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votes", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CompVotes[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x59564219" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract GovernorAlpha", + "name": "governor", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "proposalIds", + "type": "uint256[]" + } + ], + "name": "getGovProposals", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "proposalId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "eta", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "targets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "string[]", + "name": "signatures", + "type": "string[]" + }, + { + "internalType": "bytes[]", + "name": "calldatas", + "type": "bytes[]" + }, + { + "internalType": "uint256", + "name": "startBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "forVotes", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "againstVotes", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "canceled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "executed", + "type": "bool" + } + ], + "internalType": "struct CompoundLens.GovProposal[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x96994869" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract GovernorAlpha", + "name": "governor", + "type": "address" + }, + { + "internalType": "address", + "name": "voter", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "proposalIds", + "type": "uint256[]" + } + ], + "name": "getGovReceipts", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "proposalId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "hasVoted", + "type": "bool" + }, + { + "internalType": "bool", + "name": "support", + "type": "bool" + }, + { + "internalType": "uint96", + "name": "votes", + "type": "uint96" + } + ], + "internalType": "struct CompoundLens.GovReceipt[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x995ed99f" + } + ], "DAI": [ { "inputs": [ @@ -24766,4 +25422,4 @@ "signature": "0x23b872dd" } ] -} +} \ No newline at end of file diff --git a/networks/goerli.json b/networks/goerli.json index 4392e426f..1e708c628 100644 --- a/networks/goerli.json +++ b/networks/goerli.json @@ -8,6 +8,7 @@ "CNT1": "0x5E5bB47a4F5c14115f39Ce9207720fD730939c19", "GovernorAlphaHarness": "0x25E105E4f8B0039dbBEAc3BC5a362C1e06F43D8a", "cDAI": "0x822397d9a55d0fefd20F5c4bCaB33C5F65bd28Eb", + "CompoundLens": "0xE6F46170535FAE86BDbF0Cb033595e060cD99333", "DAI": "0xdc31Ee1784292379Fbb2964b3B9C4124D8F89C60", "StdComptroller": "0x95aACAf2342dcF58C08d221404f370c4b1BBD6E6", "Unitroller": "0x627EA49279FD0dE89186A58b8758aD02B6Be2867", @@ -30,8 +31,7 @@ "REP": "0x183Faf58c4461972765f3F90c6272A4ecE66Bd96", "cZRX": "0xA253295eC2157B8b69C44b2cb35360016DAa25b1", "cWBTC": "0x6CE27497A64fFFb5517AA4aeE908b1E7EB63B9fF", - "USDC": "0xD87Ba7A50B2E7E660f678A895E4B72E7CB4CCd9C", - "CompoundLens": "0x05752E558f7141C4b098D9b9B212F4Ea5aff0A3c" + "USDC": "0xD87Ba7A50B2E7E660f678A895E4B72E7CB4CCd9C" }, "Blocks": { "ZRX": 1971943, @@ -42,6 +42,7 @@ "CNT1": 2001121, "GovernorAlphaHarness": 2052861, "cDAI": 1972015, + "CompoundLens": 2520826, "DAI": 1971947, "StdComptroller": 1971931, "Unitroller": 1971914, @@ -82,6 +83,10 @@ "cEtherAddress": "0x20572e4c090f15667cF7378e16FaD2eA0e2f3EfF", "address": "0x73d3F01b8aC5063f4601C7C45DA5Fdf1b5240C92" }, + "CompoundLens": { + "name": "CompoundLens", + "contract": "CompoundLens" + }, "Unitroller": { "description": "Unitroller", "address": "0x627EA49279FD0dE89186A58b8758aD02B6Be2867" @@ -126,6 +131,7 @@ "CNT1": "0x", "GovernorAlphaHarness": "0x00000000000000000000000025e46957363e16c4e2d5f2854b062475f9f8d287000000000000000000000000e16c7165c8fea64069802ae4c4c9c320783f2b6e000000000000000000000000513c1ff435eccedd0fda5edd2ad5e5461f0e8726", "cDAI": "0x000000000000000000000000dc31ee1784292379fbb2964b3b9c4124d8f89c60000000000000000000000000627ea49279fd0de89186a58b8758ad02b6be28670000000000000000000000004c0f5b2f3739de27874e200cfbc482a9086066ce000000000000000000000000000000000000000000a56fa5b99019a5c8000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000008000000000000000000000000513c1ff435eccedd0fda5edd2ad5e5461f0e8726000000000000000000000000b40d042a65dd413ae0fd85becf8d722e16bc46f100000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000021436f6d706f756e64204d756c7469436f6c6c61746572616c2044414920f09f9388000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004634441490000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000", + "CompoundLens": "0x", "DAI": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003446169000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034441490000000000000000000000000000000000000000000000000000000000", "StdComptroller": "0x", "Unitroller": "0x", @@ -423,4 +429,4 @@ "address": "0x1E83FD76621da78266955C473CD8559D5FA1c34c" } } -} +} \ No newline at end of file diff --git a/networks/kovan-abi.json b/networks/kovan-abi.json index 1e6540dc3..6f426e527 100644 --- a/networks/kovan-abi.json +++ b/networks/kovan-abi.json @@ -3779,6 +3779,662 @@ "signature": "0x6f307dc3" } ], + "CompoundLens": [ + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address payable", + "name": "account", + "type": "address" + } + ], + "name": "cTokenBalances", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balanceOf", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowBalanceCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceOfUnderlying", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAllowance", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenBalances", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xbdf950c9" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + }, + { + "internalType": "address payable", + "name": "account", + "type": "address" + } + ], + "name": "cTokenBalancesAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balanceOf", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowBalanceCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceOfUnderlying", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAllowance", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenBalances[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x0972bf8b" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + } + ], + "name": "cTokenMetadata", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "exchangeRateCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactorMantissa", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalReserves", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalCash", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + }, + { + "internalType": "address", + "name": "underlyingAssetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "cTokenDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingDecimals", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenMetadata", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x158eca8b" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + } + ], + "name": "cTokenMetadataAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "exchangeRateCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactorMantissa", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalReserves", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalCash", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + }, + { + "internalType": "address", + "name": "underlyingAssetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "cTokenDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingDecimals", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenMetadata[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x4b70d84b" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + } + ], + "name": "cTokenUnderlyingPrice", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenUnderlyingPrice", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xc5ae5934" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + } + ], + "name": "cTokenUnderlyingPriceAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenUnderlyingPrice[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x2b2d5ed6" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract Comptroller", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getAccountLimits", + "outputs": [ + { + "components": [ + { + "internalType": "contract CToken[]", + "name": "markets", + "type": "address[]" + }, + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "shortfall", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.AccountLimits", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x7dd8f6d9" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract Comp", + "name": "comp", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getCompBalanceMetadata", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votes", + "type": "uint256" + }, + { + "internalType": "address", + "name": "delegate", + "type": "address" + } + ], + "internalType": "struct CompoundLens.CompBalanceMetadata", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x416405d7" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract Comp", + "name": "comp", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint32[]", + "name": "blockNumbers", + "type": "uint32[]" + } + ], + "name": "getCompVotes", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votes", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CompVotes[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x59564219" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract GovernorAlpha", + "name": "governor", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "proposalIds", + "type": "uint256[]" + } + ], + "name": "getGovProposals", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "proposalId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "eta", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "targets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "string[]", + "name": "signatures", + "type": "string[]" + }, + { + "internalType": "bytes[]", + "name": "calldatas", + "type": "bytes[]" + }, + { + "internalType": "uint256", + "name": "startBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "forVotes", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "againstVotes", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "canceled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "executed", + "type": "bool" + } + ], + "internalType": "struct CompoundLens.GovProposal[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x96994869" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract GovernorAlpha", + "name": "governor", + "type": "address" + }, + { + "internalType": "address", + "name": "voter", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "proposalIds", + "type": "uint256[]" + } + ], + "name": "getGovReceipts", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "proposalId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "hasVoted", + "type": "bool" + }, + { + "internalType": "bool", + "name": "support", + "type": "bool" + }, + { + "internalType": "uint96", + "name": "votes", + "type": "uint96" + } + ], + "internalType": "struct CompoundLens.GovReceipt[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x995ed99f" + } + ], "DAI": [ { "anonymous": false, @@ -25317,484 +25973,5 @@ "type": "function", "signature": "0x6e71e2d8" } - ], - "Timelock": [ - { - "inputs": [ - { - "internalType": "address", - "name": "admin_", - "type": "address" - }, - { - "internalType": "uint256", - "name": "delay_", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor", - "signature": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "txHash", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "string", - "name": "signature", - "type": "string" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "data", - "type": "bytes" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "eta", - "type": "uint256" - } - ], - "name": "CancelTransaction", - "type": "event", - "signature": "0x2fffc091a501fd91bfbff27141450d3acb40fb8e6d8382b243ec7a812a3aaf87" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "txHash", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "string", - "name": "signature", - "type": "string" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "data", - "type": "bytes" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "eta", - "type": "uint256" - } - ], - "name": "ExecuteTransaction", - "type": "event", - "signature": "0xa560e3198060a2f10670c1ec5b403077ea6ae93ca8de1c32b451dc1a943cd6e7" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "NewAdmin", - "type": "event", - "signature": "0x71614071b88dee5e0b2ae578a9dd7b2ebbe9ae832ba419dc0242cd065a290b6c" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "newDelay", - "type": "uint256" - } - ], - "name": "NewDelay", - "type": "event", - "signature": "0x948b1f6a42ee138b7e34058ba85a37f716d55ff25ff05a763f15bed6a04c8d2c" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "newPendingAdmin", - "type": "address" - } - ], - "name": "NewPendingAdmin", - "type": "event", - "signature": "0x69d78e38a01985fbb1462961809b4b2d65531bc93b2b94037f3334b82ca4a756" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "txHash", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "string", - "name": "signature", - "type": "string" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "data", - "type": "bytes" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "eta", - "type": "uint256" - } - ], - "name": "QueueTransaction", - "type": "event", - "signature": "0x76e2796dc3a81d57b0e8504b647febcbeeb5f4af818e164f11eef8131a6a763f" - }, - { - "payable": true, - "stateMutability": "payable", - "type": "fallback" - }, - { - "constant": true, - "inputs": [], - "name": "GRACE_PERIOD", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xc1a287e2" - }, - { - "constant": true, - "inputs": [], - "name": "MAXIMUM_DELAY", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x7d645fab" - }, - { - "constant": true, - "inputs": [], - "name": "MINIMUM_DELAY", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xb1b43ae5" - }, - { - "constant": false, - "inputs": [], - "name": "acceptAdmin", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x0e18b681" - }, - { - "constant": true, - "inputs": [], - "name": "admin", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xf851a440" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "string", - "name": "signature", - "type": "string" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "eta", - "type": "uint256" - } - ], - "name": "cancelTransaction", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x591fcdfe" - }, - { - "constant": true, - "inputs": [], - "name": "delay", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x6a42b8f8" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "string", - "name": "signature", - "type": "string" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "eta", - "type": "uint256" - } - ], - "name": "executeTransaction", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "payable": true, - "stateMutability": "payable", - "type": "function", - "signature": "0x0825f38f" - }, - { - "constant": true, - "inputs": [], - "name": "pendingAdmin", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0x26782247" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "string", - "name": "signature", - "type": "string" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "eta", - "type": "uint256" - } - ], - "name": "queueTransaction", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x3a66f901" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "name": "queuedTransactions", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "signature": "0xf2b06537" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint256", - "name": "delay_", - "type": "uint256" - } - ], - "name": "setDelay", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0xe177246e" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "pendingAdmin_", - "type": "address" - } - ], - "name": "setPendingAdmin", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "signature": "0x4dd18bf5" - } ] } \ No newline at end of file diff --git a/networks/kovan.json b/networks/kovan.json index 2d06cdfdb..456cee715 100644 --- a/networks/kovan.json +++ b/networks/kovan.json @@ -6,6 +6,7 @@ "PriceOracleProxy": "0x6998ED7daf969Ea0950E01071aCeeEe54CCCbab5", "Maximillion": "0x9A86176971440e442c1B2cE7859a77ED3efcd3f9", "cDAI": "0xe7bc397DBd069fC7d0109C0636d06888bb50668c", + "CompoundLens": "0xbdc41c586352f16310938BDe650042c89c01f72B", "DAI": "0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa", "StdComptroller": "0x3Afec0b1Ec510E59A757133059039828640839c7", "Unitroller": "0x1f5D7F3CaAC149fE41b8bd62A3673FE6eC0AB73b", @@ -29,8 +30,7 @@ "cZRX": "0xC014DC10A57aC78350C5fddB26Bb66f1Cb0960a0", "cWBTC": "0x3659728876EfB2780f498Ce829C5b076e496E0e3", "USDC": "0x75B0622Cec14130172EaE9Cf166B92E5C112FaFF", - "Base200bps_Slope222bps_Kink90_Jump10": "0xE057EF4be5c6C712e13E24d4408f5F257fEd4d3f", - "CompoundLens": "0x6F4853929e4C30Fcd357f36d8d1aa9b5fAC82185" + "Base200bps_Slope222bps_Kink90_Jump10": "0xE057EF4be5c6C712e13E24d4408f5F257fEd4d3f" }, "Blocks": { "ZRX": 14981231, @@ -39,6 +39,7 @@ "PriceOracleProxy": 14981272, "Maximillion": 14981247, "cDAI": 14981244, + "CompoundLens": 17909953, "StdComptroller": 14981224, "Unitroller": 14981220, "cDaiDelegate": 15520312, @@ -78,6 +79,10 @@ "cEtherAddress": "0xf92FbE0D3C0dcDAE407923b2Ac17eC223b1084E4", "address": "0x9A86176971440e442c1B2cE7859a77ED3efcd3f9" }, + "CompoundLens": { + "name": "CompoundLens", + "contract": "CompoundLens" + }, "Unitroller": { "description": "Unitroller", "address": "0x1f5D7F3CaAC149fE41b8bd62A3673FE6eC0AB73b" @@ -106,6 +111,7 @@ "PriceOracleProxy": "0x0000000000000000000000001f5d7f3caac149fe41b8bd62a3673fe6ec0ab73b0000000000000000000000007a1289ae33674031e0f29c558652e4396ab76072000000000000000000000000f92fbe0d3c0dcdae407923b2ac17ec223b1084e4000000000000000000000000cfc9bb230f00bffdb560fce2428b4e05f3442e3500000000000000000000000063c344bf8651222346dd870be254d4347c9359f7000000000000000000000000e7bc397dbd069fc7d0109c0636d06888bb50668c", "Maximillion": "0x000000000000000000000000f92fbe0d3c0dcdae407923b2ac17ec223b1084e4", "cDAI": "0x0000000000000000000000004f96fe3b7a6cf9725f59d353f723c1bdb64ca6aa0000000000000000000000001f5d7f3caac149fe41b8bd62a3673fe6ec0ab73b000000000000000000000000e057ef4be5c6c712e13e24d4408f5f257fed4d3f000000000000000000000000000000000000000000a56fa5b99019a5c8000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000008000000000000000000000000a776184fd6f545dae5f51361dbcc9018549a974900000000000000000000000064dae45c5bbdb89c6091b69ea82705cd16a85ea700000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000021436f6d706f756e64204d756c7469436f6c6c61746572616c2044414920f09f9388000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004634441490000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000", + "CompoundLens": "0x", "StdComptroller": "0x", "Unitroller": "0x", "cDaiDelegate": "0x", diff --git a/networks/mainnet-abi.json b/networks/mainnet-abi.json index 3d1613c17..a7486b607 100644 --- a/networks/mainnet-abi.json +++ b/networks/mainnet-abi.json @@ -4524,6 +4524,662 @@ "signature": "0x6f307dc3" } ], + "CompoundLens": [ + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address payable", + "name": "account", + "type": "address" + } + ], + "name": "cTokenBalances", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balanceOf", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowBalanceCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceOfUnderlying", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAllowance", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenBalances", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xbdf950c9" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + }, + { + "internalType": "address payable", + "name": "account", + "type": "address" + } + ], + "name": "cTokenBalancesAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balanceOf", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowBalanceCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceOfUnderlying", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAllowance", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenBalances[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x0972bf8b" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + } + ], + "name": "cTokenMetadata", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "exchangeRateCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactorMantissa", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalReserves", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalCash", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + }, + { + "internalType": "address", + "name": "underlyingAssetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "cTokenDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingDecimals", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenMetadata", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x158eca8b" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + } + ], + "name": "cTokenMetadataAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "exchangeRateCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactorMantissa", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalReserves", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalCash", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + }, + { + "internalType": "address", + "name": "underlyingAssetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "cTokenDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingDecimals", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenMetadata[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x4b70d84b" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + } + ], + "name": "cTokenUnderlyingPrice", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenUnderlyingPrice", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xc5ae5934" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + } + ], + "name": "cTokenUnderlyingPriceAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenUnderlyingPrice[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x2b2d5ed6" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract Comptroller", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getAccountLimits", + "outputs": [ + { + "components": [ + { + "internalType": "contract CToken[]", + "name": "markets", + "type": "address[]" + }, + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "shortfall", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.AccountLimits", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x7dd8f6d9" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract Comp", + "name": "comp", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getCompBalanceMetadata", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votes", + "type": "uint256" + }, + { + "internalType": "address", + "name": "delegate", + "type": "address" + } + ], + "internalType": "struct CompoundLens.CompBalanceMetadata", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x416405d7" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract Comp", + "name": "comp", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint32[]", + "name": "blockNumbers", + "type": "uint32[]" + } + ], + "name": "getCompVotes", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votes", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CompVotes[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x59564219" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract GovernorAlpha", + "name": "governor", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "proposalIds", + "type": "uint256[]" + } + ], + "name": "getGovProposals", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "proposalId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "eta", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "targets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "string[]", + "name": "signatures", + "type": "string[]" + }, + { + "internalType": "bytes[]", + "name": "calldatas", + "type": "bytes[]" + }, + { + "internalType": "uint256", + "name": "startBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "forVotes", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "againstVotes", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "canceled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "executed", + "type": "bool" + } + ], + "internalType": "struct CompoundLens.GovProposal[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x96994869" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract GovernorAlpha", + "name": "governor", + "type": "address" + }, + { + "internalType": "address", + "name": "voter", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "proposalIds", + "type": "uint256[]" + } + ], + "name": "getGovReceipts", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "proposalId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "hasVoted", + "type": "bool" + }, + { + "internalType": "bool", + "name": "support", + "type": "bool" + }, + { + "internalType": "uint96", + "name": "votes", + "type": "uint96" + } + ], + "internalType": "struct CompoundLens.GovReceipt[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x995ed99f" + } + ], "DAI": [ { "anonymous": false, diff --git a/networks/mainnet.json b/networks/mainnet.json index 26a18c2dc..6e8f3f7e7 100644 --- a/networks/mainnet.json +++ b/networks/mainnet.json @@ -7,6 +7,7 @@ "Maximillion": "0xf859A1AD94BcF445A406B892eF0d3082f4174088", "GovernorAlpha": "0xc0dA01a04C3f3E0be433606045bB7017A7323E38", "cDAI": "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643", + "CompoundLens": "0x1Af3De636BB341165F6C4E6aD17A1C09154c8670", "DAI": "0x6B175474E89094C44Da98b954EedeAC495271d0F", "StdComptroller": "0x62F18C451af964197341d3c86D27e98C41BB8fcC", "Poster": "0x3c6809319201b978d821190ba03fa19a3523bd96", @@ -36,8 +37,7 @@ "REP": "0x1985365e9f78359a9B6AD760e32412f4a445E862", "cZRX": "0xB3319f5D18Bc0D84dD1b4825Dcde5d5f7266d407", "cWBTC": "0xC11b1268C1A384e55C48c2391d8d480264A3A7F4", - "USDC": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", - "CompoundLens": "0xBaaD2b744336D6E4E67Fae2e071C3005b8C17102" + "USDC": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" }, "Blocks": { "cUSDC": 7710760, @@ -46,6 +46,7 @@ "Maximillion": 7710775, "GovernorAlpha": 9601447, "cDAI": 8983575, + "CompoundLens": 9833393, "StdComptroller": 7710672, "Unitroller": 7710671, "cDaiDelegate": 9122579, @@ -80,6 +81,10 @@ "cEtherAddress": "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5", "address": "0xf859A1AD94BcF445A406B892eF0d3082f4174088" }, + "CompoundLens": { + "name": "CompoundLens", + "contract": "CompoundLens" + }, "Unitroller": { "description": "Unitroller", "address": "0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B" @@ -140,6 +145,7 @@ "Maximillion": "0x0000000000000000000000004ddc2d193948926d02f9b1fe9e1daa0718270ed5", "GovernorAlpha": "0x0000000000000000000000006d903f6003cca6255d85cca4d3b5e5146dc33925000000000000000000000000c00e94cb662c3520282e6f5717214004a7f268880000000000000000000000008b8592e9570e96166336603a1b4bd1e8db20fa20", "cDAI": "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000003d9819210a31b4961b30ef54be2aed79b9c9cd3b0000000000000000000000005562024784cc914069d67d89a28e3201bf7b57e7000000000000000000000000000000000000000000a56fa5b99019a5c80000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000080000000000000000000000006d903f6003cca6255d85cca4d3b5e5146dc3392500000000000000000000000099ee778b9a6205657dd03b2b91415c8646d521ec00000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000c436f6d706f756e642044616900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004634441490000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000", + "CompoundLens": "0x", "StdComptroller": "0x", "Unitroller": "0x", "cDaiDelegate": "0x", diff --git a/networks/rinkeby-abi.json b/networks/rinkeby-abi.json index e38902685..b3fdc908d 100644 --- a/networks/rinkeby-abi.json +++ b/networks/rinkeby-abi.json @@ -4696,6 +4696,662 @@ "signature": "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925" } ], + "CompoundLens": [ + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address payable", + "name": "account", + "type": "address" + } + ], + "name": "cTokenBalances", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balanceOf", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowBalanceCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceOfUnderlying", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAllowance", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenBalances", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xbdf950c9" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + }, + { + "internalType": "address payable", + "name": "account", + "type": "address" + } + ], + "name": "cTokenBalancesAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balanceOf", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowBalanceCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceOfUnderlying", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAllowance", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenBalances[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x0972bf8b" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + } + ], + "name": "cTokenMetadata", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "exchangeRateCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactorMantissa", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalReserves", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalCash", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + }, + { + "internalType": "address", + "name": "underlyingAssetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "cTokenDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingDecimals", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenMetadata", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x158eca8b" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + } + ], + "name": "cTokenMetadataAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "exchangeRateCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactorMantissa", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalReserves", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalCash", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + }, + { + "internalType": "address", + "name": "underlyingAssetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "cTokenDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingDecimals", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenMetadata[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x4b70d84b" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + } + ], + "name": "cTokenUnderlyingPrice", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenUnderlyingPrice", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xc5ae5934" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + } + ], + "name": "cTokenUnderlyingPriceAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenUnderlyingPrice[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x2b2d5ed6" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract Comptroller", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getAccountLimits", + "outputs": [ + { + "components": [ + { + "internalType": "contract CToken[]", + "name": "markets", + "type": "address[]" + }, + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "shortfall", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.AccountLimits", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x7dd8f6d9" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract Comp", + "name": "comp", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getCompBalanceMetadata", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votes", + "type": "uint256" + }, + { + "internalType": "address", + "name": "delegate", + "type": "address" + } + ], + "internalType": "struct CompoundLens.CompBalanceMetadata", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x416405d7" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract Comp", + "name": "comp", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint32[]", + "name": "blockNumbers", + "type": "uint32[]" + } + ], + "name": "getCompVotes", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votes", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CompVotes[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x59564219" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract GovernorAlpha", + "name": "governor", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "proposalIds", + "type": "uint256[]" + } + ], + "name": "getGovProposals", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "proposalId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "eta", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "targets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "string[]", + "name": "signatures", + "type": "string[]" + }, + { + "internalType": "bytes[]", + "name": "calldatas", + "type": "bytes[]" + }, + { + "internalType": "uint256", + "name": "startBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "forVotes", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "againstVotes", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "canceled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "executed", + "type": "bool" + } + ], + "internalType": "struct CompoundLens.GovProposal[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x96994869" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract GovernorAlpha", + "name": "governor", + "type": "address" + }, + { + "internalType": "address", + "name": "voter", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "proposalIds", + "type": "uint256[]" + } + ], + "name": "getGovReceipts", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "proposalId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "hasVoted", + "type": "bool" + }, + { + "internalType": "bool", + "name": "support", + "type": "bool" + }, + { + "internalType": "uint96", + "name": "votes", + "type": "uint96" + } + ], + "internalType": "struct CompoundLens.GovReceipt[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x995ed99f" + } + ], "DAI": [ { "constant": true, diff --git a/networks/rinkeby.json b/networks/rinkeby.json index 4f7ae16d3..11ea0a2a5 100644 --- a/networks/rinkeby.json +++ b/networks/rinkeby.json @@ -7,6 +7,7 @@ "PriceOracleProxy": "0x332B6e69f21ACdBA5fb3e8DaC56ff81878527E06", "Maximillion": "0xFBBDBa59516adA2eADf50f96cE0151edC9e0A674", "cDAI": "0x6D7F0754FFeb405d23C51CE938289d4835bE3b14", + "CompoundLens": "0x2B833E2D24ac3c246664b986554A7485fDf75D8b", "DAI": "0x5592EC0cfb4dbc12D3aB100b257153436a1f0FEa", "StdComptroller": "0x99127FD9840Cbc2bBfF43dF443887f4d96268916", "Unitroller": "0x2EAa9D77AE4D8f9cdD9FAAcd44016E746485bddb", @@ -24,8 +25,7 @@ "REP": "0x6e894660985207feb7cf89Faf048998c71E8EE89", "cZRX": "0x52201ff1720134bBbBB2f6BC97Bf3715490EC19B", "cWBTC": "0x0014F450B8Ae7708593F4A46F8fa6E5D50620F96", - "USDC": "0x4DBCdF9B62e891a7cec5A2568C3F4FAF9E8Abe2b", - "CompoundLens": "0x0E01460f00C6B0b66A44D7cF1406Cb2150B718fC" + "USDC": "0x4DBCdF9B62e891a7cec5A2568C3F4FAF9E8Abe2b" }, "Blocks": { "cUSDC": 4319847, @@ -33,6 +33,7 @@ "PriceOracleProxy": 4319855, "Maximillion": 4319848, "cDAI": 4319844, + "CompoundLens": 6312618, "StdComptroller": 4319836, "Unitroller": 4319835, "cBAT": 4319843, @@ -58,6 +59,10 @@ "cEtherAddress": "0xd6801a1DfFCd0a410336Ef88DeF4320D6DF1883e", "address": "0xFBBDBa59516adA2eADf50f96cE0151edC9e0A674" }, + "CompoundLens": { + "name": "CompoundLens", + "contract": "CompoundLens" + }, "Unitroller": { "description": "Unitroller", "address": "0x2EAa9D77AE4D8f9cdD9FAAcd44016E746485bddb" @@ -91,6 +96,7 @@ "PriceOracleProxy": "0x0000000000000000000000002eaa9d77ae4d8f9cdd9faacd44016e746485bddb000000000000000000000000d2b1eca822550d9358e97e72c6c1a93ae28408d0000000000000000000000000d6801a1dffcd0a410336ef88def4320d6df1883e", "Maximillion": "0x000000000000000000000000d6801a1dffcd0a410336ef88def4320d6df1883e", "cDAI": "0x0000000000000000000000005592ec0cfb4dbc12d3ab100b257153436a1f0fea0000000000000000000000002eaa9d77ae4d8f9cdd9faacd44016e746485bddb000000000000000000000000e12630c8fdd7d0096c9cd72cd228598aebe58795000000000000000000000000000000000000000000a56fa5b99019a5c800000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000011436f6d706f756e642044616920f09f938800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046344414900000000000000000000000000000000000000000000000000000000", + "CompoundLens": "0x", "DAI": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003446169000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034441490000000000000000000000000000000000000000000000000000000000", "StdComptroller": "0x", "Unitroller": "0x", diff --git a/networks/ropsten-abi.json b/networks/ropsten-abi.json index f6e681c66..b0fa2f0f6 100644 --- a/networks/ropsten-abi.json +++ b/networks/ropsten-abi.json @@ -6012,6 +6012,662 @@ "signature": "0x6f307dc3" } ], + "CompoundLens": [ + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address payable", + "name": "account", + "type": "address" + } + ], + "name": "cTokenBalances", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balanceOf", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowBalanceCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceOfUnderlying", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAllowance", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenBalances", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xbdf950c9" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + }, + { + "internalType": "address payable", + "name": "account", + "type": "address" + } + ], + "name": "cTokenBalancesAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balanceOf", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowBalanceCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceOfUnderlying", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAllowance", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenBalances[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x0972bf8b" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + } + ], + "name": "cTokenMetadata", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "exchangeRateCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactorMantissa", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalReserves", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalCash", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + }, + { + "internalType": "address", + "name": "underlyingAssetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "cTokenDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingDecimals", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenMetadata", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x158eca8b" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + } + ], + "name": "cTokenMetadataAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "exchangeRateCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactorMantissa", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalReserves", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalCash", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + }, + { + "internalType": "address", + "name": "underlyingAssetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "cTokenDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingDecimals", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenMetadata[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x4b70d84b" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken", + "name": "cToken", + "type": "address" + } + ], + "name": "cTokenUnderlyingPrice", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenUnderlyingPrice", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0xc5ae5934" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract CToken[]", + "name": "cTokens", + "type": "address[]" + } + ], + "name": "cTokenUnderlyingPriceAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CTokenUnderlyingPrice[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x2b2d5ed6" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract Comptroller", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getAccountLimits", + "outputs": [ + { + "components": [ + { + "internalType": "contract CToken[]", + "name": "markets", + "type": "address[]" + }, + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "shortfall", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.AccountLimits", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function", + "signature": "0x7dd8f6d9" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract Comp", + "name": "comp", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getCompBalanceMetadata", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votes", + "type": "uint256" + }, + { + "internalType": "address", + "name": "delegate", + "type": "address" + } + ], + "internalType": "struct CompoundLens.CompBalanceMetadata", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x416405d7" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract Comp", + "name": "comp", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint32[]", + "name": "blockNumbers", + "type": "uint32[]" + } + ], + "name": "getCompVotes", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votes", + "type": "uint256" + } + ], + "internalType": "struct CompoundLens.CompVotes[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x59564219" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract GovernorAlpha", + "name": "governor", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "proposalIds", + "type": "uint256[]" + } + ], + "name": "getGovProposals", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "proposalId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "eta", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "targets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "string[]", + "name": "signatures", + "type": "string[]" + }, + { + "internalType": "bytes[]", + "name": "calldatas", + "type": "bytes[]" + }, + { + "internalType": "uint256", + "name": "startBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "forVotes", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "againstVotes", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "canceled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "executed", + "type": "bool" + } + ], + "internalType": "struct CompoundLens.GovProposal[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x96994869" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract GovernorAlpha", + "name": "governor", + "type": "address" + }, + { + "internalType": "address", + "name": "voter", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "proposalIds", + "type": "uint256[]" + } + ], + "name": "getGovReceipts", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "proposalId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "hasVoted", + "type": "bool" + }, + { + "internalType": "bool", + "name": "support", + "type": "bool" + }, + { + "internalType": "uint96", + "name": "votes", + "type": "uint96" + } + ], + "internalType": "struct CompoundLens.GovReceipt[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function", + "signature": "0x995ed99f" + } + ], "DAI": [ { "constant": true, diff --git a/networks/ropsten.json b/networks/ropsten.json index 2b0a7131a..ef25f8032 100644 --- a/networks/ropsten.json +++ b/networks/ropsten.json @@ -8,6 +8,7 @@ "Maximillion": "0xE77Ce01B692FcF66E2F632e518b9449D18D582d8", "GovernorAlpha": "0xc5BFEd3Bb38a3C4078d4f130F57Ca4c560551d45", "cDAI": "0x6CE27497A64fFFb5517AA4aeE908b1E7EB63B9fF", + "CompoundLens": "0x65D9E5eE0cfC8c8bCE5787792755132f91FDFf9f", "DAI": "0xB5E5D0F8C0cbA267CD3D7035d6AdC8eBA7Df7Cdd", "StdComptroller": "0x70cBa46d2e933030E2f274AE58c951C800548AeF", "Unitroller": "0xe03718b458a2E912141CF3fC8daB648362ee7463", @@ -30,8 +31,7 @@ "cZRX": "0x3A728dD027AD6F76Cdea227d5Cf5ba7ce9390A3d", "cWBTC": "0x4D15eE7DE1f86248c986f5AE7dCE855b1c1A8806", "TBTC": "0x083f652051b9CdBf65735f98d83cc329725Aa957", - "USDC": "0x8a9447df1FB47209D36204e6D56767a33bf20f9f", - "CompoundLens": "0x1496C81e6DE4928bE5E4e9F83dA575A08B616Ac8" + "USDC": "0x8a9447df1FB47209D36204e6D56767a33bf20f9f" }, "Blocks": { "ZRX": 5970747, @@ -42,6 +42,7 @@ "Maximillion": 5970773, "GovernorAlpha": 7404122, "cDAI": 7308357, + "CompoundLens": 7647526, "DAI": 5970751, "StdComptroller": 7308325, "Unitroller": 7308316, @@ -81,6 +82,10 @@ "cEtherAddress": "0x42a628e0c5F3767930097B34b08dCF77e78e4F2B", "address": "0xE77Ce01B692FcF66E2F632e518b9449D18D582d8" }, + "CompoundLens": { + "name": "CompoundLens", + "contract": "CompoundLens" + }, "Unitroller": { "description": "Unitroller", "address": "0xe03718b458a2E912141CF3fC8daB648362ee7463" @@ -125,6 +130,7 @@ "Maximillion": "0x00000000000000000000000042a628e0c5f3767930097b34b08dcf77e78e4f2b", "GovernorAlpha": "0x00000000000000000000000018646f4a178404b1c986390ac808236d37229a110000000000000000000000001Fe16De955718CFAb7A44605458AB023838C2793000000000000000000000000513c1ff435eccedd0fda5edd2ad5e5461f0e8726", "cDAI": "0x000000000000000000000000b5e5d0f8c0cba267cd3d7035d6adc8eba7df7cdd000000000000000000000000e03718b458a2e912141cf3fc8dab648362ee7463000000000000000000000000d87ba7a50b2e7e660f678a895e4b72e7cb4ccd9c000000000000000000000000000000000000000000a56fa5b99019a5c8000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000008000000000000000000000000513c1ff435eccedd0fda5edd2ad5e5461f0e8726000000000000000000000000cec4a43ebb02f9b80916f1c718338169d6d5c1f000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000021436f6d706f756e64204d756c7469436f6c6c61746572616c2044414920f09f9388000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004634441490000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000", + "CompoundLens": "0x", "DAI": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003446169000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034441490000000000000000000000000000000000000000000000000000000000", "StdComptroller": "0x", "Unitroller": "0x", diff --git a/package.json b/package.json index 1fd0aab47..37efe9631 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "compound-money-market", + "name": "compound-protocol", "version": "0.2.1", "description": "The Compound Money Market", "main": "index.js", @@ -13,7 +13,7 @@ "test": "./script/test", "test:prepare": "NO_RUN=true ./script/test" }, - "repository": "git@github.com:compound-finance/money-market.git", + "repository": "git@github.com:compound-finance/compound-protocol.git", "author": "Compound Finance", "license": "UNLICENSED", "devDependencies": { diff --git a/scenario/src/Contract/CompoundLens.ts b/scenario/src/Contract/CompoundLens.ts new file mode 100644 index 000000000..3d4cd2975 --- /dev/null +++ b/scenario/src/Contract/CompoundLens.ts @@ -0,0 +1,18 @@ +import { Contract } from '../Contract'; +import { encodedNumber } from '../Encoding'; +import { Callable, Sendable } from '../Invokation'; + +export interface CompoundLensMethods { + cTokenBalances(cToken: string, account: string): Sendable<[string,number,number,number,number,number]>; + cTokenBalancesAll(cTokens: string[], account: string): Sendable<[string,number,number,number,number,number][]>; + cTokenMetadata(cToken: string): Sendable<[string,number,number,number,number,number,number,number,number,boolean,number,string,number,number]>; + cTokenMetadataAll(cTokens: string[]): Sendable<[string,number,number,number,number,number,number,number,number,boolean,number,string,number,number][]>; + cTokenUnderlyingPrice(cToken: string): Sendable<[string,number]>; + cTokenUnderlyingPriceAll(cTokens: string[]): Sendable<[string,number][]>; + getAccountLimits(comptroller: string, account: string): Sendable<[string[],number,number]>; +} + +export interface CompoundLens extends Contract { + methods: CompoundLensMethods; + name: string; +} diff --git a/scenario/src/Contract/builder.js b/scenario/src/Contract/builder.js new file mode 100644 index 000000000..f6c11270d --- /dev/null +++ b/scenario/src/Contract/builder.js @@ -0,0 +1,63 @@ +const fs = require('fs'); +const path = require('path'); + +let [_, _f, buildFile, contract] = process.argv; + +if (!buildFile || !contract) { + throw new Error(`builder.js `); +} +if (!fs.existsSync(buildFile)) { + throw new Error(`build_file: file not found`); +} +let buildRaw = fs.readFileSync(buildFile, 'utf8'); +let build; + +try { + build = JSON.parse(buildRaw); +} catch (e) { + throw new Error(`Error parsing build file: ${e.toString()}`); +} +if (!build.contracts) { + throw new Error(`Invalid build file, missing contracts`); +} +let contractInfo = Object.entries(build.contracts).find(([k,v]) => k.split(':')[1] === contract); +if (!contractInfo) { + throw new Error(`Build file does not contain info for ${contract}`); +} +let contractABI = JSON.parse(contractInfo[1].abi); + +console.log(`export interface ${contract}Methods {`); +contractABI.forEach(abi => { + if (abi.type === 'function') { + function mapped(io) { + let typeMap = { + 'address': 'string', + 'address[]': 'string[]', + 'uint256': 'number', + 'bool': 'boolean' + }; + return typeMap[io.type] || io.type; + }; + let name = abi.name; + let args = abi.inputs.map((input) => { + return `${input.name}: ${mapped(input)}`; + }).join(', '); + let returnType = abi.outputs.map((output) => { + if (output.type == 'tuple' || output.type == 'tuple[]') { + let res = output.components.map((c) => { + return mapped(c); + }).join(','); + if (output.type == 'tuple[]') { + return `[${res}][]`; + } else { + return `[${res}]`; + } + } else { + return mapped(output); + } + }).join(','); + let able = abi.constant ? 'Callable' : 'Sendable'; + console.log(` ${name}(${args}): ${able}<${returnType}>;`); + } +}); +console.log("}"); diff --git a/scenario/src/CoreEvent.ts b/scenario/src/CoreEvent.ts index 74666ec65..c31c00b14 100644 --- a/scenario/src/CoreEvent.ts +++ b/scenario/src/CoreEvent.ts @@ -40,6 +40,7 @@ import { loadContracts } from './Networks'; import { fork } from './Hypothetical'; import { buildContractEvent } from './EventBuilder'; import { Counter } from './Contract/Counter'; +import { CompoundLens } from './Contract/CompoundLens'; import Web3 from 'web3'; export class EventProcessingError extends Error { @@ -792,6 +793,7 @@ export const commands: (View | ((world: World) => Promise>))[] = ), buildContractEvent("Counter"), + buildContractEvent("CompoundLens"), new View<{ event: EventV }>( ` diff --git a/scenario/src/CoreValue.ts b/scenario/src/CoreValue.ts index ab5f7e4f0..62ce4ccb6 100644 --- a/scenario/src/CoreValue.ts +++ b/scenario/src/CoreValue.ts @@ -960,7 +960,8 @@ const fetchers = [ ]; let contractFetchers = [ - "Counter" + "Counter", + "CompoundLens" ]; export async function getFetchers(world: World) { diff --git a/scenario/src/EventBuilder.ts b/scenario/src/EventBuilder.ts index d38bab12b..f98118a92 100644 --- a/scenario/src/EventBuilder.ts +++ b/scenario/src/EventBuilder.ts @@ -78,6 +78,7 @@ export function buildContractEvent(contractName: string) { const contract = invokation.value!; contract.address = contract._address; + const index = contractName == data.name ? [contractName] : [contractName, data.name]; world = await storeAndSaveContract( world, @@ -85,7 +86,7 @@ export function buildContractEvent(contractName: string) { data.name, invokation, [ - { index: [contractName, data.name], data: data } + { index: index, data: data } ] ); @@ -154,6 +155,10 @@ export async function buildContractFetcher(world: World, con builder: (x) => new AddressV(x), getter: getAddressV }, + 'address[]': { + builder: (x) => new ArrayV(x), + getter: (x) => getArrayV(x), + }, string: { builder: (x) => new StringV(x), getter: getStringV @@ -161,6 +166,18 @@ export async function buildContractFetcher(world: World, con uint256: { builder: (x) => new NumberV(x), getter: getNumberV + }, + 'uint256[]': { + builder: (x) => new ArrayV(x), + getter: (x) => getArrayV(x), + }, + 'uint32[]': { + builder: (x) => new ArrayV(x), + getter: (x) => getArrayV(x), + }, + 'uint96[]': { + builder: (x) => new ArrayV(x), + getter: (x) => getArrayV(x), } }; diff --git a/tests/Lens/CompoundLensTest.js b/tests/Lens/CompoundLensTest.js new file mode 100644 index 000000000..b081d5bf6 --- /dev/null +++ b/tests/Lens/CompoundLensTest.js @@ -0,0 +1,346 @@ +const { + address, + encodeParameters, +} = require('../Utils/Ethereum'); +const { + makeComptroller, + makeCToken, +} = require('../Utils/Compound'); + +function cullTuple(tuple) { + return Object.keys(tuple).reduce((acc, key) => { + if (Number.isNaN(Number(key))) { + return { + ...acc, + [key]: tuple[key] + }; + } else { + return acc; + } + }, {}); +} + +describe('CompoundLens', () => { + let compoundLens; + let acct; + + beforeEach(async () => { + compoundLens = await deploy('CompoundLens'); + acct = accounts[0]; + }); + + describe('cTokenMetadata', () => { + it('is correct for a cErc20', async () => { + let cErc20 = await makeCToken(); + expect( + cullTuple(await call(compoundLens, 'cTokenMetadata', [cErc20._address])) + ).toEqual( + { + cToken: cErc20._address, + exchangeRateCurrent: "1000000000000000000", + supplyRatePerBlock: "0", + borrowRatePerBlock: "0", + reserveFactorMantissa: "0", + totalBorrows: "0", + totalReserves: "0", + totalSupply: "0", + totalCash: "0", + isListed:false, + collateralFactorMantissa: "0", + underlyingAssetAddress: await call(cErc20, 'underlying', []), + cTokenDecimals: "8", + underlyingDecimals: "18" + } + ); + }); + + it('is correct for cEth', async () => { + let cEth = await makeCToken({kind: 'cether'}); + expect( + cullTuple(await call(compoundLens, 'cTokenMetadata', [cEth._address])) + ).toEqual({ + borrowRatePerBlock: "0", + cToken: cEth._address, + cTokenDecimals: "8", + collateralFactorMantissa: "0", + exchangeRateCurrent: "1000000000000000000", + isListed: false, + reserveFactorMantissa: "0", + supplyRatePerBlock: "0", + totalBorrows: "0", + totalCash: "0", + totalReserves: "0", + totalSupply: "0", + underlyingAssetAddress: "0x0000000000000000000000000000000000000000", + underlyingDecimals: "18", + }); + }); + }); + + describe('cTokenMetadataAll', () => { + it('is correct for a cErc20 and cEther', async () => { + let cErc20 = await makeCToken(); + let cEth = await makeCToken({kind: 'cether'}); + expect( + (await call(compoundLens, 'cTokenMetadataAll', [[cErc20._address, cEth._address]])).map(cullTuple) + ).toEqual([ + { + cToken: cErc20._address, + exchangeRateCurrent: "1000000000000000000", + supplyRatePerBlock: "0", + borrowRatePerBlock: "0", + reserveFactorMantissa: "0", + totalBorrows: "0", + totalReserves: "0", + totalSupply: "0", + totalCash: "0", + isListed:false, + collateralFactorMantissa: "0", + underlyingAssetAddress: await call(cErc20, 'underlying', []), + cTokenDecimals: "8", + underlyingDecimals: "18" + }, + { + borrowRatePerBlock: "0", + cToken: cEth._address, + cTokenDecimals: "8", + collateralFactorMantissa: "0", + exchangeRateCurrent: "1000000000000000000", + isListed: false, + reserveFactorMantissa: "0", + supplyRatePerBlock: "0", + totalBorrows: "0", + totalCash: "0", + totalReserves: "0", + totalSupply: "0", + underlyingAssetAddress: "0x0000000000000000000000000000000000000000", + underlyingDecimals: "18", + } + ]); + }); + }); + + describe('cTokenBalances', () => { + it('is correct for cERC20', async () => { + let cErc20 = await makeCToken(); + expect( + cullTuple(await call(compoundLens, 'cTokenBalances', [cErc20._address, acct])) + ).toEqual( + { + balanceOf: "0", + balanceOfUnderlying: "0", + borrowBalanceCurrent: "0", + cToken: cErc20._address, + tokenAllowance: "0", + tokenBalance: "10000000000000000000000000", + } + ); + }); + + it('is correct for cETH', async () => { + let cEth = await makeCToken({kind: 'cether'}); + let ethBalance = await web3.eth.getBalance(acct); + expect( + cullTuple(await call(compoundLens, 'cTokenBalances', [cEth._address, acct], {gasPrice: '0'})) + ).toEqual( + { + balanceOf: "0", + balanceOfUnderlying: "0", + borrowBalanceCurrent: "0", + cToken: cEth._address, + tokenAllowance: ethBalance, + tokenBalance: ethBalance, + } + ); + }); + }); + + describe('cTokenBalancesAll', () => { + it('is correct for cEth and cErc20', async () => { + let cErc20 = await makeCToken(); + let cEth = await makeCToken({kind: 'cether'}); + let ethBalance = await web3.eth.getBalance(acct); + + expect( + (await call(compoundLens, 'cTokenBalancesAll', [[cErc20._address, cEth._address], acct], {gasPrice: '0'})).map(cullTuple) + ).toEqual([ + { + balanceOf: "0", + balanceOfUnderlying: "0", + borrowBalanceCurrent: "0", + cToken: cErc20._address, + tokenAllowance: "0", + tokenBalance: "10000000000000000000000000", + }, + { + balanceOf: "0", + balanceOfUnderlying: "0", + borrowBalanceCurrent: "0", + cToken: cEth._address, + tokenAllowance: ethBalance, + tokenBalance: ethBalance, + } + ]); + }) + }); + + describe('cTokenUnderlyingPrice', () => { + it('gets correct price for cErc20', async () => { + let cErc20 = await makeCToken(); + expect( + cullTuple(await call(compoundLens, 'cTokenUnderlyingPrice', [cErc20._address])) + ).toEqual( + { + cToken: cErc20._address, + underlyingPrice: "0", + } + ); + }); + + it('gets correct price for cEth', async () => { + let cEth = await makeCToken({kind: 'cether'}); + expect( + cullTuple(await call(compoundLens, 'cTokenUnderlyingPrice', [cEth._address])) + ).toEqual( + { + cToken: cEth._address, + underlyingPrice: "1000000000000000000", + } + ); + }); + }); + + describe('cTokenUnderlyingPriceAll', () => { + it('gets correct price for both', async () => { + let cErc20 = await makeCToken(); + let cEth = await makeCToken({kind: 'cether'}); + expect( + (await call(compoundLens, 'cTokenUnderlyingPriceAll', [[cErc20._address, cEth._address]])).map(cullTuple) + ).toEqual([ + { + cToken: cErc20._address, + underlyingPrice: "0", + }, + { + cToken: cEth._address, + underlyingPrice: "1000000000000000000", + } + ]); + }); + }); + + describe('getAccountLimits', () => { + it('gets correct values', async () => { + let comptroller = await makeComptroller(); + + expect( + cullTuple(await call(compoundLens, 'getAccountLimits', [comptroller._address, acct])) + ).toEqual({ + liquidity: "0", + markets: [], + shortfall: "0" + }); + }); + }); + + describe('governance', () => { + let comp, gov; + let targets, values, signatures, callDatas; + let proposalBlock, proposalId; + + beforeEach(async () => { + comp = await deploy('Comp', [acct]); + gov = await deploy('GovernorAlpha', [address(0), comp._address, address(0)]); + targets = [acct]; + values = ["0"]; + signatures = ["getBalanceOf(address)"]; + callDatas = [encodeParameters(['address'], [acct])]; + await send(comp, 'delegate', [acct]); + await send(gov, 'propose', [targets, values, signatures, callDatas, "do nothing"]); + proposalBlock = +(await web3.eth.getBlockNumber()); + proposalId = await call(gov, 'latestProposalIds', [acct]); + }); + + describe('getGovReceipts', () => { + it('gets correct values', async () => { + expect( + (await call(compoundLens, 'getGovReceipts', [gov._address, acct, [proposalId]])).map(cullTuple) + ).toEqual([ + { + hasVoted: false, + proposalId: proposalId, + support: false, + votes: "0", + } + ]); + }) + }); + + describe('getGovProposals', () => { + it('gets correct values', async () => { + expect( + (await call(compoundLens, 'getGovProposals', [gov._address, [proposalId]])).map(cullTuple) + ).toEqual([ + { + againstVotes: "0", + calldatas: callDatas, + canceled: false, + endBlock: (Number(proposalBlock) + 17281).toString(), + eta: "0", + executed: false, + forVotes: "0", + proposalId: proposalId, + proposer: acct, + signatures: signatures, + startBlock: (Number(proposalBlock) + 1).toString(), + targets: targets + } + ]); + }) + }); + }); + + describe('comp', () => { + let comp, currentBlock; + + beforeEach(async () => { + currentBlock = +(await web3.eth.getBlockNumber()); + comp = await deploy('Comp', [acct]); + }); + + describe('getCompBalanceMetadata', () => { + it('gets correct values', async () => { + expect( + cullTuple(await call(compoundLens, 'getCompBalanceMetadata', [comp._address, acct])) + ).toEqual({ + balance: "10000000000000000000000000", + delegate: "0x0000000000000000000000000000000000000000", + votes: "0", + }); + }); + }); + + describe('getCompVotes', () => { + it('gets correct values', async () => { + expect( + (await call(compoundLens, 'getCompVotes', [comp._address, acct, [currentBlock, currentBlock - 1]])).map(cullTuple) + ).toEqual([ + { + blockNumber: currentBlock.toString(), + votes: "0", + }, + { + blockNumber: (Number(currentBlock) - 1).toString(), + votes: "0", + } + ]); + }); + + it('reverts on future value', async () => { + await expect( + call(compoundLens, 'getCompVotes', [comp._address, acct, [currentBlock + 1]]) + ).rejects.toRevert('revert Comp::getPriorVotes: not yet determined') + }); + }); + }); +}); diff --git a/tests/Utils/Compound.js b/tests/Utils/Compound.js index 6d4046ea7..8d78f0679 100644 --- a/tests/Utils/Compound.js +++ b/tests/Utils/Compound.js @@ -66,7 +66,7 @@ async function makeCToken(opts = {}) { const interestRateModel = opts.interestRateModel || await makeInterestRateModel(opts.interestRateModelOpts); const exchangeRate = etherMantissa(dfn(opts.exchangeRate, 1)); const decimals = etherUnsigned(dfn(opts.decimals, 8)); - const symbol = opts.symbol || 'cOMG'; + const symbol = opts.symbol || (kind === 'cether' ? 'cETH' : 'cOMG'); const name = opts.name || `CToken ${symbol}`; const admin = opts.admin || root;