Cushion
Automated liquidation protection for DeFi loans on platforms like AAVE
Problem Statement
Cushion is adecetralizedprotocol to provideautomated liquidation protectionfor DeFi loans on platforms likeAAVE. The system consists of two core smart contracts. TheVault (ERC4626)is a liquidity pool whereliquidity providerscan deposit stable assets (likepyUSD) to earn ayield. The second one isThe Loan Wrapper, which willwrap an existing loanfrom a lending protocol likeAAVEintoCushion NFT.This NFT representsownershipof the loan, which at some point allows our protocol to manage it. When a wrapped loansHealth Factordrops to a predetermined risky level, the Vault automaticallyinjects capital, increasing itscollateraland moving it away from theliquidation threshold. Once the market recovers and the loans health factor improves, theinjected capital, plus a smallinterest fee, is withdrawn and returned to the Vault, increasing the value of theLP tokensforliquidity providers. If the health factor drops two times, and it is not in our favor to deposit more money, the Vault canliquidatethe loan to protect its capital.
Solution
Cushion leverages a robust architecture built on battle-tested smart contract standards and key DeFi primitives to deliver automated loan protection. The system is designed with security and capital efficiency in mind.Core Smart Contracts:Vault.sol: The heart of the protocol is a sophisticated ERC4626 Tokenized Vault, built using OpenZeppelin Contracts. It accepts deposits in pyUSD from Liquidity Providers (LPs) and issues LP shares representing their stake. This contract holds the core logic for: Calculating the required capital injection amount based on the loan's collateral and debt values (provided by the LoanWrapper). Executing on-chain swaps between pyUSD and ETH using Uniswap V3 via a dedicated internal swap function (_swapPyUsdToEth, _swapEthToPyUsd). Interacting with the LoanWrapper to inject (increaseCollateral) or withdraw (decreaseCollateral) collateral (ETH). Managing the 5% annual interest rate applied to injected capital, tracking it via a global accumulatedInterest index to generate yield for LPs. Initiating and managing the loan liquidation process. Receiving ETH returned from the LoanWrapper via the receive() function and automatically swapping it back to pyUSD.LoanWrapper.sol: Each protected AAVE loan is represented by an instance of this contract It acts as a smart proxy between the loan owner, the Vault, and the AAVE V3 protocol. Its key responsibilities include:Holding the AAVE position (interacting with the AAVE IPool). Providing necessary data to the Vault (getTotalCollateralValue, getTotalDebtValue, getDebtToken, getCollateralToken, getBorrowedAmount). Receiving ETH collateral from the Vault via a payable function (increaseCollateral) and supplying it to AAVE. Returning ETH collateral to the Vault (decreaseCollateral), withdrawing it from AAVE first. Repaying the AAVE debt (repayLoan) when instructed by the Vault during liquidation, using funds provided by the Vault. Implementing a locking mechanism (locked state) to restrict owner actions after the Vault has intervened.Key Mechanisms & Partner Technologies:Off-Chain Keepers: Health Factor monitoring is intentionally kept off-chain for gas efficiency and flexibility. External Keeper bots constantly monitor the Health Factor of wrapped loans via the LoanWrapper's view functions. When a threshold is crossed, the Keeper triggers the appropriate function (injectToLoan, withdrawFromLoan, liquidate) on the Vault contract. Uniswap V3 Integration: The Vault utilizes the Uniswap V3 Router for all token swaps (pyUSD <-> WETH). It wraps/unwraps ETH automatically using the WETH9 contract. Chainlink Price Feeds: The Vault relies on Chainlink oracles (PYUSD/USD) to accurately convert the USD-denominated injection amount into the required quantity of pyUSD for swappingTech Stack: Solidity ^0.8.30 on Hardhat 3 (Sepolia & local) OpenZeppelin (ERC4626, ERC20, Ownable, Math) Uniswap V3 router for PYUSD ↔ WETH swaps (POC also has a deterministic MockSwapAdapter/Router) Chainlink price feeds (ETH/USD, PYUSD/USD) for conversions (8-dec oracle math) Python (Web3.py) Keeper bot (monitor HF, automate actions) Extensive mocks (Aave pool, addresses provider, aToken, variable debt, WETH, ERC20, oracles)
Hackathon
ETHOnline 2025
2025
Contributors
- dzvol
112 contributions
- StonedPalda
23 contributions
- RadeksGalaxy
13 contributions
- Didikong14
6 contributions
- jerabekpetr
5 contributions