Remove _usePermit function

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

Fixes ABDK CVF-34 and CVF-35.
This commit is contained in:
Jason Raymond Bell 2021-05-20 14:47:10 +01:00
parent 5b45be6a44
commit afeb5fb996

View File

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