New liquidation: over 50% of collateral?

Thank you, very helpful to locate the two relevant code scripts. Seems like the logic has not bene updated since October 2021 so that’s good. Some of the logic is clear but some is a bit tricky to check, and to trace how LiquidatedCollateral can end up > 50% of collateral.

Some of the logic is described here liquity/Scalable_Reward_Distribution_with_Compounding_Stakes.pdf at master · liquity/liquity · GitHub

But it would be easiest to discuss with the contributors and especially when they carried out unit testing for the code, the cases where liquidated collateral is excessively large.

the purpose of that paper is to properly attribute liquidation gains to pool bidders in a gas efficient manner; it is a clever way to solve a tricky problem, but i do not think it is in-scope for your core question.

i believe you’re looking for the logic that calculates the amount of collateral; i think this is what you’re looking for: money-market-contracts/collateral.rs at c85c0b8e4f7fd192504f15d7741e19da6a850f71 · Anchor-Protocol/money-market-contracts · GitHub

hope this helps!

2 Likes

Yes, totally correct, looking through the paper in a bit more detail.

Actually I found the query_liquidation_amount definition of code that directly addresses the issue:

(starting at line 34):

/// The amount of collateral to be liquidated depends on the status of the bid pools
/// for each collateral. To find out how much collateral should be liquidated
/// we find the intersaction between f(x) and g(x); where x = liquidated collateral,
/// f(x) determines liquidation amount at which the safe ratio is satisfied, and g(x) gives
/// the repay amount based on the collateral being liquidated, which takes into account the
/// available bids at different premium rates
and further down
/// The portion of collateral that liquidated from the available set is calculated
/// based on weight = min(collateral_value, available_bids) / max_ltv

I’ll review this code and see how far I get with the abstraction to arrive that the liquidated collateral is > 50% of total original collateral.

Thoughts?

Thanks!

2 Likes

You’re absolutely right, missed the check and wrongfully assumed that’s what the liquidator would call, thanks for the help.

The querier for the liquidation amount ends up at a different contract: money-market-contracts/query.rs at c85c0b8e4f7fd192504f15d7741e19da6a850f71 · Anchor-Protocol/money-market-contracts · GitHub

2 Likes

yep, this is the function to review!

yep!

im legit happy to find folks willing to read through the contracts while engaging in a discussion; hope other community members start doing the same.

1 Like

Apologies if you’ve dug deeper than this but I’d suggest joining the Kujira telegram and asking some of them how it works. They do most of the liquidations now. As other have said, it’s a bidding process which Kujira has kept typically <5% premiums (almost impossible to hit 10%+ now). I’d think they could detail how/if the contract let’s more than “enough” be liquidated.

1 Like

Would love to have that discussion, on Twitter or in any other format that works. I also like the recommendation to reach out to Kujira folks about this, thanks @Generic @jc69

Kujira built the frontend for the bids but as far as I am aware Anchor team built the contract in question.

2 Likes

@paletas @jc69 Some folks looked at the transaction closer and speculate that the liquidation queue
“has miscalculated the amount of collateral it’s telling the custody contract to send for liquidation”. From looking at the code @paletas linked, the weight parameter that determine the liquidation amount is compounded in a loop, so somehow that loop ended up getting to 52% of the total collateral, but no clarity if it could theoretically go to 100% collateral liquidation.

1 Like

This makes sense, in line with my own understanding.

A renewed discussion on Twitter got the the point I was missing: the liquidation aims to reduce not the LTV or usage % but the risk ratio, which is a slightly different calculation.

Credit to
@AgilePatryk
for getting this all cleared up for myself and the community.

Quoting his tweet (see link below):
maxLTV for bLUNA is 80% - this is when risk ration happens.

currentLTV / maxLTV = risk ratio (RR). Liquidation at RR=100%.

Anchor liquidates you all the way to “safe RR” = 80%. Equivalent of LTV = 80% * 80% = 64%.

Account for the fees (average 4-5%): ~50% collateral is gone.

So two big conclusions: 1) with the increased bLUNA usage to 80% of collateral, the liquidation to 80% risk ratio basically will sell 50% of your collateral. 2) The liquidation algorithm works as it is supposed to, without any weird outliers or anomalies.

3 Likes

Bump for how effed predatory Anchor is though needs borrowers to function Having bLUNA allowed as is, is extra brutal. LUNA price f
goes down, bLUNA tanks, UST always valued as 1$ on chain while bLUNA collateral does not get that benefit = bLUNA riskiest asset on Anchor This is all before taking into account it’ll accept bids for way more than liquidations ltv, theoretically a “partial bid” can take all collateral depending on bidder buying parameters.