Skip to content

Add yield harvesting#71

Open
jribbink wants to merge 4 commits into
mainfrom
jribbink/yield-harvesting
Open

Add yield harvesting#71
jribbink wants to merge 4 commits into
mainfrom
jribbink/yield-harvesting

Conversation

@jribbink

@jribbink jribbink commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Closes #24

Adds yield harvesting as a leg of rebalance(): when the yield factor (yield value / debt) rises above the immutable yieldFactorMax band edge, sells the surplus yield down to the debt backing and supplies it as collateral (add-only), deploying the gains back into the position. Zero-amount guards skip dust so it can't revert the rebalance. (The band's lower edge — yieldFactorMin + a delever to restore backing on a depeg — is a stacked follow-up.)

Also moves setMaxSlippageBps to onlyOwner, matching the other config setters.

@jribbink jribbink force-pushed the jribbink/yield-harvesting branch 16 times, most recently from 0a1cf50 to bb1cff9 Compare July 2, 2026 23:12
@jribbink jribbink force-pushed the jribbink/yield-harvesting branch from bb1cff9 to 04575f7 Compare July 2, 2026 23:29
@jribbink jribbink marked this pull request as ready for review July 3, 2026 10:21
Comment thread solidity/src/FCMVault.sol Outdated
Comment on lines +84 to +85
/// health-factor band bounds. The lower edge (`yieldFactorMin` + a delever) is a
/// stacked follow-up.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
/// health-factor band bounds. The lower edge (`yieldFactorMin` + a delever) is a
/// stacked follow-up.
/// health-factor band bounds.

I think this is talking about a followup PR (?). If so probably doesn't need to be in the comments

Comment thread solidity/src/FCMVault.sol
// at its oracle-expected output less maxSlippageBps.
// TODO(#72): a floor trip reverts the whole rebalance, which blocks the delever
// if over-levered. Goes away once #72 makes these swaps partial-fill.
uint256 loanGot = SwapLib.swapExactInMin(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Gornutz Do you think we can expect to have a direct yield <-> collateral swap pool? Or is it better to do two consecutive swaps using the already-configured pools, as the implementation does here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Most of the time I wouldn't expect there to be a yield token <-> collateral pool to exist. Thinking about it from how much capital we would need to keep on those pools make it quite inefficient at the moment. At the moment I do think that having 2 leg swap is probably the best path forward. Then a slightly better/ optimal path is using redemption for yield token -> deposit asset followed by a swap from deposit asset to collateral asset, just so that you are slightly decreasing slippage/swap fees.

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.

Yield Harvesting

3 participants