diff --git a/contracts/staking/contracts/src/fees/MixinExchangeFees.sol b/contracts/staking/contracts/src/fees/MixinExchangeFees.sol index 940f5f9edf..71b682a4db 100644 --- a/contracts/staking/contracts/src/fees/MixinExchangeFees.sol +++ b/contracts/staking/contracts/src/fees/MixinExchangeFees.sol @@ -84,7 +84,9 @@ contract MixinExchangeFees is /// @param makerAddress The address of the order's maker. function payProtocolFee( address makerAddress, + // solhint-disable-next-line address payerAddress, + // solhint-disable-next-line uint256 protocolFeePaid ) external diff --git a/contracts/staking/contracts/src/libs/LibFixedMath.sol b/contracts/staking/contracts/src/libs/LibFixedMath.sol index 567485bd97..cfe58695a5 100644 --- a/contracts/staking/contracts/src/libs/LibFixedMath.sol +++ b/contracts/staking/contracts/src/libs/LibFixedMath.sol @@ -72,7 +72,7 @@ library LibFixedMath { /// Negative results are clamped to zero. function _uintMul(int256 f, uint256 u) internal pure returns (uint256) { if (int256(u) < int256(0)) { - LibRichErrors.rrevert(LibFixedMathRichErrors.FixedMathUnsignedValueError( + LibRichErrors.rrevert(LibFixedMathRichErrors.UnsignedValueError( LibFixedMathRichErrors.ValueErrorCodes.TOO_LARGE, u )); @@ -112,7 +112,7 @@ library LibFixedMath { /// Reverts if `n` is too large to fit in a fixed-point number. function _toFixed(uint256 n) internal pure returns (int256 f) { if (int256(n) < int256(0)) { - LibRichErrors.rrevert(LibFixedMathRichErrors.FixedMathUnsignedValueError( + LibRichErrors.rrevert(LibFixedMathRichErrors.UnsignedValueError( LibFixedMathRichErrors.ValueErrorCodes.TOO_LARGE, n )); @@ -124,13 +124,13 @@ library LibFixedMath { /// Reverts if `n` / `d` is too large to fit in a fixed-point number. function _toFixed(uint256 n, uint256 d) internal pure returns (int256 f) { if (int256(n) < int256(0)) { - LibRichErrors.rrevert(LibFixedMathRichErrors.FixedMathUnsignedValueError( + LibRichErrors.rrevert(LibFixedMathRichErrors.UnsignedValueError( LibFixedMathRichErrors.ValueErrorCodes.TOO_LARGE, n )); } if (int256(d) < int256(0)) { - LibRichErrors.rrevert(LibFixedMathRichErrors.FixedMathUnsignedValueError( + LibRichErrors.rrevert(LibFixedMathRichErrors.UnsignedValueError( LibFixedMathRichErrors.ValueErrorCodes.TOO_LARGE, d )); @@ -146,13 +146,13 @@ library LibFixedMath { /// @dev Get the natural logarithm of a fixed-point number 0 < `x` <= LN_MAX_VAL function _ln(int256 x) internal pure returns (int256 r) { if (x > LN_MAX_VAL) { - LibRichErrors.rrevert(LibFixedMathRichErrors.FixedMathSignedValueError( + LibRichErrors.rrevert(LibFixedMathRichErrors.SignedValueError( LibFixedMathRichErrors.ValueErrorCodes.TOO_LARGE, x )); } if (x <= 0) { - LibRichErrors.rrevert(LibFixedMathRichErrors.FixedMathSignedValueError( + LibRichErrors.rrevert(LibFixedMathRichErrors.SignedValueError( LibFixedMathRichErrors.ValueErrorCodes.TOO_SMALL, x )); @@ -241,7 +241,7 @@ library LibFixedMath { return FIXED_1; } if (x > EXP_MAX_VAL) { - LibRichErrors.rrevert(LibFixedMathRichErrors.FixedMathSignedValueError( + LibRichErrors.rrevert(LibFixedMathRichErrors.SignedValueError( LibFixedMathRichErrors.ValueErrorCodes.TOO_LARGE, x )); @@ -335,7 +335,7 @@ library LibFixedMath { } c = a * b; if (c / a != b) { - LibRichErrors.rrevert(LibFixedMathRichErrors.FixedMathBinOpError( + LibRichErrors.rrevert(LibFixedMathRichErrors.BinOpError( LibFixedMathRichErrors.BinOpErrorCodes.MULTIPLICATION_OVERFLOW, a, b @@ -346,7 +346,7 @@ library LibFixedMath { /// @dev Returns the division of two numbers, reverting on division by zero. function __div(int256 a, int256 b) private pure returns (int256 c) { if (b == 0) { - LibRichErrors.rrevert(LibFixedMathRichErrors.FixedMathBinOpError( + LibRichErrors.rrevert(LibFixedMathRichErrors.BinOpError( LibFixedMathRichErrors.BinOpErrorCodes.DIVISION_BY_ZERO, a, b @@ -359,14 +359,14 @@ library LibFixedMath { function __add(int256 a, int256 b) private pure returns (int256 c) { c = a + b; if (c > 0 && a < 0 && b < 0) { - LibRichErrors.rrevert(LibFixedMathRichErrors.FixedMathBinOpError( + LibRichErrors.rrevert(LibFixedMathRichErrors.BinOpError( LibFixedMathRichErrors.BinOpErrorCodes.SUBTRACTION_OVERFLOW, a, b )); } if (c < 0 && a > 0 && b > 0) { - LibRichErrors.rrevert(LibFixedMathRichErrors.FixedMathBinOpError( + LibRichErrors.rrevert(LibFixedMathRichErrors.BinOpError( LibFixedMathRichErrors.BinOpErrorCodes.ADDITION_OVERFLOW, a, b diff --git a/contracts/staking/contracts/src/libs/LibFixedMathRichErrors.sol b/contracts/staking/contracts/src/libs/LibFixedMathRichErrors.sol index 6e919f686c..8ea570bb87 100644 --- a/contracts/staking/contracts/src/libs/LibFixedMathRichErrors.sol +++ b/contracts/staking/contracts/src/libs/LibFixedMathRichErrors.sol @@ -35,20 +35,20 @@ library LibFixedMathRichErrors { DIVISION_BY_ZERO } - // bytes4(keccak256("FixedMathSignedValueError(uint8,int256)")) + // bytes4(keccak256("SignedValueError(uint8,int256)")) bytes4 internal constant SIGNED_VALUE_ERROR_SELECTOR = - 0x0edd9c46; + 0xed2f26a1; - // bytes4(keccak256("FixedMathUnsignedValueError(uint8,uint256)")) + // bytes4(keccak256("UnsignedValueError(uint8,uint256)")) bytes4 internal constant UNSIGNED_VALUE_ERROR_SELECTOR = - 0x38e93856; + 0xbd79545f; - // bytes4(keccak256("FixedMathBinOpError(uint8,int256,int256)")) + // bytes4(keccak256("BinOpError(uint8,int256,int256)")) bytes4 internal constant BIN_OP_ERROR_SELECTOR = - 0x2bd3386e; + 0x8c12dfe7; // solhint-disable func-name-mixedcase - function FixedMathSignedValueError( + function SignedValueError( ValueErrorCodes error, int256 n ) @@ -63,7 +63,7 @@ library LibFixedMathRichErrors { ); } - function FixedMathUnsignedValueError( + function UnsignedValueError( ValueErrorCodes error, uint256 n ) @@ -78,7 +78,7 @@ library LibFixedMathRichErrors { ); } - function FixedMathBinOpError( + function BinOpError( BinOpErrorCodes error, int256 a, int256 b diff --git a/contracts/staking/test/lib_fixed_math.ts b/contracts/staking/test/lib_fixed_math.ts index a267c5105e..811be944ac 100644 --- a/contracts/staking/test/lib_fixed_math.ts +++ b/contracts/staking/test/lib_fixed_math.ts @@ -84,7 +84,7 @@ blockchainTests('LibFixedMath', env => { }); it('invert(0) throws', async () => { - const expectedError = new FixedMathRevertErrors.FixedMathBinOpError( + const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.DivisionByZero, ); const tx = testContract.invert.callAsync(toFixed(0)); @@ -125,7 +125,7 @@ blockchainTests('LibFixedMath', env => { it('mulDiv(x, y, 0) throws', async () => { const [a, n, d] = [1.2345, 149, 0]; - const expectedError = new FixedMathRevertErrors.FixedMathBinOpError( + const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.DivisionByZero, ); const tx = testContract.mulDiv.callAsync(toFixed(a), new BigNumber(n), new BigNumber(d)); @@ -158,7 +158,7 @@ blockchainTests('LibFixedMath', env => { it('throws on overflow', async () => { const [a, b] = [MAX_FIXED_VALUE, new BigNumber(1)]; - const expectedError = new FixedMathRevertErrors.FixedMathBinOpError( + const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.AdditionOverflow, a, b, @@ -169,7 +169,7 @@ blockchainTests('LibFixedMath', env => { it('throws on underflow', async () => { const [a, b] = [MIN_FIXED_VALUE, new BigNumber(-1)]; - const expectedError = new FixedMathRevertErrors.FixedMathBinOpError( + const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.SubtractionUnderflow, a, b, @@ -204,7 +204,7 @@ blockchainTests('LibFixedMath', env => { it('throws on underflow', async () => { const [a, b] = [MIN_FIXED_VALUE, new BigNumber(1)]; - const expectedError = new FixedMathRevertErrors.FixedMathBinOpError( + const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.SubtractionUnderflow, a, b.negated(), @@ -215,7 +215,7 @@ blockchainTests('LibFixedMath', env => { it('throws on overflow', async () => { const [a, b] = [MAX_FIXED_VALUE, new BigNumber(-1)]; - const expectedError = new FixedMathRevertErrors.FixedMathBinOpError( + const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.AdditionOverflow, a, b.negated(), @@ -266,7 +266,7 @@ blockchainTests('LibFixedMath', env => { it('throws on underflow', async () => { const [a, b] = [MIN_FIXED_VALUE, new BigNumber(2)]; - const expectedError = new FixedMathRevertErrors.FixedMathBinOpError( + const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow, a, b, @@ -277,7 +277,7 @@ blockchainTests('LibFixedMath', env => { it('throws on overflow', async () => { const [a, b] = [MAX_FIXED_VALUE, new BigNumber(2)]; - const expectedError = new FixedMathRevertErrors.FixedMathBinOpError( + const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow, a, b, @@ -298,7 +298,7 @@ blockchainTests('LibFixedMath', env => { it('x / 0 throws', async () => { const [a, b] = [1, 0]; - const expectedError = new FixedMathRevertErrors.FixedMathBinOpError( + const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.DivisionByZero, toFixed(a).times(FIXED_POINT_DIVISOR), toFixed(b), @@ -365,7 +365,7 @@ blockchainTests('LibFixedMath', env => { it('throws if rhs is too large', async () => { const [a, b] = [toFixed(1), MAX_FIXED_VALUE.plus(1)]; - const expectedError = new FixedMathRevertErrors.FixedMathUnsignedValueError( + const expectedError = new FixedMathRevertErrors.UnsignedValueError( FixedMathRevertErrors.ValueErrorCodes.TooLarge, b, ); @@ -375,7 +375,7 @@ blockchainTests('LibFixedMath', env => { it('throws if lhs is too large', async () => { const [a, b] = [MAX_FIXED_VALUE, new BigNumber(2)]; - const expectedError = new FixedMathRevertErrors.FixedMathBinOpError( + const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow, a, b, @@ -457,7 +457,7 @@ blockchainTests('LibFixedMath', env => { it('throws if the numerator is too large to convert', async () => { const [n, d] = [MAX_FIXED_VALUE.dividedToIntegerBy(FIXED_POINT_DIVISOR).plus(1), new BigNumber(1000)]; - const expectedError = new FixedMathRevertErrors.FixedMathBinOpError( + const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow, n, FIXED_POINT_DIVISOR, @@ -468,7 +468,7 @@ blockchainTests('LibFixedMath', env => { it('throws if the denominator is zero', async () => { const [n, d] = [new BigNumber(1), new BigNumber(0)]; - const expectedError = new FixedMathRevertErrors.FixedMathBinOpError( + const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.DivisionByZero, n.times(FIXED_POINT_DIVISOR), d, @@ -493,7 +493,7 @@ blockchainTests('LibFixedMath', env => { it('throws if the numerator is too large', async () => { const [n, d] = [MAX_FIXED_VALUE.plus(1), new BigNumber(1000)]; - const expectedError = new FixedMathRevertErrors.FixedMathUnsignedValueError( + const expectedError = new FixedMathRevertErrors.UnsignedValueError( FixedMathRevertErrors.ValueErrorCodes.TooLarge, n, ); @@ -503,7 +503,7 @@ blockchainTests('LibFixedMath', env => { it('throws if the denominator is too large', async () => { const [n, d] = [new BigNumber(1000), MAX_FIXED_VALUE.plus(1)]; - const expectedError = new FixedMathRevertErrors.FixedMathUnsignedValueError( + const expectedError = new FixedMathRevertErrors.UnsignedValueError( FixedMathRevertErrors.ValueErrorCodes.TooLarge, d, ); @@ -513,7 +513,7 @@ blockchainTests('LibFixedMath', env => { it('throws if the numerator is too large to convert', async () => { const [n, d] = [MAX_FIXED_VALUE.dividedToIntegerBy(FIXED_POINT_DIVISOR).plus(1), new BigNumber(1000)]; - const expectedError = new FixedMathRevertErrors.FixedMathBinOpError( + const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.MultiplicationOverflow, n, FIXED_POINT_DIVISOR, @@ -524,7 +524,7 @@ blockchainTests('LibFixedMath', env => { it('throws if the denominator is zero', async () => { const [n, d] = [new BigNumber(1), new BigNumber(0)]; - const expectedError = new FixedMathRevertErrors.FixedMathBinOpError( + const expectedError = new FixedMathRevertErrors.BinOpError( FixedMathRevertErrors.BinOpErrorCodes.DivisionByZero, n.times(FIXED_POINT_DIVISOR), d, @@ -554,7 +554,7 @@ blockchainTests('LibFixedMath', env => { it('ln(x = 0) throws', async () => { const x = toFixed(0); - const expectedError = new FixedMathRevertErrors.FixedMathSignedValueError( + const expectedError = new FixedMathRevertErrors.SignedValueError( FixedMathRevertErrors.ValueErrorCodes.TooSmall, x, ); @@ -564,7 +564,7 @@ blockchainTests('LibFixedMath', env => { it('ln(x > 1) throws', async () => { const x = toFixed(1.000001); - const expectedError = new FixedMathRevertErrors.FixedMathSignedValueError( + const expectedError = new FixedMathRevertErrors.SignedValueError( FixedMathRevertErrors.ValueErrorCodes.TooLarge, x, ); @@ -574,7 +574,7 @@ blockchainTests('LibFixedMath', env => { it('ln(x < 0) throws', async () => { const x = toFixed(-0.000001); - const expectedError = new FixedMathRevertErrors.FixedMathSignedValueError( + const expectedError = new FixedMathRevertErrors.SignedValueError( FixedMathRevertErrors.ValueErrorCodes.TooSmall, x, ); @@ -642,7 +642,7 @@ blockchainTests('LibFixedMath', env => { it('exp(x > EXP_MAX_VAL) throws', async () => { const x = toFixed(MAX_EXP_NUMBER).plus(1); - const expectedError = new FixedMathRevertErrors.FixedMathSignedValueError( + const expectedError = new FixedMathRevertErrors.SignedValueError( FixedMathRevertErrors.ValueErrorCodes.TooLarge, x, );