Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add sender to deposit and withdraw events #14

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions contracts/PointTokenVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ contract PointTokenVault is UUPSUpgradeable, AccessControlUpgradeable, Multicall
bool isMerkleBased;
}

event Deposit(address indexed receiver, address indexed token, uint256 amount);
event Withdraw(address indexed user, address indexed token, uint256 amount);
event Deposit(address indexed depositor, address indexed receiver, address indexed token, uint256 amount);
event Withdraw(address indexed withdrawer, address indexed receiver, address indexed token, uint256 amount);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love "withdrawer" since it's not a word that is too commonly used, but it maps nicely with depositor.

Copy link
Contributor

@jparklev jparklev May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is weird how there isn't an obvious complement to depositor but yea seems fine to me

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Expand Down Expand Up @@ -95,15 +95,15 @@ contract PointTokenVault is UUPSUpgradeable, AccessControlUpgradeable, Multicall

balances[_receiver][_token] += _amount;

emit Deposit(_receiver, address(_token), _amount);
emit Deposit(msg.sender, _receiver, address(_token), _amount);
}

function withdraw(ERC20 _token, uint256 _amount, address _receiver) public {
balances[msg.sender][_token] -= _amount;

_token.safeTransfer(_receiver, _amount);

emit Withdraw(_receiver, address(_token), _amount);
emit Withdraw(msg.sender, _receiver, address(_token), _amount);
}

/// @notice Claims point tokens after verifying the merkle proof
Expand Down
8 changes: 8 additions & 0 deletions contracts/test/PointTokenVault.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ contract PointTokenVaultTest is Test {
pointTokenVault.setCap(address(pointEarningToken), type(uint256).max);
}

event Deposit(address indexed depositor, address indexed receiver, address indexed token, uint256 amount);

function test_Deposit() public {
pointEarningToken.mint(vitalik, 1.123e18);

Expand All @@ -65,13 +67,17 @@ contract PointTokenVaultTest is Test {

// Can deposit for someone else
vm.prank(vitalik);
vm.expectEmit(true, true, true, true);
emit Deposit(vitalik, toly, address(pointEarningToken), 0.623e18);
pointTokenVault.deposit(pointEarningToken, 0.623e18, toly);

assertEq(pointEarningToken.balanceOf(vitalik), 0);
assertEq(pointTokenVault.balances(toly, pointEarningToken), 0.623e18);
assertEq(pointTokenVault.balances(vitalik, pointEarningToken), 0.5e18);
}

event Withdraw(address indexed withdrawer, address indexed receiver, address indexed token, uint256 amount);

function test_Withdraw() public {
pointEarningToken.mint(vitalik, 1.123e18);

Expand All @@ -87,6 +93,8 @@ contract PointTokenVaultTest is Test {

// Can withdraw with a different receiver
vm.prank(vitalik);
vm.expectEmit(true, true, true, true);
emit Withdraw(vitalik, toly, address(pointEarningToken), 0.5e18);
pointTokenVault.withdraw(pointEarningToken, 0.5e18, toly);

assertEq(pointEarningToken.balanceOf(vitalik), 0.623e18);
Expand Down