[ETHEREUM-CONTRACTS] [WIP] cheaper balance checks & more #2040
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
cheaper balance checks
When doing a transfer or starting a stream, we check if the sender has enough balance.
Instead of calculating the exact balance, it's enough to check if there's enough balance.
That can often be done much more cheaply, that is when a sender account has a lot of GDA pools connected.
Since the connected pools can only increase the balance, we can stop iterating as soon as the required balance threshold is met.
The current implementation violates the agreement abstraction because it needs to leave the GDA balance last.
This is made with the IDA deprecation already in mind (for this optimization to work well, we can have only 1 agreement with non-constant balance calculation cost).
This status is to be considered a PoC in order to test and show the idea, more attention should be paid to naming, avoidance of code reduncancy, testing, etc.
SuperTokenV1Library
flowWithCtx
andflowFromWithCtx