-
Notifications
You must be signed in to change notification settings - Fork 11
/
EthereumPermitBundler.sol
34 lines (30 loc) · 1.43 KB
/
EthereumPermitBundler.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.24;
import {IDaiPermit} from "./interfaces/IDaiPermit.sol";
import {MainnetLib} from "./libraries/MainnetLib.sol";
import {PermitBundler} from "../PermitBundler.sol";
/// @title EthereumPermitBundler
/// @author Morpho Labs
/// @custom:contact security@morpho.org
/// @notice PermitBundler contract specific to Ethereum, handling permit to DAI.
abstract contract EthereumPermitBundler is PermitBundler {
/// @notice Permits DAI from sender to be spent by the bundler with the given `nonce`, `expiry` & EIP-712
/// signature's `v`, `r` & `s`.
/// @param nonce The nonce of the signed message.
/// @param expiry The expiry of the signed message.
/// @param allowed Whether the initiator gives the bundler infinite Dai approval or not.
/// @param v The `v` component of a signature.
/// @param r The `r` component of a signature.
/// @param s The `s` component of a signature.
/// @param skipRevert Whether to avoid reverting the call in case the signature is frontrunned.
function permitDai(uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s, bool skipRevert)
external
payable
protected
{
try IDaiPermit(MainnetLib.DAI).permit(initiator(), address(this), nonce, expiry, allowed, v, r, s) {}
catch (bytes memory returnData) {
if (!skipRevert) _revert(returnData);
}
}
}