Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Tests for new staking mechanics
Browse files Browse the repository at this point in the history
  • Loading branch information
hysz committed Sep 4, 2019
1 parent dbbcf66 commit 213e56a
Show file tree
Hide file tree
Showing 14 changed files with 1,369 additions and 279 deletions.
7 changes: 4 additions & 3 deletions contracts/staking/contracts/src/fees/MixinExchangeFees.sol
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ contract MixinExchangeFees is

// sanity check - this is a gas optimization that can be used because we assume a non-zero
// split between stake and fees generated in the cobb-douglas computation (see below).
if (totalFeesCollected == 0 || totalWeightedStake == 0) {
if (totalFeesCollected == 0) {
return (
totalActivePools,
totalFeesCollected,
Expand All @@ -214,12 +214,13 @@ contract MixinExchangeFees is
// step 2/3 - record reward for each pool
for (uint256 i = 0; i != totalActivePools; i++) {
// compute reward using cobb-douglas formula
// we set weighted stake to 1/1 if there is no delegated stake.
uint256 reward = LibFeeMath._cobbDouglasSuperSimplified(
initialContractBalance,
activePools[i].feesCollected,
totalFeesCollected,
activePools[i].weightedStake,
totalWeightedStake
totalWeightedStake != 0 ? activePools[i].weightedStake : 1,
totalWeightedStake != 0 ? totalWeightedStake : 1
);

// record reward in vault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,12 @@ interface IStakingPoolRewardVault {
external
view
returns (uint256);

/// @dev Returns the operator share of a pool's balance.
/// @param poolId Unique Id of pool.
/// @return Operator share (integer out of 100)
function getOperatorShare(bytes32 poolId)
external
view
returns (uint256);
}
11 changes: 11 additions & 0 deletions contracts/staking/contracts/src/vaults/StakingPoolRewardVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,17 @@ contract StakingPoolRewardVault is
return balanceByPoolId[poolId].membersBalance;
}

/// @dev Returns the operator share of a pool's balance.
/// @param poolId Unique Id of pool.
/// @return Operator share (integer out of 100)
function getOperatorShare(bytes32 poolId)
external
view
returns (uint256)
{
return balanceByPoolId[poolId].operatorShare;
}

/// @dev Increments a balance struct, splitting the input amount between the
/// pool operator and members of the pool based on the pool operator's share.
/// @param balance Balance struct to increment.
Expand Down
2 changes: 0 additions & 2 deletions contracts/staking/contracts/test/LibFeeMathTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
pragma solidity ^0.5.5;




contract LibFeeMathTest {

function nthRoot(uint256 base, uint256 n) public pure returns (uint256 root) {
Expand Down
160 changes: 0 additions & 160 deletions contracts/staking/test/actors/delegator_actor.ts

This file was deleted.

Loading

0 comments on commit 213e56a

Please sign in to comment.