[fallback rolling] max LTV - #1115
Conversation
There was a problem hiding this comment.
If we say that one must use the fallback rolling only with a Blue market that has an LLTV equal or lower than the Midnight's LLTV (reasonable constrain imo), it means that they health is only improved by the rolling (minus the rolling incentive, but this is predictable and set by them). what is a situation where you would rather prevent the rolling (with requireMaxLTV) and be liquidated on Midnight post-maturity? because the LIF will be smaller on Midnight? the rolling incentive might change things as well (if you get rolled then liquidated on Blue, you have a implied LIF higher because of the incentive).
There was a problem hiding this comment.
Was expecting the Blue market LLTV to be always equal to Midnight's LLTV thus the health would be (predictably) slightly worsen by the rolling and would continue worsening through time because of the interest accrual. Thought that we could have a LTV margin that would include these two elements (interest at the expected rate over some short period such as a month) and eventually the volatility of the collateral.
There was a problem hiding this comment.
the question we should answer is: is there a setup in which you prefer to be liquidated on midnight's post maturity liquidation instead of being rolled on Blue? Maybe when 1) your LTV is so high that you will likely be liquidated soon on Blue, so you would rather be liquidated at a soft LIF on Midnight or 2) when the rolling incentive makes you close to be liquidated on Blue so same you prefer a soft liquidation?
There was a problem hiding this comment.
I would expect 2) to be way less likely than 1) because the incentive should be computed such that it's minimal (just enough to cover the gas cost)
There was a problem hiding this comment.
about 2): interestingly, the rolling incentive should be in the order of magnitude of the midnight post-maturity effective LIF (assuming gas to liquidate ~= gas to roll on blue). Meaning that they cancel out => you want fallback rolling to keep your position open (in order to not pay tax for example), not to avoid paying the midnight LIF.
then it kind of invalidates 1), no? you would rather try it on blue, hope that you will not get liquidated, rather than staying on midnight and get liquidated?
There was a problem hiding this comment.
in the order of magnitude of the midnight post-maturity effective LIF
I don't think that it would be the case for large positions because the post-maturity effecitve LIF would take the swapping cost into account (which is usually a few bps in pool fees and possibly a few extra bps in price impact) while rolling is just the gas cost (which would be the same for all position size).
That's one of the reason why I think having an auction could be beneficial here, the incentive is currently in proportion of the debt but the gas cost isn't (and can be very volatile) so an auction could capture the relevant incentive more accurately
no? you would rather try it on blue, hope that you will not get liquidated
That's an interesting point and I'm honestly not sure how borrowers would behave. Suppose my LTV on midnight is quite high and I'm close to maturity, there are three possible paths
- I don't roll and I get liquidated post-maturity (small loss, taxable event trigger, will happen surely)
- I roll and I get liquidated on blue (larger loss, taxable event trigger, more likely to happen if my LTV is very close to LLTV)
- I roll and I don't get liquidated on blue
I would guess I absolutely don't want 2) and 1) but if I know I am likely to have 2) I would prefer 1) and the max LTV could be set to ensure that
There was a problem hiding this comment.
chrmatt
left a comment
There was a problem hiding this comment.
Left some comments. Also, README probably should be updated?
How relevant is this PR after our discussion this morning?
| InconsistentCollateralToken() | ||
| ); | ||
|
|
||
| // Round in favor of the Midnight position. |
There was a problem hiding this comment.
Why not round in favor of Blue? Liquidations are worse on Blue, so it seems better to have more collateral there to avoid liquidation.
| } | ||
|
|
||
| function testRollRevertsWhenMaxLtvExceeded() public { | ||
| uint256 tightMaxLtv = BLUE_LLTV / 2; |
There was a problem hiding this comment.
Not sure I understand the logic here. This might not always be tight if other numbers change? Wouldn't it be better to retrieve the actual LTV and then pick something tight based on the actual numbers?
There was a problem hiding this comment.
the position is collateralized very close to LLTV and then a smaller tightMaxLtv is used to raise the MaxLtvExceeded. It's just a small test for this error. We could also use actual numbers yes
|
|
||
| /// @param incentive The caller incentive as a WAD-scaled percentage of the debt rolled. | ||
| function setConfig(bytes32 midnightId, bytes32 blueId, uint64 start, uint64 incentive, bool enabled) | ||
| function setConfig(bytes32 midnightId, bytes32 blueId, uint64 start, uint64 incentive, uint256 maxLtv, bool enabled) |
There was a problem hiding this comment.
I don't think I understand how this works. Can there be multiple configs be valid at once? If so, can the one rolling a position choose which one to use? So if I want to set a stricter maxLtv, can the roller still use the old value unless I disable it (how?)? It would be more intuitive for me to just have a single config at every point in time.
There was a problem hiding this comment.
In the current setting yes nothing prevents the user from setting multiple configs. The roller can use any enabled config but the user can also deactivate a config with setConfig setting enabled=False
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 49cfe2cd4b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| function testRollRevertsWhenMaxLtvIsAboveLltv() public { | ||
| uint256 invalidMaxLtv = BLUE_LLTV; |
There was a problem hiding this comment.
Use an actually above-LLTV value in this test
This test sets invalidMaxLtv equal to BLUE_LLTV, but roll only rejects values greater than blueMarketParams.lltv because the guard is maxLtv <= blueMarketParams.lltv; with the default setup this call proceeds past InvalidMaxLtv, so the test asserts the wrong boundary. Use BLUE_LLTV + 1 if the case is meant to cover values above LLTV.
AGENTS.md reference: AGENTS.md:L72-L79
Useful? React with 👍 / 👎.
Similarly as for Bundles, implement a max LTV. Rationale being