Request form
Contracts
Protocols
Discord
ERC20FlashMintUpgradeable
ERC20
Token
Audited
Docs
Source
ChefGPT

ERC20FlashMintUpgradeable

This contract implements a flash loan mechanism for ERC20 tokens. It allows users to borrow tokens temporarily, provided they implement the `IERC3156FlashBorrower` interface. The contract calculates the maximum loan amount and fees, mints tokens to the borrower, executes the loan, and ensures the borrowed tokens and fees are returned or burned at the end of the loan.

allowance(address,address) :
See {IERC20-allowance}.
approve(address,uint256) :
See {IERC20-approve}. NOTE: If `value` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address.
balanceOf(address) :
See {IERC20-balanceOf}.
decimals() :
Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5.05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the default value returned by this function, unless it's overridden. NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.
flashFee(address,uint256) :
Returns the fee applied when doing flash loans. This function calls the {_flashFee} function which returns the fee applied when doing flash loans.
flashLoan(address,address,uint256,bytes) :
Performs a flash loan. New tokens are minted and sent to the `receiver`, who is required to implement the {IERC3156FlashBorrower} interface. By the end of the flash loan, the receiver is expected to own value + fee tokens and have them approved back to the token contract itself so they can be burned.
maxFlashLoan(address) :
Returns the maximum amount of tokens available for loan.
name() :
Returns the name of the token.
symbol() :
Returns the symbol of the token, usually a shorter version of the name.
totalSupply() :
See {IERC20-totalSupply}.
transfer(address,uint256) :
See {IERC20-transfer}. Requirements: - `to` cannot be the zero address. - the caller must have a balance of at least `value`.
transferFrom(address,address,uint256) :
See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. NOTE: Does not update the allowance if the current allowance is the maximum `uint256`. Requirements: - `from` and `to` cannot be the zero address. - `from` must have a balance of at least `value`. - the caller must have allowance for ``from``'s tokens of at least `value`.
ERC20FlashMintUpgradeable.sol
IERC3156FlashBorrowerUpgradeable.sol
IERC3156FlashLenderUpgradeable.sol
ERC20Upgradeable.sol
IERC20Upgradeable.sol
IERC20MetadataUpgradeable.sol
IERC20Upgradeable.sol
ContextUpgradeable.sol
Initializable.sol
draft-IERC6093Upgradeable.sol
ABI:

17 downloads

Solidity Version

0.8.20
OpenZeppelin-Upgradeable / ERC20FlashMintUpgradeable
ERC20
Token
Audited
Docs
Source
ChefGPT
Expand
Share

ERC20FlashMintUpgradeable

This contract implements a flash loan mechanism for ERC20 tokens. It allows users to borrow tokens temporarily, provided they implement the `IERC3156FlashBorrower` interface. The contract calculates the maximum loan amount and fees, mints tokens to the borrower, executes the loan, and ensures the borrowed tokens and fees are returned or burned at the end of the loan.

allowance(address,address) :
See {IERC20-allowance}.
approve(address,uint256) :
See {IERC20-approve}. NOTE: If `value` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address.
balanceOf(address) :
See {IERC20-balanceOf}.
decimals() :
Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5.05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the default value returned by this function, unless it's overridden. NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.
flashFee(address,uint256) :
Returns the fee applied when doing flash loans. This function calls the {_flashFee} function which returns the fee applied when doing flash loans.
flashLoan(address,address,uint256,bytes) :
Performs a flash loan. New tokens are minted and sent to the `receiver`, who is required to implement the {IERC3156FlashBorrower} interface. By the end of the flash loan, the receiver is expected to own value + fee tokens and have them approved back to the token contract itself so they can be burned.
maxFlashLoan(address) :
Returns the maximum amount of tokens available for loan.
name() :
Returns the name of the token.
symbol() :
Returns the symbol of the token, usually a shorter version of the name.
totalSupply() :
See {IERC20-totalSupply}.
transfer(address,uint256) :
See {IERC20-transfer}. Requirements: - `to` cannot be the zero address. - the caller must have a balance of at least `value`.
transferFrom(address,address,uint256) :
See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. NOTE: Does not update the allowance if the current allowance is the maximum `uint256`. Requirements: - `from` and `to` cannot be the zero address. - `from` must have a balance of at least `value`. - the caller must have allowance for ``from``'s tokens of at least `value`.
ERC20FlashMintUpgradeable.sol
IERC3156FlashBorrowerUpgradeable.sol
IERC3156FlashLenderUpgradeable.sol
ERC20Upgradeable.sol
IERC20Upgradeable.sol
IERC20MetadataUpgradeable.sol
IERC20Upgradeable.sol
ContextUpgradeable.sol
Initializable.sol
draft-IERC6093Upgradeable.sol
ABI:

Get Cookin'
star icon17

copy iconOpen in VSCode
copy iconDownload Source

17 downloads

Solidity Version

0.8.20