Skip to content

add bool swapWethToUsdc parameter to collectLp() and refactor#15

Merged
junta merged 2 commits into
mainfrom
feat/swap-to-usdc-in-collect
Jul 3, 2026
Merged

add bool swapWethToUsdc parameter to collectLp() and refactor#15
junta merged 2 commits into
mainfrom
feat/swap-to-usdc-in-collect

Conversation

@junta

@junta junta commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

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.

- 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.
if (swapAmountOutMin < (expectedSwapOut * (10_000 - slippageBps)) / 10_000) {
revert SwapMinBelowSlippageFloor();
}
_validateSwapParams(swapPoolFeeTier, swapAmountOutMin, expectedSwapOut, slippageBps, lpPoolFeeTier, true);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Refactor these validations as creating internal helper method

uint256 swapAmountOutMin,
uint256 expectedSwapOut,
uint16 slippageBps,
uint256 deadline

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

added these parameters for swap collected WETH to USDC

@junta
junta merged commit f17d601 into main Jul 3, 2026
1 check passed
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.

2 participants