# Does require always reverts all state and balances? Plus Flash Loan contract

**URL:** <https://forum.openzeppelin.com/t/does-require-always-reverts-all-state-and-balances-plus-flash-loan-contract/2977>\
**Category:** Support\
**Created:** [May 31, 2020, 7:05pm UTC](https://forum.openzeppelin.com/t/does-require-always-reverts-all-state-and-balances-plus-flash-loan-contract/2977 "2020-05-31T19:05:04Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [June 1, 2020, 1:16am UTC](https://forum.openzeppelin.com/t/does-require-always-reverts-all-state-and-balances-plus-flash-loan-contract/2977/2 "2020-06-01T01:16:46Z")

</div>

Hi @4ntrek0t,

Welcome to the community 👋

Is it your code?

I'm a community manager and not an auditor so don't have the skills and training to give a lot of feedback on issues with this code. Any solution should be appropriately tested and audited.

Assuming it is your code, if you haven't already, you should document what this contract is meant to do and create extensive tests. (see: [Follow this quality checklist before an audit](https://blog.openzeppelin.com/follow-this-quality-checklist-before-an-audit-8cc6a0e44845/)). If it isn't your code, then I wouldn't use it without reading the documentation, seeing appropriate testing and reading the audit reports.

I would check if the contract has issues with reentrancy: [Reentrancy After Istanbul](https://forum.openzeppelin.com/t/reentrancy-after-istanbul/1742)

The contract fails for amounts smaller than 1kwei.

I didn't immediately pickup what the code was trying to do. It took me a bit of time to realize that this is meant to be a form of Flash Loan with a fee.

I suggest looking at the slides/video on the Flash Loan pattern (if you haven't already) and the implementation by @Austin-Williams. ⚠ Don't use these contracts in production. They have not yet been audited.

> [@Introduction to the Flash Loan Pattern and its security considerations](https://forum.openzeppelin.com/t/introduction-to-the-flash-loan-pattern-and-its-security-considerations/2331/3):
>
> @Austin-Williams linking here for reference [your implementation](https://github.com/Austin-Williams/safer-flash-loans) of safer flash loans, hope you don’t mind!

* * *

As for your first question:

> Does require always reverts all state and balances

Please see the Solidity documentation for details on this:  
[https://solidity.readthedocs.io/en/v0.5.15/control-structures.html#assert-and-require](https://solidity.readthedocs.io/en/v0.5.15/control-structures.html#assert-and-require)

> Solidity uses state-reverting exceptions to handle errors. Such an exception undoes all changes made to the state in the current call (and all its sub-calls) and flags an error to the caller.
> 
> When exceptions happen in a sub-call, they “bubble up” (i.e., exceptions are rethrown) automatically. Exceptions to this rule are `send` and the low-level functions `call` , `delegatecall` and `staticcall` , they return `false` as their first return value in case of an exception instead of “bubbling up”.

---

_[View the full topic](https://forum.openzeppelin.com/t/does-require-always-reverts-all-state-and-balances-plus-flash-loan-contract/2977)._
