ERCs

ERC-3156 — Flash Loans

eips.ethereum.org/EIPS/eip-3156

Standard flash-loan interfaces: a lender exposes the borrow API, a borrower implements the callback. Loans must be repaid in the same transaction.

import { flashLoan, maxFlashLoan, flashFee } from "@ethernauta/erc/3156/extensions/flash-lender";
import { onFlashLoan } from "@ethernauta/erc/3156/extensions/flash-borrower";

Surface

Flash lender (@ethernauta/erc/3156/extensions/flash-lender)

MethodShapePurpose
maxFlashLoan({ token })Callable<Uint256>Maximum loanable amount.
flashFee({ token, amount })Callable<Uint256>Fee for a given amount.
flashLoan({ receiver, token, amount, data })Signable<Hash32>Borrow and call back.

Flash borrower (@ethernauta/erc/3156/extensions/flash-borrower)

MethodShapePurpose
onFlashLoan({ initiator, token, amount, fee, data })callbackImplement on your borrower contract.

See also

  • ERC-20 — the token being loaned.