Skip to content

Commit

Permalink
Final deployments (#83)
Browse files Browse the repository at this point in the history
This patch adds the final deployments for the COMP distribution system (aka flywheel) to mainnet, kovan, and ropsten. It includes testnet harnesses, as well as the scripts that will be used to initialize all the pre-existing borrower COMP indices.

Co-authored-by: Max Wolff <maxcwolff@gmail.com>
Co-authored-by: Geoff Hayes <hayesgm@gmail.com>
  • Loading branch information
3 people committed Jun 15, 2020
1 parent f9901f4 commit d2a1861
Show file tree
Hide file tree
Showing 15 changed files with 8,880 additions and 8,049 deletions.
12 changes: 9 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
The software and documentation available in this repository (the "Software") is protected by copyright law and accessible pursuant to the license set forth below. Copyright © 2019 Compound Labs, Inc. All rights reserved.
Copyright 2020 Compound Labs, Inc.

Permission is hereby granted, free of charge, to any person or organization obtaining the Software (the “Licensee”) to privately study, review, and analyze the Software. Licensee shall not use the Software for any other purpose. Licensee shall not modify, transfer, assign, share, or sub-license the Software or any derivative works of the Software.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE.
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 changes: 15 additions & 6 deletions contracts/Lens/CompoundLens.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@ pragma experimental ABIEncoderV2;

import "../CErc20.sol";
import "../CToken.sol";
import "../Comptroller.sol";
import "../PriceOracle.sol";
import "../EIP20Interface.sol";
import "../Governance/GovernorAlpha.sol";
import "../Governance/Comp.sol";

interface ComptrollerLensInterface {
function markets(address) external view returns (bool, uint);
function oracle() external view returns (PriceOracle);
function getAccountLiquidity(address) external view returns (uint, uint, uint);
function getAssetsIn(address) external view returns (CToken[] memory);
function claimComp(address) external;
function compAccrued(address) external view returns (uint);
}

contract CompoundLens {
struct CTokenMetadata {
address cToken;
Expand All @@ -28,8 +37,8 @@ contract CompoundLens {

function cTokenMetadata(CToken cToken) public returns (CTokenMetadata memory) {
uint exchangeRateCurrent = cToken.exchangeRateCurrent();
Comptroller comptroller = Comptroller(address(cToken.comptroller()));
(bool isListed, uint collateralFactorMantissa, ) = comptroller.markets(address(cToken));
ComptrollerLensInterface comptroller = ComptrollerLensInterface(address(cToken.comptroller()));
(bool isListed, uint collateralFactorMantissa) = comptroller.markets(address(cToken));
address underlyingAssetAddress;
uint underlyingDecimals;

Expand Down Expand Up @@ -120,7 +129,7 @@ contract CompoundLens {
}

function cTokenUnderlyingPrice(CToken cToken) public returns (CTokenUnderlyingPrice memory) {
Comptroller comptroller = Comptroller(address(cToken.comptroller()));
ComptrollerLensInterface comptroller = ComptrollerLensInterface(address(cToken.comptroller()));
PriceOracle priceOracle = comptroller.oracle();

return CTokenUnderlyingPrice({
Expand All @@ -144,7 +153,7 @@ contract CompoundLens {
uint shortfall;
}

function getAccountLimits(Comptroller comptroller, address account) public returns (AccountLimits memory) {
function getAccountLimits(ComptrollerLensInterface comptroller, address account) public returns (AccountLimits memory) {
(uint errorCode, uint liquidity, uint shortfall) = comptroller.getAccountLiquidity(account);
require(errorCode == 0);

Expand Down Expand Up @@ -266,7 +275,7 @@ contract CompoundLens {
uint allocated;
}

function getCompBalanceMetadataExt(Comp comp, Comptroller comptroller, address account) external returns (CompBalanceMetadataExt memory) {
function getCompBalanceMetadataExt(Comp comp, ComptrollerLensInterface comptroller, address account) external returns (CompBalanceMetadataExt memory) {
uint balance = comp.balanceOf(account);
comptroller.claimComp(account);
uint newBalance = comp.balanceOf(account);
Expand Down
248 changes: 248 additions & 0 deletions networks/kovan-abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -28385,6 +28385,254 @@
"type": "function"
}
],
"Base200bps_Slope2000bps_Jump20000bps_Kink90_bad_2": [
{
"inputs": [
{
"internalType": "uint256",
"name": "baseRatePerYear",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "multiplierPerYear",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "jumpMultiplierPerYear",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "kink_",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "baseRatePerBlock",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "multiplierPerBlock",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "jumpMultiplierPerBlock",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "kink",
"type": "uint256"
}
],
"name": "NewInterestParams",
"type": "event"
},
{
"constant": true,
"inputs": [],
"name": "baseRatePerBlock",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "blocksPerYear",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "uint256",
"name": "cash",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "borrows",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "reserves",
"type": "uint256"
}
],
"name": "getBorrowRate",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "uint256",
"name": "cash",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "borrows",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "reserves",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "reserveFactorMantissa",
"type": "uint256"
}
],
"name": "getSupplyRate",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "isInterestRateModel",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "jumpMultiplierPerBlock",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "kink",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "multiplierPerBlock",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "uint256",
"name": "cash",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "borrows",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "reserves",
"type": "uint256"
}
],
"name": "utilizationRate",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "pure",
"type": "function"
}
],
"Comptroller": [
{
"inputs": [],
Expand Down

0 comments on commit d2a1861

Please sign in to comment.