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-2100]: Feat timestamp based contracts #324

Merged
merged 31 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
92e8e75
feat: add timestamp based contract functionality
Debugger022 Dec 1, 2023
671c4b3
Merge branch 'develop' into VEN-2100
Debugger022 Dec 1, 2023
d6aeca8
refactor: update getBlockOrTimestampBasedDeploymentInfo function
Debugger022 Dec 4, 2023
2534ca7
refactor: removed TimeManager contract
GitGuru7 Dec 21, 2023
c0d60df
fix: condition for selection of blocks
GitGuru7 Dec 22, 2023
3063e64
Merge pull request #338 from VenusProtocol/feat/VEN-2258
chechu Dec 22, 2023
e1cdb75
fix: SSV-01
Debugger022 Jan 10, 2024
18c14e6
Merge branch 'develop' into VEN-2100
Debugger022 Jan 10, 2024
88265c3
fix: VPB-01 value naming should be updated to reflect possible time-b…
Debugger022 Jan 10, 2024
ee4c083
fix: VPB-03 maximum should depend on chain and whether the contracts …
Debugger022 Jan 10, 2024
25ed2b1
fixup: VPB-01 value naming should be updated to reflect possible time…
Debugger022 Jan 11, 2024
59b1413
fix: VPB-02 confirmation on the handling of updated time-based contracts
Debugger022 Jan 11, 2024
1ab27b3
refactor: added natspec comments
Debugger022 Jan 11, 2024
d6311f2
refactor: move storage of shortfall and rewardsDistributor to separat…
Debugger022 Jan 12, 2024
c749e0d
feat: add function to pick borrow rate and bidder values according to…
Debugger022 Jan 12, 2024
408f033
fixup: SSV-01 block number-based variables should be made immutable
Debugger022 Jan 15, 2024
e16e4c7
fixup: VPB-01 value naming should be updated to reflect possible time…
Debugger022 Jan 15, 2024
3d5b379
Merge branch 'develop' into VEN-2100
Debugger022 Feb 26, 2024
1a6cf0c
fix: scope 1 fetch TimeBased mappings from reward distributor in pool…
Debugger022 Feb 26, 2024
119e981
Merge branch 'develop' into VEN-2100
Debugger022 Mar 13, 2024
4626a10
fix: VTIME-5
Debugger022 Mar 13, 2024
e57c00d
fix: VTIME-4
Debugger022 Mar 13, 2024
d61191c
fix: VTIME-3
Debugger022 Mar 13, 2024
aa1f7ae
docs: add audit reports from Fairyproof and Certik about time based c…
chechu Mar 17, 2024
0e557ff
Merge branch 'develop' into VEN-2100
Debugger022 Mar 19, 2024
4704168
docs: add the quantstamp audit report for the time-based contracts
chechu Mar 19, 2024
04687f7
fix: resolved merge conflicts
Debugger022 Apr 5, 2024
0408def
refactor: add isTimeBased return variable in vTokenMatedata struct an…
Debugger022 Apr 5, 2024
d530bba
Merge branch 'develop' into VEN-2100
Debugger022 Apr 19, 2024
1cd1a70
feat: update solidity version and solidity-utilities package
Debugger022 Apr 19, 2024
4445bde
fix: resolved conflicts
Debugger022 Apr 19, 2024
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
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ ETHERSCAN_API_KEY=

# Set to true or false to control gas reporting
REPORT_GAS=

# Set to true or false to deploy contracts based on timestamp or block
IS_TIME_BASED_DEPLOYMENT=false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ REPORT_GAS=true npx hardhat test

