Add yield harvesting#71
Conversation
0a1cf50 to
bb1cff9
Compare
bb1cff9 to
04575f7
Compare
| /// health-factor band bounds. The lower edge (`yieldFactorMin` + a delever) is a | ||
| /// stacked follow-up. |
There was a problem hiding this comment.
| /// 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
| // 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( |
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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.
Closes #24
Adds yield harvesting as a leg of
rebalance(): when the yield factor (yield value / debt) rises above the immutableyieldFactorMaxband 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
setMaxSlippageBpstoonlyOwner, matching the other config setters.