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
- Client Side: User encrypts sensitive data using shared secrets
- Solana Program: Queues computation request with encrypted data and public parameters (like price feeds)
- Arcium MXE: Performs computation on encrypted data without decryption
- 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 stateadd_collateral: Adds to encrypted collateral amountswithdraw_collateral: Validates withdrawals against encrypted stateadd_borrow: Performs LTV checks on encrypted amountsrepay_borrow: Repays from encrypted borrowed amounts
Account Structures
LendingPool: Pool parameters and aggregate statisticsLenderPosition: Public lender shares and depositsPrivateBorrowerPosition: 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://