Liquidation Logic - A Complete Guide
Liquidations are the cornerstone of any lending protocol’s risk management system. In Twyne, they take on even greater importance because we’re allowing borrowers to access higher leverage while protecting the Credit LPs who make this possible. This guide will take you from the conceptual foundations through the mathematical theory to the practical implementation details.
Conceptual Overview: The Two Safety Nets
To understand Twyne’s liquidation system, imagine a tightrope walker (the borrower) crossing between two buildings. Traditional lending protocols give them one safety net below. Twyne gives them two safety nets at different heights.
The first safety net (Twyne’s liquidation threshold) catches them early, allowing for a controlled landing where someone else can take over the walk. The second safety net (the external protocol’s liquidation threshold) is the last resort - if you hit this one, it’s messy and potentially painful for everyone involved.
This dual-safety-net system is what allows Twyne to offer higher leverage while maintaining security. The borrower can walk higher on the tightrope (borrow more), but we ensure they’re caught before they’d hit the ground (external liquidation).
Why Two Liquidation Thresholds?
In traditional lending protocols like Aave or Euler, there’s a single liquidation threshold. When your position becomes undercollateralized beyond this point, liquidators swoop in, repay part of your debt, and take your collateral plus a bonus. It’s efficient but limiting - the protocol must be conservative to protect all lenders equally.
Twyne introduces a paradigm shift. By creating a two-tier system, we can offer borrowers higher effective LTVs while ensuring the underlying protocol never sees an unsafe position. Think of it like subletting an apartment - the landlord (external protocol) only cares that the total rent is paid, not how the tenants (borrower + CLPs) split it among themselves.
The Mathematics of Dual Liquidation Thresholds
Now let’s build up the mathematical framework that makes this system work. We’ll start simple and add complexity as we go.
Understanding the Two LTV Perspectives
Every position in Twyne has two different LTV calculations that matter:
Twyne LTV represents how leveraged the borrower is from their own perspective:
λ_t = B / C
Where B is the borrowed amount and C is the borrower’s own collateral.
External LTV represents how the position looks to the underlying protocol:
λ_e = B / (C + C_LP)
Where C_LP is the additional collateral provided by Credit LPs.
The magic happens in the relationship between these two values. While λ_t might be 85% (quite risky), λ_e might only be 70% (quite safe). This gap is what Twyne exploits to provide additional borrowing power.
The Liquidation Conditions
A position becomes liquidatable in Twyne when EITHER of these conditions is met:
Condition 1: Twyne Threshold Breached
B > λ̃_t × C
This checks if the borrower’s debt exceeds what’s allowed given their chosen Twyne liquidation LTV (λ̃_t) and their own collateral.
Condition 2: External Safety at Risk
B > β_safe × λ̃_e × (C + C_LP)
This ensures we maintain a safety buffer (β_safe, typically 95%) below the external protocol’s liquidation threshold.
Let’s understand why we need both conditions through an example:
Imagine Alice has:
- 1 ETH of her own collateral (C = 1)
- 0.5 ETH reserved from CLPs (C_LP = 0.5)
- 0.8 ETH worth of debt (B = 0.8)
- Chosen Twyne liquidation LTV of 85% (λ̃_t = 0.85)
- External protocol liquidation LTV of 75% (λ̃_e = 0.75)
- Safety buffer of 95% (β_safe = 0.95)
Let’s check both conditions:
- Condition 1: 0.8 > 0.85 × 1 = 0.85 ✗ (Not triggered)
- Condition 2: 0.8 > 0.95 × 0.75 × 1.5 = 1.069 ✗ (Not triggered)
Alice’s position is safe. But if her debt increases to 0.86 ETH:
- Condition 1: 0.86 > 0.85 × 1 = 0.85 ✓ (Triggered!)
- Condition 2: 0.86 > 1.069 ✗ (Still safe)
Now Twyne will liquidate her position even though the external protocol still sees it as safe. This is the key to protecting CLPs.
The Innovation: Liquidation by Inheritance
Traditional DeFi liquidations work like a fire sale - liquidators repay debt, seize collateral at a discount, and immediately sell it for profit. This creates selling pressure during market stress and requires sophisticated infrastructure to execute profitably.
Twyne introduces a fundamentally different approach: liquidation by inheritance. Instead of dismantling positions, we transfer them intact to new owners who can manage them back to health.
How Inheritance Works
When a position becomes liquidatable, any user with sufficient collateral can “inherit” it entirely. Let’s walk through the process:
- Position Identification: Alice’s position becomes liquidatable with:
- Collateral: 100 USDC
- Debt: 95 USDC
- Twyne LTV: 95% (exceeding her 90% threshold)
-
Inheritance Execution: Bob, who has 50 USDC of his own collateral, inherits Alice’s position
- Post-Inheritance State: Bob now has:
- Collateral: 150 USDC (his 50 + Alice’s 100)
- Debt: 95 USDC
- Twyne LTV: 63.3% (much healthier)
- Profit Mechanism: Bob effectively acquired 100 USDC worth of collateral for 95 USDC of debt, netting 5 USDC in value
Economic Incentives for Inheritance
The inheritance model creates unique incentives that benefit the protocol:
For Liquidators:
- No need for flash loans or DEX infrastructure
- Can hold positions to profit from market recovery
- Lower technical barriers to entry
- Earn ongoing yield if they keep the position
For the Protocol:
- Capital remains in the system
- No market impact from forced selling
- Broader participation in liquidations
- More stable liquidation execution
For Credit LPs:
- Positions are resolved before external liquidation
- No exposure to DEX slippage or MEV
- Maintained protocol solvency
Fallback Liquidations: When Inheritance Fails
Despite our best efforts, positions might not be inherited quickly enough during extreme market conditions. When this happens, the external protocol performs its own liquidation. This is where things get complex and potentially lossy for Credit LPs.
Understanding External Protocol Liquidations
When Euler or another underlying protocol liquidates a Twyne position, it doesn’t distinguish between borrower and CLP collateral. From its perspective, it’s liquidating a single position with combined collateral.
The challenge for Twyne is determining how to split the remaining assets fairly between the borrower and CLPs after an external liquidation.
Post-Liquidation Accounting
After an external liquidation, Twyne must:
- Assess Remaining Assets: Determine what collateral and debt remain
- Prioritize CLP Protection: Ensure CLPs recover maximum possible value
- Maintain Liquidatability: Keep borrower in a liquidatable state
- Prevent Gaming: Avoid creating exploitable conditions
The mathematical framework for this is covered in detail in Section 6.2.1 of the whitepaper. The key insight is that we reset the borrower’s liquidation LTV to the maximum allowed value and redistribute assets accordingly.
Calculating CLP Losses
Credit LPs face potential losses when external liquidations occur. The loss amount depends on several factors:
- The borrower’s risk level (ρ = λ̃_t / λ̃_max_t)
- The external protocol’s liquidation parameters (incentive and closing factor)
- The safety buffer maintained by Twyne
The whitepaper provides detailed loss analysis showing that CLPs are protected as long as specific conditions are met. For typical parameters (5% liquidation incentive, 50% closing factor), CLPs face no losses unless borrowers choose extremely high liquidation LTVs.
Practical Examples and Edge Cases
Let’s walk through several scenarios to cement understanding of how liquidations work in practice.
Example 1: Standard Twyne Liquidation
Initial State:
- Alice deposits 10 ETH, borrows 8 ETH worth of USDC
- Her Twyne liquidation LTV: 85%
- CLP credit reserved: 2.5 ETH
- Total position: 12.5 ETH collateral, 8 ETH debt
Market Movement: ETH price drops 10%
- Debt value in ETH terms: 8 / 0.9 = 8.89 ETH
- Alice’s Twyne LTV: 8.89 / 10 = 88.9% > 85% ✓ Liquidatable!
Liquidation by Bob:
- Bob has 5 ETH available
- He inherits Alice’s entire position
- New position: 15 ETH collateral, 8.89 ETH debt
- Bob’s Twyne LTV: 59.3% (healthy)
- Bob’s profit: 10 - 8.89 = 1.11 ETH in value
Example 2: Near External Liquidation Threshold
Initial State:
- Charlie has a high-risk position with ρ = 0.95
- External protocol liquidation LTV: 75%
- Safety buffer: 95%
- Position barely safe from external liquidation
Rapid Market Movement: 15% price drop in one block
- Position bypasses Twyne liquidation opportunity
- External protocol liquidates with 5% incentive
- Remaining assets split between Charlie and CLPs
Outcome Analysis:
- CLPs recover their principal (due to safety mechanisms)
- Charlie loses his excess collateral
- Protocol remains solvent
Example 3: Cascade Prevention
Scenario: Multiple correlated positions approaching liquidation
- Position A: 84% LTV (threshold 85%)
- Position B: 83% LTV (threshold 85%)
- Position C: 82% LTV (threshold 85%)
Market Drop: 2% price movement would liquidate all three
Twyne’s Response:
- Inheritance model allows gradual absorption
- Different liquidators can take different positions
- No forced selling creates price pressure
- Market can stabilize without cascade
Monitoring and Managing Liquidation Risk
Understanding when and why liquidations occur is crucial for all protocol participants. Here’s how different users should monitor their risk:
For Borrowers
Monitor two health factors:
Twyne Health = (userCollateral × twyneLiqLTV) / debt
External Health = (totalCollateral × externalLiqLTV × safetyBuffer) / debt
Keep both values above 1.1 for safety. The lower value determines your true liquidation risk.
For Credit LPs
Track utilization and borrower risk profiles:
- High utilization means more yield but more exposure
- Monitor the distribution of borrower ρ values
- Understand loss scenarios from the whitepaper
For Liquidators
Develop monitoring systems that:
- Track all Twyne positions in real-time
- Calculate profitability including gas costs
- Prepare capital for inheritance opportunities
- Monitor external protocol parameters
Integration with Other Protocol Mechanisms
Liquidations don’t exist in isolation. They interact with several other Twyne mechanisms:
Rebalancing and Liquidations
As positions are rebalanced, excess credit is released. This affects:
- The external LTV (worsens as less collateral underwrites debt - core safety conditions are still respected)
- The CLP exposure (reduced risk)
Interest Rates and Liquidation Risk
Higher utilization leads to higher interest rates, which:
- Accelerates position deterioration
- Incentivizes borrowers to reduce leverage
- Creates natural deleveraging before liquidations
Dynamic Safety Buffers - NOT IMPLEMENTED YET
For high-risk borrowers (high ρ), the protocol automatically increases safety buffers. This:
- Provides extra protection for CLPs
- Requires more CLP credit reservation
- Reduces maximum achievable leverage
Conclusion: A New Paradigm for DeFi Liquidations
Twyne’s liquidation system represents a fundamental innovation in DeFi risk management. By introducing dual thresholds and inheritance-based liquidations, we’ve created a system that:
- Enables Higher Leverage - Borrowers can access more capital while remaining safe
- Protects Lenders - CLPs are shielded by early liquidations and safety buffers
- Reduces Market Impact - No forced selling during market stress
- Democratizes Liquidations - Anyone can participate without sophisticated infrastructure
- Maintains Composability - Works seamlessly with existing lending protocols
The mathematical rigor ensuring these properties is detailed in the whitepaper, while this guide has focused on building intuition and practical understanding. As you work with Twyne, remember that every parameter and mechanism exists to balance the competing needs of capital efficiency and risk management.
For developers building on Twyne, the liquidation system provides rich opportunities for innovation - from automated inheritance strategies to risk assessment tools. The foundation we’ve built ensures that creative applications can flourish while maintaining the security that DeFi demands.