Fix build

This commit is contained in:
Amir Bandeali
2019-09-15 11:04:29 -05:00
parent 97c107be3e
commit fd4141e1f3
7 changed files with 50 additions and 55 deletions

View File

@@ -164,7 +164,8 @@ export class FinalizerActor extends BaseActor {
private async _getOperatorShareByPoolIdAsync(poolIds: string[]): Promise<OperatorShareByPoolId> {
const operatorShareByPoolId: OperatorShareByPoolId = {};
for (const poolId of poolIds) {
const operatorShare = await this._stakingApiWrapper.rewardVaultContract.getOperatorShare.callAsync(poolId);
const pool = await this._stakingApiWrapper.rewardVaultContract.poolById.callAsync(poolId);
const operatorShare = new BigNumber(pool[1]);
operatorShareByPoolId[poolId] = operatorShare;
}
return operatorShareByPoolId;
@@ -179,15 +180,13 @@ export class FinalizerActor extends BaseActor {
}
private async _getRewardVaultBalanceAsync(poolId: string): Promise<RewardVaultBalance> {
const balances = await Promise.all([
this._stakingApiWrapper.rewardVaultContract.balanceOf.callAsync(poolId),
this._stakingApiWrapper.rewardVaultContract.balanceOfOperator.callAsync(poolId),
this._stakingApiWrapper.rewardVaultContract.balanceOfMembers.callAsync(poolId),
]);
const pool = await this._stakingApiWrapper.rewardVaultContract.poolById.callAsync(poolId);
const operatorBalance = pool[2];
const membersBalance = pool[3];
return {
poolBalance: balances[0],
operatorBalance: balances[1],
membersBalance: balances[2],
poolBalance: operatorBalance.plus(membersBalance),
operatorBalance,
membersBalance,
};
}
}

View File

@@ -1,5 +1,5 @@
import { expect } from '@0x/contracts-test-utils';
import { RevertError } from '@0x/utils';
import { BigNumber, RevertError } from '@0x/utils';
import * as _ from 'lodash';
import { constants as stakingConstants } from '../utils/constants';
@@ -13,7 +13,7 @@ export class PoolOperatorActor extends BaseActor {
revertError?: RevertError,
): Promise<string> {
// query next pool id
const nextPoolId = await this._stakingApiWrapper.stakingContract.getNextStakingPoolId.callAsync();
const nextPoolId = await this._stakingApiWrapper.stakingContract.nextPoolId.callAsync();
// create pool
const poolIdPromise = this._stakingApiWrapper.utils.createStakingPoolAsync(
this._owner,
@@ -35,7 +35,7 @@ export class PoolOperatorActor extends BaseActor {
);
expect(poolIdOfMaker, 'pool id of maker').to.be.equal(poolId);
// check the number of makers in the pool
const numMakersAfterRemoving = await this._stakingApiWrapper.stakingContract.getNumberOfMakersInStakingPool.callAsync(
const numMakersAfterRemoving = await this._stakingApiWrapper.stakingContract.numMakersByPoolId.callAsync(
poolId,
);
expect(numMakersAfterRemoving, 'number of makers in pool').to.be.bignumber.equal(1);
@@ -103,9 +103,8 @@ export class PoolOperatorActor extends BaseActor {
}
await txReceiptPromise;
// Check operator share
const decreasedOperatorShare = await this._stakingApiWrapper.rewardVaultContract.getOperatorShare.callAsync(
poolId,
);
const pool = await this._stakingApiWrapper.rewardVaultContract.poolById.callAsync(poolId);
const decreasedOperatorShare = new BigNumber(pool[1]);
expect(decreasedOperatorShare, 'updated operator share').to.be.bignumber.equal(newOperatorShare);
}
}

View File

@@ -171,7 +171,7 @@ export class StakerActor extends BaseActor {
const stakerBalances: StakeBalances = {
zrxBalance: await this._stakingApiWrapper.zrxTokenContract.balanceOf.callAsync(this._owner),
stakeBalance: await this._stakingApiWrapper.stakingContract.getTotalStake.callAsync(this._owner),
stakeBalanceInVault: await this._stakingApiWrapper.zrxVaultContract.balanceOf.callAsync(this._owner),
stakeBalanceInVault: await this._stakingApiWrapper.zrxVaultContract.balances.callAsync(this._owner),
withdrawableStakeBalance: await this._stakingApiWrapper.stakingContract.getWithdrawableStake.callAsync(
this._owner,
),

View File

@@ -27,18 +27,14 @@ blockchainTests('Exchange Integrations', env => {
});
blockchainTests.resets('Exchange Tracking in Staking Contract', () => {
it('basic exchange tracking', async () => {
const {
isValidExchangeAddress,
addExchangeAddress,
removeExchangeAddress,
} = stakingApiWrapper.stakingContract;
const { validExchanges, addExchangeAddress, removeExchangeAddress } = stakingApiWrapper.stakingContract;
// 1 try querying an invalid addresses
const invalidAddress = '0x0000000000000000000000000000000000000001';
const isInvalidAddressValid = await isValidExchangeAddress.callAsync(invalidAddress);
const isInvalidAddressValid = await validExchanges.callAsync(invalidAddress);
expect(isInvalidAddressValid).to.be.false();
// 2 add valid address
await addExchangeAddress.awaitTransactionSuccessAsync(exchange);
const isValidAddressValid = await isValidExchangeAddress.callAsync(exchange);
const isValidAddressValid = await validExchanges.callAsync(exchange);
expect(isValidAddressValid).to.be.true();
// 3 try adding valid address again
let revertError = new StakingRevertErrors.ExchangeAddressAlreadyRegisteredError(exchange);
@@ -46,7 +42,7 @@ blockchainTests('Exchange Integrations', env => {
await expect(tx).to.revertWith(revertError);
// 4 remove valid address
await removeExchangeAddress.awaitTransactionSuccessAsync(exchange);
const isValidAddressStillValid = await isValidExchangeAddress.callAsync(exchange);
const isValidAddressStillValid = await validExchanges.callAsync(exchange);
expect(isValidAddressStillValid).to.be.false();
// 5 try removing valid address again
revertError = new StakingRevertErrors.ExchangeAddressNotRegisteredError(exchange);

View File

@@ -40,7 +40,7 @@ blockchainTests('Staking Pool Management', env => {
const poolId = await poolOperator.createStakingPoolAsync(operatorShare, false);
expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID);
// check that the next pool id was incremented
const nextPoolId = await stakingApiWrapper.stakingContract.getNextStakingPoolId.callAsync();
const nextPoolId = await stakingApiWrapper.stakingContract.nextPoolId.callAsync();
expect(nextPoolId).to.be.equal(stakingConstants.SECOND_POOL_ID);
});
it('Should fail to create a pool with operator share > 100', async () => {
@@ -66,7 +66,7 @@ blockchainTests('Staking Pool Management', env => {
const poolId = await poolOperator.createStakingPoolAsync(operatorShare, true);
expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID);
// check that the next pool id was incremented
const nextPoolId = await stakingApiWrapper.stakingContract.getNextStakingPoolId.callAsync();
const nextPoolId = await stakingApiWrapper.stakingContract.nextPoolId.callAsync();
expect(nextPoolId).to.be.equal(stakingConstants.SECOND_POOL_ID);
});
it('Should throw if operatorShare is > PPM_DENOMINATOR', async () => {
@@ -138,7 +138,7 @@ blockchainTests('Staking Pool Management', env => {
);
// check the number of makers in the pool
let numMakers = await stakingApiWrapper.stakingContract.getNumberOfMakersInStakingPool.callAsync(poolId);
let numMakers = await stakingApiWrapper.stakingContract.numMakersByPoolId.callAsync(poolId);
expect(numMakers, 'number of makers in pool after adding').to.be.bignumber.equal(3);
// remove maker from pool
@@ -149,7 +149,7 @@ blockchainTests('Staking Pool Management', env => {
);
// check the number of makers in the pool
numMakers = await stakingApiWrapper.stakingContract.getNumberOfMakersInStakingPool.callAsync(poolId);
numMakers = await stakingApiWrapper.stakingContract.numMakersByPoolId.callAsync(poolId);
expect(numMakers, 'number of makers in pool after removing').to.be.bignumber.equal(0);
});
it('Should fail if maker already assigned to another pool tries to join', async () => {
@@ -337,7 +337,7 @@ blockchainTests('Staking Pool Management', env => {
);
// check the number of makers in the pool
const numMakers = await stakingApiWrapper.stakingContract.getNumberOfMakersInStakingPool.callAsync(poolId);
const numMakers = await stakingApiWrapper.stakingContract.numMakersByPoolId.callAsync(poolId);
expect(numMakers, 'number of makers in pool').to.be.bignumber.equal(
stakingConstants.DEFAULT_PARAMS.maximumMakersInPool,
);

View File

@@ -167,7 +167,7 @@ blockchainTests('Protocol Fee Unit Tests', env => {
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID },
);
assertNoWETHTransferLogs(receipt.logs);
const poolFees = await testContract.getProtocolFeesThisEpochByPool.callAsync(poolId);
const poolFees = await testContract.protocolFeesThisEpochByPool.callAsync(poolId);
expect(poolFees).to.bignumber.eq(DEFAULT_PROTOCOL_FEE_PAID);
});
@@ -180,7 +180,7 @@ blockchainTests('Protocol Fee Unit Tests', env => {
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID },
);
assertNoWETHTransferLogs(receipt.logs);
const poolFees = await testContract.getProtocolFeesThisEpochByPool.callAsync(poolId);
const poolFees = await testContract.protocolFeesThisEpochByPool.callAsync(poolId);
expect(poolFees).to.bignumber.eq(ZERO_AMOUNT);
});
@@ -198,7 +198,7 @@ blockchainTests('Protocol Fee Unit Tests', env => {
await payAsync();
await payAsync();
const expectedTotalFees = DEFAULT_PROTOCOL_FEE_PAID.times(2);
const poolFees = await testContract.getProtocolFeesThisEpochByPool.callAsync(poolId);
const poolFees = await testContract.protocolFeesThisEpochByPool.callAsync(poolId);
expect(poolFees).to.bignumber.eq(expectedTotalFees);
});
});
@@ -238,7 +238,7 @@ blockchainTests('Protocol Fee Unit Tests', env => {
{ from: exchangeAddress, value: ZERO_AMOUNT },
);
assertWETHTransferLogs(receipt.logs, payerAddress, DEFAULT_PROTOCOL_FEE_PAID);
const poolFees = await testContract.getProtocolFeesThisEpochByPool.callAsync(poolId);
const poolFees = await testContract.protocolFeesThisEpochByPool.callAsync(poolId);
expect(poolFees).to.bignumber.eq(DEFAULT_PROTOCOL_FEE_PAID);
});
@@ -251,7 +251,7 @@ blockchainTests('Protocol Fee Unit Tests', env => {
{ from: exchangeAddress, value: ZERO_AMOUNT },
);
assertWETHTransferLogs(receipt.logs, payerAddress, DEFAULT_PROTOCOL_FEE_PAID);
const poolFees = await testContract.getProtocolFeesThisEpochByPool.callAsync(poolId);
const poolFees = await testContract.protocolFeesThisEpochByPool.callAsync(poolId);
expect(poolFees).to.bignumber.eq(ZERO_AMOUNT);
});
@@ -269,7 +269,7 @@ blockchainTests('Protocol Fee Unit Tests', env => {
await payAsync();
await payAsync();
const expectedTotalFees = DEFAULT_PROTOCOL_FEE_PAID.times(2);
const poolFees = await testContract.getProtocolFeesThisEpochByPool.callAsync(poolId);
const poolFees = await testContract.protocolFeesThisEpochByPool.callAsync(poolId);
expect(poolFees).to.bignumber.eq(expectedTotalFees);
});
@@ -289,7 +289,7 @@ blockchainTests('Protocol Fee Unit Tests', env => {
await payAsync(true);
await payAsync(false);
const expectedTotalFees = DEFAULT_PROTOCOL_FEE_PAID.times(2);
const poolFees = await testContract.getProtocolFeesThisEpochByPool.callAsync(poolId);
const poolFees = await testContract.protocolFeesThisEpochByPool.callAsync(poolId);
expect(poolFees).to.bignumber.eq(expectedTotalFees);
});
});
@@ -309,7 +309,7 @@ blockchainTests('Protocol Fee Unit Tests', env => {
await payAsync(makerAddress);
await payAsync(otherMakerAddress);
const expectedTotalFees = DEFAULT_PROTOCOL_FEE_PAID.times(2);
const poolFees = await testContract.getProtocolFeesThisEpochByPool.callAsync(poolId);
const poolFees = await testContract.protocolFeesThisEpochByPool.callAsync(poolId);
expect(poolFees).to.bignumber.eq(expectedTotalFees);
});
@@ -330,8 +330,8 @@ blockchainTests('Protocol Fee Unit Tests', env => {
await payAsync(poolId, makerAddress, fee);
await payAsync(otherPoolId, otherMakerAddress, otherFee);
const [poolFees, otherPoolFees] = await Promise.all([
testContract.getProtocolFeesThisEpochByPool.callAsync(poolId),
testContract.getProtocolFeesThisEpochByPool.callAsync(otherPoolId),
testContract.protocolFeesThisEpochByPool.callAsync(poolId),
testContract.protocolFeesThisEpochByPool.callAsync(otherPoolId),
]);
expect(poolFees).to.bignumber.eq(fee);
expect(otherPoolFees).to.bignumber.eq(otherFee);
@@ -347,7 +347,7 @@ blockchainTests('Protocol Fee Unit Tests', env => {
DEFAULT_PROTOCOL_FEE_PAID,
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID },
);
const feesCredited = await testContract.getProtocolFeesThisEpochByPool.callAsync(poolId);
const feesCredited = await testContract.protocolFeesThisEpochByPool.callAsync(poolId);
expect(feesCredited).to.bignumber.eq(DEFAULT_PROTOCOL_FEE_PAID);
});
@@ -359,7 +359,7 @@ blockchainTests('Protocol Fee Unit Tests', env => {
DEFAULT_PROTOCOL_FEE_PAID,
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID },
);
const feesCredited = await testContract.getProtocolFeesThisEpochByPool.callAsync(poolId);
const feesCredited = await testContract.protocolFeesThisEpochByPool.callAsync(poolId);
expect(feesCredited).to.bignumber.eq(DEFAULT_PROTOCOL_FEE_PAID);
});
@@ -371,7 +371,7 @@ blockchainTests('Protocol Fee Unit Tests', env => {
DEFAULT_PROTOCOL_FEE_PAID,
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID },
);
const feesCredited = await testContract.getProtocolFeesThisEpochByPool.callAsync(poolId);
const feesCredited = await testContract.protocolFeesThisEpochByPool.callAsync(poolId);
expect(feesCredited).to.bignumber.eq(0);
});
});

