Skip to content

Commit

Permalink
Merge pull request #33 from soramitsu/feature/merge_penaltyclaim_to_c…
Browse files Browse the repository at this point in the history
…laim_

[Update] merge PenaltyClaim() with Claim()
  • Loading branch information
ayodeko authored Jun 17, 2024
2 parents 2d5fde2 + 25161b0 commit f026729
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 27 deletions.
9 changes: 8 additions & 1 deletion contracts/interfaces/IERC20Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,15 @@ interface IPoolERC20 {
* @dev Emitted in 'claim' function
* @param user The address of the user who claims rewards
* @param amount The amount of rewards claimed
* @param penaltyAmount The amount deducted as penalty fee
* @param totalPenalties The total amount of deducted penalty fee
*/
event Claim(address indexed user, uint256 amount);
event Claim(
address indexed user,
uint256 amount,
uint256 penaltyAmount,
uint256 totalPenalties
);

/**
* @notice Event to notify when the staking pool is updated
Expand Down
11 changes: 9 additions & 2 deletions contracts/interfaces/IERC721Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,15 @@ interface IPoolERC721 {
* @notice Event emitted when a user claims their rewards.
* @param user The address of the user who claimed the rewards.
* @param pending The amount of rewards claimed.
*/
event Claim(address indexed user, uint256 pending);
* @param penaltyAmount The amount deducted as penalty fee
* @param totalPenalties The total amount of deducted penalty fee
*/
event Claim(
address indexed user,
uint256 pending,
uint256 penaltyAmount,
uint256 totalPenalties
);

/**
* @notice Event emitted when the pool parameters are updated
Expand Down
15 changes: 1 addition & 14 deletions contracts/interfaces/IPenaltyFeePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,5 @@ interface IPenaltyFeePoolStorage {
*/
event FeeClaim(uint256 amount);

/**
* @notice Event to notify when a user claims rewards in penalty pool
* @dev Emitted in 'claim' function
* @param user The address of the user who claims rewards
* @param amount The amount of rewards claimed
* @param amount The amount of rewards claimed
* @param amount The amount of rewards claimed
*/
event PenaltyClaim(
address indexed user,
uint256 amount,
uint256 penalityAmount,
uint256 totalPenalties
);

}
2 changes: 1 addition & 1 deletion contracts/pools/ERC20LockUpStakingPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ contract ERC20LockUpPool is ReentrancyGuard, Ownable, IPoolERC20, ILockUpPoolSto
}
pool.totalClaimed += pending;
IERC20(pool.rewardToken).safeTransfer(msg.sender, pending);
emit Claim(msg.sender, pending);
emit Claim(msg.sender, pending, 0, 0);
} else {
revert NothingToClaim();
}
Expand Down
8 changes: 4 additions & 4 deletions contracts/pools/ERC20PenaltyFeePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,19 @@ contract ERC20PenaltyFeePool is ReentrancyGuard, Ownable, IPoolERC20, IPenaltyFe
}
if (pending > 0) {
user.pending = 0;
uint256 penalityAmount = _calculatePenalizedAmount(
uint256 penaltyAmount = _calculatePenalizedAmount(
user.penalized,
pending
);
pending -= penalityAmount;
pending -= penaltyAmount;
if (user.penalized) user.penalized = false;
unchecked {
user.claimed += pending;
}
pool.totalClaimed += pending;
pool.totalPenalties += penalityAmount;
pool.totalPenalties += penaltyAmount;
IERC20(pool.rewardToken).safeTransfer(msg.sender, pending);
emit PenaltyClaim(msg.sender, pending, penalityAmount, pool.totalPenalties);
emit Claim(msg.sender, pending, penaltyAmount, pool.totalPenalties);
} else {
revert NothingToClaim();
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/pools/ERC721/ERC721LockUpStakingPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ contract ERC721LockUpPool is
}
pool.totalClaimed += pending;
IERC20(pool.rewardToken).safeTransfer(msg.sender, pending);
emit Claim(msg.sender, pending);
emit Claim(msg.sender, pending, 0, 0);
} else {
revert NothingToClaim();
}
Expand Down
8 changes: 4 additions & 4 deletions contracts/pools/ERC721/ERC721PenaltyFeePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,19 @@ contract draftERC721PenaltyFeepPool is
}
if (pending > 0) {
user.pending = 0;
uint256 penalityAmount = _calculatePenalizedAmount(
uint256 penaltyAmount = _calculatePenalizedAmount(
user.penalized,
pending
);
pending -= penalityAmount;
pending -= penaltyAmount;
if (user.penalized) user.penalized = false;
unchecked {
user.claimed += pending;
}
pool.totalClaimed += pending;
pool.totalPenalties += penalityAmount;
pool.totalPenalties += penaltyAmount;
IERC20(pool.rewardToken).safeTransfer(msg.sender, pending);
emit PenaltyClaim(msg.sender, pending, penalityAmount, pool.totalPenalties);
emit Claim(msg.sender, pending, penaltyAmount, pool.totalPenalties);
} else {
revert NothingToClaim();
}
Expand Down

0 comments on commit f026729

Please sign in to comment.