add bool swapWethToUsdc parameter to collectLp() and refactor#15
Merged
Conversation
- Replaced inline validation checks in the collectLp function with a dedicated _validateSwapParams function to streamline code and improve readability. - Updated the collectLp function signature to include new parameters for swap options, enhancing flexibility in handling WETH to USDC swaps. - Modified integration and mock tests to accommodate the new function signature and validate the correct behavior of the collectLp function under various scenarios. - Ensured comprehensive error handling for edge cases related to token pairs and position ownership.
junta
commented
Jun 24, 2026
| if (swapAmountOutMin < (expectedSwapOut * (10_000 - slippageBps)) / 10_000) { | ||
| revert SwapMinBelowSlippageFloor(); | ||
| } | ||
| _validateSwapParams(swapPoolFeeTier, swapAmountOutMin, expectedSwapOut, slippageBps, lpPoolFeeTier, true); |
Collaborator
Author
There was a problem hiding this comment.
Refactor these validations as creating internal helper method
junta
commented
Jun 24, 2026
| uint256 swapAmountOutMin, | ||
| uint256 expectedSwapOut, | ||
| uint16 slippageBps, | ||
| uint256 deadline |
Collaborator
Author
There was a problem hiding this comment.
added these parameters for swap collected WETH to USDC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an optional WETH→USDC swap to collectLp() so harvested LP fees can be returned to the Safe as USDC in a single call, and consolidates the swap validation/execution logic shared by
openLp, closeLp, and collectLp into two internal helpers. closeLp and openLp behavior is unchanged.
Motivation
collectLp() previously harvested LP fees in-kind (WETH + USDC) and forwarded them to the Safe, leaving the caller to swap the WETH leg separately. This adds an opt-in swap so a fee harvest
can settle entirely in USDC, mirroring the swap safety already used by openLp/closeLp.