Crypto Lending Mobile App Development
Crypto lending is when user locks ETH as collateral and borrows stablecoin USDC. Or opposite — depositor places USDC and earns interest. On smart contract looks elegant. In mobile app becomes complex interfaces: position health, liquidation threshold, real-time interest rates and alerts "your collateral almost liquidated."
Key Mechanics to Implement Correctly
Health Factor and Liquidation
Health Factor = (Collateral × Liquidation Threshold) / Borrowed Amount. If HF drops below 1 — position liquidates. Must show user in real time with visual indicator — not just number but scale with zones: safe (green, HF > 1.5), risk (yellow, 1.1–1.5), critical (red, < 1.1).
Collateral asset price changes every few seconds. Means HF must recalculate on client on each price update — via Chainlink Price Feeds or CEX WebSocket. Important not to overload server with polling from thousands of clients every 2 seconds; reasonable to subscribe to Binance WebSocket wss://stream.binance.com:9443/ws/ethusdt@ticker and calculate HF locally.
// Health Factor calculation on client
struct LendingPosition {
let collateralUSD: Decimal // collateral value in USD
let liquidationThreshold: Decimal // e.g., 0.82 for ETH
let borrowedUSD: Decimal // debt amount in USD
var healthFactor: Decimal {
guard borrowedUSD > 0 else { return Decimal.greatestFiniteMagnitude }
return (collateralUSD * liquidationThreshold) / borrowedUSD
}
var riskLevel: RiskLevel {
switch healthFactor {
case ..<1.1: return .critical
case 1.1..<1.5: return .warning
default: return .safe
}
}
}
Push notification at HF < 1.2 — mandatory feature. Without it user won't know about liquidation. Implement via server worker monitoring positions through smart contract events (LiquidationCall event in protocol ABI) or protocol API (if Aave, Compound), broadcast push via FCM/APNs when thresholds hit.
Protocol Connection
If building on existing DeFi protocol — Aave V3, Compound V3, Morpho — use their SDK:
-
Aave:
@aave/contract-helpers+@aave/math-utils(TypeScript packages, called via JavaScript bridge in React Native or via custom backend) -
Compound:
compound-jsor direct calls viaweb3j/web3.swift
For native iOS/Android apps without React Native easier to keep all Web3 logic on backend and expose via REST API: client doesn't know ABI, just calls POST /positions/deposit or GET /positions/{id}.
// Android: position display via Jetpack Compose
@Composable
fun PositionCard(position: LendingPosition, currentPrice: BigDecimal) {
val updatedPosition = position.copy(
collateralUSD = position.collateralAmount * currentPrice
)
Card(
colors = CardDefaults.cardColors(
containerColor = when (updatedPosition.riskLevel) {
RiskLevel.CRITICAL -> MaterialTheme.colorScheme.errorContainer
RiskLevel.WARNING -> Color(0xFFFFF3E0)
RiskLevel.SAFE -> MaterialTheme.colorScheme.surfaceVariant
}
)
) {
Column(modifier = Modifier.padding(16.dp)) {
Text("Collateral: ${updatedPosition.collateralUSD.formatUSD()}")
Text("Debt: ${updatedPosition.borrowedUSD.formatUSD()}")
HealthFactorBar(hf = updatedPosition.healthFactor)
}
}
}
Interest Rates and APY
Rates in DeFi protocols dynamic — change based on pool utilization rate. Must update in UI every few minutes. For custodial platforms (Nexo, BlockFi-like) rates set administratively and change rarely.
Show both APY vs APR. Users confused: 8% APR ≠ 8% APY. APY with compounding higher. Formula: APY = (1 + APR/n)^n - 1, where n — number of compounding periods per year.
Transactions and Gas
On EVM smart contract interaction each action is on-chain transaction. deposit(), borrow(), repay(), withdraw() — each costs gas. Before sending show user gas estimate via eth_estimateGas and current price from eth_gasPrice or EIP-1559 eth_maxFeePerGas.
If building on L2 (Arbitrum, Optimism, Base) — gas 90% cheaper compared to mainnet, critical for mobile lending UX.
Verification and Compliance
KYC via Sum Sub or Veriff for regulated platforms. Jurisdiction restrictions — US users can't use most DeFi platforms without SEC registration. Geo-filtering by IP on server, additionally — check on registration.
Timeline and Stages
| Stage | Duration |
|---|---|
| Architecture: DeFi protocol or custodial scheme | 3–5 days |
| Smart contracts or protocol integration | 1–3 weeks |
| Server layer (positions, prices, notifications) | 2 weeks |
| Mobile client iOS + Android | 3–4 weeks |
| Testnet testing | 1 week |
Total: 8–12 weeks. Cost calculated individually after requirements analysis.







