Skip to content

Commit

Permalink
Merge pull request #19 from sense-finance/feat/convert-rewards-event
Browse files Browse the repository at this point in the history
feat: add rewards converted event
  • Loading branch information
stevenvaleri authored May 3, 2024
2 parents c5b2aaf + 99b58a5 commit 7f0f722
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions contracts/PointTokenVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ contract PointTokenVault is UUPSUpgradeable, AccessControlUpgradeable, Multicall
event RootUpdated(bytes32 prevRoot, bytes32 newRoot);
event PTokensClaimed(address indexed account, bytes32 indexed pointsId, uint256 amount);
event RewardsClaimed(address indexed owner, address indexed receiver, bytes32 indexed pointsId, uint256 amount);
event RewardsConverted(address indexed owner, address indexed receiver, bytes32 indexed pointsId, uint256 amount);
event RewardRedemptionSet(
bytes32 indexed pointsId, ERC20 rewardToken, uint256 rewardsPerPToken, bool isMerkleBased
);
Expand Down Expand Up @@ -170,6 +171,8 @@ contract PointTokenVault is UUPSUpgradeable, AccessControlUpgradeable, Multicall

rewardToken.safeTransferFrom(msg.sender, address(this), _amountToConvert);
pTokens[_pointsId].mint(_receiver, FixedPointMathLib.divWadDown(_amountToConvert, rewardsPerPToken)); // Round down for mint.

emit RewardsConverted(msg.sender, _receiver, _pointsId, _amountToConvert);
}

function deployPToken(bytes32 _pointsId) public {
Expand Down
4 changes: 4 additions & 0 deletions contracts/test/PointTokenVault.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ contract PointTokenVaultTest is Test {
assertEq(pointTokenVault.pTokens(eigenPointsId).balanceOf(vitalik), 1e18);
}

event RewardsConverted(address indexed owner, address indexed receiver, bytes32 indexed pointsId, uint256 amount);

function test_MintPTokensForRewards() public {
bytes32 root = 0x4e40a10ce33f33a4786960a8bb843fe0e170b651acd83da27abc97176c4bed3c;

Expand Down Expand Up @@ -497,6 +499,8 @@ contract PointTokenVaultTest is Test {
vm.prank(vitalik);
rewardToken.approve(address(pointTokenVault), 1e18);
vm.prank(vitalik);
vm.expectEmit(true, true, true, true);
emit RewardsConverted(vitalik, vitalik, eigenPointsId, 1e18);
pointTokenVault.convertRewardsToPTokens(vitalik, eigenPointsId, 1e18);

assertEq(rewardToken.balanceOf(vitalik), 1e18);
Expand Down

0 comments on commit 7f0f722

Please sign in to comment.