Skip to content

Borrowing

How borrowing flows through the protocol - health checks, debt shares, and async execution

On this page

Borrow Flow Overview

BlockchainMinterPoolProtocolLendingWalletBlockchainMinterPoolProtocolLendingWalletPhase 1: Synchronousalt[Health Factor OK][Health Factor Too Low]Phase 2: AsynchronousUserSign borrow requestSignatureborrow_assets(SignedRequest)Verify signature & noncesync_pool(pool_id)Update indicesborrow(user, pool, amount)Check liquidityMint debt sharesCheck health factorSchedule async withdrawalOutflowDetailsRollback debt sharesError: InsufficientCollateralwithdraw(request)Burn ckAssetSend native assetAsset receivedUser

Two-Phase Execution

Phase 1: Synchronous (Atomic)

All state changes happen atomically:

  1. Verify signature
  2. Increment nonce (replay protection)
  3. Sync pool indices
  4. Check liquidity
  5. Mint debt shares
  6. Check health factor - if too low, rollback and return error
  7. Schedule async withdrawal

Phase 2: Asynchronous (WAL-backed)

The borrowed assets are sent to the user via the Write-Ahead Log, which handles retries on failure.

Health Factor Validation

Before approving a borrow, the protocol checks two limits after adding the new debt: total debt must stay within the borrowing power set by Max LTV, and the Health Factor must stay at or above 1.0.

Example Calculation:

  • User has: 1 BTC @ $50,000 = $50,000 collateral (Max LTV = 65%, LT = 74%)
  • Borrowing power: $50,000 × 0.65 = $32,500
  • Current debt: $20,000 USDC
  • Current HF: (50000 × 0.74) / 20000 = 1.85 ✓

User wants to borrow $10,000 more:

  • New debt: $30,000, within the $32,500 borrowing power
  • New HF: (50000 × 0.74) / 30000 = 1.23 ✓ Approved

If user tried to borrow $15,000 more:

  • New debt: $35,000, above the $32,500 borrowing power
  • ✗ Rejected with MaxLtvExceeded, even though the HF would still be 1.06

The 0.5% activation fee is part of the new debt, so the actual limit is slightly lower than shown here.

Debt Share Minting

Debt is tracked using shares, similar to deposits:

shares = borrow_amount / borrow_index

Example: User borrows 1000 USDT at borrow_index = 1.10 → 909.09 shares minted. After 1 year, index = 1.15: Debt = 909.09 × 1.15 = 1045.45 USDT (45.45 USDT interest owed)

Cross-Chain Borrowing

Users can borrow assets on a different chain than their collateral:

EthereumMinterUSDC PoolBTC PoolLendingEthereumMinterUSDC PoolBTC PoolLendingHas 1 BTC collateralUserborrow(USDT, $30000, eth_address)Check BTC collateral valueMint USDT debt sharesValidate health factorwithdraw(30000 USDT, eth_address)Calculate gas feewithdraw_erc_20()Send USDT30000 USDT receivedUser

Key points:

  • Collateral stays in BTC Pool
  • Debt tracked in USDT Pool
  • Health factor considers both positions
  • User receives native USDT on Ethereum

Borrow Caps

Each pool has a maximum borrow cap to limit protocol risk exposure to any single asset. If the total debt plus the new borrow exceeds the cap, the request is rejected.

Same-Asset Borrowing

Some pools may restrict borrowing the same asset you've supplied. This prevents circular positions that could game the interest rate model.

Interest Accrual

Debt automatically accrues interest through the borrow index:

Multiply

Debt Shares - Fixed

Borrow Index - Growing

Current Debt - Increasing

No action required from borrowers - interest compounds automatically.

Signature Requirements

Borrow requests must be signed with the user's wallet:

Chain Standard Format
Bitcoin BIP322 Message signature
Ethereum EIP-191 personal_sign
Solana Ed25519 Direct signature

Nonce Protection

Each account has an incrementing nonce to prevent replay attacks. The provided nonce must match the expected value, and is incremented after each successful request.

Error Scenarios

Error Cause Solution
Max LTV Exceeded Total debt would exceed borrowing power Add more collateral or borrow less
Health Factor Too Low Health factor would drop below 1.0 Add more collateral or borrow less
No Liquidity Pool doesn't have enough funds Wait for deposits or borrow less
Borrow Cap Exceeded Pool reached maximum debt Borrow from different pool or wait
Same-Asset Borrowing Disabled You supply the asset you want to borrow Withdraw that supply first
Pool Frozen The pool has been frozen by the admin Wait until the pool is unfrozen

Borrowing creates debt that accrues interest. Monitor your health factor to avoid liquidation during market volatility.

Esc