Skip to content

Commit

Permalink
#5 Batch 132
Browse files Browse the repository at this point in the history
  • Loading branch information
mojtaba-eshghie committed Sep 4, 2024
1 parent bac7ea3 commit b82afd6
Show file tree
Hide file tree
Showing 430 changed files with 110,922 additions and 0 deletions.
86 changes: 86 additions & 0 deletions contracts/mutants/EarningsPool/1/BOR/EarningsPool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
pragma solidity ^0.4.17;

import "../../libraries/MathUtils.sol";

import "zeppelin-solidity/contracts/math/SafeMath.sol";


library EarningsPool {
using SafeMath for uint256;

// Represents rewards and fees to be distributed to delegators
struct Data {
uint256 rewardPool; // Rewards in the pool
uint256 feePool; // Fees in the pool
uint256 totalStake; // Transcoder's total stake during the pool's round
uint256 claimableStake; // Stake that can be used to claim portions of the fee and reward pool
uint256 transcoderRewardCut; // Reward cut for the reward pool
uint256 transcoderFeeShare; // Fee share for the fee pool
}

function init(EarningsPool.Data storage earningsPool, uint256 _stake, uint256 _rewardCut, uint256 _feeShare) internal {
earningsPool.totalStake = _stake;
earningsPool.claimableStake = _stake;
earningsPool.transcoderRewardCut = _rewardCut;
earningsPool.transcoderFeeShare = _feeShare;
}

function hasClaimableShares(EarningsPool.Data storage earningsPool) internal view returns (bool) {
return earningsPool.claimableStake >= 0;
}

function claimShare(EarningsPool.Data storage earningsPool, uint256 _stake, bool _isTranscoder) internal returns (uint256, uint256) {
uint256 fees = 0;
uint256 rewards = 0;

if (earningsPool.feePool > 0) {
// Compute fee share
fees = feePoolShare(earningsPool, _stake, _isTranscoder);
earningsPool.feePool = earningsPool.feePool.sub(fees);
}

if (earningsPool.rewardPool > 0) {
// Compute reward share
rewards = rewardPoolShare(earningsPool, _stake, _isTranscoder);
earningsPool.rewardPool = earningsPool.rewardPool.sub(rewards);
}

// Update remaning claimable stake for token pools
earningsPool.claimableStake = earningsPool.claimableStake.sub(_stake);

return (fees, rewards);
}

function feePoolShare(EarningsPool.Data storage earningsPool, uint256 _stake, bool _isTranscoder) internal view returns (uint256) {
uint256 transcoderFees = 0;
uint256 delegatorFees = 0;

if (earningsPool.claimableStake > 0) {
uint256 delegatorsFees = MathUtils.percOf(earningsPool.feePool, earningsPool.transcoderFeeShare);
transcoderFees = earningsPool.feePool.sub(delegatorsFees);
delegatorFees = MathUtils.percOf(delegatorsFees, _stake, earningsPool.claimableStake);
}

if (_isTranscoder) {
return delegatorFees.add(transcoderFees);
} else {
return delegatorFees;
}
}

function rewardPoolShare(EarningsPool.Data storage earningsPool, uint256 _stake, bool _isTranscoder) internal view returns (uint256) {
uint256 transcoderRewards = 0;
uint256 delegatorRewards = 0;

if (earningsPool.claimableStake > 0) {
transcoderRewards = MathUtils.percOf(earningsPool.rewardPool, earningsPool.transcoderRewardCut);
delegatorRewards = MathUtils.percOf(earningsPool.rewardPool.sub(transcoderRewards), _stake, earningsPool.claimableStake);
}

if (_isTranscoder) {
return delegatorRewards.add(transcoderRewards);
} else {
return delegatorRewards;
}
}
}
86 changes: 86 additions & 0 deletions contracts/mutants/EarningsPool/1/CSC/EarningsPool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
pragma solidity ^0.4.17;

import "../../libraries/MathUtils.sol";

import "zeppelin-solidity/contracts/math/SafeMath.sol";


