-
Notifications
You must be signed in to change notification settings - Fork 3
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
WIP: Calculate fees for multiple redemptions at once #28
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
The amount by which the totalPoolSupply will change should be
totalPoolSupply-=redemptionAmount
feeAmount is not being burnt.
The way in works from the user perspective is as follows:
This different from the deposits where:
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.
Also in case someone passes
2 items which both are same tco2
you would need to track the tco2Balance as well
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.
@kosecki123 @0xmichalis I could be misunderstanding, but this sounds problematic to me, for the following reasons:
If the user wants to redeem all their pool tokens, it requires them to work backwards from their balance to figure out the correct redemption amount. In your example above, if they have exactly 10 pool tokens, they would need to find a value around 9.9 tokens to redeem which totals exactly 10 pool tokens when the fee is added on top. However, because the fee is on a non-linear curve, I suspect this turns into a really complicated mathematical equation to solve, even if there's UI code to do it for the user:
If the pool diversity changes slightly to increase the fee in between receiving the quote and submitting the transaction, it could easily increase the fee enough that the amount of pool tokens would exceed their balance of 10, and the transaction would fail.
If instead the fee decreases in that window between quote and execution, then the user gets left with annoying amount of pool token dust which they probably can't make use of because it's not worth the gas fees to get rid of it.
In contrast, if we take the approach that the fee is deducted from the amount of pool tokens the user requests to redeem, then all of these problems go away: the user will always spend exactly 10 pool tokens, and the only thing which can change is how much TCO2 they get back (which BTW will also have a lower bound due to the max fee cap which we are adding).