Remove 64 and 96 bit LibSafeMath contracts
This commit is contained in:
		@@ -1,93 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 | 
			
		||||
  Copyright 2018 ZeroEx Intl.
 | 
			
		||||
 | 
			
		||||
  Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
  you may not use this file except in compliance with the License.
 | 
			
		||||
  You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
    http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
  Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
  distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
  See the License for the specific language governing permissions and
 | 
			
		||||
  limitations under the License.
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
pragma solidity ^0.5.9;
 | 
			
		||||
 | 
			
		||||
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
 | 
			
		||||
import "@0x/contracts-utils/contracts/src/LibSafeMathRichErrors.sol";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
library LibSafeMath64 {
 | 
			
		||||
 | 
			
		||||
    /// @dev Returns the addition of two unsigned integers, reverting on overflow.
 | 
			
		||||
    /// Note that this reverts on overflow.
 | 
			
		||||
    function safeAdd(uint64 a, uint64 b) internal pure returns (uint64) {
 | 
			
		||||
        uint64 c = a + b;
 | 
			
		||||
        if (c < a) {
 | 
			
		||||
            LibRichErrors.rrevert(LibSafeMathRichErrors.Uint64BinOpError(
 | 
			
		||||
                LibSafeMathRichErrors.BinOpErrorCodes.ADDITION_OVERFLOW,
 | 
			
		||||
                a,
 | 
			
		||||
                b
 | 
			
		||||
            ));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return c;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Returns the subtraction of two unsigned integers.
 | 
			
		||||
    /// Note that this reverts on underflow.
 | 
			
		||||
    function safeSub(uint64 a, uint64 b) internal pure returns (uint64) {
 | 
			
		||||
        if (b > a) {
 | 
			
		||||
            LibRichErrors.rrevert(LibSafeMathRichErrors.Uint64BinOpError(
 | 
			
		||||
                LibSafeMathRichErrors.BinOpErrorCodes.SUBTRACTION_UNDERFLOW,
 | 
			
		||||
                a,
 | 
			
		||||
                b
 | 
			
		||||
            ));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        uint64 c = a - b;
 | 
			
		||||
        return c;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Returns the multiplication of two unsigned integers, reverting on overflow.
 | 
			
		||||
    /// Note that this reverts on overflow.
 | 
			
		||||
    function safeMul(uint64 a, uint64 b) internal pure returns (uint64) {
 | 
			
		||||
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
 | 
			
		||||
        // benefit is lost if 'b' is also tested.
 | 
			
		||||
        // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
 | 
			
		||||
        if (a == 0) {
 | 
			
		||||
            return 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        uint64 c = a * b;
 | 
			
		||||
        if (c / a != b) {
 | 
			
		||||
            LibRichErrors.rrevert(LibSafeMathRichErrors.Uint64BinOpError(
 | 
			
		||||
                LibSafeMathRichErrors.BinOpErrorCodes.MULTIPLICATION_OVERFLOW,
 | 
			
		||||
                a,
 | 
			
		||||
                b
 | 
			
		||||
            ));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return c;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Returns the integer division of two unsigned integers.
 | 
			
		||||
    /// Note that this reverts on division by zero. The result is rounded towards zero.
 | 
			
		||||
    function safeDiv(uint64 a, uint64 b) internal pure returns (uint64) {
 | 
			
		||||
        if (b == 0) {
 | 
			
		||||
            LibRichErrors.rrevert(LibSafeMathRichErrors.Uint64BinOpError(
 | 
			
		||||
                LibSafeMathRichErrors.BinOpErrorCodes.DIVISION_BY_ZERO,
 | 
			
		||||
                a,
 | 
			
		||||
                b
 | 
			
		||||
            ));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        uint64 c = a / b;
 | 
			
		||||
        return c;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,111 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 | 
			
		||||
  Copyright 2018 ZeroEx Intl.
 | 
			
		||||
 | 
			
		||||
  Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
  you may not use this file except in compliance with the License.
 | 
			
		||||
  You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
    http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
  Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
  distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
  See the License for the specific language governing permissions and
 | 
			
		||||
  limitations under the License.
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
pragma solidity ^0.5.9;
 | 
			
		||||
 | 
			
		||||
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
 | 
			
		||||
import "@0x/contracts-utils/contracts/src/LibSafeMathRichErrors.sol";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
library LibSafeMath96 {
 | 
			
		||||
 | 
			
		||||
    /// @dev Returns the addition of two unsigned integers, reverting on overflow.
 | 
			
		||||
    /// Note that this reverts on overflow.
 | 
			
		||||
    function safeAdd(uint96 a, uint96 b) internal pure returns (uint96) {
 | 
			
		||||
        uint96 c = a + b;
 | 
			
		||||
        if (c < a) {
 | 
			
		||||
            LibRichErrors.rrevert(LibSafeMathRichErrors.Uint96BinOpError(
 | 
			
		||||
                LibSafeMathRichErrors.BinOpErrorCodes.ADDITION_OVERFLOW,
 | 
			
		||||
                a,
 | 
			
		||||
                b
 | 
			
		||||
            ));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return c;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Returns the subtraction of two unsigned integers.
 | 
			
		||||
    /// Note that this reverts on underflow.
 | 
			
		||||
    function safeSub(uint96 a, uint96 b) internal pure returns (uint96) {
 | 
			
		||||
        if (b > a) {
 | 
			
		||||
            LibRichErrors.rrevert(LibSafeMathRichErrors.Uint96BinOpError(
 | 
			
		||||
                LibSafeMathRichErrors.BinOpErrorCodes.SUBTRACTION_UNDERFLOW,
 | 
			
		||||
                a,
 | 
			
		||||
                b
 | 
			
		||||
            ));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        uint96 c = a - b;
 | 
			
		||||
        return c;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Returns the multiplication of two unsigned integers, reverting on overflow.
 | 
			
		||||
    /// Note that this reverts on overflow.
 | 
			
		||||
    function safeMul(uint96 a, uint96 b) internal pure returns (uint96) {
 | 
			
		||||
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
 | 
			
		||||
        // benefit is lost if 'b' is also tested.
 | 
			
		||||
        // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
 | 
			
		||||
        if (a == 0) {
 | 
			
		||||
            return 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        uint96 c = a * b;
 | 
			
		||||
        if (c / a != b) {
 | 
			
		||||
            LibRichErrors.rrevert(LibSafeMathRichErrors.Uint96BinOpError(
 | 
			
		||||
                LibSafeMathRichErrors.BinOpErrorCodes.MULTIPLICATION_OVERFLOW,
 | 
			
		||||
                a,
 | 
			
		||||
                b
 | 
			
		||||
            ));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return c;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Returns the integer division of two unsigned integers.
 | 
			
		||||
    /// Note that this reverts on division by zero. The result is rounded towards zero.
 | 
			
		||||
    function safeDiv(uint96 a, uint96 b) internal pure returns (uint96) {
 | 
			
		||||
        if (b == 0) {
 | 
			
		||||
            LibRichErrors.rrevert(LibSafeMathRichErrors.Uint96BinOpError(
 | 
			
		||||
                LibSafeMathRichErrors.BinOpErrorCodes.DIVISION_BY_ZERO,
 | 
			
		||||
                a,
 | 
			
		||||
                b
 | 
			
		||||
            ));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        uint96 c = a / b;
 | 
			
		||||
        return c;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Computes the percentage `numerator` is of `value`.
 | 
			
		||||
    /// @param value The whole amount.
 | 
			
		||||
    /// @param slice A slice of `value`.
 | 
			
		||||
    /// @return The percentage `slice` is of `value`
 | 
			
		||||
    function _computePercentageCeil(uint96 value, uint8 slice)
 | 
			
		||||
        internal
 | 
			
		||||
        pure
 | 
			
		||||
        returns (uint96)
 | 
			
		||||
    {
 | 
			
		||||
        uint96 scaledNumerator = safeMul(value, slice);
 | 
			
		||||
        uint96 ceilScalar = uint96(99);
 | 
			
		||||
        uint96 denominator = uint96(100);
 | 
			
		||||
        return safeDiv(
 | 
			
		||||
            safeAdd(scaledNumerator, ceilScalar),
 | 
			
		||||
            denominator
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -36,7 +36,7 @@
 | 
			
		||||
        "compile:truffle": "truffle compile"
 | 
			
		||||
    },
 | 
			
		||||
    "config": {
 | 
			
		||||
        "abis": "./generated-artifacts/@(IStaking|IStakingEvents|IStakingPoolRewardVault|IStakingProxy|IStructs|IVaultCore|IWallet|IZrxVault|LibEIP712Hash|LibFeeMath|LibFeeMathTest|LibRewardMath|LibSafeDowncast|LibSafeMath64|LibSafeMath96|LibSignatureValidator|LibStakingRichErrors|MixinConstants|MixinDelegatedStake|MixinDeploymentConstants|MixinExchangeFees|MixinExchangeManager|MixinScheduler|MixinStake|MixinStakeBalances|MixinStakingPool|MixinStakingPoolRewardVault|MixinStakingPoolRewards|MixinStorage|MixinTimeLockedStake|MixinVaultCore|MixinZrxVault|Staking|StakingPoolRewardVault|StakingProxy|ZrxVault).json",
 | 
			
		||||
        "abis": "./generated-artifacts/@(IStaking|IStakingEvents|IStakingPoolRewardVault|IStakingProxy|IStructs|IVaultCore|IWallet|IZrxVault|LibEIP712Hash|LibFeeMath|LibFeeMathTest|LibRewardMath|LibSafeDowncast|LibSignatureValidator|LibStakingRichErrors|MixinConstants|MixinDelegatedStake|MixinDeploymentConstants|MixinExchangeFees|MixinExchangeManager|MixinScheduler|MixinStake|MixinStakeBalances|MixinStakingPool|MixinStakingPoolRewardVault|MixinStakingPoolRewards|MixinStorage|MixinTimeLockedStake|MixinVaultCore|MixinZrxVault|Staking|StakingPoolRewardVault|StakingProxy|TestStorageLayout|ZrxVault).json",
 | 
			
		||||
        "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
 | 
			
		||||
    },
 | 
			
		||||
    "repository": {
 | 
			
		||||
 
 | 
			
		||||
@@ -18,8 +18,6 @@ import * as LibFeeMath from '../generated-artifacts/LibFeeMath.json';
 | 
			
		||||
import * as LibFeeMathTest from '../generated-artifacts/LibFeeMathTest.json';
 | 
			
		||||
import * as LibRewardMath from '../generated-artifacts/LibRewardMath.json';
 | 
			
		||||
import * as LibSafeDowncast from '../generated-artifacts/LibSafeDowncast.json';
 | 
			
		||||
import * as LibSafeMath64 from '../generated-artifacts/LibSafeMath64.json';
 | 
			
		||||
import * as LibSafeMath96 from '../generated-artifacts/LibSafeMath96.json';
 | 
			
		||||
import * as LibSignatureValidator from '../generated-artifacts/LibSignatureValidator.json';
 | 
			
		||||
import * as LibStakingRichErrors from '../generated-artifacts/LibStakingRichErrors.json';
 | 
			
		||||
import * as MixinConstants from '../generated-artifacts/MixinConstants.json';
 | 
			
		||||
@@ -40,6 +38,7 @@ import * as MixinZrxVault from '../generated-artifacts/MixinZrxVault.json';
 | 
			
		||||
import * as Staking from '../generated-artifacts/Staking.json';
 | 
			
		||||
import * as StakingPoolRewardVault from '../generated-artifacts/StakingPoolRewardVault.json';
 | 
			
		||||
import * as StakingProxy from '../generated-artifacts/StakingProxy.json';
 | 
			
		||||
import * as TestStorageLayout from '../generated-artifacts/TestStorageLayout.json';
 | 
			
		||||
import * as ZrxVault from '../generated-artifacts/ZrxVault.json';
 | 
			
		||||
export const artifacts = {
 | 
			
		||||
    Staking: Staking as ContractArtifact,
 | 
			
		||||
@@ -61,8 +60,6 @@ export const artifacts = {
 | 
			
		||||
    LibFeeMath: LibFeeMath as ContractArtifact,
 | 
			
		||||
    LibRewardMath: LibRewardMath as ContractArtifact,
 | 
			
		||||
    LibSafeDowncast: LibSafeDowncast as ContractArtifact,
 | 
			
		||||
    LibSafeMath64: LibSafeMath64 as ContractArtifact,
 | 
			
		||||
    LibSafeMath96: LibSafeMath96 as ContractArtifact,
 | 
			
		||||
    LibSignatureValidator: LibSignatureValidator as ContractArtifact,
 | 
			
		||||
    LibStakingRichErrors: LibStakingRichErrors as ContractArtifact,
 | 
			
		||||
    MixinDelegatedStake: MixinDelegatedStake as ContractArtifact,
 | 
			
		||||
@@ -78,4 +75,5 @@ export const artifacts = {
 | 
			
		||||
    StakingPoolRewardVault: StakingPoolRewardVault as ContractArtifact,
 | 
			
		||||
    ZrxVault: ZrxVault as ContractArtifact,
 | 
			
		||||
    LibFeeMathTest: LibFeeMathTest as ContractArtifact,
 | 
			
		||||
    TestStorageLayout: TestStorageLayout as ContractArtifact,
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -16,8 +16,6 @@ export * from '../generated-wrappers/lib_fee_math';
 | 
			
		||||
export * from '../generated-wrappers/lib_fee_math_test';
 | 
			
		||||
export * from '../generated-wrappers/lib_reward_math';
 | 
			
		||||
export * from '../generated-wrappers/lib_safe_downcast';
 | 
			
		||||
export * from '../generated-wrappers/lib_safe_math64';
 | 
			
		||||
export * from '../generated-wrappers/lib_safe_math96';
 | 
			
		||||
export * from '../generated-wrappers/lib_signature_validator';
 | 
			
		||||
export * from '../generated-wrappers/lib_staking_rich_errors';
 | 
			
		||||
export * from '../generated-wrappers/mixin_constants';
 | 
			
		||||
@@ -38,4 +36,5 @@ export * from '../generated-wrappers/mixin_zrx_vault';
 | 
			
		||||
export * from '../generated-wrappers/staking';
 | 
			
		||||
export * from '../generated-wrappers/staking_pool_reward_vault';
 | 
			
		||||
export * from '../generated-wrappers/staking_proxy';
 | 
			
		||||
export * from '../generated-wrappers/test_storage_layout';
 | 
			
		||||
export * from '../generated-wrappers/zrx_vault';
 | 
			
		||||
 
 | 
			
		||||
@@ -16,8 +16,6 @@
 | 
			
		||||
        "generated-artifacts/LibFeeMathTest.json",
 | 
			
		||||
        "generated-artifacts/LibRewardMath.json",
 | 
			
		||||
        "generated-artifacts/LibSafeDowncast.json",
 | 
			
		||||
        "generated-artifacts/LibSafeMath64.json",
 | 
			
		||||
        "generated-artifacts/LibSafeMath96.json",
 | 
			
		||||
        "generated-artifacts/LibSignatureValidator.json",
 | 
			
		||||
        "generated-artifacts/LibStakingRichErrors.json",
 | 
			
		||||
        "generated-artifacts/MixinConstants.json",
 | 
			
		||||
@@ -38,6 +36,7 @@
 | 
			
		||||
        "generated-artifacts/Staking.json",
 | 
			
		||||
        "generated-artifacts/StakingPoolRewardVault.json",
 | 
			
		||||
        "generated-artifacts/StakingProxy.json",
 | 
			
		||||
        "generated-artifacts/TestStorageLayout.json",
 | 
			
		||||
        "generated-artifacts/ZrxVault.json"
 | 
			
		||||
    ],
 | 
			
		||||
    "exclude": ["./deploy/solc/solc_bin"]
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user