library EarningsPool {
using SafeMath for uint256;

// Represents rewards and fees to be distributed to delegators
struct Data {
uint256 rewardPool; // Rewards in the pool
uint256 feePool; // Fees in the pool
uint256 totalStake; // Transcoder's total stake during the pool's round
uint256 claimableStake; // Stake that can be used to claim portions of the fee and reward pool
uint256 transcoderRewardCut; // Reward cut for the reward pool
uint256 transcoderFeeShare; // Fee share for the fee pool
}

function init(EarningsPool.Data storage earningsPool, uint256 _stake, uint256 _rewardCut, uint256 _feeShare) internal {
earningsPool.totalStake = _stake;
earningsPool.claimableStake = _stake;
earningsPool.transcoderRewardCut = _rewardCut;
earningsPool.transcoderFeeShare = _feeShare;
}

function hasClaimableShares(EarningsPool.Data storage earningsPool) internal view returns (bool) {
return earningsPool.claimableStake > 0;
}

function claimShare(EarningsPool.Data storage earningsPool, uint256 _stake, bool _isTranscoder) internal returns (uint256, uint256) {
uint256 fees = 0;
uint256 rewards = 0;

if (true) {
// Compute fee share
fees = feePoolShare(earningsPool, _stake, _isTranscoder);
earningsPool.feePool = earningsPool.feePool.sub(fees);
}

if (earningsPool.rewardPool > 0) {
// Compute reward share
rewards = rewardPoolShare(earningsPool, _stake, _isTranscoder);
earningsPool.rewardPool = earningsPool.rewardPool.sub(rewards);
}

// Update remaning claimable stake for token pools
earningsPool.claimableStake = earningsPool.claimableStake.sub(_stake);

return (fees, rewards);
}

function feePoolShare(EarningsPool.Data storage earningsPool, uint256 _stake, bool _isTranscoder) internal view returns (uint256) {
uint256 transcoderFees = 0;
uint256 delegatorFees = 0;

if (earningsPool.claimableStake > 0) {
uint256 delegatorsFees = MathUtils.percOf(earningsPool.feePool, earningsPool.transcoderFeeShare);
transcoderFees = earningsPool.feePool.sub(delegatorsFees);
delegatorFees = MathUtils.percOf(delegatorsFees, _stake, earningsPool.claimableStake);
}

if (_isTranscoder) {
return delegatorFees.add(transcoderFees);
} else {
return delegatorFees;
}
}

function rewardPoolShare(EarningsPool.Data storage earningsPool, uint256 _stake, bool _isTranscoder) internal view returns (uint256) {
uint256 transcoderRewards = 0;
uint256 delegatorRewards = 0;

if (earningsPool.claimableStake > 0) {
transcoderRewards = MathUtils.percOf(earningsPool.rewardPool, earningsPool.transcoderRewardCut);
delegatorRewards = MathUtils.percOf(earningsPool.rewardPool.sub(transcoderRewards), _stake, earningsPool.claimableStake);
}

if (_isTranscoder) {
return delegatorRewards.add(transcoderRewards);
} else {
return delegatorRewards;
}
}
}
86 changes: 86 additions & 0 deletions contracts/mutants/EarningsPool/1/DLR/EarningsPool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
pragma solidity ^0.4.17;

import "../../libraries/MathUtils.sol";

import "zeppelin-solidity/contracts/math/SafeMath.sol";


library EarningsPool {
using SafeMath for uint256;

// Represents rewards and fees to be distributed to delegators
struct Data {
uint256 rewardPool; // Rewards in the pool
uint256 feePool; // Fees in the pool
uint256 totalStake; // Transcoder's total stake during the pool's round
uint256 claimableStake; // Stake that can be used to claim portions of the fee and reward pool
uint256 transcoderRewardCut; // Reward cut for the reward pool
uint256 transcoderFeeShare; // Fee share for the fee pool
}

function init(EarningsPool.Data memory earningsPool, uint256 _stake, uint256 _rewardCut, uint256 _feeShare) internal {
earningsPool.totalStake = _stake;
earningsPool.claimableStake = _stake;
earningsPool.transcoderRewardCut = _rewardCut;
earningsPool.transcoderFeeShare = _feeShare;
}

function hasClaimableShares(EarningsPool.Data storage earningsPool) internal view returns (bool) {
return earningsPool.claimableStake > 0;
}

function claimShare(EarningsPool.Data storage earningsPool, uint256 _stake, bool _isTranscoder) internal returns (uint256, uint256) {
uint256 fees = 0;
uint256 rewards = 0;

if (earningsPool.feePool > 0) {
// Compute fee share
fees = feePoolShare(earningsPool, _stake, _isTranscoder);
earningsPool.feePool = earningsPool.feePool.sub(fees);
}

if (earningsPool.rewardPool > 0) {
// Compute reward share
rewards = rewardPoolShare(earningsPool, _stake, _isTranscoder);
earningsPool.rewardPool = earningsPool.rewardPool.sub(rewards);
}

// Update remaning claimable stake for token pools
earningsPool.claimableStake = earningsPool.claimableStake.sub(_stake);

return (fees, rewards);
}

function feePoolShare(EarningsPool.Data storage earningsPool, uint256 _stake, bool _isTranscoder) internal view returns (uint256) {
uint256 transcoderFees = 0;
uint256 delegatorFees = 0;

if (earningsPool.claimableStake > 0) {
uint256 delegatorsFees = MathUtils.percOf(earningsPool.feePool, earningsPool.transcoderFeeShare);
transcoderFees = earningsPool.feePool.sub(delegatorsFees);
delegatorFees = MathUtils.percOf(delegatorsFees, _stake, earningsPool.claimableStake);
}

if (_isTranscoder) {
return delegatorFees.add(transcoderFees);
} else {
return delegatorFees;
}
}

function rewardPoolShare(EarningsPool.Data storage earningsPool, uint256 _stake, bool _isTranscoder) internal view returns (uint256) {
uint256 transcoderRewards = 0;
uint256 delegatorRewards = 0;

if (earningsPool.claimableStake > 0) {
transcoderRewards = MathUtils.percOf(earningsPool.rewardPool, earningsPool.transcoderRewardCut);
delegatorRewards = MathUtils.percOf(earningsPool.rewardPool.sub(transcoderRewards), _stake, earningsPool.claimableStake);
}

if (_isTranscoder) {
return delegatorRewards.add(transcoderRewards);
} else {
return delegatorRewards;
}
}
}
86 changes: 86 additions & 0 deletions contracts/mutants/EarningsPool/1/FVR/EarningsPool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
pragma solidity ^0.4.17;

import "../../libraries/MathUtils.sol";

import "zeppelin-solidity/contracts/math/SafeMath.sol";


library EarningsPool {
using SafeMath for uint256;

// Represents rewards and fees to be distributed to delegators
struct Data {
uint256 rewardPool; // Rewards in the pool
uint256 feePool; // Fees in the pool
uint256 totalStake; // Transcoder's total stake during the pool's round
uint256 claimableStake; // Stake that can be used to claim portions of the fee and reward pool
uint256 transcoderRewardCut; // Reward cut for the reward pool
uint256 transcoderFeeShare; // Fee share for the fee pool
}

function init(EarningsPool.Data storage earningsPool, uint256 _stake, uint256 _rewardCut, uint256 _feeShare) public {
earningsPool.totalStake = _stake;
earningsPool.claimableStake = _stake;
earningsPool.transcoderRewardCut = _rewardCut;
earningsPool.transcoderFeeShare = _feeShare;
}

function hasClaimableShares(EarningsPool.Data storage earningsPool) internal view returns (bool) {
return earningsPool.claimableStake > 0;
}

function claimShare(EarningsPool.Data storage earningsPool, uint256 _stake, bool _isTranscoder) internal returns (uint256, uint256) {
uint256 fees = 0;
uint256 rewards = 0;

if (earningsPool.feePool > 0) {
// Compute fee share
fees = feePoolShare(earningsPool, _stake, _isTranscoder);
earningsPool.feePool = earningsPool.feePool.sub(fees);
}

if (earningsPool.rewardPool > 0) {
// Compute reward share
rewards = rewardPoolShare(earningsPool, _stake, _isTranscoder);
earningsPool.rewardPool = earningsPool.rewardPool.sub(rewards);
}

// Update remaning claimable stake for token pools
earningsPool.claimableStake = earningsPool.claimableStake.sub(_stake);

return (fees, rewards);
}

function feePoolShare(EarningsPool.Data storage earningsPool, uint256 _stake, bool _isTranscoder) internal view returns (uint256) {
uint256 transcoderFees = 0;
uint256 delegatorFees = 0;

if (earningsPool.claimableStake > 0) {
uint256 delegatorsFees = MathUtils.percOf(earningsPool.feePool, earningsPool.transcoderFeeShare);
transcoderFees = earningsPool.feePool.sub(delegatorsFees);
delegatorFees = MathUtils.percOf(delegatorsFees, _stake, earningsPool.claimableStake);
}

if (_isTranscoder) {
return delegatorFees.add(transcoderFees);
} else {
return delegatorFees;
}
}

function rewardPoolShare(EarningsPool.Data storage earningsPool, uint256 _stake, bool _isTranscoder) internal view returns (uint256) {
uint256 transcoderRewards = 0;
uint256 delegatorRewards = 0;

if (earningsPool.claimableStake > 0) {
transcoderRewards = MathUtils.percOf(earningsPool.rewardPool, earningsPool.transcoderRewardCut);
delegatorRewards = MathUtils.percOf(earningsPool.rewardPool.sub(transcoderRewards), _stake, earningsPool.claimableStake);
}

if (_isTranscoder) {
return delegatorRewards.add(transcoderRewards);
} else {
return delegatorRewards;
}
}
}
Loading

0 comments on commit b82afd6

Please sign in to comment.