From 9343bbd09d32837deba142d1c95dde834db1ad1e Mon Sep 17 00:00:00 2001 From: ControlCplusControlV <44706811+ControlCplusControlV@users.noreply.github.com> Date: Fri, 23 Feb 2024 18:23:06 -0700 Subject: [PATCH] Removed decreaseAllowance and increaseAllowance --- contracts/lending/Vault.vy | 49 +------------------------------------- 1 file changed, 1 insertion(+), 48 deletions(-) diff --git a/contracts/lending/Vault.vy b/contracts/lending/Vault.vy index 6da048db..cd9ad205 100644 --- a/contracts/lending/Vault.vy +++ b/contracts/lending/Vault.vy @@ -600,9 +600,7 @@ def transfer(_to: address, _value: uint256) -> bool: def approve(_spender: address, _value: uint256) -> bool: """ @notice Allow `_spender` to transfer up to `_value` amount of tokens from the caller's account. - @dev Non-zero to non-zero approvals are allowed, but should be used cautiously. The methods - increaseAllowance + decreaseAllowance are available to prevent any front-running that - may occur. + @dev Non-zero to non-zero approvals are allowed, but should be used cautiously. @param _spender The account permitted to spend up to `_value` amount of caller's funds. @param _value The amount of tokens `_spender` is allowed to spend. """ @@ -610,51 +608,6 @@ def approve(_spender: address, _value: uint256) -> bool: return True -@external -def increaseAllowance(_spender: address, _add_value: uint256) -> bool: - """ - @notice Increase the allowance granted to `_spender`. - @dev This function will never overflow, and instead will bound - allowance to MAX_UINT256. This has the potential to grant an - infinite approval. - @param _spender The account to increase the allowance of. - @param _add_value The amount to increase the allowance by. - """ - cached_allowance: uint256 = self.allowance[msg.sender][_spender] - allowance: uint256 = unsafe_add(cached_allowance, _add_value) - - # check for an overflow - if allowance < cached_allowance: - allowance = max_value(uint256) - - if allowance != cached_allowance: - self._approve(msg.sender, _spender, allowance) - - return True - - -@external -def decreaseAllowance(_spender: address, _sub_value: uint256) -> bool: - """ - @notice Decrease the allowance granted to `_spender`. - @dev This function will never underflow, and instead will bound - allowance to 0. - @param _spender The account to decrease the allowance of. - @param _sub_value The amount to decrease the allowance by. - """ - cached_allowance: uint256 = self.allowance[msg.sender][_spender] - allowance: uint256 = unsafe_sub(cached_allowance, _sub_value) - - # check for an underflow - if cached_allowance < allowance: - allowance = 0 - - if allowance != cached_allowance: - self._approve(msg.sender, _spender, allowance) - - return True - - @external @view def admin() -> address: