Skip to content

Commit

Permalink
Merge pull request #131 from floor-licker/pragma-safeMath-refactor
Browse files Browse the repository at this point in the history
Update Solidity to v0.8.0 and Refactor Contracts to Remove SafeMath
  • Loading branch information
marcelomorgado authored Dec 9, 2024
2 parents 086910b + 522c0aa commit 4e4cd1e
Show file tree
Hide file tree
Showing 28 changed files with 31 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/aave/contracts/FlashloanReceiverBase.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

import "./IFlashLoanReceiver.sol";

Expand Down
3 changes: 1 addition & 2 deletions src/aave/contracts/IFlashLoanReceiver.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";

import "./ILendingPoolAddressesProvider.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/aave/contracts/ILendingPool.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

interface ILendingPool {
function addressesProvider () external view returns ( address );
Expand Down
2 changes: 1 addition & 1 deletion src/aave/contracts/ILendingPoolAddressesProvider.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

/**
@title ILendingPoolAddressesProvider interface
Expand Down
2 changes: 1 addition & 1 deletion src/balancer/contracts/BFactory.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

import "./BPool.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/balancer/contracts/BPool.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

interface BPool {

Expand Down
2 changes: 1 addition & 1 deletion src/balancer/contracts/ExchangeProxy.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;


interface ExchangeProxy {
Expand Down
2 changes: 1 addition & 1 deletion src/compound/contracts/ICEther.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

contract ICEther {
function mint() external payable;
Expand Down
2 changes: 1 addition & 1 deletion src/compound/contracts/ICToken.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

interface ICToken {
function mint(uint mintAmount) external returns (uint);
Expand Down
2 changes: 1 addition & 1 deletion src/compound/contracts/ICompoundPriceOracle.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

contract ICompoundPriceOracle {
function getUnderlyingPrice(address cToken) external view returns (uint256);
Expand Down
2 changes: 1 addition & 1 deletion src/compound/contracts/IComptroller.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

interface IComptroller {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/curvefi/contracts/ICurveFiCurve.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

contract ICurveFiCurve {
function get_virtual_price() external returns (uint256 out);
Expand Down
2 changes: 1 addition & 1 deletion src/curvefi/contracts/ICurveFiPoolToken.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

contract ICurveFiPoolToken {
function set_minter(address _minter) external;
Expand Down
2 changes: 1 addition & 1 deletion src/curvefi/contracts/ICurveFiZap.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;


contract ICurveFiZap {
Expand Down
5 changes: 2 additions & 3 deletions src/dydx/contracts/DydxFlashloanBase.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pragma solidity ^0.5.7;
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import "./ISoloMargin.sol";
Expand Down Expand Up @@ -40,7 +39,7 @@ contract DydxFlashloanBase {
{
// Needs to be overcollateralize
// Needs to provide +2 wei to be safe
return amount.add(2);
return amount + 2;
}

function _getAccountInfo() internal view returns (Account.Info memory) {
Expand Down
2 changes: 1 addition & 1 deletion src/dydx/contracts/ICallee.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.7;
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import { Account } from "./ISoloMargin.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/dydx/contracts/ISoloMargin.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.7;
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;


Expand Down
2 changes: 1 addition & 1 deletion src/kyber/contracts/KyberNetworkProxy.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

// Note: Kyber uses it owns ERC20 interface
// See: https://github.com/KyberNetwork/smart-contracts/blob/master/contracts/ERC20Interface.sol
Expand Down
2 changes: 1 addition & 1 deletion src/maker/contracts/DssProxyActionsBase.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

import "./IDssProxyActions.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/maker/contracts/IDssProxyActions.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;


contract GemLike {
Expand Down
2 changes: 1 addition & 1 deletion src/mstable/contracts/Masset.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

interface Masset {

Expand Down
2 changes: 1 addition & 1 deletion src/mstable/contracts/StakingRewardsWithPlatformToken.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/onesplit/contracts/IOneSplit.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/uniswap/contracts/IUniswapExchange.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

interface IUniswapExchange {
// Address of ERC20 token sold on this exchange
Expand Down
2 changes: 1 addition & 1 deletion src/uniswap/contracts/IUniswapFactory.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

interface IUniswapFactory {
// Create Exchange
Expand Down
2 changes: 1 addition & 1 deletion tests/aave.test.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import "@studydefi/money-legos/aave/contracts/ILendingPool.sol";
Expand Down
7 changes: 3 additions & 4 deletions tests/compound.test.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

import "@studydefi/money-legos/compound/contracts/IComptroller.sol";
import "@studydefi/money-legos/compound/contracts/ICEther.sol";
import "@studydefi/money-legos/compound/contracts/ICToken.sol";

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";

contract CompoundManager {
using SafeMath for uint256;
Expand Down Expand Up @@ -76,7 +75,7 @@ contract CompoundManager {
) = ICToken(cToken).getAccountSnapshot(owner);

// Source: balanceOfUnderlying from any ctoken
return cTokenBalance.mul(exchangeRateMantissa).div(1e18);
return cTokenBalance * exchangeRateMantissa / 1e18;
}

function enterMarkets(
Expand Down Expand Up @@ -191,4 +190,4 @@ contract CompoundManager {
"cmpnd-mgr-ctoken-redeem-underlying-failed"
);
}
}
}
2 changes: 1 addition & 1 deletion tests/kyber.test.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.0;

import "@studydefi/money-legos/kyber/contracts/KyberNetworkProxy.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
Expand Down

0 comments on commit 4e4cd1e

Please sign in to comment.