From eb2a5c4de0d9573418055ee9c69e7043fea06af4 Mon Sep 17 00:00:00 2001 From: defcon022 Date: Fri, 10 Mar 2023 18:57:42 +0530 Subject: [PATCH] Upgraded solidity version from 0.5.16 to 0.8.13. --- contracts/Governance/GovernorAlpha2.sol | 2 +- contracts/Governance/Timelock.sol | 6 +++--- contracts/Governance/VTreasury.sol | 4 ++-- contracts/InterestRateModels/InterestRateModel.sol | 8 ++++---- contracts/InterestRateModels/JumpRateModel.sol | 6 +++--- .../WhitePaperInterestRateModel.sol | 6 +++--- contracts/Lens/ComptrollerLens.sol | 2 +- contracts/Oracle/PriceOracle.sol | 6 +++--- contracts/Utils/Context.sol | 6 +++--- contracts/VRTVault/VRTVaultProxy.sol | 12 ++++++------ contracts/XVSVault/XVSVaultProxy.sol | 10 +++++----- 11 files changed, 34 insertions(+), 34 deletions(-) diff --git a/contracts/Governance/GovernorAlpha2.sol b/contracts/Governance/GovernorAlpha2.sol index c009718df..2bd49f127 100644 --- a/contracts/Governance/GovernorAlpha2.sol +++ b/contracts/Governance/GovernorAlpha2.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.5.16; +pragma solidity 0.8.13; pragma experimental ABIEncoderV2; contract GovernorAlpha2 { diff --git a/contracts/Governance/Timelock.sol b/contracts/Governance/Timelock.sol index b20cb4ebf..e35a81960 100644 --- a/contracts/Governance/Timelock.sol +++ b/contracts/Governance/Timelock.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.5.16; +pragma solidity 0.8.13; import "../Utils/SafeMath.sol"; @@ -51,7 +51,7 @@ contract Timelock { delay = delay_; } - function() external payable {} + receive() external payable {} function setDelay(uint delay_) public { require(msg.sender == address(this), "Timelock::setDelay: Call must come from Timelock."); @@ -137,7 +137,7 @@ contract Timelock { } // solium-disable-next-line security/no-call-value - (bool success, bytes memory returnData) = target.call.value(value)(callData); + (bool success, bytes memory returnData) = target.call{ value: value }(callData); require(success, "Timelock::executeTransaction: Transaction execution reverted."); emit ExecuteTransaction(txHash, target, value, signature, data, eta); diff --git a/contracts/Governance/VTreasury.sol b/contracts/Governance/VTreasury.sol index 22bd3fc80..bc290538d 100644 --- a/contracts/Governance/VTreasury.sol +++ b/contracts/Governance/VTreasury.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.5.16; +pragma solidity 0.8.13; import "../Utils/IBEP20.sol"; import "../Utils/SafeBEP20.sol"; @@ -20,7 +20,7 @@ contract VTreasury is Ownable { /** * @notice To receive BNB */ - function() external payable {} + receive() external payable {} /** * @notice Withdraw Treasury BEP20 Tokens, Only owner call it diff --git a/contracts/InterestRateModels/InterestRateModel.sol b/contracts/InterestRateModels/InterestRateModel.sol index 654f4040a..3cd21808a 100644 --- a/contracts/InterestRateModels/InterestRateModel.sol +++ b/contracts/InterestRateModels/InterestRateModel.sol @@ -1,10 +1,10 @@ -pragma solidity ^0.5.16; +pragma solidity 0.8.13; /** * @title Venus's InterestRateModel Interface * @author Venus */ -contract InterestRateModel { +abstract contract InterestRateModel { /// @notice Indicator that this is an InterestRateModel contract (for inspection) bool public constant isInterestRateModel = true; @@ -15,7 +15,7 @@ contract InterestRateModel { * @param reserves The total amnount of reserves the market has * @return The borrow rate per block (as a percentage, and scaled by 1e18) */ - function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint); + function getBorrowRate(uint cash, uint borrows, uint reserves) external view virtual returns (uint); /** * @notice Calculates the current supply interest rate per block @@ -30,5 +30,5 @@ contract InterestRateModel { uint borrows, uint reserves, uint reserveFactorMantissa - ) external view returns (uint); + ) external view virtual returns (uint); } diff --git a/contracts/InterestRateModels/JumpRateModel.sol b/contracts/InterestRateModels/JumpRateModel.sol index a1254aced..48f49e219 100644 --- a/contracts/InterestRateModels/JumpRateModel.sol +++ b/contracts/InterestRateModels/JumpRateModel.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.5.16; +pragma solidity 0.8.13; import "../Utils/SafeMath.sol"; import "./InterestRateModel.sol"; @@ -76,7 +76,7 @@ contract JumpRateModel is InterestRateModel { * @param reserves The amount of reserves in the market * @return The borrow rate percentage per block as a mantissa (scaled by 1e18) */ - function getBorrowRate(uint cash, uint borrows, uint reserves) public view returns (uint) { + function getBorrowRate(uint cash, uint borrows, uint reserves) public view override returns (uint) { uint util = utilizationRate(cash, borrows, reserves); if (util <= kink) { @@ -101,7 +101,7 @@ contract JumpRateModel is InterestRateModel { uint borrows, uint reserves, uint reserveFactorMantissa - ) public view returns (uint) { + ) public view override returns (uint) { uint oneMinusReserveFactor = uint(1e18).sub(reserveFactorMantissa); uint borrowRate = getBorrowRate(cash, borrows, reserves); uint rateToPool = borrowRate.mul(oneMinusReserveFactor).div(1e18); diff --git a/contracts/InterestRateModels/WhitePaperInterestRateModel.sol b/contracts/InterestRateModels/WhitePaperInterestRateModel.sol index 962f4d73d..e30fcdd53 100644 --- a/contracts/InterestRateModels/WhitePaperInterestRateModel.sol +++ b/contracts/InterestRateModels/WhitePaperInterestRateModel.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.5.16; +pragma solidity 0.8.13; import "../Utils/SafeMath.sol"; import "./InterestRateModel.sol"; @@ -63,7 +63,7 @@ contract WhitePaperInterestRateModel is InterestRateModel { * @param reserves The amount of reserves in the market * @return The borrow rate percentage per block as a mantissa (scaled by 1e18) */ - function getBorrowRate(uint cash, uint borrows, uint reserves) public view returns (uint) { + function getBorrowRate(uint cash, uint borrows, uint reserves) public view override returns (uint) { uint ur = utilizationRate(cash, borrows, reserves); return ur.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock); } @@ -81,7 +81,7 @@ contract WhitePaperInterestRateModel is InterestRateModel { uint borrows, uint reserves, uint reserveFactorMantissa - ) public view returns (uint) { + ) public view override returns (uint) { uint oneMinusReserveFactor = uint(1e18).sub(reserveFactorMantissa); uint borrowRate = getBorrowRate(cash, borrows, reserves); uint rateToPool = borrowRate.mul(oneMinusReserveFactor).div(1e18); diff --git a/contracts/Lens/ComptrollerLens.sol b/contracts/Lens/ComptrollerLens.sol index b5a296a47..c474d843c 100644 --- a/contracts/Lens/ComptrollerLens.sol +++ b/contracts/Lens/ComptrollerLens.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.5.16; +pragma solidity 0.8.13; pragma experimental ABIEncoderV2; import "../Tokens/VTokens/VBep20.sol"; diff --git a/contracts/Oracle/PriceOracle.sol b/contracts/Oracle/PriceOracle.sol index 15f44c18b..219cfe34f 100644 --- a/contracts/Oracle/PriceOracle.sol +++ b/contracts/Oracle/PriceOracle.sol @@ -1,8 +1,8 @@ -pragma solidity ^0.5.16; +pragma solidity ^0.8.13; import "../Tokens/VTokens/VToken.sol"; -contract PriceOracle { +abstract contract PriceOracle { /// @notice Indicator that this is a PriceOracle contract (for inspection) bool public constant isPriceOracle = true; @@ -12,5 +12,5 @@ contract PriceOracle { * @return The underlying asset price mantissa (scaled by 1e18). * Zero means the price is unavailable. */ - function getUnderlyingPrice(VToken vToken) external view returns (uint); + function getUnderlyingPrice(VToken vToken) external view virtual returns (uint); } diff --git a/contracts/Utils/Context.sol b/contracts/Utils/Context.sol index 24a7f00ec..ff604b6bf 100644 --- a/contracts/Utils/Context.sol +++ b/contracts/Utils/Context.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.5.16; +pragma solidity 0.8.13; /* * @dev Provides information about the current execution context, including the @@ -10,13 +10,13 @@ pragma solidity ^0.5.16; * * This contract is only required for intermediate, library-like contracts. */ -contract Context { +abstract contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor() internal {} function _msgSender() internal view returns (address payable) { - return msg.sender; + return payable(msg.sender); } function _msgData() internal view returns (bytes memory) { diff --git a/contracts/VRTVault/VRTVaultProxy.sol b/contracts/VRTVault/VRTVaultProxy.sol index 5f8e605fe..1c3dd8ab3 100644 --- a/contracts/VRTVault/VRTVaultProxy.sol +++ b/contracts/VRTVault/VRTVaultProxy.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.5.16; +pragma solidity 0.8.13; import "./VRTVaultStorage.sol"; @@ -62,7 +62,7 @@ contract VRTVaultProxy is VRTVaultAdminStorage { (bool success, bytes memory returnData) = callee.delegatecall(data); assembly { if eq(success, 0) { - revert(add(returnData, 0x20), returndatasize) + revert(add(returnData, 0x20), returndatasize()) } } return returnData; @@ -149,20 +149,20 @@ contract VRTVaultProxy is VRTVaultAdminStorage { * It returns to the external caller whatever the implementation returns * or forwards reverts. */ - function() external payable { + fallback() external payable { // delegate all other functions to current implementation (bool success, ) = implementation.delegatecall(msg.data); assembly { let free_mem_ptr := mload(0x40) - returndatacopy(free_mem_ptr, 0, returndatasize) + returndatacopy(free_mem_ptr, 0, returndatasize()) switch success case 0 { - revert(free_mem_ptr, returndatasize) + revert(free_mem_ptr, returndatasize()) } default { - return(free_mem_ptr, returndatasize) + return(free_mem_ptr, returndatasize()) } } } diff --git a/contracts/XVSVault/XVSVaultProxy.sol b/contracts/XVSVault/XVSVaultProxy.sol index b37c07c03..3d7f331a0 100644 --- a/contracts/XVSVault/XVSVaultProxy.sol +++ b/contracts/XVSVault/XVSVaultProxy.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.5.16; +pragma solidity 0.8.13; import "./XVSVaultStorage.sol"; import "./XVSVaultErrorReporter.sol"; @@ -125,20 +125,20 @@ contract XVSVaultProxy is XVSVaultAdminStorage, XVSVaultErrorReporter { * It returns to the external caller whatever the implementation returns * or forwards reverts. */ - function() external payable { + fallback() external payable { // delegate all other functions to current implementation (bool success, ) = implementation.delegatecall(msg.data); assembly { let free_mem_ptr := mload(0x40) - returndatacopy(free_mem_ptr, 0, returndatasize) + returndatacopy(free_mem_ptr, 0, returndatasize()) switch success case 0 { - revert(free_mem_ptr, returndatasize) + revert(free_mem_ptr, returndatasize()) } default { - return(free_mem_ptr, returndatasize) + return(free_mem_ptr, returndatasize()) } } }