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

Add proportional helper to calculate BPT from a reference amount for boosted pools #486

Merged
merged 15 commits into from
Nov 25, 2024

Conversation

brunoguerios
Copy link
Member

Closes #455

@brunoguerios brunoguerios added the enhancement New feature or request label Nov 8, 2024
@brunoguerios brunoguerios self-assigned this Nov 8, 2024
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 comments but its looking good.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is an attempt to fix an unrelated test that was intermittently failing.

Copy link
Member

Choose a reason for hiding this comment

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

Nice creating the test client just once in the before all hook is good improvment 🏆

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for trying to address this! Whats your thoughts on the reason it was intermittently failing?

Copy link
Member Author

Choose a reason for hiding this comment

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

My assumption was that the failure came from parallel threads not being handled properly. Since tests were reusing the same fork, they could be affecting each other's results.
The idea of forcing a snapshot and keeping each test on its own fork sounded like something that would prevent this from happening.
But then again, I'm not completely sure this is the case and that's why I mentioned it was an "attempt" 😅
We can dig deeper in case the issue starts happening again 🤷‍♂️

({ rpcUrl } = await startFork(
ANVIL_NETWORKS.SEPOLIA,
undefined,
7010800n,
Copy link
Member

@MattPereira MattPereira Nov 22, 2024

Choose a reason for hiding this comment

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

Is the block number fixed here to protect against external changes to pool liquidity that could cause test to fail?

Looks like addLiquidityBoosted.integration.test.tsdoes not specify a block number when starting the fork.

beforeAll(async () => {
({ rpcUrl } = await startFork(ANVIL_NETWORKS[ChainId[chainId]]));

Is there some reason that is okay there but not here?

Or is it better practice to always fix the blockNumber the fork starts? Or is that not worth the trade off of having to update block numbers each time a new version of v3 is deployed?

Would it make sense to centralize the block all v3 tests run at using a constants file?

Copy link
Member

Choose a reason for hiding this comment

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

Also interested about this. Seems to run ok without fixing block number (which I would expect to always be the case) and I think ideally we avoid explicitly setting it if possible?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I had to fix the blockNumber due to how tests were setup (see line 220).
On this addLiquidityPartialBoosted we're testing the queryOutput separated from the actual transaction, so we can't compare to token balance delta as we do on other files.
For add liquidity unbalanced that's ok, because we can compare queryOutputs with amountsIn provided as input, but for add liquidity proportional, we don't have that.
So, if we want to check queryOutput against all amountsIn, we have to provide a known/hardcoded value, which requires blockNumber to be fixed.
With that being said, I usually prefer to avoid fixing blockNumbers as well.
We could refactor addLiquidityPartialBoosted to follow the same pattern as addLiquidityBoosted and this would be solved.
What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Soooo clean and ez to read ☺️

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.

Matou a pau! 🪵 ✨

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.

Looks good! Once we're happy with the final decision on test block number lets release and let the FE guys know so it can be used as part of the QA testing that is due to start soon.

@brunoguerios brunoguerios merged commit d4cfee1 into main Nov 25, 2024
4 checks passed
@brunoguerios brunoguerios deleted the bpt-from-reference-amount-boosted branch November 25, 2024 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing BPT amount calculation from reference amount in add liquidity boosted
3 participants