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.

Overview

Nostra is a CDP (Collateralized Debt Position) lending protocol on StarkNet. Sable integrates Nostra as the backend for its CDP product, enabling users to borrow USDC against WBTC collateral.
Nostra’s CDP model is similar to MakerDAO — users maintain a health factor above 1.0 to avoid liquidation.

What is Nostra?

Nostra is a decentralized lending protocol on StarkNet that offers:
  • Collateralized borrowing: Deposit assets, borrow against them
  • Interest-bearing tokens: iTokens (collateral) and dTokens (debt)
  • Isolated positions: Each user’s CDP is independent
  • Liquidation engine: Automatic liquidation when health factor drops below 1.0

Key Features

  • iTokens: Interest-bearing collateral tokens (e.g., iWBTC-c)
  • dTokens: Debt tokens that accrue interest (e.g., dUSDC)
  • Max LTV: Up to 70% for WBTC collateral
  • Liquidation Threshold: ~75% (Nostra parameter)

How Sable Integrates with Nostra

Sable’s CDP contract uses Nostra as the underlying lending protocol for all collateral and debt operations.

CDP Lifecycle

┌──────────────────────────────────────────────────┐
│              SABLE CDP CONTRACT                  │
│                                                  │
│  User deposits WBTC ──► Forwarded to Nostra CDP  │
│  Manager as iWBTC-c collateral                   │
│                                                  │
│  User borrows USDC ◄── Borrowed from Nostra as   │
│  dUSDC debt                                      │
│                                                  │
│  Health Factor = (collateral × LT) / debt        │
│                                                  │
│  If HF < 1.0 → Liquidation risk                  │
└──────────────────────────────────────────────────┘

Open Position

  1. Deposit Collateral
    User ──► approve(WBTC, Sable CDP, amount)
         ──► CDP.deposit_collateral(amount)
         ──► CDP approves WBTC to Nostra CDP Manager
         ──► Nostra deposits as iWBTC-c collateral
    
  2. Borrow USDC
    User ──► CDP.borrow(amount)
         ──► CDP borrows USDC from Nostra (creates dUSDC debt)
         ──► USDC transferred to user
    

Manage Position

Health Factor Formula:
Health Factor = (collateral_value × liquidation_threshold) / debt_value
Status Indicators:
Health FactorStatusColor
> 2.0Very Safe🟢 Green
1.5 – 2.0Safe🟢 Green
1.0 – 1.5Caution🟡 Yellow
< 1.0Liquidation Risk🔴 Red

Close Position

Atomic closure in a single transaction:
User ──► CDP.close_position()
     ──► Calculates total debt (principal + accrued interest)
     ──► User approves USDC to cover full debt
     ──► Repays 100% of debt to Nostra
     ──► Withdraws 100% of collateral from Nostra
     ──► Returns all WBTC to user
The close_position() function ensures no partial state — either the full position closes successfully or the transaction reverts.

Contract Addresses

Sable CDP Contract

0x042f0f1cbb5ce44cc411f608d3c8295f3816ef7c3b6764cd6e46463efc7ca499
View on Voyager

Nostra CDP Manager

The backend Nostra contract used by Sable CDP.
0x073f6addc9339de9822cab4dac8c9431779c09077f02ba7bc36904ea342dd9eb
View on Voyager

Token Integration

iWBTC-c (Collateral Token)

Nostra’s interest-bearing collateral token for WBTC.
0x05b7...f0c
  • Symbol: iWBTC-c
  • Decimals: 8
  • Purpose: Represents WBTC deposited as collateral on Nostra

dUSDC (Debt Token)

Nostra’s debt token for USDC borrowing.
0x063d...a51
  • Symbol: dUSDC
  • Decimals: 6
  • Purpose: Represents accrued USDC debt on Nostra
  • Interest: Automatically compounds over time

CDP Parameters

ParameterValue
Collateral TokenWBTC (8 decimals)
Debt TokenUSDC (6 decimals)
Max LTV70%
Liquidation Threshold~75% (Nostra parameter)
Interest RateVariable (based on utilization)
Backend ProtocolNostra Finance

Integration Pattern

Sable’s CDP contract acts as a proxy layer between users and Nostra.
// Simplified Cairo pseudocode

#[external(v0)]
fn deposit_collateral(amount: u256) {
    // Transfer WBTC from user to CDP contract
    wbtc.transfer_from(caller, self, amount);
    
    // Approve Nostra CDP Manager
    wbtc.approve(nostra_cdp_manager, amount);
    
    // Deposit to Nostra as iWBTC-c
    nostra_cdp_manager.deposit(wbtc_address, amount);
}

#[external(v0)]
fn borrow(amount: u256) {
    // Borrow USDC from Nostra (creates dUSDC debt)
    nostra_cdp_manager.borrow(usdc_address, amount);
    
    // Transfer USDC to user
    usdc.transfer(caller, amount);
}

#[external(v0)]
fn close_position() {
    let total_debt = get_total_debt(); // principal + interest
    
    // User must have approved USDC
    usdc.transfer_from(caller, self, total_debt);
    
    // Repay full debt to Nostra
    usdc.approve(nostra_cdp_manager, total_debt);
    nostra_cdp_manager.repay(usdc_address, total_debt);
    
    // Withdraw all collateral from Nostra
    let collateral = get_total_collateral();
    nostra_cdp_manager.withdraw(wbtc_address, collateral);
    
    // Return WBTC to user
    wbtc.transfer(caller, collateral);
}

Liquidation Price Calculation

Users can calculate their liquidation price to monitor risk. Formula:
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)
                  = 5000 / 0.07
                  = $71,428
If BTC drops below $71,428, the position can be liquidated.

Which Sable Features Use Nostra?

CDP Contract

WBTC → USDC BorrowingAll CDP operations (deposit, borrow, repay, withdraw, close) route through Nostra.Users maintain health factor > 1.0.

CDP Page

User Interface/cdp page displays:
  • Collateral value
  • Debt value
  • Health factor
  • Liquidation price
  • Position management UI

Frontend Integration

Sable’s CDP page fetches position data from both the Sable CDP contract and Nostra.
// From: ~/workspace/source/src/hooks/use-cdp.ts

import { Contract } from "starknet";
import { CDP_ABI } from "@/lib/abi/cdp";

const CDP_ADDRESS = "0x042f0f1cbb5ce44cc411f608d3c8295f3816ef7c3b6764cd6e46463efc7ca499";

const cdp = new Contract(CDP_ABI, CDP_ADDRESS, provider);

// Get user position
const collateral = await cdp.get_collateral(userAddress);
const debt = await cdp.get_debt(userAddress);
const healthFactor = await cdp.get_health_factor(userAddress);

// Calculate liquidation price
const liquidationPrice = (debt * 100) / (collateral * 0.7);

console.log({
  collateral: Number(collateral) / 1e8, // WBTC has 8 decimals
  debt: Number(debt) / 1e6,             // USDC has 6 decimals
  healthFactor: Number(healthFactor) / 1e18,
  liquidationPrice,
});

External Resources

Nostra Documentation

Official Nostra protocol documentation

Nostra App

Nostra lending interface

Integration Source Code: ~/workspace/source/contracts/src/cdp.cairo