```

- To run fork tests add FORK_MAINNET=true and QUICK_NODE_KEY in the .env file.
- To run fork tests add FORK=true, FORKED_NETWORK and one ARCHIVE_NODE var in the .env file.

## Deployment

Expand Down
Binary file added audits/088_timeBased_certik_20240117.pdf
Binary file not shown.
Binary file added audits/089_timeBased_quantstamp_20240319.pdf
Binary file not shown.
Binary file added audits/094_timeBased_fairyproof_20240304.pdf
Binary file not shown.
207 changes: 0 additions & 207 deletions contracts/BaseJumpRateModelV2.sol

This file was deleted.

2 changes: 1 addition & 1 deletion contracts/Comptroller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
{
// PoolRegistry, immutable to save on gas
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address public immutable poolRegistry;

Check warning on line 50 in contracts/Comptroller.sol

View workflow job for this annotation

GitHub Actions / Lint

Immutable variables name are set to be in capitalized SNAKE_CASE

/// @notice Emitted when an account enters a market
event MarketEntered(VToken indexed vToken, address indexed account);
Expand Down Expand Up @@ -382,7 +382,7 @@
* @param redeemAmount The amount of the underlying asset being redeemed
* @param redeemTokens The number of tokens being redeemed
*/
function redeemVerify(address vToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external {

Check warning on line 385 in contracts/Comptroller.sol

View workflow job for this annotation

GitHub Actions / Lint

Variable "redeemAmount" is unused

Check warning on line 385 in contracts/Comptroller.sol

View workflow job for this annotation

GitHub Actions / Lint

Variable "redeemTokens" is unused
if (address(prime) != address(0)) {
prime.accrueInterestAndUpdateScore(redeemer, vToken);
}
Expand Down Expand Up @@ -865,7 +865,7 @@

for (uint256 i; i < marketsCount; ++i) {
(, uint256 borrowBalance, ) = _safeGetAccountSnapshot(borrowMarkets[i], borrower);
require(borrowBalance == 0, "Nonzero borrow balance after liquidation");

Check warning on line 868 in contracts/Comptroller.sol

View workflow job for this annotation

GitHub Actions / Lint

Use Custom Errors instead of require statements
}
}

Expand All @@ -877,8 +877,8 @@
*/
function setCloseFactor(uint256 newCloseFactorMantissa) external {
_checkAccessAllowed("setCloseFactor(uint256)");
require(MAX_CLOSE_FACTOR_MANTISSA >= newCloseFactorMantissa, "Close factor greater than maximum close factor");

Check warning on line 880 in contracts/Comptroller.sol

View workflow job for this annotation

GitHub Actions / Lint

Use Custom Errors instead of require statements
require(MIN_CLOSE_FACTOR_MANTISSA <= newCloseFactorMantissa, "Close factor smaller than minimum close factor");

Check warning on line 881 in contracts/Comptroller.sol

View workflow job for this annotation

GitHub Actions / Lint

Use Custom Errors instead of require statements

uint256 oldCloseFactorMantissa = closeFactorMantissa;
closeFactorMantissa = newCloseFactorMantissa;
Expand Down Expand Up @@ -953,7 +953,7 @@
* @custom:access Controlled by AccessControlManager
*/
function setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external {
require(newLiquidationIncentiveMantissa >= MANTISSA_ONE, "liquidation incentive should be greater than 1e18");

Check warning on line 956 in contracts/Comptroller.sol

View workflow job for this annotation

GitHub Actions / Lint

Use Custom Errors instead of require statements

_checkAccessAllowed("setLiquidationIncentive(uint256)");

Expand Down Expand Up @@ -981,7 +981,7 @@
revert MarketAlreadyListed(address(vToken));
}

require(vToken.isVToken(), "Comptroller: Invalid vToken"); // Sanity check to make sure its really a VToken

Check warning on line 984 in contracts/Comptroller.sol

View workflow job for this annotation

GitHub Actions / Lint

Use Custom Errors instead of require statements

Market storage newMarket = markets[address(vToken)];
newMarket.isListed = true;
Expand Down Expand Up @@ -1015,7 +1015,7 @@
uint256 numMarkets = vTokens.length;
uint256 numBorrowCaps = newBorrowCaps.length;

require(numMarkets != 0 && numMarkets == numBorrowCaps, "invalid input");

Check warning on line 1018 in contracts/Comptroller.sol

View workflow job for this annotation

GitHub Actions / Lint

Use Custom Errors instead of require statements

_ensureMaxLoops(numMarkets);

Expand All @@ -1039,7 +1039,7 @@
_checkAccessAllowed("setMarketSupplyCaps(address[],uint256[])");
uint256 vTokensCount = vTokens.length;

require(vTokensCount != 0, "invalid number of markets");

Check warning on line 1042 in contracts/Comptroller.sol

View workflow job for this annotation

GitHub Actions / Lint

Use Custom Errors instead of require statements
require(vTokensCount == newSupplyCaps.length, "invalid number of markets");

_ensureMaxLoops(vTokensCount);
Expand Down Expand Up @@ -1091,7 +1091,7 @@

/**
* @notice Add a new RewardsDistributor and initialize it with all markets. We can add several RewardsDistributor
* contracts with the same rewardToken, and there could be overlaping among them considering the last reward block
* contracts with the same rewardToken, and there could be overlaping among them considering the last reward slot (block or second)
* @dev Only callable by the admin
* @param _rewardsDistributor Address of the RewardDistributor contract to add
* @custom:access Only Governance
Expand Down
8 changes: 4 additions & 4 deletions contracts/InterestRateModel.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ pragma solidity 0.8.13;
*/
abstract contract InterestRateModel {
/**
* @notice Calculates the current borrow interest rate per block
* @notice Calculates the current borrow interest rate per slot (block or second)
* @param cash The total amount of cash the market has
* @param borrows The total amount of borrows the market has outstanding
* @param reserves The total amount of reserves the market has
* @param badDebt The amount of badDebt in the market
* @return The borrow rate per block (as a percentage, and scaled by 1e18)
* @return The borrow rate percentage per slot (block or second) as a mantissa (scaled by EXP_SCALE)
*/
function getBorrowRate(
uint256 cash,
Expand All @@ -22,13 +22,13 @@ abstract contract InterestRateModel {
) external view virtual returns (uint256);

/**
* @notice Calculates the current supply interest rate per block
* @notice Calculates the current supply interest rate per slot (block or second)
* @param cash The total amount of cash the market has
* @param borrows The total amount of borrows the market has outstanding
* @param reserves The total amount of reserves the market has
* @param reserveFactorMantissa The current reserve factor the market has
* @param badDebt The amount of badDebt in the market
* @return The supply rate per block (as a percentage, and scaled by 1e18)
* @return The supply rate percentage per slot (block or second) as a mantissa (scaled by EXP_SCALE)
*/
function getSupplyRate(
uint256 cash,
Expand Down
Loading
Loading