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

New composite router for boosted pool operations #572

Merged
merged 23 commits into from
Jan 29, 2025

Conversation

MattPereira
Copy link
Member

@MattPereira MattPereira commented Jan 25, 2025

Closes #555

Summary

  • Temporarily splitting composite router into boosted and nested versions
  • New composite router allows for passing array of booleans that determine if token should be wrapped / unwrapped

Update 1

  • For proportional boosted queries, using the new tokensIn and tokensOut that are returned by composite router

Update 2

  • Major refactor of implementation to infer wrapUnderlying and unwrapWrapped so user only has to worry about which tokens they want to add / remove

@MattPereira MattPereira marked this pull request as ready for review January 25, 2025 00:33
@MattPereira MattPereira changed the title New composite router for boosted operations New composite router for boosted pool operations Jan 25, 2025
Copy link
Member

@johngrantuk johngrantuk left a comment

Choose a reason for hiding this comment

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

Just a few loose ends to tidy and a changeset to add.

Copy link
Member

@brunoguerios brunoguerios left a comment

Choose a reason for hiding this comment

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

Can you please add an add liquidity proportional test covering a scenario that was not previously supported?
I believe that will expose an issue with existing calculateProportionalAmounts helper not being able to handle these new possibilities for amountsIn combinations.

@MattPereira
Copy link
Member Author

MattPereira commented Jan 28, 2025

@brunoguerios new tests for query add with single wrap and remove with single unwrap are ready for review. Also, thanks again for the assist! ❤️

switch (input.kind) {
case AddLiquidityKind.Unbalanced: {
// Use poolState to add token index to amountsIn
const tokensIn = input.amountsIn.map((amountIn) => {
Copy link
Member

Choose a reason for hiding this comment

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

It feels like a lot of this tokensIn logic is repeated within unbalanced and proportional implementations. Do you think it's worth extracting/reusing?

Copy link
Member

Choose a reason for hiding this comment

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

given we're in a bit of a tight schedule, we can leave this refactor to be done in a new (low-priority) PR

Copy link
Member Author

Choose a reason for hiding this comment

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

yup I agree on both notes 👍

Copy link
Member

@brunoguerios brunoguerios left a comment

Choose a reason for hiding this comment

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

I like this solution a lot better 😃 👏
Thanks for following up on the requested changes!
There is one detail on the priceImpact side of things that I'd like to double check, but other than that it LGTM! ✅

src/entities/addLiquidityBoosted/index.ts Outdated Show resolved Hide resolved
* }
* }
*/
export function buildPoolStateTokenMap(
Copy link
Member

Choose a reason for hiding this comment

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

Nice helper 👏

@brunoguerios brunoguerios merged commit 9c43fcb into main Jan 29, 2025
4 checks passed
@brunoguerios brunoguerios deleted the new-composite-liquidity-router branch January 29, 2025 15:19
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.

Update to new CompositeLiquidity and Nested Routers
3 participants