Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/collinsville22/Sable/llms.txt

Use this file to discover all available pages before exploring further.

CDP (Collateralized Debt Position)

Borrow USDC against WBTC collateral via Nostra lending protocol. Users maintain a health factor above 1.0 to avoid liquidation.

Overview

Sable’s CDP contract enables users to:
  1. Deposit WBTC as collateral
  2. Borrow USDC against collateral (up to 70% LTV)
  3. Monitor health factor in real-time
  4. Repay debt and withdraw collateral anytime
  5. Close position atomically in a single transaction

CDP Parameters

ParameterValue
Collateral TokenWBTC (8 decimals)
Debt TokenUSDC (6 decimals)
Max LTV70%
Liquidation Threshold~75% (Nostra parameter)
Backend ProtocolNostra Finance
Collateral Token (Nostra)iWBTC-c (0x05b7...f0c)
Debt Token (Nostra)dUSDC (0x063d...a51)

CDP Lifecycle

Open Position

1

Deposit Collateral

User approves WBTC and deposits into CDP contract:
WBTC.approve(CDP_CONTRACT, collateral_amount)
CDP.deposit_collateral(collateral_amount)
The contract:
  1. Transfers WBTC from user
  2. Approves WBTC to Nostra CDP Manager
  3. Deposits as iWBTC-c collateral on Nostra
2

Borrow USDC

User borrows USDC against deposited collateral:
CDP.borrow(usdc_amount)
The contract:
  1. Borrows USDC from Nostra against iWBTC-c
  2. Transfers USDC to user’s wallet
Max borrow = Collateral Value × 70%. Borrowing more will revert.

Manage Position

Health Factor measures your position’s safety:
Health Factor = (Collateral Value × Liquidation Threshold) / Debt Value
Example:
Collateral: 0.001 WBTC ($100)
Debt: $50 USDC
Liquidation Threshold: 75%

Health Factor = ($100 × 0.75) / $50 = 1.5
Health FactorStatusAction
> 2.0Very Safe (green)Can borrow more
1.5 – 2.0Safe (green)Healthy position
1.0 – 1.5Caution (yellow)Add collateral or repay
< 1.0LIQUIDATION RISK (red)Immediate action required

Close Position

Close your CDP atomically in a single transaction:
USDC.approve(CDP_CONTRACT, total_debt)
CDP.close_position()
1

Calculate Total Debt

Contract calculates total debt including accrued interest:
total_debt = principal + accrued_interest
2

Repay 100% of Debt

User must approve enough USDC to cover full debt. Contract repays entire debt to Nostra.
3

Withdraw 100% of Collateral

Contract withdraws all iWBTC-c from Nostra and returns WBTC to user.
close_position() is atomic — no partial state. Either the entire position closes successfully, or the transaction reverts.

Liquidation Price Calculation

Your liquidation price is the BTC price at which health factor drops to 1.0:
Liquidation Price = (Debt USDC × 100) / (Collateral WBTC × Max LTV)
Example:
Collateral: 0.001 WBTC
Debt: $50 USDC
Max LTV: 70%

Liquidation Price = ($50 × 100) / (0.001 × 70) = $71,428

If BTC drops below $71,428, your position can be liquidated.
Liquidation on Nostra involves a penalty (typically 5-10%). Always maintain health factor > 1.5 for safety.

LTV (Loan-to-Value) Calculation

LTV = (Debt Value / Collateral Value) × 100
Example:
Collateral: 0.001 WBTC ($100)
Debt: $50 USDC

LTV = ($50 / $100) × 100 = 50%
LTV RangeStatusRisk Level
0% – 45%SafeLow
45% – 60%ModerateMedium
60% – 70%HighHigh
> 70%ImpossibleCannot borrow more

CDP Contract Flow

┌──────────┐
│   User   │
│          │
│  (WBTC)  │
└────┬─────┘
     │ deposit_collateral

