[AMM Pool] Rename variables and extract methods #1772
Merged
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.
@Brechtpd After working on this PR, I finally figured out how your design works :) I do have the following suggestions regarding the pool token's mint/burn logic:
Now we calculate the amount of tokens that will be accepted into the pool based on the Join's
poolAmountOut
parameter. IfpoolAmountOut
is large enough, this join will likely to fail; otherwise, if it is small enough, the user ends up with a smaller amount of pool tokens than he deserves. I suggest we calculate the amount of pool tokens assuming his join will be accepted, then compare the new pool tokens to mint to him with aminPoolTokenAmount
parameter that the user provides. IfminPoolTokenAmount
is smaller than or equal to the pool tokens to be minted, then this Join will be accepted, otherwise, the join will be rejected. By doing this, a user will feel really comfortable by providing a small value forminPoolTokenAmount
, or even zero if he doesn't care about slippage.For exits, I suggest we only take one parameter - the amount of pool tokens the user would like to burn. Then calculate the amount of each token that will be released back to layer1 for withdrawal. There should be no slippage option for exits at all, as users collectively owns what's left in the pool anyway. I believe this is also the case with uniswap.