Skip to content

Commit

Permalink
feat: add sender to deposit and withdraw events
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenvaleri committed May 3, 2024
1 parent e757804 commit e509224
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
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);
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

0 comments on commit e509224

Please sign in to comment.