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

calculateProportionalAmounts for boosted pools #468

Open
agualis opened this issue Nov 4, 2024 · 5 comments
Open

calculateProportionalAmounts for boosted pools #468

agualis opened this issue Nov 4, 2024 · 5 comments
Assignees

Comments

@agualis
Copy link
Contributor

agualis commented Nov 4, 2024

The FE we uses calculateProportionalAmounts when the user choses “Proportional addable pool tokens”.
They fill one token input and we auto calculate and fill the other inputs proportionally using calculateProportionalAmounts that will be used with kind: AddLiquidityKind.Unbalanced underneath.

From a DX point of view, it would be easier to make it work with underlying tokens as the rest of the boosted integration.

@brunoguerios
Copy link
Member

Hey @agualis !
I'm wondering if the SDK is the best place to adapt this logic 🤔
The helper itself is simply calculating proportional amounts given a reference amount, while the FE is handling pool state by fetching/managing poolStateWithBalances.
If you use underlying token amounts as input, it should work as is.
Looking at the FE code, it seems to me that within _calculateProportionalHumanAmountsIn you could shift between poolStateWithBalances and something like boostedPoolStateWithBalances accordingly.
Does that make sense?

cc @johngrantuk (any idea/feedback on the suggested approach?)

@johngrantuk
Copy link
Member

Hey @agualis ! I'm wondering if the SDK is the best place to adapt this logic 🤔 The helper itself is simply calculating proportional amounts given a reference amount, while the FE is handling pool state by fetching/managing poolStateWithBalances. If you use underlying token amounts as input, it should work as is. Looking at the FE code, it seems to me that within _calculateProportionalHumanAmountsIn you could shift between poolStateWithBalances and something like boostedPoolStateWithBalances accordingly. Does that make sense?

cc @johngrantuk (any idea/feedback on the suggested approach?)

I was also thinking if this was best placed in SDK or not. If Alberto is ok with the suggestion then it seems a reasonable approach. I'm not sure if it would still be a bit confusing for external users though so maybe we can think about options to improve after the V3 launch.

@agualis
Copy link
Contributor Author

agualis commented Nov 7, 2024

@johngrantuk @brunoguerios I'm ok with the suggestion and with trying to improve the DX after V3 launch

@brunoguerios
Copy link
Member

Yeah, my concern is that if we shift that to the SDK, it will have to perform a few on-chain calls to query the underlying balances and then calculate amounts proportional to it.
While current helper expects the pool state (balances) to be provided as input.
I'm actually implementing something like that, with on-chain calls to solve a similar issue.
I'll share with you after I'm done so we can evaluate if some of that is reusable into solving/improving this.

@brunoguerios
Copy link
Member

@agualis - sharing in case it's helpful:

PR #486 adds the concept of PoolStateWithUnderlyingBalance and also shows how you can adapt it to PoolStateWithBalance to reuse it within calculateProportionalAmounts.

Let me know if you think any of this can be used/adapted to improve DX after v3 launch

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

No branches or pull requests

3 participants