Skip to content

Commit

Permalink
Merge pull request #224 from VenusProtocol/feat/diamond-proxy
Browse files Browse the repository at this point in the history
[VEN-1146]: Comptroller Diamond Proxy
  • Loading branch information
Debugger022 authored Sep 25, 2023
2 parents f8790a5 + 66f90f4 commit 3733de6
Show file tree
Hide file tree
Showing 79 changed files with 3,845 additions and 12,392 deletions.
Binary file modified .yarn/install-state.gz
Binary file not shown.
1,600 changes: 0 additions & 1,600 deletions contracts/Comptroller/Comptroller.sol

This file was deleted.

1,605 changes: 0 additions & 1,605 deletions contracts/Comptroller/ComptrollerG1.sol

This file was deleted.

1,605 changes: 0 additions & 1,605 deletions contracts/Comptroller/ComptrollerG2.sol

This file was deleted.

1,561 changes: 0 additions & 1,561 deletions contracts/Comptroller/ComptrollerG3.sol

This file was deleted.

1,560 changes: 0 additions & 1,560 deletions contracts/Comptroller/ComptrollerG4.sol

This file was deleted.

1,576 changes: 0 additions & 1,576 deletions contracts/Comptroller/ComptrollerG5.sol

This file was deleted.

26 changes: 12 additions & 14 deletions contracts/Comptroller/ComptrollerInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ pragma solidity ^0.5.16;

import "../Tokens/VTokens/VToken.sol";
import "../Oracle/PriceOracle.sol";
import "../Tokens/VAI/VAIControllerInterface.sol";

contract ComptrollerInterfaceG1 {
contract ComptrollerInterface {
/// @notice Indicator that this is a Comptroller contract (for inspection)
bool public constant isComptroller = true;

Expand Down Expand Up @@ -88,27 +89,14 @@ contract ComptrollerInterfaceG1 {
) external view returns (uint, uint);

function setMintedVAIOf(address owner, uint amount) external returns (uint);
}

contract ComptrollerInterfaceG2 is ComptrollerInterfaceG1 {
function liquidateVAICalculateSeizeTokens(
address vTokenCollateral,
uint repayAmount
) external view returns (uint, uint);
}

contract ComptrollerInterfaceG3 is ComptrollerInterfaceG2 {
function liquidateVAICalculateSeizeTokens(
address vTokenCollateral,
uint repayAmount
) external view returns (uint, uint);
}

contract ComptrollerInterfaceG4 is ComptrollerInterfaceG3 {
function getXVSAddress() public view returns (address);
}

contract ComptrollerInterface is ComptrollerInterfaceG4 {
function markets(address) external view returns (bool, uint);

function oracle() external view returns (PriceOracle);
Expand Down Expand Up @@ -138,6 +126,16 @@ contract ComptrollerInterface is ComptrollerInterfaceG4 {
function venusSupplyState(address) external view returns (uint224, uint32);

function approvedDelegates(address borrower, address delegate) external view returns (bool);

function vaiController() external view returns (VAIControllerInterface);

function liquidationIncentiveMantissa() external view returns (uint);

function protocolPaused() external view returns (bool);

function mintedVAIs(address user) external view returns (uint);

function vaiMintRate() external view returns (uint);
}

interface IVAIVault {
Expand Down
67 changes: 43 additions & 24 deletions contracts/Comptroller/ComptrollerStorage.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity ^0.5.16;

import "../Tokens/VTokens/VToken.sol";
import "../Oracle/PriceOracle.sol";
import "../Tokens/VAI/VAIControllerInterface.sol";
import "./ComptrollerLensInterface.sol";
import { VToken } from "../Tokens/VTokens/VToken.sol";
import { PriceOracle } from "../Oracle/PriceOracle.sol";
import { VAIControllerInterface } from "../Tokens/VAI/VAIControllerInterface.sol";
import { ComptrollerLensInterface } from "./ComptrollerLensInterface.sol";

contract UnitrollerAdminStorage {
/**
Expand Down Expand Up @@ -36,17 +38,17 @@ contract ComptrollerV1Storage is UnitrollerAdminStorage {
/**
* @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow
*/
uint public closeFactorMantissa;
uint256 public closeFactorMantissa;

/**
* @notice Multiplier representing the discount on collateral that a liquidator receives
*/
uint public liquidationIncentiveMantissa;
uint256 public liquidationIncentiveMantissa;

/**
* @notice Max number of assets a single account can participate in (borrow or use as collateral)
*/
uint public maxAssets;
uint256 public maxAssets;

/**
* @notice Per-account mapping of "assets you are in", capped by maxAssets
Expand All @@ -61,7 +63,7 @@ contract ComptrollerV1Storage is UnitrollerAdminStorage {
* For instance, 0.9 to allow borrowing 90% of collateral value.
* Must be between 0 and 1, and stored as a mantissa.
*/
uint collateralFactorMantissa;
uint256 collateralFactorMantissa;
/// @notice Per-market mapping of "accounts in this asset"
mapping(address => bool) accountMembership;
/// @notice Whether or not this market receives XVS
Expand Down Expand Up @@ -103,10 +105,10 @@ contract ComptrollerV1Storage is UnitrollerAdminStorage {
VToken[] public allMarkets;

/// @notice The rate at which the flywheel distributes XVS, per block
uint internal venusRate;
uint256 internal venusRate;

/// @notice The portion of venusRate that each market currently receives
mapping(address => uint) internal venusSpeeds;
mapping(address => uint256) internal venusSpeeds;

/// @notice The Venus market supply state for each market
mapping(address => VenusMarketState) public venusSupplyState;
Expand All @@ -115,22 +117,22 @@ contract ComptrollerV1Storage is UnitrollerAdminStorage {
mapping(address => VenusMarketState) public venusBorrowState;

/// @notice The Venus supply index for each market for each supplier as of the last time they accrued XVS
mapping(address => mapping(address => uint)) public venusSupplierIndex;
mapping(address => mapping(address => uint256)) public venusSupplierIndex;

/// @notice The Venus borrow index for each market for each borrower as of the last time they accrued XVS
mapping(address => mapping(address => uint)) public venusBorrowerIndex;
mapping(address => mapping(address => uint256)) public venusBorrowerIndex;

/// @notice The XVS accrued but not yet transferred to each user
mapping(address => uint) public venusAccrued;
mapping(address => uint256) public venusAccrued;

/// @notice The Address of VAIController
VAIControllerInterface public vaiController;

/// @notice The minted VAI amount to each user
mapping(address => uint) public mintedVAIs;
mapping(address => uint256) public mintedVAIs;

/// @notice VAI Mint Rate as a percentage
uint public vaiMintRate;
uint256 public vaiMintRate;

/**
* @notice The Pause Guardian can pause certain actions as a safety mechanism.
Expand All @@ -144,12 +146,12 @@ contract ComptrollerV1Storage is UnitrollerAdminStorage {
bool public protocolPaused;

/// @notice The rate at which the flywheel distributes XVS to VAI Minters, per block (deprecated)
uint private venusVAIRate;
uint256 private venusVAIRate;
}

contract ComptrollerV2Storage is ComptrollerV1Storage {
/// @notice The rate at which the flywheel distributes XVS to VAI Vault, per block
uint public venusVAIVaultRate;
uint256 public venusVAIVaultRate;

// address of VAI Vault
address public vaiVaultAddress;
Expand All @@ -166,7 +168,7 @@ contract ComptrollerV3Storage is ComptrollerV2Storage {
address public borrowCapGuardian;

/// @notice Borrow caps enforced by borrowAllowed for each vToken address. Defaults to zero which corresponds to unlimited borrowing.
mapping(address => uint) public borrowCaps;
mapping(address => uint256) public borrowCaps;
}

contract ComptrollerV4Storage is ComptrollerV3Storage {
Expand All @@ -182,10 +184,10 @@ contract ComptrollerV4Storage is ComptrollerV3Storage {

contract ComptrollerV5Storage is ComptrollerV4Storage {
/// @notice The portion of XVS that each contributor receives per block (deprecated)
mapping(address => uint) private venusContributorSpeeds;
mapping(address => uint256) private venusContributorSpeeds;

/// @notice Last block at which a contributor's XVS rewards have been allocated (deprecated)
mapping(address => uint) private lastContributorBlock;
mapping(address => uint256) private lastContributorBlock;
}

contract ComptrollerV6Storage is ComptrollerV5Storage {
Expand Down Expand Up @@ -218,15 +220,15 @@ contract ComptrollerV9Storage is ComptrollerV8Storage {
}

/// @notice True if a certain action is paused on a certain market
mapping(address => mapping(uint => bool)) internal _actionPaused;
mapping(address => mapping(uint256 => bool)) internal _actionPaused;
}

contract ComptrollerV10Storage is ComptrollerV9Storage {
/// @notice The rate at which venus is distributed to the corresponding borrow market (per block)
mapping(address => uint) public venusBorrowSpeeds;
mapping(address => uint256) public venusBorrowSpeeds;

/// @notice The rate at which venus is distributed to the corresponding supply market (per block)
mapping(address => uint) public venusSupplySpeeds;
mapping(address => uint256) public venusSupplySpeeds;
}

contract ComptrollerV11Storage is ComptrollerV10Storage {
Expand All @@ -236,6 +238,23 @@ contract ComptrollerV11Storage is ComptrollerV10Storage {
}

contract ComptrollerV12Storage is ComptrollerV11Storage {
/// @notice Flag indicating whether forced liquidation enabled for a market
mapping(address => bool) public isForcedLiquidationEnabled;
}

contract ComptrollerV13Storage is ComptrollerV12Storage {
struct FacetAddressAndPosition {
address facetAddress;
uint96 functionSelectorPosition; // position in _facetFunctionSelectors.functionSelectors array
}

struct FacetFunctionSelectors {
bytes4[] functionSelectors;
uint256 facetAddressPosition; // position of facetAddress in _facetAddresses array
}

mapping(bytes4 => FacetAddressAndPosition) internal _selectorToFacetAndPosition;
// maps facet addresses to function selectors
mapping(address => FacetFunctionSelectors) internal _facetFunctionSelectors;
// facet addresses
address[] internal _facetAddresses;
}
Loading

0 comments on commit 3733de6

Please sign in to comment.