Skip to content

[AMM Pool] Rename variables and extract methods #1772

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

Merged
merged 4 commits into from
Sep 19, 2020

Conversation

dong77
Copy link
Contributor

@dong77 dong77 commented Sep 19, 2020

@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. If poolAmountOut 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 a minPoolTokenAmount parameter that the user provides. If minPoolTokenAmount 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 for minPoolTokenAmount, 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.

@dong77 dong77 requested a review from Brechtpd September 19, 2020 03:13
@dong77 dong77 changed the title Rename variables Rename variables and extract methods Sep 19, 2020
@dong77 dong77 changed the title Rename variables and extract methods [AMM Pool] Rename variables and extract methods Sep 19, 2020
@Brechtpd
Copy link
Contributor

It seems like uniswap does have very similar checks: https://github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/UniswapV2Router01.sol. So both uniswap and balancer check this (for a good reason I assume).

I do think this doesn't matter a lot in most cases (I think it only really matters when the pool is small, otherwise it's just small potential slippage risks, but pools can be small so we have to make sure that scenario also works).

@Brechtpd Brechtpd merged commit 162d390 into protocol36-ammpool Sep 19, 2020
@Brechtpd Brechtpd deleted the rename-variables-2 branch September 19, 2020 14:39
Brechtpd added a commit that referenced this pull request Sep 22, 2020
* [protocol 3.6] AMM pool testing

* [protocol 3.6] More AMM pool testing

* [protocol 3.6] Improved AMM pool + testing

* [protocol 3.6] Small optimizations

* [protocol 3.6] Misc improvements/fixes AMM pool

* unify submitBlocksCompressedWithCallbacks (#1761)

* unify submitBlocksCompressedWithCallbacks

* unify submitBlocksCompressedWithCallbacks

* Amm approve erc20 on setup (#1762)

* approve upon setup

* approve upon setup

* allow withdraw all tokens (#1763)

* make agent explicitly inherit IAgent (#1765)

* [protocol 3.6] Small fixes

* [protocol 3.6] uint96 safe math (#1766)

* [AMM Pool] Rename variables and extract methods (#1772)

* rename variables

* extract methods

* extract methods

* [AMM Pool] Some small improvements (#1773)

* add changes based on my questions

* more

Co-authored-by: wangdong <wangdong@zhongan.io>
Co-authored-by: Brechtpd <Brechtp.Devos@gmail.com>

* [AMM pool] Changed approvals + locking logic (#1771)

* [protocol 3.6] Changed approvals + locking logic

* [protocol 3.6] LP tokens

* [protocol 3.6] Use minPoolAmountOut for joins

* [protocol 3.6] AMM pool signature assisted L1 withdrawals + fixes

* [protocol 3.6] Small improvements/fixes

Co-authored-by: Daniel Wang <daniel@loopring.org>
Co-authored-by: wangdong <wangdong@zhongan.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants