diff --git a/contracts/staking/contracts/src/staking_pools/MixinStakingPool.sol b/contracts/staking/contracts/src/staking_pools/MixinStakingPool.sol index 66294d7244..6365ea6bfe 100644 --- a/contracts/staking/contracts/src/staking_pools/MixinStakingPool.sol +++ b/contracts/staking/contracts/src/staking_pools/MixinStakingPool.sol @@ -164,8 +164,8 @@ contract MixinStakingPool is poolId, newOperatorShare )); - } else if (newOperatorShare >= currentOperatorShare) { - // new share must be less than the current share + } else if (newOperatorShare > currentOperatorShare) { + // new share must be less than or equal to the current share LibRichErrors.rrevert(LibStakingRichErrors.OperatorShareError( LibStakingRichErrors.OperatorShareErrorCodes.CanOnlyDecreaseOperatorShare, poolId, diff --git a/contracts/staking/test/pools_test.ts b/contracts/staking/test/pools_test.ts index 9bde7fbd24..a5ace2b4aa 100644 --- a/contracts/staking/test/pools_test.ts +++ b/contracts/staking/test/pools_test.ts @@ -174,7 +174,7 @@ blockchainTests('Staking Pool Management', env => { // decrease operator share await poolOperator.decreaseStakingPoolOperatorShareAsync(poolId, increasedOperatorShare, revertError); }); - it('Should fail if operator calls decreaseStakingPoolOperatorShare but newOperatorShare == oldOperatorShare', async () => { + it('Should be successful if operator calls decreaseStakingPoolOperatorShare and newOperatorShare == oldOperatorShare', async () => { // test parameters const operatorAddress = users[0]; const operatorShare = (39 / 100) * PPM_DENOMINATOR; @@ -184,13 +184,8 @@ blockchainTests('Staking Pool Management', env => { const poolId = await poolOperator.createStakingPoolAsync(operatorShare, false); expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID); - const revertError = new StakingRevertErrors.OperatorShareError( - StakingRevertErrors.OperatorShareErrorCodes.CanOnlyDecreaseOperatorShare, - poolId, - operatorShare, - ); // decrease operator share - await poolOperator.decreaseStakingPoolOperatorShareAsync(poolId, operatorShare, revertError); + await poolOperator.decreaseStakingPoolOperatorShareAsync(poolId, operatorShare); }); it('should fail to decrease operator share if not called by operator', async () => { // test parameters diff --git a/contracts/staking/test/unit_tests/staking_pool_test.ts b/contracts/staking/test/unit_tests/staking_pool_test.ts index b39bfa15d2..2849a28d15 100644 --- a/contracts/staking/test/unit_tests/staking_pool_test.ts +++ b/contracts/staking/test/unit_tests/staking_pool_test.ts @@ -170,6 +170,20 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { expect(pool.operator).to.eq(operator); expect(pool.operatorShare).to.bignumber.eq(operatorShare); }); + it('records pool details when operator share is 100%', async () => { + const operatorShare = constants.PPM_100_PERCENT; + await testContract.createStakingPool.awaitTransactionSuccessAsync(operatorShare, false, { from: operator }); + const pool = await testContract.getStakingPool.callAsync(nextPoolId); + expect(pool.operator).to.eq(operator); + expect(pool.operatorShare).to.bignumber.eq(operatorShare); + }); + it('records pool details when operator share is 0%', async () => { + const operatorShare = constants.ZERO_AMOUNT; + await testContract.createStakingPool.awaitTransactionSuccessAsync(operatorShare, false, { from: operator }); + const pool = await testContract.getStakingPool.callAsync(nextPoolId); + expect(pool.operator).to.eq(operator); + expect(pool.operatorShare).to.bignumber.eq(operatorShare); + }); it('returns the next pool ID', async () => { const poolId = await testContract.createStakingPool.callAsync(randomOperatorShare(), false, { from: operator, @@ -239,20 +253,6 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { const expectedError = new StakingRevertErrors.OnlyCallableByPoolOperatorError(maker, poolId); return expect(tx).to.revertWith(expectedError); }); - it('fails if operator share is equal to current', async () => { - const { poolId, operatorShare } = await createPoolAsync(); - const tx = testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( - poolId, - operatorShare, - { from: operator }, - ); - const expectedError = new StakingRevertErrors.OperatorShareError( - StakingRevertErrors.OperatorShareErrorCodes.CanOnlyDecreaseOperatorShare, - poolId, - operatorShare, - ); - return expect(tx).to.revertWith(expectedError); - }); it('fails if operator share is greater than current', async () => { const { poolId, operatorShare } = await createPoolAsync(); const tx = testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( @@ -291,6 +291,14 @@ blockchainTests.resets('MixinStakingPool unit tests', env => { const pool = await testContract.getStakingPool.callAsync(poolId); expect(pool.operatorShare).to.bignumber.eq(operatorShare - 1); }); + it('does not modify operator share if equal to current', async () => { + const { poolId, operatorShare } = await createPoolAsync(); + await testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync(poolId, operatorShare, { + from: operator, + }); + const pool = await testContract.getStakingPool.callAsync(poolId); + expect(pool.operatorShare).to.bignumber.eq(operatorShare); + }); it('does not modify operator', async () => { const { poolId, operatorShare } = await createPoolAsync(); await testContract.decreaseStakingPoolOperatorShare.awaitTransactionSuccessAsync( diff --git a/packages/migrations/src/test_contract_configs.ts b/packages/migrations/src/test_contract_configs.ts index aa29aa8cdd..3fe2ac5bfa 100644 --- a/packages/migrations/src/test_contract_configs.ts +++ b/packages/migrations/src/test_contract_configs.ts @@ -265,9 +265,6 @@ async function testContractConfigsAsync(provider: SupportedProvider): Promise