@0x/contracts-staking: Remove getTotalBalance() function.

`@0x/contracts-staking`: Fix linter errors.
This commit is contained in:
Lawrence Forman
2019-09-23 14:21:18 -04:00
parent 196cc4313f
commit 3883297991
4 changed files with 13 additions and 18 deletions

View File

@@ -127,19 +127,6 @@ contract MixinExchangeFees is
activePoolsThisEpoch[poolId] = pool;
}
/// @dev Returns the total balance of this contract, including WETH.
/// @return totalBalance Total balance.
function getTotalBalance()
external
view
returns (uint256 totalBalance)
{
totalBalance = address(this).balance.safeAdd(
IEtherToken(_getWETHAddress()).balanceOf(address(this))
);
return totalBalance;
}
/// @dev Get information on an active staking pool in this epoch.
/// @param poolId Pool Id to query.
/// @return pool ActivePool struct.

View File

@@ -83,10 +83,10 @@ contract TestDelegatorRewards is
external
{
unfinalizedPoolRewardsByEpoch[currentEpoch][poolId] = UnfinalizedPoolReward({
operatorReward: operatorReward,
membersReward: membersReward,
membersStake: membersStake
});
operatorReward: operatorReward,
membersReward: membersReward,
membersStake: membersStake
});
// Lazily initialize this pool.
_poolById[poolId].operator = operatorAddress;
_setOperatorShare(poolId, operatorReward, membersReward);

View File

@@ -241,7 +241,9 @@ export class FinalizerActor extends BaseActor {
this._stakingApiWrapper.stakingContract.getActiveStakingPoolThisEpoch.callAsync(poolId),
),
);
const totalRewards = await this._stakingApiWrapper.stakingContract.getTotalBalance.callAsync();
const totalRewards = await this._stakingApiWrapper.utils.getEthAndWethBalanceOfAsync(
this._stakingApiWrapper.stakingContract.address,
);
const totalFeesCollected = BigNumber.sum(...activePools.map(p => p.feesCollected));
const totalWeightedStake = BigNumber.sum(...activePools.map(p => p.weightedStake));
if (totalRewards.eq(0) || totalFeesCollected.eq(0) || totalWeightedStake.eq(0)) {

View File

@@ -128,6 +128,12 @@ export class StakingApiWrapper {
);
},
getEthAndWethBalanceOfAsync: async (address: string): Promise<BigNumber> => {
const ethBalance = await this._web3Wrapper.getBalanceInWeiAsync(address);
const wethBalance = await this.wethContract.balanceOf.callAsync(address);
return BigNumber.sum(ethBalance, wethBalance);
},
getParamsAsync: async (): Promise<StakingParams> => {
return (_.zipObject(
[