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

feat/enable disable flashloan config #710

Merged
merged 28 commits into from
Nov 15, 2022

Conversation

stevenvaleri
Copy link
Contributor

@stevenvaleri stevenvaleri commented Aug 29, 2022

Adds a configuration to enable and disable flashloans for a specific asset.

All existing assets will continue to have flashloans enabled. In the future this will allow for explicit errors when attempting to flashloan gho.

This is dependent on an update to the deploy repo. The update enables flashloans for all assets during the reserve configuration process.

@stevenvaleri stevenvaleri changed the title DRAFT: feat/enable disable flashloan config feat/enable disable flashloan config Aug 29, 2022
contracts/protocol/pool/PoolConfigurator.sol Outdated Show resolved Hide resolved
contracts/interfaces/IPoolConfigurator.sol Outdated Show resolved Hide resolved
test-suites/pool-flashloan.spec.ts Outdated Show resolved Hide resolved
test-suites/pool-flashloan.spec.ts Outdated Show resolved Hide resolved
test-suites/pool-flashloan.spec.ts Show resolved Hide resolved
test-suites/configurator.spec.ts Show resolved Hide resolved
@stevenvaleri
Copy link
Contributor Author

Comments addressed - ready for re-review

Copy link
Contributor

@miguelmtzinf miguelmtzinf left a comment

Choose a reason for hiding this comment

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

Missing a couple of test cases, but lgtm in general

@stevenvaleri
Copy link
Contributor Author

stevenvaleri commented Oct 25, 2022

Additional updates added - ready for re-review

  • switch to using bit 63 in reserve configuration
  • add reserve configuration unit tests
  • minor test case updates

@kyzia551
Copy link
Collaborator

All existing assets will continue to have flashloans enabled. In the future this will allow for explicit errors when attempting to flashloan gho.

Hey @stevenvaleri ! How is it achieved in PR? Maybe I'm missing something, but by default this bit will be 0 and an asset will become flashloanable only when you set it to 1 (for existing deployments, I mean)

@@ -472,6 +472,7 @@ library ValidationLogic {
.configuration;
require(!configuration.getPaused(), Errors.RESERVE_PAUSED);
require(configuration.getActive(), Errors.RESERVE_INACTIVE);
require(configuration.getFlashLoanEnabled(), Errors.FLASHLOAN_DISABLED);
Copy link
Collaborator

@kyzia551 kyzia551 Oct 27, 2022

Choose a reason for hiding this comment

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

the same require missing in the validateFlashloanSimple in some lines above. Because of that looks like a good idea to reuse simple ie:

   ...
    require(assets.length == amounts.length, Errors.INCONSISTENT_FLASHLOAN_PARAMS);
    for (uint256 i = 0; i < assets.length; i++) {
      validateFlashloanSimple(reservesData[assets[i]].configuration);
    }

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch. Let's add tests and evaluate this change!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed - will update

@stevenvaleri
Copy link
Contributor Author

All existing assets will continue to have flashloans enabled. In the future this will allow for explicit errors when attempting to flashloan gho.

Hey @stevenvaleri ! How is it achieved in PR? Maybe I'm missing something, but by default this bit will be 0 and an asset will become flashloanable only when you set it to 1 (for existing deployments, I mean)

@kyzia551 It's updated in the deploy repo. If you re-install dependencies in this repo, it will pull in beta version of the deploy repo with this update.

@kyzia551
Copy link
Collaborator

kyzia551 commented Oct 27, 2022 via email

@stevenvaleri
Copy link
Contributor Author

I think it makes more sense to enable separately after the reserve is added - this would be consistent with making something borrowable, or enabled as collateral.

If you want an asset not flashloanable, but it is configured to be enabled by default, you'd need to remember to disable it in the same transaction when listing it, or we'd need to change the initReserve function to have a flag to override the default. I think it is less risky / prone to error to have all disabled by default and I don't think we'd consider updating the initReserve params.

@miguelmtzinf
Copy link
Contributor

miguelmtzinf commented Oct 27, 2022

I think it makes more sense to enable separately after the reserve is added - this would be consistent with making something borrowable, or enabled as collateral.

If you want an asset not flashloanable, but it is configured to be enabled by default, you'd need to remember to disable it in the same transaction when listing it, or we'd need to change the initReserve function to have a flag to override the default. I think it is less risky / prone to error to have all disabled by default and I don't think we'd consider updating the initReserve params.

Totally agree. Having it enabled by default would lead to errors because breaks the consistency across the reserve configuration.

@miguelmtzinf miguelmtzinf merged commit c18e3c4 into feat/3.0.1 Nov 15, 2022
@miguelmtzinf miguelmtzinf deleted the feat/enable-disable-flashloan-config branch November 15, 2022 14:19
@eboadom eboadom mentioned this pull request Nov 16, 2022
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