Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VEN-1146]: Comptroller Diamond Proxy #224

Merged
merged 164 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 141 commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
aec462b
test: add simulations for swapping the debt
kkirka Feb 23, 2023
202f672
Added diamond proxy structure
Debugger022 Mar 3, 2023
fd87920
Added reward and setter Facet
Debugger022 Mar 3, 2023
6c5c7ef
Added Helper libraries
Debugger022 Mar 3, 2023
1912289
Update stroage access and fix Lint
Debugger022 Mar 6, 2023
1e4c321
Update imports
Debugger022 Mar 6, 2023
981c62d
Added Policy and Market Facet
Debugger022 Mar 7, 2023
8f86561
lint fix.
Debugger022 Mar 7, 2023
6cef23b
Added facet interface
Debugger022 Mar 7, 2023
53860a3
Update storage access in library
Debugger022 Mar 7, 2023
0f31c2a
Fix: lint fix
Debugger022 Mar 7, 2023
a41278c
Fix: lint fix
Debugger022 Mar 7, 2023
5756e61
Added library and refactored diamond facets.
Debugger022 Mar 10, 2023
b46f80d
Upgraded solidity version from 0.5.16 to 0.8.13.
Debugger022 Mar 10, 2023
ad098d4
Upgraded solidity version and refactor comptroller contracts.
Debugger022 Mar 10, 2023
12bf2f5
Upgraded solidity version and refactor vToken contracts.
Debugger022 Mar 10, 2023
83932ac
Upgraded solidity version and refactor Test contracts.
Debugger022 Mar 10, 2023
fdc8ff4
Upgraded solidity version from 0.5.16 to 0.8.13.
Debugger022 Mar 10, 2023
b234a2f
Fix: lint issues.
Debugger022 Mar 10, 2023
3cb18d7
Refactor LibHelper, PolicyFacet, RewardFacet and resolve errors.
Debugger022 Mar 10, 2023
25e26ba
Fixed lint.
Debugger022 Mar 10, 2023
5601101
Fix: minor issues.
Debugger022 Mar 13, 2023
310b950
Fixed tests.
Debugger022 Mar 13, 2023
56a541f
Added scripts for diamond proxy.
Debugger022 Mar 13, 2023
f819efe
Fixed some issues.
Debugger022 Mar 15, 2023
2f61258
Fixed diamond proxy issue.
Debugger022 Mar 17, 2023
12ee219
Added access control tests for diamond proxy.
Debugger022 Mar 17, 2023
910103e
Refactored diamond proxy deployment script.
Debugger022 Mar 20, 2023
b07d5a6
Added tests for comptroller's diamond proxy.
Debugger022 Mar 20, 2023
d6f81f0
Refactor VToken and ComptrollerLens.
Debugger022 Mar 22, 2023
295e315
Added getters in MarketFacet.
Debugger022 Mar 22, 2023
4a4a96d
Updated diamond test cases.
Debugger022 Mar 22, 2023
6aa8b44
Added diamond fork test.
Debugger022 Mar 22, 2023
169916e
Fixed test.
Debugger022 Mar 22, 2023
aa924bf
Update diamond fork test.
Debugger022 Mar 22, 2023
9baa703
Added rewards diamond fork test.
Debugger022 Mar 22, 2023
2b3e2ae
add: getter in Market facet
Debugger022 Mar 23, 2023
7b2eeeb
fix: script owner rights and facet calls
Debugger022 Mar 23, 2023
c9417cf
fix: no of optimizer runs
Debugger022 Mar 23, 2023
a87f3e7
fix: comptroller diamond test for script
Debugger022 Mar 23, 2023
3adf806
fix: diamond layout test
Debugger022 Mar 23, 2023
a412683
testEnv: add hardhat contract sizer
Debugger022 Mar 23, 2023
1f8263e
fix: script for unitrollerAddress empty
Debugger022 Mar 24, 2023
26ed072
remove: .only flag
Debugger022 Mar 24, 2023
b78a97e
Removed unwanted comptroller contracts.
Debugger022 Mar 28, 2023
a0e90e0
Added tests to verify storage.
Debugger022 Mar 28, 2023
f89e206
Refactored comptroller contracts.
Debugger022 Mar 28, 2023
b109e41
Reverted solidity version for unwanted contracts.
Debugger022 Mar 28, 2023
955c732
Added contracts with updated solidity version.
Debugger022 Mar 28, 2023
38996db
Refactored the tests.
Debugger022 Mar 28, 2023
4158bbb
Refactored diamond deploy script.
Debugger022 Mar 28, 2023
028693c
Added setter facet tests for diamond comptroller.
Debugger022 Mar 28, 2023
8295e84
Refactored tests for access control manager contract version.
Debugger022 Mar 28, 2023
cf8a951
Lint fix.
Debugger022 Mar 28, 2023
65c03bc
Fix lint issue.
Debugger022 Mar 28, 2023
d116671
Removed unsafe math from upper solidity version contracts.
Debugger022 Mar 28, 2023
ca044ff
Lint fix.
Debugger022 Mar 28, 2023
b4495e6
Stable solidity version.
Debugger022 Mar 28, 2023
10f8396
Minor fix.
Debugger022 Mar 28, 2023
628014f
Lint fix.
Debugger022 Mar 28, 2023
cb39d13
Minor fix.
Debugger022 Mar 28, 2023
f9f0ac0
Refactored tests.
Debugger022 Mar 29, 2023
67ee0f1
Diamond comptroller VIP.
Debugger022 Apr 3, 2023
d729c84
Minor fix.
Debugger022 Apr 4, 2023
bbb4182
lint fixes.
Debugger022 Apr 4, 2023
6b10ccd
Removed unwanted code.
Debugger022 Apr 5, 2023
7864c01
FIx PR comment.
Debugger022 Apr 5, 2023
a86ac91
Changes in the vip of the diamond proxy for comptroller.
Debugger022 Apr 7, 2023
2a634fb
fix: resolve issues in script files
Debugger022 Apr 19, 2023
7bbbe9b
test:added diamond vip for testnet and mainnet
Debugger022 Apr 19, 2023
8e211cd
fix:added dimaond hooks tests separately
Debugger022 Apr 20, 2023
a1e2f09
Refactor signature's args method.
Debugger022 Apr 21, 2023
e8f27e1
refactor: diamond proxy for comptroller.
Debugger022 May 3, 2023
d4d5f30
refactor: deployment script for diamond proxy.
Debugger022 May 3, 2023
50ecc1b
refactor: removed consoles.
Debugger022 May 3, 2023
5c4dcb9
refactor: removed all 0.8.13 version files.
Debugger022 May 3, 2023
363552b
refactor: revert new version in tests contracts.
Debugger022 May 4, 2023
f8f4eeb
refactor: revert all tests changes and added cut params for mainnet.
Debugger022 May 4, 2023
9f4d17d
refactor: added comments to the diamond proxy.
Debugger022 May 5, 2023
c7406bd
refactor: minor change in hardhat config.
Debugger022 May 5, 2023
22e3887
fix: lint errors.
Debugger022 May 5, 2023
3ab26f2
refactor: diamond tests.
Debugger022 May 12, 2023
de2cb91
refactor: move some common code.
Debugger022 May 12, 2023
0a0df60
refactor: added comments.
Debugger022 May 12, 2023
582ae89
refactor: added tests for diamond cut methods.
Debugger022 May 16, 2023
cc5c433
refactor: VEN-1452 script to generate cut params.
Debugger022 May 16, 2023
9d714c9
refactor: moved vips to vips repo.
Debugger022 May 18, 2023
16311ec
refactor: xvs rewards methods.
Debugger022 Jun 7, 2023
5cdaa26
fix: pr comments, used external instead of public
Debugger022 Jun 7, 2023
53a4dec
fix: pr comments, undo unwanted changes
Debugger022 Jun 7, 2023
295609e
fix: resolved conflicts, merged latest develop
Debugger022 Jun 7, 2023
68ef09b
fix: pr comments
Debugger022 Jun 9, 2023
fc2835e
refactor: removed comptroller.sol dependency
Debugger022 Jun 14, 2023
2371c98
test: moved tests to diamond folder
Debugger022 Jun 15, 2023
b254f90
test: added mock comptroller for tests
Debugger022 Jun 15, 2023
11041cf
test: refactored tests to use mock comptroller instead of comptroller
Debugger022 Jun 15, 2023
4c1222b
refactor: added missing view methods
Debugger022 Jun 15, 2023
3edb979
refactor: ven-1580 removed comptroller.sol
Debugger022 Jun 15, 2023
9ef6b75
fix: ven-1619 1.1 unnecessary immutable function
Debugger022 Jun 21, 2023
b5f701f
fix: ven-1619 2.1 added missing methods
Debugger022 Jun 21, 2023
0225801
fix: ven-1619 2.2, 2.3 moved MarketEntered event
Debugger022 Jun 21, 2023
8f5eeb5
fix: ven-1619 3.1 re-entrancy check in claimVenus
Debugger022 Jun 21, 2023
c256072
fix: ven-1619 3.3 shadowed variables in _setActionsPaused
Debugger022 Jun 21, 2023
d12981f
feat: ven-1619 3.4 added view methods for facets states
Debugger022 Jun 21, 2023
579b11b
refactor: ven-1619 3.4 added view methods for facets states
Debugger022 Jun 21, 2023
a46b205
fix: docgen issue
Debugger022 Jun 21, 2023
05ff797
fix: ven-1630 check for market not as collateral
Debugger022 Jun 28, 2023
f285dd1
fix: ven-1699 pve001
Debugger022 Jul 4, 2023
4598d00
fix: ven-1699 n1
Debugger022 Jul 4, 2023
13c0a92
fix: ven-1699 n2
Debugger022 Jul 4, 2023
b5ef58e
fix: ven-1699 pve002
Debugger022 Jul 4, 2023
249eaee
fix: resolved merge conflicts with develop branch
Debugger022 Jul 6, 2023
94bc2e4
fix: VEN-1686
Debugger022 Jul 7, 2023
c57d257
fix: enter markets return empty array
Debugger022 Jul 11, 2023
e762a5d
fix: gas-01
Debugger022 Jul 20, 2023
b3503c2
fix: gas-02
Debugger022 Jul 20, 2023
0aea270
fix: gas-06
Debugger022 Jul 20, 2023
0f769e1
fix : vd-004
Debugger022 Jul 20, 2023
9198069
tests: vd-004
Debugger022 Jul 21, 2023
558c29d
merge develop branch into feat/diamond-proxy
Debugger022 Jul 24, 2023
53a08eb
fix: ven-1757 vai-01 unnecesary remnant casting
Debugger022 Jul 24, 2023
c797f14
fix: ven-1759 ddc-04 diamond loupe methods
Debugger022 Jul 24, 2023
6982bc5
fix: removed unwanted checks from setTreasuryData
Debugger022 Jul 26, 2023
7417d8f
fix: ven-1759 ddc-04
Debugger022 Jul 26, 2023
3909ff7
refactor: netspec comments
Debugger022 Aug 3, 2023
6d0a33c
fix: ven-1795 n-01 n-03 n-09
Debugger022 Aug 4, 2023
0387b34
fix: ven-1795 n-04
Debugger022 Aug 4, 2023
5533343
fix: ven-1795 n-05
Debugger022 Aug 4, 2023
847afd7
fix: ven-1795 n-06
Debugger022 Aug 4, 2023
4596c2b
fix: ven-1795 n-07
Debugger022 Aug 4, 2023
b0f39a1
fix: ven-1795 n-08
Debugger022 Aug 4, 2023
4c72287
fix: ven-1795 test for n-08
Debugger022 Aug 4, 2023
4c72e43
fix: ven-1795 n-10
Debugger022 Aug 4, 2023
cfaa69a
fix: ven-1795 l-02
Debugger022 Aug 4, 2023
0aa7e17
fix: ven-1795 l-06
Debugger022 Aug 4, 2023
50761a0
fix: ven-1795 n-02
Debugger022 Aug 4, 2023
fd07edd
revert: ven-1795 changes for n-08
Debugger022 Aug 4, 2023
728d618
Merge pull request #312 from VenusProtocol/VEN-1795
chechu Aug 6, 2023
fb06750
merge branch 'develop' into feat/diamond-proxy
Debugger022 Aug 7, 2023
b745623
fix: ven-1887 ven-08
Debugger022 Aug 28, 2023
0e24ded
fix: ven-1887 ven-12
Debugger022 Aug 28, 2023
c60497a
fix: ven-1887 ven-04
Debugger022 Aug 28, 2023
d09d8d3
fix: lint
Debugger022 Aug 28, 2023
fa26e52
fix: replaced And operator with OR while checking cutoff
Debugger022 Sep 1, 2023
547f77f
refactor: netspec comments
Debugger022 Sep 4, 2023
cf9c7cb
feat: force liquidation implementation
Debugger022 Sep 7, 2023
c563562
Revert "fix: ven-1887 ven-12"
Debugger022 Sep 8, 2023
a34816a
fix: lint
Debugger022 Sep 8, 2023
df08df4
[VEN-1887]: Quantstamp audit fix for comptroller diamond proxy (#328)
Debugger022 Sep 8, 2023
9af2d4a
Revert "[VEN-1887]: Quantstamp audit fix for comptroller diamond prox…
Debugger022 Sep 8, 2023
3586e05
Merge pull request #338 from VenusProtocol/VEN-1887
Debugger022 Sep 8, 2023
0af25d4
refactor: optimized code
Debugger022 Sep 9, 2023
b4ddc09
fix: resolved conflicts
Debugger022 Sep 9, 2023
1f1b0f9
fix: resolved conflicts
Debugger022 Sep 11, 2023
35b5517
fix: pr comments
Debugger022 Sep 11, 2023
e6e9ca5
fix: merge branch 'develop' into feat/diamond-proxy
Debugger022 Sep 11, 2023
032cc8e
fix: updated yarn.lock
Debugger022 Sep 11, 2023
3313948
Merge pull request #335 from VenusProtocol/feat/force-liquidation-dia…
Debugger022 Sep 12, 2023
6c0d496
Merge branch 'develop' into feat/diamond-proxy
web3rover Sep 14, 2023
456ad85
docs: add natspect to _setForcedLiquidation
chechu Sep 18, 2023
e3621e3
fix: resolve merge conflicts
Debugger022 Sep 19, 2023
0710b66
fix: pr comments
Debugger022 Sep 19, 2023
a1d991f
fix: moved diamond's facets script
Debugger022 Sep 22, 2023
66f90f4
feat: diamond proxy implementation of comptroller
Debugger022 Sep 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,581 changes: 0 additions & 1,581 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.

11 changes: 11 additions & 0 deletions contracts/Comptroller/ComptrollerInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pragma solidity ^0.5.16;

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

contract ComptrollerInterfaceG1 {
kkirka marked this conversation as resolved.
Show resolved Hide resolved
/// @notice Indicator that this is a Comptroller contract (for inspection)
Expand Down Expand Up @@ -138,6 +139,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
66 changes: 43 additions & 23 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 public venusRate;
uint256 public venusRate;

/// @notice The portion of venusRate that each market currently receives
mapping(address => uint) public venusSpeeds;
mapping(address => uint256) public 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,19 +220,37 @@ 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 {
/// @notice Whether the delegate is allowed to borrow on behalf of the borrower
//mapping(address borrower => mapping (address delegate => bool approved)) public approvedDelegates;
mapping(address => mapping(address => bool)) public approvedDelegates;
}

contract ComptrollerV12Storage is ComptrollerV11Storage {
struct FacetAddressAndPosition {
address facetAddress;
chechu marked this conversation as resolved.
Show resolved Hide resolved
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
Loading