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 prev cap #16

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
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