Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERC3156 - Flash Loans #3156

Merged
merged 5 commits into from
Dec 8, 2020
Merged

ERC3156 - Flash Loans #3156

merged 5 commits into from
Dec 8, 2020

Conversation

alcueca
Copy link
Contributor

@alcueca alcueca commented Dec 7, 2020

Flash loans allow smart contracts to lend an amount of tokens without a requirement for collateral, with the condition that they must be returned within the same transaction.

The aim of this ERC is to provide a standard interfaces and processes for flash lenders and borrowers, allowing for flash loan integration without a need to consider each particular implementation.

@alcueca alcueca changed the title EIP - Flash Loans ERC3156 - Flash Loans Dec 7, 2020
EIPS/eip-flash-loans.md Outdated Show resolved Hide resolved
EIPS/eip-flash-loans.md Outdated Show resolved Hide resolved

## Simple Summary

Flash loans allow smart contracts to lend an amount of tokens without a requirement for collateral, with the condition that they must be returned within the same transaction.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The simple summary should generally one sentence with no motivation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check again, thanks.


The aim of this ERC is to provide a standard interfaces and processes for flash lenders and borrowers, allowing for flash loan integration without a need to consider each particular implementation.

## Abstract
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The abstract should be a technical overview of the EIP. I don't recommend it for an ERC.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check again, thanks.

EIPS/eip-flash-loans.md Outdated Show resolved Hide resolved
EIPS/eip-flash-loans.md Outdated Show resolved Hide resolved
EIPS/eip-flash-loans.md Outdated Show resolved Hide resolved
@MickdeGraaf
Copy link

Standardizing flashloans would be great! One thing this proposal does not take into accounts is contracts which hold multiple assets like PieDAO pies. I propose to add an extra param to the flashloan function to signal which asset the receiver is expecting like this:

function flashLoan(address receiver, address asset, uint256 amount, bytes calldata data) external {
  ...
  FlashBorrowerLike(receiver).onFlashLoan(msg.sender, asset, amount, fee, data);
  ...
}

Flash minting an asset could be done by passing the address of the contract itself to the asset param.

I've did a POC implementation a while back and the interface looks pretty much the same:

https://github.com/pie-dao/ExperiPie/blob/feature/flash-loans/contracts/facets/FlashLoan/FlashLoanFacet.sol
https://github.com/pie-dao/ExperiPie/blob/feature/flash-loans/contracts/facets/FlashLoan/FlashLoanMint.sol

@fubuloubu
Copy link
Contributor

Standardizing flashloans would be great! One thing this proposal does not take into accounts is contracts which hold multiple assets like PieDAO pies.

@MickdeGraaf would it be possible to use the data parameter for this type of interaction? Why would adding an asset field be generally useful, or avoid an extra security assumption?

@MickdeGraaf
Copy link

MickdeGraaf commented Dec 8, 2020

Standardizing flashloans would be great! One thing this proposal does not take into accounts is contracts which hold multiple assets like PieDAO pies.

@MickdeGraaf would it be possible to use the data parameter for this type of interaction? Why would adding an asset field be generally useful, or avoid an extra security assumption?

Not using the data parameter would avoid some confusion for implementers because they don't have to make an distinction between multi and single asset contracts but I guess it would work.

In most circumstances I would expect the data to only be actually used by flashLoanBorrower and not the lender itself.

Additionally it would be nice to have some getters allowing me to get a quote from a contract on how much fee I would have to pay and if there is sufficient liquidity for my flashloan.

@fubuloubu
Copy link
Contributor

Not using the data parameter would avoid some confusion for implementers because they don't have to make an distinction between multi and single asset contracts but I guess it would work.

In most circumstances I would expect the data to only be actually used by flashLoanBorrower and not the lender itself.

So, the intent of the data field was the facilitate more complex interactions with flash loan borrowing, and be flexible enough to support innovative use cases like yours where the intention is not generic enough to be useful for others.


Additionally it would be nice to have some getters allowing me to get a quote from a contract on how much fee I would have to pay and if there is sufficient liquidity for my flashloan.

This is a great idea!

@MickdeGraaf
Copy link

So, the intent of the data field was the facilitate more complex interactions with flash loan borrowing, and be flexible enough to support innovative use cases like yours where the intention is not generic enough to be useful for others.

Makes sense. I do think however that a very large portion of contracts is a token itself which holds one or more other tokens. In these cases the asset param would be a welcome addition imo.

@alcueca
Copy link
Contributor Author

alcueca commented Dec 8, 2020

Hi @MickdeGraaf, thanks a lot for your suggestion.

I think that for projects that hold and lend multiple assets an architecture like Uniswap would work with proposed standard. In Uniswap you go to a given Pair to exchange two tokens. Using this standard you would go to a given FlashLender (possibly built with a factory) to obtain a flash loan of a given token. You could have multiple receivers, or use the data parameter.

I don't dislike your suggestion, but I think there is value in simpler interfaces as long as we are not significantly limited by them.

@lightclient lightclient merged commit 07ba023 into ethereum:master Dec 8, 2020
@fubuloubu
Copy link
Contributor

@albertocuestacanada @MickdeGraaf please migrate your conversation to https://ethereum-magicians.org/t/flash-loan-eip-erc-3156-early-draft/4993

@fubuloubu fubuloubu deleted the flash-loans branch December 9, 2020 01:23
Arachnid pushed a commit to Arachnid/EIPs that referenced this pull request Mar 6, 2021
* initial draft

* typo

* reorganized summary, abstract and motivation

* renamed and added reference implementations

* updated tests and reference implementation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants