From afeb5fb996d693e69b8d3da1b74950c9aeb66797 Mon Sep 17 00:00:00 2001
From: Jason Raymond Bell <jason@epixxware.com>
Date: Thu, 20 May 2021 14:47:10 +0100
Subject: [PATCH] Remove _usePermit function

Just use a simple check if deadline is set or not.

Fixes ABDK CVF-34 and CVF-35.
---
 contracts/adapters/BaseParaSwapAdapter.sol | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/contracts/adapters/BaseParaSwapAdapter.sol b/contracts/adapters/BaseParaSwapAdapter.sol
index 849e1f1e..d06e9ec5 100644
--- a/contracts/adapters/BaseParaSwapAdapter.sol
+++ b/contracts/adapters/BaseParaSwapAdapter.sol
@@ -86,7 +86,8 @@ abstract contract BaseParaSwapAdapter is FlashLoanReceiverBase, Ownable {
     uint256 amount,
     PermitSignature memory permitSignature
   ) internal {
-    if (_usePermit(permitSignature)) {
+    // If deadline is set to zero, assume there is no signature for permit
+    if (permitSignature.deadline != 0) {
       IERC20WithPermit(reserveAToken).permit(
         user,
         address(this),
@@ -108,17 +109,6 @@ abstract contract BaseParaSwapAdapter is FlashLoanReceiverBase, Ownable {
     );
   }
 
-  /**
-   * @dev Tells if the permit method should be called by inspecting if there is a valid signature.
-   * If signature params are set to 0, then permit won't be called.
-   * @param signature struct containing the permit signature
-   * @return whether or not permit should be called
-   */
-  function _usePermit(PermitSignature memory signature) internal pure returns (bool) {
-    return
-      !(uint256(signature.deadline) == uint256(signature.v) && uint256(signature.deadline) == 0);
-  }
-
   /**
    * @dev Emergency rescue for token stucked on this contract, as failsafe mechanism
    * - Funds should never remain in this contract more time than during transactions