Skip to content
Lattice

ERC20FlashMint

Git Source

Inherits: IERC20FlashMint

Title: ERC20FlashMint

Author: Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/ERC20FlashMint.sol)

Stateless Diamond facet — ERC-3156 flash loans at the token level (the token mints itself as the loan).

Pure delegator to ERC20FlashMintLib. Default fee is 0 (burned). A supply cap (ERC20Capped) is not reflected by maxFlashLoan — pair with a cap-aware flash-mint library if that composition is needed.

Notes:

  • lattice-version: 0.1.0
  • lattice-source: OpenZeppelin v5.6.1

Functions

maxFlashLoan

The amount of currency available to be lent.

function maxFlashLoan(address token) public view virtual returns (uint256);

Parameters

NameTypeDescription
tokenaddressThe loan currency.

Returns

NameTypeDescription
<none>uint256The amount of token that can be borrowed.

flashFee

The fee to be charged for a given loan.

function flashFee(address token, uint256 value) public view virtual returns (uint256);

Parameters

NameTypeDescription
tokenaddressThe loan currency.
valueuint256The amount of tokens lent.

Returns

NameTypeDescription
<none>uint256The amount of token to be charged for the loan, on top of the returned principal.

flashLoan

Initiate a flash loan.

function flashLoan(IERC3156FlashBorrower receiver, address token, uint256 value, bytes calldata data)
        public
        virtual
        returns (bool);

Parameters

NameTypeDescription
receiverIERC3156FlashBorrowerThe receiver of the tokens in the loan, and the receiver of the callback.
tokenaddressThe loan currency.
valueuint256The amount of tokens lent.
databytesArbitrary data structure, intended to contain user-defined parameters.

Returns

NameTypeDescription
<none>bool

exportSelectors

ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).

Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches forge inspect ERC20FlashMint methodIdentifiers (alphabetical by signature); kept in exact parity by ExportSelectorsParityTest. Chunks: flashFee(address,uint256) 0xd9d98ce4 flashLoan(address,address,uint256,bytes) 0x5cffe9de maxFlashLoan(address) 0x613255ab

function exportSelectors() external pure virtual returns (bytes memory selectors);

Returns

NameTypeDescription
selectorsbytes