┌──────────────────────┐
│   Sable CDP Contract   │
│                        │
│  deposit ──────────► │
│                        │
│  borrow  ◄────────── │
│                        │
│  repay   ──────────► │
│                        │
│  withdraw◄────────── │
└────────┬─────────────┘


┌──────────────────────┐
│  Nostra CDP Manager   │
│                        │
│  iWBTC-c (collateral) │
│  dUSDC (debt)         │
│                        │
│  Health tracking      │
│  Liquidation engine   │
└────────┬─────────────┘


┌──────────────────────┐
│  Pragma Oracle       │
│  (BTC/USD price)     │
└──────────────────────┘

Interest Accrual

Debt accrues interest over time based on Nostra’s borrow rate:
Borrow Rate (variable):
  • Depends on USDC pool utilization
  • Typically 3-8% APR
  • Updates continuously

Example:
  Initial debt: $100 USDC
  Borrow rate: 5% APR
  After 30 days: $100.41 USDC debt
  After 1 year: $105.00 USDC debt
Interest is compounded continuously on Nostra. Your debt increases every block.

CDP Contract

Address: 0x042f0f1cbb5ce44cc411f608d3c8295f3816ef7c3b6764cd6e46463efc7ca499 Key Functions:
// Deposit WBTC as collateral
fn deposit_collateral(amount: u256);

// Borrow USDC against collateral
fn borrow(amount: u256);

// Repay USDC debt
fn repay(amount: u256);

// Withdraw collateral (if health permits)
fn withdraw_collateral(amount: u256);

// Close position atomically
fn close_position();

// View functions
fn get_position(user: ContractAddress) -> CdpPosition;
fn get_health_factor(user: ContractAddress) -> u256;
fn get_liquidation_price(user: ContractAddress) -> u256;

Example Position

Step 1: Deposit 0.001 WBTC ($100)
  Collateral: 0.001 WBTC
  Debt: $0
  Health Factor: ∞ (no debt)
  Max Borrow: $70 USDC (70% LTV)

Step 2: Borrow $50 USDC
  Collateral: 0.001 WBTC ($100)
  Debt: $50 USDC
  LTV: 50%
  Health Factor: 1.5
  Liquidation Price: $71,428

Use Cases

Leverage Long BTC

Borrow USDC, buy more BTC. Amplify BTC exposure without selling.Risk: BTC price drop can trigger liquidation.

Unlock Liquidity

Access USDC without selling BTC. Keep your BTC exposure.Risk: Interest accrues on borrowed USDC.

Yield Farming

Borrow USDC at low rate, deploy to higher-yield strategies (Vesu, Sentinel vault).Risk: Yield may not cover borrow rate + gas.

Arb Opportunities

Borrow USDC to capture arbitrage opportunities on DEXes.Risk: Arb window may close before execution.

Safety Best Practices

Critical: Always maintain health factor > 1.5 for safety margin against:
  • Sudden BTC price drops
  • Oracle price updates
  • Network congestion (can’t repay in time)

Tips

  1. Start Conservative: Borrow max 50% LTV initially
  2. Set Price Alerts: Monitor BTC price near liquidation level
  3. Keep USDC Reserve: Have extra USDC for emergency repayment
  4. Monitor Interest: Debt grows continuously — check regularly
  5. Use Stop Loss: Close position if BTC drops > 10%

Risk Factors

  • Liquidation risk: BTC volatility can trigger liquidation
  • BTC price volatility: 10-20% daily swings are common
  • Smart contract risk: Sable CDP + Nostra protocol risks
  • Oracle risk: Pragma oracle manipulation or outage
  • Interest rate changes: Borrow rate can spike during high utilization
  • Network congestion: High gas fees may prevent timely repayment

Next Steps

Open Your First CDP

Step-by-step guide to borrowing USDC

Calculate Liquidation Price

Tools and formulas for risk management

CDP Contract Reference

Technical documentation and ABIs

Nostra Integration

How Sable integrates with Nostra