Replaced protocolFeePaid -> protocolFeeAmount. Changed some wording in comments.

This commit is contained in:
Greg Hysen 2019-10-24 13:43:19 -07:00
parent 06715201a7
commit cc7452da8f
5 changed files with 24 additions and 24 deletions

View File

@ -41,17 +41,17 @@ contract MixinExchangeFees is
/// (MixinExchangeManager). /// (MixinExchangeManager).
/// @param makerAddress The address of the order's maker. /// @param makerAddress The address of the order's maker.
/// @param payerAddress The address of the protocol fee payer. /// @param payerAddress The address of the protocol fee payer.
/// @param protocolFeePaid The protocol fee that should be paid. /// @param protocolFee The protocol fee amount. This is either passed as ETH or transferred as WETH.
function payProtocolFee( function payProtocolFee(
address makerAddress, address makerAddress,
address payerAddress, address payerAddress,
uint256 protocolFeePaid uint256 protocolFee
) )
external external
payable payable
onlyExchange onlyExchange
{ {
_assertValidProtocolFee(protocolFeePaid); _assertValidProtocolFee(protocolFee);
// Transfer the protocol fee to this address if it should be paid in // Transfer the protocol fee to this address if it should be paid in
// WETH. // WETH.
@ -60,7 +60,7 @@ contract MixinExchangeFees is
getWethContract().transferFrom( getWethContract().transferFrom(
payerAddress, payerAddress,
address(this), address(this),
protocolFeePaid protocolFee
), ),
"WETH_TRANSFER_FAILED" "WETH_TRANSFER_FAILED"
); );
@ -106,10 +106,10 @@ contract MixinExchangeFees is
} }
// Credit the fees to the pool. // Credit the fees to the pool.
poolStatsPtr.feesCollected = feesCollectedByPool.safeAdd(protocolFeePaid); poolStatsPtr.feesCollected = feesCollectedByPool.safeAdd(protocolFee);
// Increase the total fees collected this epoch. // Increase the total fees collected this epoch.
aggregatedStatsPtr.totalFeesCollected = aggregatedStatsPtr.totalFeesCollected.safeAdd(protocolFeePaid); aggregatedStatsPtr.totalFeesCollected = aggregatedStatsPtr.totalFeesCollected.safeAdd(protocolFee);
} }
/// @dev Get stats on a staking pool in this epoch. /// @dev Get stats on a staking pool in this epoch.
@ -155,18 +155,18 @@ contract MixinExchangeFees is
/// @dev Checks that the protocol fee passed into `payProtocolFee()` is /// @dev Checks that the protocol fee passed into `payProtocolFee()` is
/// valid. /// valid.
/// @param protocolFeePaid The `protocolFeePaid` parameter to /// @param protocolFee The `protocolFee` parameter to
/// `payProtocolFee.` /// `payProtocolFee.`
function _assertValidProtocolFee(uint256 protocolFeePaid) function _assertValidProtocolFee(uint256 protocolFee)
private private
view view
{ {
// The protocol fee must equal the value passed to the contract; unless // The protocol fee must equal the value passed to the contract; unless
// the value is zero, in which case the fee is taken in WETH. // the value is zero, in which case the fee is taken in WETH.
if (msg.value != protocolFeePaid && msg.value != 0) { if (msg.value != protocolFee && msg.value != 0) {
LibRichErrors.rrevert( LibRichErrors.rrevert(
LibStakingRichErrors.InvalidProtocolFeePaymentError( LibStakingRichErrors.InvalidProtocolFeePaymentError(
protocolFeePaid, protocolFee,
msg.value msg.value
) )
); );

View File

@ -40,11 +40,11 @@ interface IStaking {
/// @dev Pays a protocol fee in ETH. /// @dev Pays a protocol fee in ETH.
/// @param makerAddress The address of the order's maker. /// @param makerAddress The address of the order's maker.
/// @param payerAddress The address that is responsible for paying the protocol fee. /// @param payerAddress The address that is responsible for paying the protocol fee.
/// @param protocolFeePaid The amount of protocol fees that should be paid. /// @param protocolFee The amount of protocol fees that should be paid.
function payProtocolFee( function payProtocolFee(
address makerAddress, address makerAddress,
address payerAddress, address payerAddress,
uint256 protocolFeePaid uint256 protocolFee
) )
external external
payable; payable;

View File

@ -178,19 +178,19 @@ contract MixinStake is
staker staker
); );
// Increment how much stake the staker has delegated to the input pool. // Increase how much stake the staker has delegated to the input pool.
_increaseNextBalance( _increaseNextBalance(
_delegatedStakeToPoolByOwner[staker][poolId], _delegatedStakeToPoolByOwner[staker][poolId],
amount amount
); );
// Increment how much stake has been delegated to pool. // Increase how much stake has been delegated to pool.
_increaseNextBalance( _increaseNextBalance(
_delegatedStakeByPoolId[poolId], _delegatedStakeByPoolId[poolId],
amount amount
); );
// Increase next balance of global delegated stake // Increase next balance of global delegated stake.
_increaseNextBalance( _increaseNextBalance(
_globalStakeByStatus[uint8(IStructs.StakeStatus.DELEGATED)], _globalStakeByStatus[uint8(IStructs.StakeStatus.DELEGATED)],
amount amount
@ -216,19 +216,19 @@ contract MixinStake is
staker staker
); );
// decrement how much stake the staker has delegated to the input pool // Decrease how much stake the staker has delegated to the input pool.
_decreaseNextBalance( _decreaseNextBalance(
_delegatedStakeToPoolByOwner[staker][poolId], _delegatedStakeToPoolByOwner[staker][poolId],
amount amount
); );
// decrement how much stake has been delegated to pool // Decrease how much stake has been delegated to pool.
_decreaseNextBalance( _decreaseNextBalance(
_delegatedStakeByPoolId[poolId], _delegatedStakeByPoolId[poolId],
amount amount
); );
// decrease next balance of global delegated stake // Decrease next balance of global delegated stake (aggregated across all stakers).
_decreaseNextBalance( _decreaseNextBalance(
_globalStakeByStatus[uint8(IStructs.StakeStatus.DELEGATED)], _globalStakeByStatus[uint8(IStructs.StakeStatus.DELEGATED)],
amount amount

View File

@ -90,7 +90,7 @@ blockchainTests('Protocol Fees unit tests', env => {
return expect(tx).to.revertWith(expectedError); return expect(tx).to.revertWith(expectedError);
}); });
it('should revert if `protocolFeePaid` is zero with non-zero value sent', async () => { it('should revert if `protocolFee` is zero with non-zero value sent', async () => {
const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync( const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress, makerAddress,
payerAddress, payerAddress,
@ -104,7 +104,7 @@ blockchainTests('Protocol Fees unit tests', env => {
return expect(tx).to.revertWith(expectedError); return expect(tx).to.revertWith(expectedError);
}); });
it('should revert if `protocolFeePaid` is < than the provided message value', async () => { it('should revert if `protocolFee` is < than the provided message value', async () => {
const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync( const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress, makerAddress,
payerAddress, payerAddress,
@ -118,7 +118,7 @@ blockchainTests('Protocol Fees unit tests', env => {
return expect(tx).to.revertWith(expectedError); return expect(tx).to.revertWith(expectedError);
}); });
it('should revert if `protocolFeePaid` is > than the provided message value', async () => { it('should revert if `protocolFee` is > than the provided message value', async () => {
const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync( const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress, makerAddress,
payerAddress, payerAddress,

View File

@ -24,7 +24,7 @@ interface TestLog {
export class CumulativeRewardTrackingSimulation { export class CumulativeRewardTrackingSimulation {
private readonly _amountToStake = toBaseUnitAmount(100); private readonly _amountToStake = toBaseUnitAmount(100);
private readonly _protocolFeeAmount = new BigNumber(10); private readonly _protocolFee = new BigNumber(10);
private readonly _stakingApiWrapper: StakingApiWrapper; private readonly _stakingApiWrapper: StakingApiWrapper;
private readonly _staker: string; private readonly _staker: string;
private readonly _poolOperator: string; private readonly _poolOperator: string;
@ -141,8 +141,8 @@ export class CumulativeRewardTrackingSimulation {
receipt = await this._stakingApiWrapper.stakingContract.payProtocolFee.awaitTransactionSuccessAsync( receipt = await this._stakingApiWrapper.stakingContract.payProtocolFee.awaitTransactionSuccessAsync(
this._poolOperator, this._poolOperator,
this._takerAddress, this._takerAddress,
this._protocolFeeAmount, this._protocolFee,
{ from: this._exchangeAddress, value: this._protocolFeeAmount }, { from: this._exchangeAddress, value: this._protocolFee },
); );
break; break;