View File

@@ -119,25 +119,25 @@ blockchainTests.resets('Testing Rewards', env => {
? _expectedEndBalances.membersRewardVaultBalance
: ZERO,
};
const pool = await stakingApiWrapper.rewardVaultContract.poolById.callAsync(poolId);
const operatorBalance = pool[2];
const membersBalance = pool[3];
const poolBalances = { poolBalance: operatorBalance.plus(membersBalance), operatorBalance, membersBalance };
const finalEndBalancesAsArray = await Promise.all([
// staker 1
stakingApiWrapper.stakingContract.computeRewardBalanceOfDelegator.callAsync(
poolId,
stakers[0].getOwner(),
),
stakingApiWrapper.ethVaultContract.balanceOf.callAsync(stakers[0].getOwner()),
stakingApiWrapper.ethVaultContract.balances.callAsync(stakers[0].getOwner()),
// staker 2
stakingApiWrapper.stakingContract.computeRewardBalanceOfDelegator.callAsync(
poolId,
stakers[1].getOwner(),
),
stakingApiWrapper.ethVaultContract.balanceOf.callAsync(stakers[1].getOwner()),
stakingApiWrapper.ethVaultContract.balances.callAsync(stakers[1].getOwner()),
// operator
stakingApiWrapper.rewardVaultContract.balanceOfOperator.callAsync(poolId),
stakingApiWrapper.ethVaultContract.balanceOf.callAsync(poolOperator),
// undivided balance in reward pool
stakingApiWrapper.rewardVaultContract.balanceOf.callAsync(poolId),
stakingApiWrapper.rewardVaultContract.balanceOfMembers.callAsync(poolId),
stakingApiWrapper.ethVaultContract.balances.callAsync(poolOperator),
]);
expect(finalEndBalancesAsArray[0], 'stakerRewardVaultBalance_1').to.be.bignumber.equal(
expectedEndBalances.stakerRewardVaultBalance_1,
@@ -151,16 +151,17 @@ blockchainTests.resets('Testing Rewards', env => {
expect(finalEndBalancesAsArray[3], 'stakerEthVaultBalance_2').to.be.bignumber.equal(
expectedEndBalances.stakerEthVaultBalance_2,
);
expect(finalEndBalancesAsArray[4], 'operatorRewardVaultBalance').to.be.bignumber.equal(
expectedEndBalances.operatorRewardVaultBalance,
);
expect(finalEndBalancesAsArray[5], 'operatorEthVaultBalance').to.be.bignumber.equal(
expect(finalEndBalancesAsArray[4], 'operatorEthVaultBalance').to.be.bignumber.equal(
expectedEndBalances.operatorEthVaultBalance,
);
expect(finalEndBalancesAsArray[6], 'poolRewardVaultBalance').to.be.bignumber.equal(
expect(poolBalances.operatorBalance, 'operatorRewardVaultBalance').to.be.bignumber.equal(
expectedEndBalances.operatorRewardVaultBalance,
);
expect(poolBalances.poolBalance, 'poolRewardVaultBalance').to.be.bignumber.equal(
expectedEndBalances.poolRewardVaultBalance,
);
expect(finalEndBalancesAsArray[7], 'membersRewardVaultBalance').to.be.bignumber.equal(
expect(poolBalances.membersBalance, 'membersRewardVaultBalance').to.be.bignumber.equal(
expectedEndBalances.membersRewardVaultBalance,
);
};