Track WETH reserved for rewards
This commit is contained in:
@@ -146,6 +146,9 @@ contract MixinStorage is
|
|||||||
/// @dev State for unfinalized rewards.
|
/// @dev State for unfinalized rewards.
|
||||||
IStructs.UnfinalizedState public unfinalizedState;
|
IStructs.UnfinalizedState public unfinalizedState;
|
||||||
|
|
||||||
|
/// @dev The WETH balance of this contract that is reserved for pool reward payouts.
|
||||||
|
uint256 _reservedWethBalance;
|
||||||
|
|
||||||
/// @dev Adds owner as an authorized address.
|
/// @dev Adds owner as an authorized address.
|
||||||
constructor()
|
constructor()
|
||||||
public
|
public
|
||||||
|
@@ -217,6 +217,7 @@ contract MixinStake is
|
|||||||
// to.
|
// to.
|
||||||
IStructs.StoredBalance memory finalDelegatedStakeToPoolByOwner =
|
IStructs.StoredBalance memory finalDelegatedStakeToPoolByOwner =
|
||||||
_loadSyncedBalance(_delegatedStakeToPoolByOwner[owner][poolId]);
|
_loadSyncedBalance(_delegatedStakeToPoolByOwner[owner][poolId]);
|
||||||
|
|
||||||
_withdrawAndSyncDelegatorRewards(
|
_withdrawAndSyncDelegatorRewards(
|
||||||
poolId,
|
poolId,
|
||||||
owner,
|
owner,
|
||||||
@@ -256,6 +257,7 @@ contract MixinStake is
|
|||||||
// from
|
// from
|
||||||
IStructs.StoredBalance memory finalDelegatedStakeToPoolByOwner =
|
IStructs.StoredBalance memory finalDelegatedStakeToPoolByOwner =
|
||||||
_loadSyncedBalance(_delegatedStakeToPoolByOwner[owner][poolId]);
|
_loadSyncedBalance(_delegatedStakeToPoolByOwner[owner][poolId]);
|
||||||
|
|
||||||
_withdrawAndSyncDelegatorRewards(
|
_withdrawAndSyncDelegatorRewards(
|
||||||
poolId,
|
poolId,
|
||||||
owner,
|
owner,
|
||||||
|
@@ -204,6 +204,7 @@ contract MixinStakingPoolRewards is
|
|||||||
if (membersReward > 0) {
|
if (membersReward > 0) {
|
||||||
// Increment the balance of the pool
|
// Increment the balance of the pool
|
||||||
balanceByPoolId[poolId] = balanceByPoolId[poolId].safeAdd(membersReward);
|
balanceByPoolId[poolId] = balanceByPoolId[poolId].safeAdd(membersReward);
|
||||||
|
_reservedWethBalance = _reservedWethBalance.safeAdd(membersReward);
|
||||||
|
|
||||||
// Fetch the last epoch at which we stored an entry for this pool;
|
// Fetch the last epoch at which we stored an entry for this pool;
|
||||||
// this is the most up-to-date cumulative rewards for this pool.
|
// this is the most up-to-date cumulative rewards for this pool.
|
||||||
@@ -297,6 +298,7 @@ contract MixinStakingPoolRewards is
|
|||||||
|
|
||||||
// Decrement the balance of the pool
|
// Decrement the balance of the pool
|
||||||
balanceByPoolId[poolId] = balanceByPoolId[poolId].safeSub(balance);
|
balanceByPoolId[poolId] = balanceByPoolId[poolId].safeSub(balance);
|
||||||
|
_reservedWethBalance = _reservedWethBalance.safeSub(balance);
|
||||||
|
|
||||||
// Withdraw the member's WETH balance
|
// Withdraw the member's WETH balance
|
||||||
_getWethContract().transfer(member, balance);
|
_getWethContract().transfer(member, balance);
|
||||||
|
@@ -248,7 +248,9 @@ contract MixinFinalizer is
|
|||||||
if (ethBalance != 0) {
|
if (ethBalance != 0) {
|
||||||
wethContract.deposit.value(ethBalance)();
|
wethContract.deposit.value(ethBalance)();
|
||||||
}
|
}
|
||||||
wethBalance = wethContract.balanceOf(address(this));
|
wethBalance = wethContract.balanceOf(address(this))
|
||||||
|
.safeSub(_reservedWethBalance);
|
||||||
|
|
||||||
return wethBalance;
|
return wethBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ import { DelegatorsByPoolId, OperatorByPoolId, StakeInfo, StakeStatus } from './
|
|||||||
|
|
||||||
// tslint:disable:no-unnecessary-type-assertion
|
// tslint:disable:no-unnecessary-type-assertion
|
||||||
// tslint:disable:max-file-line-count
|
// tslint:disable:max-file-line-count
|
||||||
blockchainTests.resets.skip('Testing Rewards', env => {
|
blockchainTests.resets('Testing Rewards', env => {
|
||||||
// tokens & addresses
|
// tokens & addresses
|
||||||
let accounts: string[];
|
let accounts: string[];
|
||||||
let owner: string;
|
let owner: string;
|
||||||
|
Reference in New Issue
Block a user