-
Notifications
You must be signed in to change notification settings - Fork 74
ERC-3156 flash loans #277
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
ERC-3156 flash loans #277
Conversation
3fd8f0b to
b087476
Compare
andreivladbrg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why didn't you check if the {SablierV2Comptroller-flashFee} is greater than the MAX_FEE in the {SablierV2FlashLoan-flashLoan}?
If you created a dedicated dir for the flash loan functions tests, why not move the SablierV2 tests (claimProtocolRevenues, getProtocolRevenues, setComptroller) from shared dir to a dedicated one aswell?
For context - the author of the EIP still recommends using it, and I am in very much in favor of that.
Why wouldn't he? It doesn't mean that it is the best version that can be implemented of the flash loan functionality.
The benefits of complying with the EIP are:
I am going to name some cons too:
- Larger contract size:
CALLBACK_SUCCESSconstantflashFeefunction andmaxFlashLoanfunction, they are not mandatory to be able to make the functionality work. - Contradictories regarding on how we write code in our contracts:
addressinstead ofIERC20,uint256instead ofuint128. - Close doors to customizations / personalizations: implementing the idea on my comment would not follow the EIP.
But let's not debate this anymore, we are gonna follow the EIP.
b087476 to
eaa270e
Compare
|
Thanks for the review, @andreivladbrg.
Good question. My rationale was based on the following reasons:
Again, good question. The answer is simple, but technical. The mechanism by which the protocol revenues are generated is stream-dependent - by simply inheriting the abstract contract Nonetheless, what might be useful is to create a dedicated directory for the
I know Alberto for 3+ years already. He's working at Yield, which is (was?) Hifi's main competitor. Alberto is a top-notch software engineer, with a sense of intellectual honesty. If the ERC standard wasn't useful anymore, he would have said it.
I don't think "cons" is a good word to use in this context - instead I would call of those points the "costs" for implementing the ERC. And they are fine to me. A 32 bytes constant doesn't cost much bytecode. The lack of consistency is easily handled by separation of concerns (the separate |
eaa270e to
632ef3a
Compare
Fair enough, don't have anything to add here.
Same for the flash loans, if there are no streams created, there is no liquidity in the contracts.
No, we shouldn't reintroduce the mock, the constructor must be tested in the |
Nope, but I see that my formulation was ambiguous. What I meant to say is that the values in the On the other hand, in the case of the flash loan contract, we can simply use the
Ah, so this is what you meant! Ok, thanks for clarifying. Let's do this later though, there's no rush to do in this PR (doing this would trigger a lot of git conflicts down the line). I will create an issue about this because I realize that we haven't tested something super important in the constructor - that the |
|
@andreivladbrg, here are some concrete figures for the statement that you made in the first comment:
I removed this constant from the |
632ef3a to
5c90e59
Compare
build: install "erc2156" git submodule
docs: add header separators in "ISablierV2Comptroller"
docs: improve wording in NatSpec comments
docs: surround contracts and functions with brackets {}
refactor: add missing "override" in "getRange" function
refactor: add missing "override" in "getReturnableAmount" function"
refactor: move abstract contracts in "abstracts" directory
refactor: rename "newFee" param to "newProtocolFee"
refactor: use "intoUint256" instead of "unwrap" for UD60x18
feat: add "SablierV2FlashLoan" contract
test: add flash loan-related constants
test: add mock receiver contracts for flash loan tests
test: fully test "SablierV2FlashLoan" contract
test: rename "ComptrollerTest" to "Comptroller_Test"
test: test that "SetProtocolFee" event gets emitted
Co-authored-by: Andrei Vlad Birgaoanu <[email protected]>
chore: fix number of contract dependencies mentioned in comments
5c90e59 to
e215392
Compare
Fair enough.
All the args have to be tested:
It may not be that much, but it is unnecessary, would've been much easier to check for a bool. Looks like it can be merged |
|
Thanks for your final review.
Yup, tested all of them in #284.
It would have even easier to just not return anything, but EIPs are not modifiable once finalized. |
* refactor: remove isPaused from storage slot refactor: update snapshot time in pause and void * docs: polish comment in ongoingDebt * refactor: allow zero rps in create * docs: update diagram for create * Address my feedback and other changes (#282) * address my feedback refactor: use _adjustRatePerSecond function in _pause and _restart refactor: remove zero check in _adjustRatePerSecond refactor: remove no longer needed custom error test: update tests accordingly test: add a new invariant for stream status docs: undo diagrams change * docs: update invariant in readme * shub feedback --------- Co-authored-by: smol-ninja <[email protected]> * test: add rps zero tests in create and adjustRPS --------- Co-authored-by: Andrei Vlad Birgaoanu <[email protected]> Co-authored-by: andreivladbrg <[email protected]>
Implements #246 by strictly following ERC-3156 and the advice I have given in this comment.
For context - the author of the EIP still recommends using it, and I am in very much in favor of that.
The benefits of complying with the EIP are: