Skip to main content

Overview

The Lending & Borrowing module allows users to deposit RWT or stablecoins (USDC, USDY) to earn interest, and borrow stablecoins against RWT collateral. It operates as a standalone lending market built on AREAL’s native infrastructure — not an extension of DEX pools. The core use case: a user holds RWT and wants USDC liquidity without selling their RWT. They deposit RWT as collateral, borrow USDC, and continue to benefit from RWT’s NAV Book Value growth while using the borrowed stablecoins.
This module focuses on RWT ↔ stablecoin pairs only. Ownership Token lending may be added in the future as a separate market with different risk parameters.

How It Works

For depositors (earn interest)

Deposit USDC or USDY into the lending market. Your tokens are made available for borrowers. In return, you earn per-second interest — accrued continuously via MagicBlock Ephemeral Rollup and auto-compounded into your position.
  • No lock-ups — withdraw at any time (subject to available liquidity)
  • Interest rate adjusts dynamically based on market utilization
  • Higher utilization = higher APY for depositors

For borrowers (get stablecoins without selling RWT)

Deposit RWT as collateral and borrow USDC or USDY. Your RWT remains in the protocol and continues to appreciate from NAV Book Value growth — you don’t lose yield exposure.
  • Borrow up to the configured LTV ratio of your collateral value
  • Interest accrues per-second — repay at any time, no deadlines
  • If your Health Factor drops below 1.0, your position can be liquidated

On-Chain Accounts

LendingMarket

Main market PDA. Stores total deposits, total borrows, current interest rate, utilization ratio, and reserve factor. One market per stablecoin (USDC market, USDY market). Seeds: ["lending_market", stablecoin_mint].

DepositPosition

Per-depositor PDA. Tracks deposited stablecoin amount and accrued interest. Interest is auto-compounded — the position value grows every second. Seeds: ["deposit", market, depositor].

BorrowPosition

Per-borrower PDA. Stores deposited RWT collateral amount, borrowed stablecoin amount, accrued interest, entry timestamp, and Health Factor snapshot. Seeds: ["borrow", market, borrower].

LendingConfig

Global configuration managed by AREAL DAO: LTV ratio, liquidation threshold, liquidation penalty, interest rate model parameters, reserve factor, and oracle references. Seeds: ["lending_config"].

Core Instructions

initialize_market

Creates a new lending market for a specific stablecoin (USDC or USDY). Sets the interest rate model, LTV, liquidation threshold, and other parameters. Only AREAL DAO can create markets.Authority: Engine Authority (AREAL DAO)
Accounts:
  - engine_authority:    Signer
  - lending_market:      PDA (init)
  - lending_config:      PDA
  - stablecoin_mint:     USDC or USDY mint
  - rwt_mint:            RWT mint (collateral)
  - system_program

Args:
  - ltv_bps: u16                    Loan-to-Value ratio (e.g., 7500 = 75%)
  - liquidation_threshold_bps: u16  Liquidation threshold (e.g., 8000 = 80%)
  - liquidation_penalty_bps: u16    Liquidation penalty (e.g., 500 = 5%)
  - reserve_factor_bps: u16         Protocol reserve share of interest (e.g., 1000 = 10%)
  - rate_model: RateModel           Interest rate curve parameters
Deposits stablecoins (USDC or USDY) into the lending market to earn interest. Creates or updates a DepositPosition PDA. Interest accrues per-second and is auto-compounded — no manual claiming.Authority: Permissionless
Accounts:
  - depositor:           Signer
  - lending_market:      PDA (mut)
  - deposit_position:    PDA (init or mut)
  - depositor_stable_ata: Depositor's stablecoin account (mut)
  - market_vault:        Market's stablecoin vault (mut)
  - token_program

Args:
  - amount: u64          Stablecoin amount to deposit
Withdraws deposited stablecoins plus accrued interest. May be partially limited if market utilization is very high (most stablecoins lent out to borrowers).Authority: Depositor (must sign)
Accounts:
  - depositor:           Signer
  - lending_market:      PDA (mut)
  - deposit_position:    PDA (mut)
  - market_vault:        Market's stablecoin vault (mut)
  - depositor_stable_ata: Depositor's stablecoin account (mut)
  - token_program

Args:
  - amount: u64          Amount to withdraw (0 = full position + interest)
Deposits RWT as collateral and borrows stablecoins. The maximum borrow amount is determined by:
max_borrow = rwt_collateral_value_usd × LTV
RWT value is determined by the current market price from the RWT/USDY master pool on the native DEX. This is the real price at which liquidators can sell — making collateral valuation accurate and actionable.Authority: Permissionless
Accounts:
  - borrower:            Signer
  - lending_market:      PDA (mut)
  - borrow_position:     PDA (init or mut)
  - rwt_usdy_pool:       RWT/USDY master pool PDA (price source)
  - borrower_rwt_ata:    Borrower's RWT account (mut)
  - borrower_stable_ata: Borrower's stablecoin account (mut)
  - collateral_vault:    Market's RWT collateral vault (mut)
  - market_vault:        Market's stablecoin vault (mut)
  - token_program

Args:
  - collateral_amount: u64   RWT to deposit as collateral
  - borrow_amount: u64       Stablecoin amount to borrow
Repays borrowed stablecoins plus accrued interest. After full repayment, RWT collateral is released back to the borrower. Partial repayment improves Health Factor.Authority: Borrower (must sign)
Accounts:
  - borrower:            Signer
  - lending_market:      PDA (mut)
  - borrow_position:     PDA (mut)
  - borrower_stable_ata: Borrower's stablecoin account (mut)
  - borrower_rwt_ata:    Borrower's RWT account (mut)
  - market_vault:        Market's stablecoin vault (mut)
  - collateral_vault:    Market's collateral vault (mut)
  - token_program

Args:
  - repay_amount: u64    Amount to repay (0 = full repayment + all interest)
Adds more RWT collateral to an existing borrow position without borrowing more. Improves the Health Factor.Authority: Borrower (must sign)
Accounts:
  - borrower:            Signer
  - borrow_position:     PDA (mut)
  - borrower_rwt_ata:    Borrower's RWT account (mut)
  - collateral_vault:    Market's collateral vault (mut)
  - token_program

Args:
  - amount: u64          Additional RWT collateral
Liquidates an undercollateralized borrow position (Health Factor < 1.0). The liquidator repays part of the debt and receives the borrower’s RWT collateral at a discount (liquidation penalty).
  • HF between 0.95 and 1.0 → up to 50% of position can be liquidated
  • HF below 0.95 → up to 100% can be liquidated
Authority: Permissionless (anyone can liquidate unhealthy positions)
Accounts:
  - liquidator:          Signer
  - lending_market:      PDA (mut)
  - borrow_position:     PDA (mut)
  - rwt_usdy_pool:       RWT/USDY master pool PDA (price source)
  - liquidator_stable_ata: Liquidator's stablecoin account (mut)
  - liquidator_rwt_ata:    Liquidator receives discounted RWT (mut)
  - collateral_vault:    Market's collateral vault (mut)
  - market_vault:        Market's stablecoin vault (mut)
  - token_program

Args:
  - repay_amount: u64    Debt amount to repay for the borrower
Accrues interest on all positions in the market. Runs every second inside the MagicBlock Ephemeral Rollup. Updates deposit position values (auto-compound) and borrow position debt amounts.Authority: Permissionless (crank, runs in ER)
Accounts:
  - crank:               Signer
  - lending_market:      PDA (mut)
Updates market parameters: LTV, liquidation threshold, interest rate model, reserve factor. Changes apply to new positions only — existing positions keep their entry parameters.Authority: Engine Authority (AREAL DAO)
Accounts:
  - engine_authority:    Signer
  - lending_config:      PDA (mut)

