Interfaces

This document is better viewed at https://docs.openzeppelin.com/contracts/api/interfaces

List of standardized interfaces

Detailed ABI

IERC1271

import "@openzeppelin/contracts/interfaces/IERC1271.sol";

Interface of the ERC1271 standard signature validation method for contracts as defined in ERC-1271.

Available since v4.1.

isValidSignature(bytes32 hash, bytes signature) → bytes4 magicValue external

Should return whether the signature provided is valid for the provided data

IERC1363

import "@openzeppelin/contracts/interfaces/IERC1363.sol";

Interface of an ERC1363 compliant contract, as defined in the EIP.

Defines a interface for ERC20 tokens that supports executing recipient code after transfer or transferFrom, or spender code after approve.

transferAndCall(address to, uint256 amount) → bool external

Transfer tokens from msg.sender to another address and then call onTransferReceived on receiver

transferAndCall(address to, uint256 amount, bytes data) → bool external

Transfer tokens from msg.sender to another address and then call onTransferReceived on receiver

transferFromAndCall(address from, address to, uint256 amount) → bool external

Transfer tokens from one address to another and then call onTransferReceived on receiver

transferFromAndCall(address from, address to, uint256 amount, bytes data) → bool external

Transfer tokens from one address to another and then call onTransferReceived on receiver

approveAndCall(address spender, uint256 amount) → bool external

Approve the passed address to spend the specified amount of tokens on behalf of msg.sender and then call onApprovalReceived on spender.

approveAndCall(address spender, uint256 amount, bytes data) → bool external

Approve the passed address to spend the specified amount of tokens on behalf of msg.sender and then call onApprovalReceived on spender.

IERC1363Receiver

import "@openzeppelin/contracts/interfaces/IERC1363Receiver.sol";

Interface for any contract that wants to support IERC1363.transferAndCall or IERC1363.transferFromAndCall from {ERC1363} token contracts.

onTransferReceived(address operator, address from, uint256 amount, bytes data) → bytes4 external

Any ERC1363 smart contract calls this function on the recipient after a transfer or a transferFrom. This function MAY throw to revert and reject the transfer. Return of other than the magic value MUST result in the transaction being reverted. Note: the token contract address is always the message sender.

IERC1363Spender

import "@openzeppelin/contracts/interfaces/IERC1363Spender.sol";

Interface for any contract that wants to support IERC1363.approveAndCall from {ERC1363} token contracts.

onApprovalReceived(address owner, uint256 amount, bytes data) → bytes4 external

Any ERC1363 smart contract calls this function on the recipient after an approve. This function MAY throw to revert and reject the approval. Return of other than the magic value MUST result in the transaction being reverted. Note: the token contract address is always the message sender.

IERC1822Proxiable

import "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";

ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified proxy whose upgrades are fully controlled by the current implementation.

Functions

proxiableUUID() → bytes32 external

Returns the storage slot that the proxiable contract assumes is being used to store the implementation address.

A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this function revert if invoked through a proxy.

IERC2612

import "@openzeppelin/contracts/interfaces/IERC2612.sol";

IERC2981

import "@openzeppelin/contracts/interfaces/IERC2981.sol";

Interface for the NFT Royalty Standard.

A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal support for royalty payments across all NFT marketplaces and ecosystem participants.

Available since v4.5.

royaltyInfo(uint256 tokenId, uint256 salePrice) → address receiver, uint256 royaltyAmount external

Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of exchange. The royalty amount is denominated and should be paid in that same unit of exchange.

IERC3156FlashLender

import "@openzeppelin/contracts/interfaces/IERC3156FlashLender.sol";

Interface of the ERC3156 FlashLender, as defined in ERC-3156.

Available since v4.1.

maxFlashLoan(address token) → uint256 external

The amount of currency available to be lended.

flashFee(address token, uint256 amount) → uint256 external

The fee to be charged for a given loan.

flashLoan(contract IERC3156FlashBorrower receiver, address token, uint256 amount, bytes data) → bool external

Initiate a flash loan.

IERC3156FlashBorrower

import "@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol";

Interface of the ERC3156 FlashBorrower, as defined in ERC-3156.

Available since v4.1.

onFlashLoan(address initiator, address token, uint256 amount, uint256 fee, bytes data) → bytes32 external

Receive a flash loan.

IERC4626

import "@openzeppelin/contracts/interfaces/IERC4626.sol";

Interface of the ERC4626 "Tokenized Vault Standard", as defined in ERC-4626.

Available since v4.7.

asset() → address assetTokenAddress external

Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.

  • MUST be an ERC-20 token contract.

  • MUST NOT revert.

