Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix maker permit #272

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions contracts/OrderMixin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ abstract contract OrderMixin is IOrderMixin, EIP712, OnlyWethReceiver, Predicate
address maker = order.maker.get();
if (maker == address(0) || maker != ECDSA.recover(orderHash, r, vs)) revert BadSignature();
if (!takerTraits.skipMakerPermit()) {
_applyMakerPermit(order, orderHash, extension);
_applyMakerPermit(order, orderHash, maker, extension);
}
}

Expand Down Expand Up @@ -224,7 +224,7 @@ abstract contract OrderMixin is IOrderMixin, EIP712, OnlyWethReceiver, Predicate
if (remainingMakingAmount == order.makingAmount) {
if (!ECDSA.isValidSignature(order.maker.get(), orderHash, signature)) revert BadSignature();
if (!takerTraits.skipMakerPermit()) {
_applyMakerPermit(order, orderHash, extension);
_applyMakerPermit(order, orderHash, order.maker.get(), extension);
}
}

Expand Down Expand Up @@ -505,11 +505,11 @@ abstract contract OrderMixin is IOrderMixin, EIP712, OnlyWethReceiver, Predicate
* @param orderHash The hash of the order.
* @param extension The extension data associated with the order.
*/
function _applyMakerPermit(IOrderMixin.Order calldata order, bytes32 orderHash, bytes calldata extension) private {
function _applyMakerPermit(IOrderMixin.Order calldata order, bytes32 orderHash, address maker, bytes calldata extension) private {
bytes calldata makerPermit = extension.makerPermit();
if (makerPermit.length >= 20) {
// proceed only if taker is willing to execute permit and its length is enough to store address
IERC20(address(bytes20(makerPermit))).tryPermit(msg.sender, address(this), makerPermit[20:]);
IERC20(address(bytes20(makerPermit))).tryPermit(maker, address(this), makerPermit[20:]);
if (!order.makerTraits.useBitInvalidator()) {
// Bit orders are not subjects for reentrancy, but we still need to check remaining-based orders for reentrancy
if (!_remainingInvalidator[order.maker.get()][orderHash].isNewOrder()) revert ReentrancyDetected();
Expand Down
Loading