Args:
  - ltv_bps: Option<u16>
  - liquidation_threshold_bps: Option<u16>
  - liquidation_penalty_bps: Option<u16>
  - reserve_factor_bps: Option<u16>
  - rate_model: Option<RateModel>

Health Factor

The Health Factor determines how close a borrow position is to liquidation:
Health Factor = (RWT collateral value × liquidation threshold) / total debt
Where:
  • RWT collateral value = rwt_amount × RWT market price (from the RWT/USDY master pool on the native DEX, updated every second in ER)
  • Total debt = borrowed amount + accrued interest
Health FactorStatus
> 1.5Safe — well-collateralized
1.0 – 1.5Caution — consider adding collateral or repaying
< 1.0Liquidatable — anyone can liquidate the position
RWT market price is read from the RWT/USDY master pool on the native DEX — this is the actual price at which liquidators can sell seized collateral. Using market price (not NAV) ensures that collateral valuation reflects real liquidity conditions.
While NAV Book Value grows deterministically from yield, the market price can temporarily trade below or above NAV. This means Health Factor follows market reality, not just theoretical fair value — protecting the protocol from scenarios where NAV is high but actual market liquidity is thin.

Interest Rate Model

Utilization-based model that balances depositor yield with borrower cost:
utilization = total_borrows / (total_deposits + total_borrows)
1

Low utilization (0-70%)

Interest rate increases gradually. Depositors earn modest APY, borrowers pay low rates. Encourages borrowing.
2

Optimal range (70-80%)

Target utilization zone. Balanced rates — depositors earn competitive APY, borrowers pay fair rates.
3

High utilization (80-100%)

Interest rate increases steeply (exponential). Discourages new borrows, incentivizes repayment, and attracts new deposits. Ensures liquidity for withdrawals.
ParameterDescriptionDefault
Optimal utilizationTarget borrowing level75%
Base rateMinimum interest rate2% APR
Slope 1Rate increase below optimal4% APR per 100% utilization
Slope 2Rate increase above optimal (steep)300% APR per 100% utilization
Reserve factorProtocol share of interest → AREAL DAO10%

RWT as Collateral — Why It Works

RWT is uniquely suited as collateral because its value is deterministic and growing:

Market price from native DEX

RWT collateral is valued at the real market price from the RWT/USDY master pool on the native DEX — the actual price at which liquidators can sell. Updated every second in MagicBlock ER.

NAV as price floor

NAV Book Value grows every second from OT yield, creating a rising price floor. Market price tends to track NAV over time, meaning collateral value naturally appreciates — improving Health Factor gradually.

Deep liquidity

RWT trades on the native DEX in concentrated master pools (RWT/USDY, RWT/USDC). Liquidators can efficiently sell seized collateral without excessive slippage.

MagicBlock Integration

OperationWhere it runsFrequency
accrue_interestEphemeral RollupEvery second
RWT market price readEphemeral RollupEvery second (from RWT/USDY pool)
deposit / withdrawSolana L1On-demand
borrow / repaySolana L1On-demand
liquidateSolana L1On-demand

Security Considerations

Market price valuation

RWT collateral is valued at the real market price from the RWT/USDY master pool — the price at which liquidators can actually sell. Updated every second in MagicBlock ER. No external oracle dependency.

Variable liquidation

Variable close factor: 50% at HF 0.95-1.0, 100% at HF < 0.95. Prevents partial liquidation from leaving underwater positions.

NAV as rising floor

While Health Factor uses market price, NAV Book Value grows every second from yield — creating a rising price floor. Market price tends to converge toward NAV, reducing long-term liquidation risk.

Market isolation

USDC and USDY markets are fully isolated. Bad debt in one market cannot affect the other.

DAO-governed parameters

LTV, liquidation threshold, rate model, and reserve factor are managed by AREAL DAO. Changes apply to new positions only — existing borrowers are protected.

Per-second accrual

Interest accrues every second in MagicBlock ER. No stale interest — positions always reflect the latest state.
The Lending & Borrowing module is currently in development. This documentation describes the target architecture. Module code has not yet been audited.