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

Update compiler versions, eliminate safeMath dependency, and refactor safeMath arithmetic in smart contracts #4

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
8e6dd3d
update contracts/Errors.sol: refactored SafeMath expressions
Dec 13, 2024
7461f98
update contracts/reqCoinProxy.sol: refactored SafeMath expressions
Dec 13, 2024
8b01297
update contracts/reqTokenProxy.sol: refactored SafeMath expressions
Dec 13, 2024
9495c1d
update contracts/SafeMath.sol: refactored SafeMath expressions
Dec 13, 2024
2360d7d
update contracts/marketHandler/tokenSI.sol: refactored SafeMath expre…
Dec 13, 2024
dce68dd
update contracts/marketHandler/coinHandler.sol: refactored SafeMath e…
Dec 13, 2024
299cdd4
update contracts/marketHandler/coinSI.sol: refactored SafeMath expres…
Dec 13, 2024
bd99bef
update contracts/marketHandler/tokenHandler.sol: refactored SafeMath …
Dec 13, 2024
60bf7e7
update contracts/marketHandler/marketHandlerDataStorage/marketSIHandl…
Dec 13, 2024
9a584a5
update contracts/marketHandler/marketHandlerDataStorage/handlerDataSt…
Dec 13, 2024
cfa1b08
update contracts/truffleKit/tokens.sol: refactored SafeMath expressions
Dec 13, 2024
191fb3c
update contracts/truffleKit/LiquidationManager.sol: refactored SafeMa…
Dec 13, 2024
5437db4
update contracts/truffleKit/InterestModel.sol: refactored SafeMath ex…
Dec 13, 2024
9f9ddcb
update contracts/truffleKit/marketManagerSide/ManagerDataStorages.sol…
Dec 13, 2024
e781f0c
update contracts/truffleKit/marketManagerSide/Manager.sol: refactored…
Dec 13, 2024
4797efa
update contracts/truffleKit/OracleSide/chainlinkOracles.sol: refactor…
Dec 13, 2024
0e0809a
update contracts/truffleKit/OracleSide/OracleProxy.sol: refactored Sa…
Dec 13, 2024
1856296
update contracts/truffleKit/marketHandlerSide/marketHandlerLogics.sol…
Dec 13, 2024
a410607
update contracts/truffleKit/marketHandlerSide/marketHandlerProxys.sol…
Dec 13, 2024
ba40905
update contracts/truffleKit/marketHandlerSide/marketHandlerDataStorag…
Dec 13, 2024
c6291a2
update contracts/truffleKit/siHandlerSide/siDataStorages.sol: refacto…
Dec 13, 2024
6a5c510
update contracts/truffleKit/siHandlerSide/siHandlerLogics.sol: refact…
Dec 13, 2024
50f6151
update contracts/oracle/bscChainlinkOracle.sol: refactored SafeMath e…
Dec 13, 2024
b62c928
update contracts/oracle/oracle.sol: refactored SafeMath expressions
Dec 13, 2024
89f1180
update contracts/oracle/oracleProxy.sol: refactored SafeMath expressions
Dec 13, 2024
bef4bb7
update contracts/observer/observer.sol: refactored SafeMath expressions
Dec 13, 2024
ed0ef3d
update contracts/tokenStandard/token.sol: refactored SafeMath express…
Dec 13, 2024
d8bb6ef
update contracts/tokenStandard/openzeppelinERC20.sol: refactored Safe…
Dec 13, 2024
d4ea749
update contracts/tokenStandard/standardIERC20.sol: refactored SafeMat…
Dec 13, 2024
e1b7526
update contracts/marketManager/tokenManager.sol: refactored SafeMath …
Dec 13, 2024
689b976
update contracts/marketManager/liquidationManager.sol: refactored Saf…
Dec 13, 2024
8494feb
update contracts/marketManager/managerDataStorage/managerDataStorage.…
Dec 13, 2024
45e7188
update contracts/front/callProxy.sol: refactored SafeMath expressions
Dec 13, 2024
dc78cf0
update contracts/interestModel/interestModel.sol: refactored SafeMath…
Dec 13, 2024
dcb11f0
update contracts/interfaces/marketHandlerInterface.sol: refactored Sa…
Dec 13, 2024
069598d
update contracts/interfaces/marketHandlerDataStorageInterface.sol: re…
Dec 13, 2024
5d4b715
update contracts/interfaces/liquidationManagerInterface.sol: refactor…
Dec 13, 2024
0392513
update contracts/interfaces/SIInterface.sol: refactored SafeMath expr…
Dec 13, 2024
9b6ca14
update contracts/interfaces/observerInterface.sol: refactored SafeMat…
Dec 13, 2024
4e7b9fe
update contracts/interfaces/oracleInterface.sol: refactored SafeMath …
Dec 13, 2024
5aa4c0e
update contracts/interfaces/oracleProxyInterface.sol: refactored Safe…
Dec 13, 2024
90a3061
update contracts/interfaces/marketSIHandlerDataStorageInterface.sol: …
Dec 13, 2024
3db694b
update contracts/interfaces/proxyContractInterface.sol: refactored Sa…
Dec 13, 2024
5aaab38
update contracts/interfaces/marketManagerInterface.sol: refactored Sa…
Dec 13, 2024
713c403
update contracts/interfaces/managerDataStorageInterface.sol: refactor…
Dec 13, 2024
21eff0d
update contracts/interfaces/interestModelInterface.sol: refactored Sa…
Dec 13, 2024
0a374c5
update contracts/interfaces/tokenInterface.sol: refactored SafeMath e…
Dec 13, 2024
8854155
update contracts/interfacesForManager/managerDataStorageInterfaceForM…
Dec 13, 2024
63003e2
update contracts/interfacesForManager/oracleProxyInterfaceForManager.…
Dec 13, 2024
d075072
Remove blank spaces in interestModel.sol
floor-licker Dec 13, 2024
7fa674f
Remove blank spaces in interestModel.sol
floor-licker Dec 13, 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
2 changes: 1 addition & 1 deletion contracts/Errors.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

contract Modifier {
string internal constant ONLY_OWNER = "O";
Expand Down
2 changes: 1 addition & 1 deletion contracts/SafeMath.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity ^0.6.12;
pragma solidity ^0.8.0;

// from: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/SafeMath.sol
// Subject to the MIT license.
Expand Down
2 changes: 1 addition & 1 deletion contracts/front/callProxy.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import "../interfaces/marketManagerInterface.sol";
Expand Down
24 changes: 11 additions & 13 deletions contracts/interestModel/interestModel.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

import "../interfaces/interestModelInterface.sol";
import "../interfaces/marketHandlerDataStorageInterface.sol";
import "../SafeMath.sol";
import "../Errors.sol";

/**
Expand All @@ -13,7 +12,6 @@ import "../Errors.sol";
* @author BiFi(seinmyung25, Miller-kk, tlatkdgus1, dongchangYoo)
*/
contract interestModel is interestModelInterface, InterestErrors {
using SafeMath for uint256;

address owner;
mapping(address => bool) public operators;
Expand Down Expand Up @@ -182,7 +180,7 @@ contract interestModel is interestModelInterface, InterestErrors {
function _viewInterestAmount(address handlerDataStorageAddr, address payable userAddr) internal view returns (bool, uint256, uint256, bool, uint256, uint256)
{
marketHandlerDataStorageInterface handlerDataStorage = marketHandlerDataStorageInterface(handlerDataStorageAddr);
uint256 blockDelta = block.number.sub(handlerDataStorage.getLastUpdatedBlock());
uint256 blockDelta = block.number - handlerDataStorage.getLastUpdatedBlock();
/* check action in block */
uint256 globalDepositEXR;
uint256 globalBorrowEXR;
Expand Down Expand Up @@ -248,18 +246,18 @@ contract interestModel is interestModelInterface, InterestErrors {
uint256 _jmpPoint = jumpPoint;
/* BIR = minimumRate + (UtilRate * liquiditySensitivity) */
if(utilRate < _jmpPoint) {
BIR = utilRate.unifiedMul(basicSensitivity).add(minRate);
BIR = utilRate.unifiedMul(basicSensitivity) + minRate;
} else {
/*
Formula : BIR = minRate + jumpPoint * basicSensitivity + (utilRate - jumpPoint) * jumpSensitivity

uint256 _baseBIR = _jmpPoint.unifiedMul(basicSensitivity);
uint256 _jumpBIR = utilRate.sub(_jmpPoint).unifiedMul(jumpSensitivity);
BIR = minRate.add(_baseBIR).add(_jumpBIR);
uint256 _jumpBIR = utilRate - _jmpPoint.unifiedMul(jumpSensitivity);
BIR = minRate + _baseBIR + _jumpBIR;
*/
BIR = minRate
.add( _jmpPoint.unifiedMul(basicSensitivity) )
.add( utilRate.sub(_jmpPoint).unifiedMul(jumpSensitivity) );
+ _jmpPoint.unifiedMul(basicSensitivity)
+ utilRate - _jmpPoint.unifiedMul(jumpSensitivity);
}

/* SIR = UtilRate * BIR */
Expand All @@ -278,7 +276,7 @@ contract interestModel is interestModelInterface, InterestErrors {
uint256 SIR;
uint256 BIR;
(SIR, BIR) = _getSIRandBIR(depositTotalAmount, borrowTotalAmount);
return ( SIR.div(blocksPerYear), BIR.div(blocksPerYear) );
return ( SIR / blocksPerYear, BIR / blocksPerYear );
}

/**
Expand All @@ -290,7 +288,7 @@ contract interestModel is interestModelInterface, InterestErrors {
*/
function _getNewGlobalEXR(uint256 actionEXR, uint256 interestRate, uint256 delta) internal pure returns (uint256)
{
return interestRate.mul(delta).add(unifiedPoint).unifiedMul(actionEXR);
return interestRate * delta + unifiedPoint.unifiedMul(actionEXR);
}

/**
Expand Down Expand Up @@ -325,10 +323,10 @@ contract interestModel is interestModelInterface, InterestErrors {
uint256 EXR = newGlobalEXR.unifiedDiv(lastUserEXR);
if (EXR >= unifiedPoint)
{
return ( false, EXR.sub(unifiedPoint) );
return (false, EXR - unifiedPoint);
}

return ( true, unifiedPoint.sub(EXR) );
return (true, unifiedPoint - EXR);
}
//TODO: Need comment
function getMinRate() external view returns (uint256) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/SIInterface.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

/**
* @title BiFi's si interface
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/interestModelInterface.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

/**
* @title BiFi's interest model interface
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/liquidationManagerInterface.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

/**
* @title BiFi's liquidation manager interface
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/managerDataStorageInterface.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

/**
* @title BiFi's manager data storage interface
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/marketHandlerDataStorageInterface.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

/**
* @title BiFi's market handler data storage interface
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/marketHandlerInterface.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

/**
* @title BiFi's market handler interface
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/marketManagerInterface.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

/**
* @title BiFi's market manager interface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

/**
* @title BiFi's market si handler data storage interface
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/observerInterface.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

/**
* @title BiFi's observer interface
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/oracleInterface.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/oracleProxyInterface.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

/**
* @title BiFi's oracle proxy interface
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/proxyContractInterface.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

/**
* @title BiFi's proxy interface
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/tokenInterface.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
// from: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol
pragma solidity 0.6.12;
pragma solidity ^0.8.0;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

/**
* @title BiFi's manager data storage interface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

/**
* @title BiFi's oracle proxy interface
Expand Down
2 changes: 1 addition & 1 deletion contracts/marketHandler/coinHandler.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

import "../interfaces/marketHandlerInterface.sol";
import "../interfaces/marketHandlerDataStorageInterface.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/marketHandler/coinSI.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

import "../interfaces/SIInterface.sol";
import "../interfaces/marketHandlerDataStorageInterface.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

import "../../interfaces/marketHandlerDataStorageInterface.sol";
import "../../Errors.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

import "../../interfaces/marketSIHandlerDataStorageInterface.sol";
import "../../Errors.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/marketHandler/tokenHandler.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

import "../interfaces/marketHandlerInterface.sol";
import "../interfaces/marketHandlerDataStorageInterface.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/marketHandler/tokenSI.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

import "../interfaces/SIInterface.sol";
import "../interfaces/marketHandlerDataStorageInterface.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/marketManager/liquidationManager.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

import "../interfaces/marketManagerInterface.sol";
import "../interfaces/managerDataStorageInterface.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity 0.6.12;
pragma solidity ^0.8.0;

import "../../interfaces/managerDataStorageInterface.sol";
import "../../Errors.sol";
Expand Down
Loading