Skip to content

Commit

Permalink
add sendPraise to interface, forge fmt, remove some checks
Browse files Browse the repository at this point in the history
  • Loading branch information
divine-comedian committed Feb 19, 2024
1 parent 1c30d00 commit 4ada5ab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
7 changes: 2 additions & 5 deletions contracts/ModifiedTokenDistro.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import './interfaces/IDistroModified.sol';
* The distributor is in charge of releasing the corresponding amounts to its recipients.
* This distributor is expected to be another smart contract, such as a merkledrop or the liquidity mining smart contract
*/
contract TokenDistroV2 is Initializable, IDistro, AccessControlEnumerableUpgradeable {
contract TokenDistroV1 is Initializable, IDistro, AccessControlEnumerableUpgradeable {
using SafeERC20Upgradeable for IERC20Upgradeable;

// bytes32 public constant DISTRIBUTOR_ROLE = keccak256("DISTRIBUTOR_ROLE");
Expand Down Expand Up @@ -261,7 +261,6 @@ contract TokenDistroV2 is Initializable, IDistro, AccessControlEnumerableUpgrade
function claimableAt(address recipient, uint256 timestamp) public view override returns (uint256) {
require(!hasRole(DISTRIBUTOR_ROLE, recipient), 'TokenDistro::claimableAt: DISTRIBUTOR_ROLE_CANNOT_CLAIM');
require(timestamp >= getTimestamp(), 'TokenDistro::claimableAt: NOT_VALID_PAST_TIMESTAMP');
require(totalTokens > 0, 'TokenDistro::claimableAt: TOTAL_TOKENS_ZERO');
uint256 unlockedAmount = (globallyClaimableAt(timestamp) * balances[recipient].allocatedTokens) / totalTokens;
if (unlockedAmount > balances[recipient].claimed) return unlockedAmount - balances[recipient].claimed;
return 0;
Expand Down Expand Up @@ -324,9 +323,7 @@ contract TokenDistroV2 is Initializable, IDistro, AccessControlEnumerableUpgrade

function _transferAllocation(address prevRecipient, address newRecipient) internal {
require(
balances[prevRecipient].allocatedTokens > 0
&& balances[prevRecipient].allocatedTokens != balances[prevRecipient].claimed,
'TokenDistro::transferAllocation: NO_ALLOCATION_TO_TRANSFER'
balances[prevRecipient].allocatedTokens > 0, 'TokenDistro::transferAllocation: NO_ALLOCATION_TO_TRANSFER'
);
require(
!hasRole(DISTRIBUTOR_ROLE, prevRecipient) && !hasRole(DISTRIBUTOR_ROLE, newRecipient),
Expand Down
7 changes: 7 additions & 0 deletions contracts/TokenDistro.sol
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,11 @@ contract TokenDistro is Initializable, IDistro, AccessControlEnumerableUpgradeab

emit DurationChanged(newDuration);
}

event PraiseRewardPaid(address distributor);

function sendPraiseRewards(address[] memory recipients, uint256[] memory amounts) external {
_allocateMany(recipients, amounts);
emit PraiseRewardPaid(msg.sender);
}
}
2 changes: 2 additions & 0 deletions contracts/interfaces/IDistroModified.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,6 @@ interface IDistro {
function claimableNow(address recipient) external view returns (uint256);

function transferAllocation(address prevRecipient, address newRecipient) external;

function sendPraiseRewards(address[] memory recipients, uint256[] memory amounts) external;
}

0 comments on commit 4ada5ab

Please sign in to comment.