diff --git a/contracts/PointTokenVault.sol b/contracts/PointTokenVault.sol index 06eb097..00a6f6e 100644 --- a/contracts/PointTokenVault.sol +++ b/contracts/PointTokenVault.sol @@ -40,7 +40,6 @@ contract PointTokenVault is UUPSUpgradeable, AccessControlUpgradeable, Multicall mapping(bytes32 => RedemptionParams) public redemptions; // pointsId => redemptionParams mapping(address => uint256) public caps; // asset => deposit cap - bool public isCapped; struct Claim { bytes32 pointsId; @@ -86,13 +85,16 @@ contract PointTokenVault is UUPSUpgradeable, AccessControlUpgradeable, Multicall __AccessControl_init(); __Multicall_init(); _grantRole(DEFAULT_ADMIN_ROLE, _admin); - isCapped = true; } // Rebasing and fee-on-transfer tokens must be wrapped before depositing. function deposit(ERC20 _token, uint256 _amount, address _receiver) public { - if (isCapped && (_amount + _token.balanceOf(address(this)) > caps[address(_token)])) { - revert DepositExceedsCap(); + uint256 cap = caps[address(_token)]; + + if (cap != type(uint256).max) { + if (_amount + _token.balanceOf(address(this)) > cap) { + revert DepositExceedsCap(); + } } _token.safeTransferFrom(msg.sender, address(this), _amount); @@ -238,10 +240,6 @@ contract PointTokenVault is UUPSUpgradeable, AccessControlUpgradeable, Multicall emit CapSet(_token, prevCap, _cap); } - function setIsCapped(bool _isCapped) external onlyRole(OPERATOR_ROLE) { - isCapped = _isCapped; - } - // Can be used to unlock reward token redemption (can also modify a live redemption, so use with care). function setRedemption(bytes32 _pointsId, ERC20 _rewardToken, uint256 _rewardsPerPToken, bool _isMerkleBased) external diff --git a/contracts/test/PointTokenVault.t.sol b/contracts/test/PointTokenVault.t.sol index 7e7605b..f304d66 100644 --- a/contracts/test/PointTokenVault.t.sol +++ b/contracts/test/PointTokenVault.t.sol @@ -135,9 +135,9 @@ contract PointTokenVaultTest is Test { assertEq(pointTokenVault.balances(vitalik, newMockToken), 1e18); - // Remove the cap + // Set deposit cap to max vm.prank(operator); - pointTokenVault.setIsCapped(false); + pointTokenVault.setCap(address(newMockToken), 2**256 - 1); // Approve and deposit more than the previous cap vm.startPrank(vitalik);