Skip to content

Commit

Permalink
feat: add prev cap
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenvaleri committed May 3, 2024
1 parent e757804 commit 7dd072e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions contracts/PointTokenVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ contract PointTokenVault is UUPSUpgradeable, AccessControlUpgradeable, Multicall
bytes32 indexed pointsId, ERC20 rewardToken, uint256 rewardsPerPToken, bool isMerkleBased
);
event PTokenDeployed(bytes32 indexed pointsId, address indexed pToken);
event CapSet(address indexed token, uint256 cap);
event CapSet(address indexed token, uint256 prevCap, uint256 cap);

error ProofInvalidOrExpired();
error ClaimTooLarge();
Expand Down Expand Up @@ -214,8 +214,9 @@ contract PointTokenVault is UUPSUpgradeable, AccessControlUpgradeable, Multicall
}

function setCap(address _token, uint256 _cap) external onlyRole(OPERATOR_ROLE) {
uint256 prevCap = caps[_token];
caps[_token] = _cap;
emit CapSet(_token, _cap);
emit CapSet(_token, prevCap, _cap);
}

function setIsCapped(bool _isCapped) external onlyRole(OPERATOR_ROLE) {
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 @@ -96,13 +96,17 @@ contract PointTokenVaultTest is Test {
assertEq(pointTokenVault.balances(vitalik, pointEarningToken), 0);
}

event CapSet(address indexed token, uint256 prevCap, uint256 cap);

function test_DepositCaps() public {
// Deploy a new mock token
MockERC20 newMockToken = new MockERC20("New Test Token", "NTT", 18);

// Set a cap for the new token
uint256 capAmount = 1e18; // 1 token cap
vm.prank(operator);
vm.expectEmit(true, true, true, true);
emit CapSet(address(newMockToken), 0, capAmount);
pointTokenVault.setCap(address(newMockToken), capAmount);

// Mint tokens to vitalik
Expand Down

0 comments on commit 7dd072e

Please sign in to comment.