diff --git a/contracts/staking/contracts/src/fees/MixinExchangeFees.sol b/contracts/staking/contracts/src/fees/MixinExchangeFees.sol index c5d2fec6fc..d8ba2516bf 100644 --- a/contracts/staking/contracts/src/fees/MixinExchangeFees.sol +++ b/contracts/staking/contracts/src/fees/MixinExchangeFees.sol @@ -225,6 +225,8 @@ contract MixinExchangeFees is activePoolsThisEpoch.length = 0; // step 3/3 send total payout to vault + + // Sanity check rewards calculation if (totalRewardsPaid > initialContractBalance) { LibRichErrors.rrevert(LibStakingRichErrors.MiscalculatedRewardsError( totalRewardsPaid, diff --git a/contracts/staking/contracts/src/libs/LibStakingRichErrors.sol b/contracts/staking/contracts/src/libs/LibStakingRichErrors.sol index e6bd75a87c..cab19f0e1d 100644 --- a/contracts/staking/contracts/src/libs/LibStakingRichErrors.sol +++ b/contracts/staking/contracts/src/libs/LibStakingRichErrors.sol @@ -39,8 +39,8 @@ library LibStakingRichErrors { 0x7dc025b0; // bytes4(keccak256("SignatureLengthGreaterThan0RequiredError()")) - bytes4 internal constant SIGNATURE_LENGTH_GREATER_THAN_0_REQUIRED_ERROR_SELECTOR = - 0x2dcb01d9; + bytes internal constant SIGNATURE_LENGTH_GREATER_THAN_0_REQUIRED_ERROR = + hex"2dcb01d9"; // bytes4(keccak256("SignatureUnsupportedError(bytes)")) bytes4 internal constant SIGNATURE_UNSUPPORTED_ERROR_SELECTOR = @@ -98,13 +98,13 @@ library LibStakingRichErrors { bytes4 internal constant ONLY_CALLABLE_BY_STAKING_CONTRACT_ERROR_SELECTOR = 0xca1d07a2; - // bytes4(keccak256("OnlyCallableInCatastrophicFailureError()")) - bytes4 internal constant ONLY_CALLABLE_IN_CATASTROPHIC_FAILURE_ERROR_SELECTOR = - 0xa4f5de9d; + // bytes4(keccak256("OnlyCallableIfInCatastrophicFailureError()")) + bytes internal constant ONLY_CALLABLE_IF_IN_CATASTROPHIC_FAILURE_ERROR = + hex"3ef081cc"; - // bytes4(keccak256("OnlyCallableNotInCatastrophicFailureError()")) - bytes4 internal constant ONLY_CALLABLE_NOT_IN_CATASTROPHIC_FAILURE_ERROR_SELECTOR = - 0x7e8d2ed9; + // bytes4(keccak256("OnlyCallableIfNotInCatastrophicFailureError()")) + bytes internal constant ONLY_CALLABLE_IF_NOT_IN_CATASTROPHIC_FAILURE_ERROR = + hex"7dd020ce"; // bytes4(keccak256("AmountExceedsBalanceOfPoolError(uint256,uint96)")) bytes4 internal constant AMOUNT_EXCEEDS_BALANCE_OF_POOL_ERROR_SELECTOR = @@ -178,7 +178,7 @@ library LibStakingRichErrors { pure returns (bytes memory) { - return abi.encodeWithSelector(SIGNATURE_LENGTH_GREATER_THAN_0_REQUIRED_ERROR_SELECTOR); + return SIGNATURE_LENGTH_GREATER_THAN_0_REQUIRED_ERROR; } function SignatureUnsupportedError( @@ -385,20 +385,20 @@ library LibStakingRichErrors { ); } - function OnlyCallableInCatastrophicFailureError() + function OnlyCallableIfInCatastrophicFailureError() internal pure returns (bytes memory) { - return abi.encodeWithSelector(ONLY_CALLABLE_IN_CATASTROPHIC_FAILURE_ERROR_SELECTOR); + return ONLY_CALLABLE_IF_IN_CATASTROPHIC_FAILURE_ERROR; } - function OnlyCallableNotInCatastrophicFailureError() + function OnlyCallableIfNotInCatastrophicFailureError() internal pure returns (bytes memory) { - return abi.encodeWithSelector(ONLY_CALLABLE_NOT_IN_CATASTROPHIC_FAILURE_ERROR_SELECTOR); + return ONLY_CALLABLE_IF_NOT_IN_CATASTROPHIC_FAILURE_ERROR; } function AmountExceedsBalanceOfPoolError( diff --git a/contracts/staking/contracts/src/vaults/MixinVaultCore.sol b/contracts/staking/contracts/src/vaults/MixinVaultCore.sol index b80a140939..cfb915b445 100644 --- a/contracts/staking/contracts/src/vaults/MixinVaultCore.sol +++ b/contracts/staking/contracts/src/vaults/MixinVaultCore.sol @@ -65,9 +65,7 @@ contract MixinVaultCore is /// @dev Asserts that this contract *is in* Catastrophic Failure Mode. modifier onlyInCatastrophicFailure { if (!isInCatastrophicFailure) { - LibRichErrors.rrevert( - LibStakingRichErrors.OnlyCallableInCatastrophicFailureError() - ); + LibRichErrors.rrevert(LibStakingRichErrors.OnlyCallableIfInCatastrophicFailureError()); } _; } @@ -75,9 +73,7 @@ contract MixinVaultCore is /// @dev Asserts that this contract *is not in* Catastrophic Failure Mode. modifier onlyNotInCatastrophicFailure { if (isInCatastrophicFailure) { - LibRichErrors.rrevert( - LibStakingRichErrors.OnlyCallableNotInCatastrophicFailureError() - ); + LibRichErrors.rrevert(LibStakingRichErrors.OnlyCallableIfNotInCatastrophicFailureError()); } _; } diff --git a/packages/order-utils/src/staking_revert_errors.ts b/packages/order-utils/src/staking_revert_errors.ts index c855e75b27..9a8ac68e51 100644 --- a/packages/order-utils/src/staking_revert_errors.ts +++ b/packages/order-utils/src/staking_revert_errors.ts @@ -157,15 +157,15 @@ export class OnlyCallableByStakingContractError extends RevertError { } } -export class OnlyCallableInCatastrophicFailureError extends RevertError { +export class OnlyCallableIfInCatastrophicFailureError extends RevertError { constructor() { - super('OnlyCallableInCatastrophicFailureError', 'OnlyCallableInCatastrophicFailureError()', {}); + super('OnlyCallableIfInCatastrophicFailureError', 'OnlyCallableIfInCatastrophicFailureError()', {}); } } -export class OnlyCallableNotInCatastrophicFailureError extends RevertError { +export class OnlyCallableIfNotInCatastrophicFailureError extends RevertError { constructor() { - super('OnlyCallableNotInCatastrophicFailureError', 'OnlyCallableNotInCatastrophicFailureError()', {}); + super('OnlyCallableIfNotInCatastrophicFailureError', 'OnlyCallableIfNotInCatastrophicFailureError()', {}); } } @@ -215,8 +215,8 @@ const types = [ WithdrawAmountExceedsMemberBalanceError, BlockTimestampTooLowError, OnlyCallableByStakingContractError, - OnlyCallableInCatastrophicFailureError, - OnlyCallableNotInCatastrophicFailureError, + OnlyCallableIfInCatastrophicFailureError, + OnlyCallableIfNotInCatastrophicFailureError, AmountExceedsBalanceOfPoolError, OperatorShareMustBeBetween0And100Error, PoolAlreadyExistsError,