Skip to content
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] V3 nested pool support #442

Merged
merged 11 commits into from
Oct 25, 2024
Merged

[WIP] V3 nested pool support #442

merged 11 commits into from
Oct 25, 2024

Conversation

johngrantuk
Copy link
Member

@johngrantuk johngrantuk commented Oct 23, 2024

  • Support for addLiquidity (unbalanced only as thats what router supports) using Permit2 direct and signatures
  • Tests as currently failing with different final BPT result from query result. Assuming its router for now and hoping its fixed in deploy10.
  • Support for removeLiquidity (proportional only).
  • Tests for direct approval and Permit sig. Both failing at the moment - assuming due to Router issues.

Still to do:

Closes #257

Comment on lines +39 to +52
// Address of the highest level pool (which contains BPTs of other pools), i.e. the pool we wish to join
const parentPool = nestedPoolState.pools.reduce((max, curr) =>
curr.level > max.level ? curr : max,
);
// query function input, `tokensIn` array, must have all tokens from child pools
// and all tokens that are not BPTs from the nested pool (parent pool).
const mainTokens = nestedPoolState.mainTokens.map(
(t) => new Token(input.chainId, t.address, t.decimals),
);
// This will add 0 amount for any tokensIn the user hasn't included
const maxAmountsIn = getAmounts(mainTokens, input.amountsIn, 0n);

// Query the router to get the onchain amount
// Note - tokens do not have to be sorted, user preference is fine
Copy link
Member

@MattPereira MattPereira Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent job explaining the trickier parts / nuances with these comments 👏

Copy link
Member

@MattPereira MattPereira Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor inconsequential suggestion, but might make sense to have only one test file that runs both .buildCall and .buildCallWithPermit2 for the addLiquidityNestedV3 ( unless I'm missing good reason is better to split? )

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Goes back to what we were discussing in our last meeting - I thought it was quite hard to follow approvals, etc in the other tests where everything is nested deeply and this was an attempt to make it easier to understand.

Copy link
Member

@MattPereira MattPereira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 Full steam ahead, captain!

@johngrantuk johngrantuk merged commit d7ad259 into main Oct 25, 2024
3 of 4 checks passed
@johngrantuk johngrantuk deleted the v3-nested-pools branch October 25, 2024 07:34
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.

Add Liquidity Nested - Unbalanced
2 participants