Skip to main content

Overview

The Credit feature enables you to access liquidity without selling your cryptocurrency holdings. Take out over-collateralized loans by pledging crypto assets as collateral, with flexible terms, competitive rates, and real-time liquidation price monitoring.

What You Can Do

Collateralized Loans

Borrow stablecoins and other assets using your crypto as collateral

Flexible Terms

Choose loan duration, over-collateralization ratio, and repayment schedule

Liquidation Protection

Monitor liquidation prices in real-time to manage risk

Debt Management

Adjust collateral or repay debt anytime to improve loan health

Key Capabilities

Loan Types

The LoanComponent supports various loan models:
  • Short-Term: 7-30 day loans with lower origination fees
  • Medium-Term: 30-90 day loans balanced for rate and flexibility
  • Long-Term: 90+ day loans with predictable long-term rates
Each loan type has distinct:
  • APR (Annual Percentage Rate)
  • Over-collateralization requirements
  • Origination fee percentages
  • Minimum/maximum loan sizes

Loan Interface

The main credit interface (LoanComponent) provides:
  1. Loan Asset Selection: Choose what you want to borrow (e.g., USDC, USDT)
  2. Collateral Selection: Pick which crypto to pledge (e.g., BTC, ETH)
  3. Quantity Input:
    • Enter loan amount in the borrowed asset
    • System auto-calculates required collateral
    • Real-time conversion using useTokenSwap hook
    • Min/Max buttons for quick selection
  4. Loan Type Tabs: Switch between available loan models
  5. Loan Calculator: Displays critical metrics:
    • APY: Interest rate for the loan
    • Over-collateralization: Required collateral ratio (e.g., 150%)
    • Origination Fee: Upfront cost as percentage
    • Origination Cost: Fee amount in borrowed asset
    • Over-collateralization Cost: Extra collateral required
    • Loan Total Cost: Principal + origination + over-collateralization
    • Collateral: Total collateral amount needed
    • Liquidation Price: Price at which loan gets liquidated
    • Daily Cost: Interest accrued per day

Loan Calculation

The useLoanSelectedData hook computes all loan metrics:
// Example loan calculation flow:
Loan Amount: 10,000 USDC
Collateral: ETH (price: $2,000)
Over-collateralization: 150%

Collateral Required: 10,000 × 1.5 ÷ 2,000 = 7.5 ETH
Origination Fee (2%): 200 USDC  
Liquidation Price: Calculate based on 150% ratio
If the collateral asset price drops to the liquidation price, your collateral will be automatically liquidated to repay the loan. Monitor this metric closely.

Loan History

The LoanHistoryTable component shows:
  • All active loans with current health status
  • Historical loan records
  • Filterable by:
    • Loan type
    • Collateral asset
    • Borrowed asset
    • Status (Active, Repaid, Liquidated)
    • Date range via useLoanHistoryFilters

Manage Existing Loans

For active loans, you can:
Use ManageDebtModal to:
  • Repay partial or full loan amount
  • View current debt balance
  • See interest accrued
  • Check remaining term

How to Take Out a Loan

1

Navigate to Credit

Go to the Credit page from the main menu. You’ll see the loan interface and your loan history.
2

Select Borrow Asset

Choose what you want to borrow from the “Asset” dropdown. Typically stablecoins like USDC or USDT for accessing USD liquidity.
3

Select Collateral

Choose which cryptocurrency to pledge as collateral. Higher-value, less volatile assets often get better terms.
4

Choose Loan Type

Review the loan type tabs:
  • Compare APY rates
  • Check over-collateralization requirements
  • Consider origination fees
  • Match duration to your needs
5

Enter Loan Amount

Input how much you want to borrow:
  • Type the quantity directly
  • Use “MIN” for minimum loan amount
  • Use “MAX” for maximum based on available collateral
  • System auto-calculates required collateral
6

Review Loan Terms

Carefully review all displayed metrics:
  • Total collateral required
  • Liquidation price
  • Daily interest cost
  • Origination fee
  • Total loan cost
7

Confirm Loan

Click the “Loan” button. The system will:
  • Validate inputs via useValueVerifier
  • Check available collateral balance
  • Submit loan via usePostLoan mutation
  • Display liquidation price in success toast
  • Update loan history

Loan Workflow

The loan creation process:
// From credit.tsx
const handleLoan = (userId: string, ratio: string, size: string, typeId: string) => {
  postLoan.mutate(
    { userId, ratio, size, typeId },
    {
      onSuccess: (data) => {
        showToast(
          `Loan successful. Liquidation price: ${data.liqPrice} ${data.sizeCurrencyId}/${data.collatCurrencyId}`,
          ToastType.SUCCESS
        );
      },
      onError: (err) => {
        showToast(getDisplayMessage(err, "Loan failed"), ToastType.ERROR);
      }
    }
  );
};

Loan Health Monitoring

For active loans, monitor these key indicators:
  1. Collateral Ratio: Current collateral value ÷ loan value
    • Should stay above over-collateralization requirement
    • Warning if approaching liquidation threshold
  2. Liquidation Price: Critical price level for collateral
    • Loan liquidates if collateral price hits this level
    • Calculated based on required ratio
  3. Accrued Interest: Daily interest adding to loan balance
    • Compounds based on APY
    • Added to total debt owed
The LoanInfo component displays real-time loan health metrics for all active positions.

Data Components

Key hooks used by the credit feature:
  • useLoanData: Fetches available loan types and user’s eligible assets
  • useLoanSelectedData: Computes all loan metrics (liquidation price, costs, etc.)
  • useTokenSwap: Handles collateral ↔ loan asset conversions
  • useValueVerifier: Validates loan and collateral amounts
  • usePostLoan: Mutation hook for creating loans
  • useLoanHistoryData: Retrieves user’s loan history
  • useLoanHistoryFilters: Manages history table filters
  • useLoanEventsData: Tracks loan-related events (repayments, liquidations)

Risk Management

Liquidation Risk: If your collateral value drops significantly, your loan may be automatically liquidated. Always maintain a healthy collateral ratio above the minimum requirement.
Add extra collateral beyond the minimum requirement to create a safety buffer against price volatility. A 200% collateral ratio is safer than 150%.
Set up price alerts for your collateral assets to get notified before approaching liquidation levels.

Loan Examples

Conservative Loan

  • Borrow: 5,000 USDC
  • Collateral: 2 ETH (@ 2,500=2,500 = 5,000)
  • Over-collateralization: 200% (conservative)
  • Required Collateral: 10,000 ÷ 2,500 = 4 ETH
  • Liquidation Price: ~$1,250 per ETH
  • APY: 6.5%
  • Daily Cost: 0.89 USDC

Aggressive Loan

  • Borrow: 10,000 USDC
  • Collateral: 3 BTC (@ 50,000=50,000 = 150,000)
  • Over-collateralization: 150% (minimum)
  • Required Collateral: 15,000 ÷ 50,000 = 0.3 BTC
  • Liquidation Price: ~$40,000 per BTC
  • APY: 8.2%
  • Daily Cost: 2.25 USDC

Session Modes

In mock/demo mode, loan simulations are available but actual loan creation is restricted. The interface will show “isSessionModeMock” warnings.

Troubleshooting

Loan button is disabled:
  • Check you have sufficient collateral balance
  • Verify loan amount is within min/max bounds
  • Ensure both asset and collateral are selected
  • Confirm collateral value meets over-collateralization requirement
Collateral not auto-calculating:
  • Wait for useTokenSwap hook to fetch conversion rates
  • Verify both assets have valid market prices
  • Check network connection
Error: “Loan failed”
  • Review error message from getDisplayMessage
  • Check if assets are supported for loans
  • Verify account has borrowing permissions
  • Ensure no existing loan limits are exceeded
  • Portfolio - View total loan obligations
  • Activity - Track loan events and repayments
  • Governance - Loan policies and approval workflows

Build docs developers (and LLMs) love