Skip to content

Bibhu padhy

@bs_dev

Bibhu padhy

@bs_dev

React

Hyderabad, India

Loanify - Private Lending POC using Arcium

Loanify is a Proof of Concept demonstrating private lending and borrowing operations on Solana using Arcium's confidential computing infrastructure. This protocol showcases how to perform lending operations while keeping individual position amounts private through encrypted state transitions.

🎯 Project Objective

This POC demonstrates:

  • Private lending positions using encrypted state
  • Confidential computation of LTV ratios without revealing amounts
  • Secure multi-party execution for sensitive financial operations
  • Integration between Solana blockchain and Arcium's confidential computing environment
  • Privacy-preserving liquidation mechanisms

πŸ—οΈ Architecture Overview

Components

  • Solana Program: Core on-chain logic and state management
  • Arcium MXE: Confidential computing environment for private operations
  • Encrypted Instructions: Computation that runs on encrypted data
  • Callback System: Results from confidential computations

Privacy Model

  • Public Data: Pool parameters, total deposits, total borrowed, risk flags
  • Private Data: Individual collateral amounts, borrowed amounts, health factors
  • Access Control: Only Arcium MXE can decrypt encrypted position data

πŸ” Arcium Integration

How Confidential Computing Works

  1. Client Side: User encrypts sensitive data using shared secrets
  2. Solana Program: Queues computation request with encrypted data and public parameters (like price feeds)
  3. Arcium MXE: Performs computation on encrypted data without decryption
  4. Result: Computation result returned securely via callback

Example: Private Borrowing

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Client    │───▢│  Solana Program  │───▢│    Arcium   β”‚
β”‚ (User A)    β”‚    β”‚                  β”‚    β”‚    MXE      β”‚
β”‚             β”‚    β”‚ - Encrypts       β”‚    β”‚ - Performs  β”‚
β”‚ - Encrypts  β”‚    β”‚   borrow amount  β”‚    β”‚   LTV check β”‚
β”‚   collateralβ”‚    β”‚ - Includes       β”‚    β”‚   on        β”‚
β”‚   amount    β”‚    β”‚   Pyth price     β”‚    β”‚   encrypted β”‚
β”‚ - Submits   β”‚    β”‚   as plaintext   β”‚    β”‚   amounts   β”‚
β”‚   tx        β”‚    β”‚ - Queues comp    β”‚    β”‚ - Returns   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚    β–²
                        β”‚    β”‚ Callback
                        β–Ό    β”‚ (if approved)
                 Update encrypted position
                 on Solana and transfer
                 borrowed tokens

πŸ“‹ Milestones Implemented

M1: Basic Lending Foundation

  • Core lending pool functionality
  • Supply and withdrawal operations
  • Basic interest rate model

M2: Collateral & Borrowing

  • Collateral deposit functionality
  • Borrowing against collateral with LTV checks
  • Health factor calculations using Pyth oracles
  • Liquidation mechanisms for unhealthy positions

M3: Private Operations POC

  • M3a: Private deposits using encrypted state
  • M3b: Private borrowing with confidential LTV checks
  • M3c: Private liquidation discovery system

πŸ”§ Technical Implementation

Key Components

Solana Program (programs/loanify/src/lib.rs)

  • Main lending protocol logic
  • Integration with Arcium's callback system
  • Account management for lenders and borrowers
  • Price oracle integration with Pyth

Encrypted Instructions (encrypted-ixs/src/lib.rs)

  • init_position: Creates encrypted position state
  • add_collateral: Adds to encrypted collateral amounts
  • withdraw_collateral: Validates withdrawals against encrypted state
  • add_borrow: Performs LTV checks on encrypted amounts
  • repay_borrow: Repays from encrypted borrowed amounts

Account Structures

  • LendingPool: Pool parameters and aggregate statistics
  • LenderPosition: Public lender shares and deposits
  • PrivateBorrowerPosition: Public metadata with encrypted position data

Security Considerations

  • MXE is trusted for computation integrity
  • All sensitive amounts stored in encrypted form
  • Public parameters like prices verified on-chain before sending to MXE
  • Callback-based results ensure authenticity

πŸ§ͺ POC Validation

Test Scenarios

  • Private deposit and withdrawal operations
  • Confidential LTV calculations
  • Privacy-preserving liquidation triggers
  • Encrypted position state updates

Key Metrics Demonstrated

  • Successful confidential computation of financial metrics
  • Correct handling of encrypted state transitions
  • Seamless integration between Solana and Arcium MXE
  • Preservation of privacy without compromising protocol security

πŸš€ Running the POC

Prerequisites

  • Rust toolchain (stable)
  • Solana CLI tools
  • Anchor framework
  • Arcium development environment

Setup

# Install dependencies
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cargo install --git https://github.com/coral-xyz/anchor avm --locked
avm install latest
avm use latest

# Install Solana CLI
sh -c "$(curl -sSfL https://