Volta_Loan

Black-Scholes powered DeFi lending: 12.5% APR + automatic put option protection

Volta_Loan

Created At

ETHGlobal Cannes

Winner of

katana - Coolest project built on Katana 1st place

Project Description

StockLend is a revolutionary DeFi lending protocol that introduces mathematical precision to cryptocurrency lending through the integration of Black-Scholes option pricing models. The protocol represents the first implementation of traditional financial mathematics in decentralized finance, specifically targeting the enhancement of lending yields while providing automatic downside protection through put options. At its core, StockLend allows users to supply USDC to earn enhanced yields that significantly exceed traditional DeFi rates. While standard USDC lending typically offers around 3.75% APR, StockLend's innovative approach delivers yields of 12.5% APR or higher through its sophisticated yield optimization mechanism. This enhancement is achieved by leveraging the protocol's unique ability to generate additional revenue streams through put option premiums and optimized capital deployment strategies. The protocol's borrowing mechanism is equally innovative, enabling users to borrow USDC against tokenized stock collateral such as Apple (AAPL), Tesla (TSLA), and other major equity tokens. When borrowers create loans, the protocol automatically calculates and includes put option protection using Black-Scholes mathematical models. This means every loan comes with built-in insurance against significant price drops in the underlying collateral. The put options are dynamically priced based on current market conditions, volatility calculations, and time to expiration, ensuring mathematically sound risk management. The Black-Scholes integration works by calculating optimal strike prices, premiums, and protection levels for each loan. When a borrower takes out a loan against their stock collateral, the protocol determines the most efficient put option parameters that maximize yield while providing meaningful downside protection. For example, if Alice borrows $12,000 USDC against 100 AAPL shares valued at $200 each, the protocol might set a put strike at $190 (5% below current price) with a premium of approximately $300, giving her protection if Apple's stock price falls significantly. The protocol's automation capabilities are powered by Chainlink technology, which continuously monitors market conditions and automatically exercises put options when they become profitable. This means users don't need to actively manage their positions or worry about timing the market. When stock prices drop below the strike price, the system automatically triggers the put option exercise, providing immediate protection payouts to users without requiring manual intervention.

How it's Made

Smart Contract Architecture: Built the core protocol in Solidity using Hardhat and Foundry. The centerpiece is StockLendProtocolV3.sol, but the real innovation is BlackScholesLib.sol where I implemented the full Black-Scholes mathematical model directly in Solidity. Since Solidity lacks floating-point arithmetic, I created fixed-point mathematical functions for complex calculations like natural logarithms, exponentials, and cumulative normal distributions. Black-Scholes Implementation: The most technically intensive part was translating the Black-Scholes formula into gas-efficient Solidity code. I implemented custom mathematical libraries using Taylor series approximations and built a cumulative normal distribution function using polynomial approximations. This runs entirely on-chain during loan creation, making it the first truly decentralized implementation of institutional-grade options pricing. Chainlink Integration: Used Chainlink price feeds for real-time stock data and Chainlink Automation for autonomous put option exercise. The automation system continuously monitors all active loans and automatically triggers exercises when profitable. I designed a custom upkeep mechanism that batches multiple loan checks into single transactions for gas efficiency. LayerZero Cross-Chain: Implemented LayerZero OFT adapters to enable cross-chain lending, allowing users to deposit collateral on one chain and borrow on another. The OFT adapters handle token bridging while maintaining loan state consistency across chains with varying block times. Frontend Architecture: Built a responsive React frontend using Next.js, TypeScript, and Wagmi for Web3 interactions. Created a comprehensive demo system that walks users through Alice's journey step-by-step, showing real-time Black-Scholes calculations and interactive put option visualizations. Gas Optimization Tricks: Implemented several hacky optimizations to make Black-Scholes calculations affordable. Used packed structs, batch calculations, and lookup tables for mathematical constants. The most notable hack was implementing custom fixed-point arithmetic that maintains precision while using only integer operations, reducing gas costs by about 60%. Notable Hacks: The most significant hack was implementing efficient square root and logarithm functions in Solidity without external libraries. Used bit manipulation and Newton-Raphson iterations for square roots, and Taylor series with optimized coefficients for logarithms. Also created a custom volatility calculation system that estimates implied volatility from historical price data using iterative numerical methods that converge within acceptable gas limits. The entire system runs autonomously once deployed, with Chainlink automation handling all time-sensitive operations and the Black-Scholes calculations providing mathematically sound risk management without requiring any centralized components.

background image mobile

Join the mailing list

Get the latest news and updates