totalAssets() → uint256 totalManagedAssets external

Returns the total amount of the underlying asset that is “managed” by Vault.

  • SHOULD include any compounding that occurs from yield.

  • MUST be inclusive of any fees that are charged against assets in the Vault.

  • MUST NOT revert.

convertToShares(uint256 assets) → uint256 shares external

Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal scenario where all the conditions are met.

  • MUST NOT be inclusive of any fees that are charged against assets in the Vault.

  • MUST NOT show any variations depending on the caller.

  • MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.

  • MUST NOT revert.

This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.

convertToAssets(uint256 shares) → uint256 assets external

Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal scenario where all the conditions are met.

  • MUST NOT be inclusive of any fees that are charged against assets in the Vault.

  • MUST NOT show any variations depending on the caller.

  • MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.

  • MUST NOT revert.

This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.

maxDeposit(address receiver) → uint256 maxAssets external

Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, through a deposit call.

  • MUST return a limited value if receiver is subject to some deposit limit.

  • MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.

  • MUST NOT revert.

previewDeposit(uint256 assets) → uint256 shares external

Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given current on-chain conditions.

  • MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called in the same transaction.

  • MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the deposit would be accepted, regardless if the user has enough tokens approved, etc.

  • MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.

  • MUST NOT revert.

any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by depositing.

deposit(uint256 assets, address receiver) → uint256 shares external

Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.

  • MUST emit the Deposit event.

  • MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the deposit execution, and are accounted for during deposit.

  • MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc).

most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.

maxMint(address receiver) → uint256 maxShares external

Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call. - MUST return a limited value if receiver is subject to some mint limit. - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted. - MUST NOT revert.

previewMint(uint256 shares) → uint256 assets external

Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given current on-chain conditions.

  • MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the same transaction.

  • MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint would be accepted, regardless if the user has enough tokens approved, etc.

  • MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.

  • MUST NOT revert.

any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by minting.

mint(uint256 shares, address receiver) → uint256 assets external

Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.

  • MUST emit the Deposit event.

  • MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint execution, and are accounted for during mint.

  • MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc).

most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.

maxWithdraw(address owner) → uint256 maxAssets external

Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the Vault, through a withdraw call.

  • MUST return a limited value if owner is subject to some withdrawal limit or timelock.

  • MUST NOT revert.

previewWithdraw(uint256 assets) → uint256 shares external

Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, given current on-chain conditions.

  • MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if called in the same transaction.

  • MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though the withdrawal would be accepted, regardless if the user has enough shares, etc.

  • MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.

  • MUST NOT revert.

any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by depositing.

withdraw(uint256 assets, address receiver, address owner) → uint256 shares external

Burns shares from owner and sends exactly assets of underlying tokens to receiver.

  • MUST emit the Withdraw event.

  • MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the withdraw execution, and are accounted for during withdraw.

  • MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner not having enough shares, etc).

Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. Those methods should be performed separately.

maxRedeem(address owner) → uint256 maxShares external

Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, through a redeem call.

  • MUST return a limited value if owner is subject to some withdrawal limit or timelock.

  • MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.

  • MUST NOT revert.

previewRedeem(uint256 shares) → uint256 assets external

Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, given current on-chain conditions.

  • MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the same transaction.

  • MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the redemption would be accepted, regardless if the user has enough shares, etc.

  • MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.

  • MUST NOT revert.

any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by redeeming.

redeem(uint256 shares, address receiver, address owner) → uint256 assets external

Burns exactly shares from owner and sends assets of underlying tokens to receiver.

  • MUST emit the Withdraw event.

  • MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the redeem execution, and are accounted for during redeem.

  • MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner not having enough shares, etc).

some implementations will require pre-requesting to the Vault before a withdrawal may be performed. Those methods should be performed separately.

Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares) event

Withdraw(address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares) event

IERC5313

import "@openzeppelin/contracts/interfaces/IERC5313.sol";

Interface for the Light Contract Ownership Standard.

A standardized minimal interface required to identify an account that controls a contract

Available since v4.9.

Functions

owner() → address external

Gets the address of the owner.

IERC5267

import "@openzeppelin/contracts/interfaces/IERC5267.sol";
Functions

eip712Domain() → bytes1 fields, string name, string version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] extensions external

returns the fields and values that describe the domain separator used by this contract for EIP-712 signature.

EIP712DomainChanged() event

MAY be emitted to signal that the domain could have changed.

IERC6372

import "@openzeppelin/contracts/interfaces/IERC6372.sol";
Functions

clock() → uint48 external

Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).

CLOCK_MODE() → string external

Description of the clock