Remove getAvailableRewardsBalance public function, make wethReservedForPoolRewards public

This commit is contained in:
Amir Bandeali 2019-09-24 09:08:21 -07:00
parent b6a96cea23
commit a7aa7feff4
6 changed files with 12 additions and 23 deletions

View File

@ -124,20 +124,6 @@ contract MixinExchangeFees is
activePoolsThisEpoch[poolId] = pool;
}
/// @dev Returns the total balance of this contract, including WETH,
/// minus any WETH that has been reserved for rewards.
/// @return totalBalance Total balance.
function getAvailableRewardsBalance()
external
view
returns (uint256 totalBalance)
{
totalBalance = address(this).balance.safeAdd(
_getAvailableWethBalance()
);
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

@ -147,7 +147,7 @@ contract MixinStorage is
IStructs.UnfinalizedState public unfinalizedState;
/// @dev The WETH balance of this contract that is reserved for pool reward payouts.
uint256 internal _wethReservedForPoolRewards;
uint256 public wethReservedForPoolRewards;
/// @dev Adds owner as an authorized address.
constructor()

View File

@ -435,7 +435,7 @@ contract MixinStakingPoolRewards is
private
{
rewardsByPoolId[poolId] = rewardsByPoolId[poolId].safeAdd(amount);
_wethReservedForPoolRewards = _wethReservedForPoolRewards.safeAdd(amount);
wethReservedForPoolRewards = wethReservedForPoolRewards.safeAdd(amount);
}
/// @dev Decreases rewards for a pool.
@ -445,6 +445,6 @@ contract MixinStakingPoolRewards is
private
{
rewardsByPoolId[poolId] = rewardsByPoolId[poolId].safeSub(amount);
_wethReservedForPoolRewards = _wethReservedForPoolRewards.safeSub(amount);
wethReservedForPoolRewards = wethReservedForPoolRewards.safeSub(amount);
}
}

View File

@ -257,7 +257,7 @@ contract MixinFinalizer is
returns (uint256 wethBalance)
{
wethBalance = _getWethContract().balanceOf(address(this))
.safeSub(_wethReservedForPoolRewards);
.safeSub(wethReservedForPoolRewards);
return wethBalance;
}

View File

@ -241,7 +241,7 @@ export class FinalizerActor extends BaseActor {
this._stakingApiWrapper.stakingContract.getActiveStakingPoolThisEpoch.callAsync(poolId),
),
);
const totalRewards = await this._stakingApiWrapper.stakingContract.getAvailableRewardsBalance.callAsync();
const totalRewards = await this._stakingApiWrapper.utils.getAvailableRewardsBalanceAsync();
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

@ -122,10 +122,13 @@ 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);
getAvailableRewardsBalanceAsync: async (): Promise<BigNumber> => {
const [ethBalance, wethBalance, reservedRewards] = await Promise.all([
this._web3Wrapper.getBalanceInWeiAsync(this.stakingProxyContract.address),
this.wethContract.balanceOf.callAsync(this.stakingProxyContract.address),
this.stakingContract.wethReservedForPoolRewards.callAsync(),
]);
return BigNumber.sum(ethBalance, wethBalance).minus(reservedRewards);
},
getParamsAsync: async (): Promise<StakingParams> => {