IERC20Permit.sol 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity >=0.6.0 <0.8.0;
  3. /**
  4. * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
  5. * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
  6. *
  7. * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
  8. * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
  9. * need to send a transaction, and thus is not required to hold Ether at all.
  10. */
  11. interface IERC20Permit {
  12. /**
  13. * @dev Sets `amount` as the allowance of `spender` over `owner`'s tokens,
  14. * given `owner`'s signed approval.
  15. *
  16. * IMPORTANT: The same issues {IERC20-approve} has related to transaction
  17. * ordering also apply here.
  18. *
  19. * Emits an {Approval} event.
  20. *
  21. * Requirements:
  22. *
  23. * - `spender` cannot be the zero address.
  24. * - `deadline` must be a timestamp in the future.
  25. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
  26. * over the EIP712-formatted function arguments.
  27. * - the signature must use ``owner``'s current nonce (see {nonces}).
  28. *
  29. * For more information on the signature format, see the
  30. * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
  31. * section].
  32. */
  33. function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
  34. /**
  35. * @dev Returns the current nonce for `owner`. This value must be
  36. * included whenever a signature is generated for {permit}.
  37. *
  38. * Every successful call to {permit} increases ``owner``'s nonce by one. This
  39. * prevents a signature from being used multiple times.
  40. */
  41. function nonces(address owner) external view returns (uint256);
  42. /**
  43. * @dev Returns the domain separator used in the encoding of the signature for `permit`, as defined by {EIP712}.
  44. */
  45. // solhint-disable-next-line func-name-mixedcase
  46. function DOMAIN_SEPARATOR() external view returns (bytes32);
  47. }