Skip to content

Commit

Permalink
no other options are usable for permit2 signatureTransfer
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNe0x1 committed Sep 8, 2024
1 parent 52fd168 commit 8653940
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 38 deletions.
29 changes: 10 additions & 19 deletions contracts/DePayRouterV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -206,32 +206,23 @@ contract DePayRouterV2 is Ownable2Step {
}
}

/// @dev Processes the payIn operations.
/// @dev Processes the payIn operations (exlusively for permit2 SignatureTransfer).
/// @param payment The payment data.
/// @param permitTransferFromAndSignature permitTransferFromAndSignature for permit2 permitTransferFrom.
function _payIn(
IDePayRouterV2.Payment calldata payment,
IDePayRouterV2.PermitTransferFromAndSignature calldata permitTransferFromAndSignature
) internal {
if(payment.tokenInAddress == NATIVE) {
// Make sure that the sender has paid in the correct token & amount
if(msg.value != payment.amountIn) {
revert WrongAmountPaidIn();
}
} else if(payment.permit2) {

IPermit2(PERMIT2).permitTransferFrom(
permitTransferFromAndSignature.permitTransferFrom,
IPermit2.SignatureTransferDetails({
to: address(this),
requestedAmount: payment.amountIn
}),
msg.sender,
permitTransferFromAndSignature.signature
);
} else {
IERC20(payment.tokenInAddress).safeTransferFrom(msg.sender, address(this), payment.amountIn);
}
IPermit2(PERMIT2).permitTransferFrom(
permitTransferFromAndSignature.permitTransferFrom,
IPermit2.SignatureTransferDetails({
to: address(this),
requestedAmount: payment.amountIn
}),
msg.sender,
permitTransferFromAndSignature.signature
);
}

/// @dev Processes the payment.
Expand Down
29 changes: 10 additions & 19 deletions flatten/DePayRouterV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1044,32 +1044,23 @@ contract DePayRouterV2 is Ownable2Step {
}
}

/// @dev Processes the payIn operations.
/// @dev Processes the payIn operations (exlusively for permit2 SignatureTransfer).
/// @param payment The payment data.
/// @param permitTransferFromAndSignature permitTransferFromAndSignature for permit2 permitTransferFrom.
function _payIn(
IDePayRouterV2.Payment calldata payment,
IDePayRouterV2.PermitTransferFromAndSignature calldata permitTransferFromAndSignature
) internal {
if(payment.tokenInAddress == NATIVE) {
// Make sure that the sender has paid in the correct token & amount
if(msg.value != payment.amountIn) {
revert WrongAmountPaidIn();
}
} else if(payment.permit2) {

IPermit2(PERMIT2).permitTransferFrom(
permitTransferFromAndSignature.permitTransferFrom,
IPermit2.SignatureTransferDetails({
to: address(this),
requestedAmount: payment.amountIn
}),
msg.sender,
permitTransferFromAndSignature.signature
);
} else {
IERC20(payment.tokenInAddress).safeTransferFrom(msg.sender, address(this), payment.amountIn);
}
IPermit2(PERMIT2).permitTransferFrom(
permitTransferFromAndSignature.permitTransferFrom,
IPermit2.SignatureTransferDetails({
to: address(this),
requestedAmount: payment.amountIn
}),
msg.sender,
permitTransferFromAndSignature.signature
);
}

/// @dev Processes the payment.
Expand Down

0 comments on commit 8653940

Please sign in to comment.