Skip to content

Commit

Permalink
chore: emit right reward event vals, improve verbiage
Browse files Browse the repository at this point in the history
  • Loading branch information
jparklev committed Apr 17, 2024
1 parent 9706936 commit cc4bec7
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions contracts/PointTokenVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ contract PointTokenVault is UUPSUpgradeable, OwnableUpgradeable {

error ProofInvalidOrExpired();
error ClaimTooLarge();
error NotDistributed();
error RewardsNotReleased();
error InvalidPointsId();

constructor() {
Expand Down Expand Up @@ -96,8 +96,8 @@ contract PointTokenVault is UUPSUpgradeable, OwnableUpgradeable {

(ERC20 rewardToken, uint256 exchangeRate, bool isMerkleBased) = pointTokenHub.redemptionParams(pointsId);

if (rewardToken == ERC20(address(0))) {
revert NotDistributed();
if (address(rewardToken) == address(0)) {
revert RewardsNotReleased();
}

if (isMerkleBased) {
Expand Down Expand Up @@ -139,15 +139,15 @@ contract PointTokenVault is UUPSUpgradeable, OwnableUpgradeable {

if (totalClaimable < alreadyClaimed + amountToClaim) revert ClaimTooLarge();

_claimed[_account][pointsId] = amountToClaim + alreadyClaimed;
_claimed[_account][pointsId] = alreadyClaimed + amountToClaim;
}

// Admin ---

function updateRoot(bytes32 _newRoot) external onlyOwner {
emit RootUpdated(prevRoot, _newRoot);
prevRoot = currRoot;
currRoot = _newRoot;
emit RootUpdated(prevRoot, currRoot);
}

// To handle arbitrary reward claiming logic.
Expand All @@ -162,9 +162,7 @@ contract PointTokenVault is UUPSUpgradeable, OwnableUpgradeable {
}

contract PointTokenHub is UUPSUpgradeable, OwnableUpgradeable {
error OnlyTrusted();
// Trust ---

mapping(address => bool) isTrusted; // user => isTrusted

mapping(bytes32 => PToken) public pointTokens; // pointsId => pointTokens
Expand All @@ -176,14 +174,16 @@ contract PointTokenHub is UUPSUpgradeable, OwnableUpgradeable {
bool isMerkleBased;
}

event Trusted(address indexed user, bool trusted);
event RewardRedemptionSet(bytes32 indexed pointsId, ERC20 rewardToken, uint256 exchangeRate, bool isMerkleBased);

error OnlyTrusted();

modifier onlyTrusted() {
if (!isTrusted[msg.sender]) revert OnlyTrusted();
_;
}

event Trusted(address indexed user, bool trusted);
event RewardRedemptionSet(bytes32 indexed pointsId, ERC20 rewardToken, uint256 exchangeRate, bool isMerkleBased);

constructor() {
_disableInitializers();
}
Expand All @@ -208,8 +208,8 @@ contract PointTokenHub is UUPSUpgradeable, OwnableUpgradeable {

// Admin ---

// Can be used to unlock reward token redemption (can also be used to modify a live redemption)
// Should be used after claiming rewards.
// Can be used to unlock reward token redemption (can also be used to modify a live redemption).
// Should only be used after rewards have been claimed.
function setRedemption(bytes32 _pointsId, ERC20 _rewardToken, uint256 _exchangeRate, bool _isMerkleBased)
external
onlyOwner
Expand Down

0 comments on commit cc4bec7

Please sign in to comment.