Skip to main content

Getting a Loan

This guide walks through the complete process of getting a Bitcoin-backed loan using the SDK.

Overview

The loan process involves:
  1. Quote - Get available loan quotes
  2. Borrow - Execute the loan; the SDK prepares wallet/session state automatically
  3. Deposit - Send Bitcoin collateral
  4. Complete - Receive borrowed stablecoins

Prerequisites

Use the explicit borrow flow so your UI can show quotes, fees, and a final review before creating the borrow workflow:

Optional: Setup

Use setup() when you want to preload account state for a dashboard. You can skip it for a borrow-only path; executeBorrow() prepares the required platform wallet, loan wallet, and session automatically.

Step 2: Get Quotes

Step 3: Select Quote

Step 3a: Fetch Fees for the Selected Quote

Call getQuoteFees() to get the bridge fees and the borrow-side breakdown (platform fee, applied disbursement bps, campaign waiver, net loan amount):
For lower latency, fetch quotes and quote fees in parallel with Promise.all once your UI has both a collateral and a loan amount.

Step 4: Start New Loan

Step 5: Execute Borrow

Step 6: Track Workflow

Understanding Quotes

A quote contains:

Quote Selection Strategies

Loan Parameters

Collateral Amount

The amount of BTC you’re willing to put up as collateral:

Loan Amount

The USD value you want to borrow:

Loan-to-Value (LTV)

The ratio of loan amount to collateral value. For example, borrowing $7,000 against $10,000 of BTC collateral is 70% LTV.

Handling the Deposit

When onDepositReady fires, you need to send BTC to the provided address:

Manual Deposit

Display the deposit info to the user:

Programmatic Deposit

If your wallet supports sending:

Monitoring Progress

Status Updates

Progress Stages

Failure and recovery stages include FAILED, DISBURSEMENT_FAILED, CANCELLED, REFUND_INITIATED, and REFUND_COMPLETED. See Workflows for terminal-stage behavior.

Error Handling

After the Loan

Once complete, your borrowed stablecoins are in your smart account. You can:

Check Positions

View Loan History

Withdraw to Bitcoin

Complete Example