Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Removed assertion that protocol fee != 0 from staking contract.
Browse files Browse the repository at this point in the history
  • Loading branch information
hysz committed Oct 22, 2019
1 parent 9ac715f commit e3bfbbe
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 30 deletions.
4 changes: 4 additions & 0 deletions contracts/staking/CHANGELOG.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
{
"note": "Add more overflow safeguards to `LibFixedMath`",
"pr": 2255
},
{
"note": "Refactored finalization state.",
"pr": 2276
}
]
},
Expand Down
1 change: 0 additions & 1 deletion contracts/staking/contracts/src/fees/MixinExchangeFees.sol
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ contract MixinExchangeFees is
if (msg.value != protocolFeePaid && msg.value != 0) {
LibRichErrors.rrevert(
LibStakingRichErrors.InvalidProtocolFeePaymentError(
LibStakingRichErrors.ProtocolFeePaymentErrorCodes.MismatchedFeeAndPayment,
protocolFeePaid,
msg.value
)
Expand Down
10 changes: 2 additions & 8 deletions contracts/staking/contracts/src/libs/LibStakingRichErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ library LibStakingRichErrors {
CanOnlyDecreaseOperatorShare
}

enum ProtocolFeePaymentErrorCodes {
MismatchedFeeAndPayment
}

enum InitializationErrorCodes {
MixinSchedulerAlreadyInitialized,
MixinParamsAlreadyInitialized
Expand Down Expand Up @@ -103,9 +99,9 @@ library LibStakingRichErrors {
bytes4 internal constant INVALID_PARAM_VALUE_ERROR_SELECTOR =
0xfc45bd11;

// bytes4(keccak256("InvalidProtocolFeePaymentError(uint8,uint256,uint256)"))
// bytes4(keccak256("InvalidProtocolFeePaymentError(uint256,uint256)"))
bytes4 internal constant INVALID_PROTOCOL_FEE_PAYMENT_ERROR_SELECTOR =
0xefd6cb33;
0x31d7a505;

// bytes4(keccak256("PreviousEpochNotFinalizedError(uint256,uint256)"))
bytes4 internal constant PREVIOUS_EPOCH_NOT_FINALIZED_ERROR_SELECTOR =
Expand Down Expand Up @@ -251,7 +247,6 @@ library LibStakingRichErrors {
}

function InvalidProtocolFeePaymentError(
ProtocolFeePaymentErrorCodes errorCodes,
uint256 expectedProtocolFeePaid,
uint256 actualProtocolFeePaid
)
Expand All @@ -261,7 +256,6 @@ library LibStakingRichErrors {
{
return abi.encodeWithSelector(
INVALID_PROTOCOL_FEE_PAYMENT_ERROR_SELECTOR,
errorCodes,
expectedProtocolFeePaid,
actualProtocolFeePaid
);
Expand Down
18 changes: 0 additions & 18 deletions contracts/staking/test/unit_tests/protocol_fees_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,6 @@ blockchainTests('Protocol Fees unit tests', env => {
return expect(tx).to.revertWith(expectedError);
});

it('should revert if `protocolFeePaid` is zero with zero value sent', async () => {
const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
payerAddress,
ZERO_AMOUNT,
{ from: exchangeAddress, value: ZERO_AMOUNT },
);
const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError(
StakingRevertErrors.ProtocolFeePaymentErrorCodes.ZeroProtocolFeePaid,
ZERO_AMOUNT,
ZERO_AMOUNT,
);
return expect(tx).to.revertWith(expectedError);
});

it('should revert if `protocolFeePaid` is zero with non-zero value sent', async () => {
const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
Expand All @@ -113,7 +98,6 @@ blockchainTests('Protocol Fees unit tests', env => {
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID },
);
const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError(
StakingRevertErrors.ProtocolFeePaymentErrorCodes.ZeroProtocolFeePaid,
ZERO_AMOUNT,
DEFAULT_PROTOCOL_FEE_PAID,
);
Expand All @@ -128,7 +112,6 @@ blockchainTests('Protocol Fees unit tests', env => {
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.minus(1) },
);
const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError(
StakingRevertErrors.ProtocolFeePaymentErrorCodes.MismatchedFeeAndPayment,
DEFAULT_PROTOCOL_FEE_PAID,
DEFAULT_PROTOCOL_FEE_PAID.minus(1),
);
Expand All @@ -143,7 +126,6 @@ blockchainTests('Protocol Fees unit tests', env => {
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.plus(1) },
);
const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError(
StakingRevertErrors.ProtocolFeePaymentErrorCodes.MismatchedFeeAndPayment,
DEFAULT_PROTOCOL_FEE_PAID,
DEFAULT_PROTOCOL_FEE_PAID.plus(1),
);
Expand Down
5 changes: 2 additions & 3 deletions packages/order-utils/src/staking_revert_errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,13 @@ export class InvalidParamValueError extends RevertError {

export class InvalidProtocolFeePaymentError extends RevertError {
constructor(
errorCode?: ProtocolFeePaymentErrorCodes,
expectedProtocolFeePaid?: BigNumber | number | string,
actualProtocolFeePaid?: BigNumber | number | string,
) {
super(
'InvalidProtocolFeePaymentError',
'InvalidProtocolFeePaymentError(uint8 errorCode, uint256 expectedProtocolFeePaid, uint256 actualProtocolFeePaid)',
{ errorCode, expectedProtocolFeePaid, actualProtocolFeePaid },
'InvalidProtocolFeePaymentError(uint256 expectedProtocolFeePaid, uint256 actualProtocolFeePaid)',
{ expectedProtocolFeePaid, actualProtocolFeePaid },
);
}
}
Expand Down

0 comments on commit e3bfbbe

Please sign in to comment.