-
Notifications
You must be signed in to change notification settings - Fork 47
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
DRAFT: CompositeLiquidityRouterV2 #1068
Conversation
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.
Good job @elshan-eth!
As discussed off-thread, I think this would be a good candidate for a future iteration of the composite liquidity router. At this point the SDK team has already moved forward with the initial interface, and we won't be able to be ready to launch if we introduce a big change like this one.
I would not discard this, however. Let's keep the composite liquidity router as is, and rename the one in this PR to CompositeLiquidityRouterV2
.
Description
The idea behind this refactoring is to use recursion for handling nested pools, as well as to represent the input arguments as a structure. Introducing the structure made it possible to apply the parameters minBptAmountOut, wethIsEth, and userData individually for each operation.
NestedAddPoolOperation
is a structure that represents a single liquidity addition operation.prevPool
— if the target pool is nested within another pool, we need to specify this. This allows the same wrapped asset to be used across multiple pools.pool
— the target pool.tokensInAmounts
— the token amounts we want to use in the operation. If one of the tokens is nested, its amount should be set to 0. If we want to add liquidity to an ERC4626, we need to specify only one element in tokensInAmounts.Example:
If we want to wrap
ETH -> WETH
andDAI -> wDAI
, as well as add liquidity toBPT_POOL_B
, the nestedPoolOperations array will be populated as follows:The order of operations will be as follows:
ETH → wETH
.DAI → wDAI
.POOL_A
(this operation is executed automatically, even if it's not in our list of operations, because its children were affected).POOL_B
.MAIN_POOL
(this operation is also executed automatically, even if it's not in our list of operations, because its children were affected).If we want to add wDAI instead of wrapping DAI, then our structure will look like this:
The order of operations will be as follows:
ETH → wETH
.POOL_A
POOL_B
.MAIN_POOL
(this operation is also executed automatically, even if it's not in our list of operations, because its children were affected).Type of change
Checklist:
main
, or there's a description of how to mergeIssue Resolution
Closes #1044