Increase your exposure to a token with automatic leverage via Aave and Uniswap.
Airlift Finance increases your exposure to an asset using a passive leverage strategy. There is only one vault (so far), which aims to provide 2X exposure to WETH: - Deposited WETH is supplied to Aave and begins to earn yield + rewards - Using Uniswap V3 Flash Swaps, the strategy borrows USD stablecoins from Aave which are used via the Flash Swaps to buy more WETH, which is also deposited in Aave - Liquidity mining rewards are automatically swapped for WETH and compounded - The risk profile can be modified when warranted by market movements, in order to minimize the chance of liquidations - Airlift offers an easy way to achieve and manage leverage: simply deposit WETH into the vault and Airlift takes care of the rest: _Airlift lifts you up_.
How it's made
The vault and strategy contracts were initally based on open-source contracts from Beefy Finance, though the `StrategyAaveLeveraged.sol` strategy is significantly different than the original, as it actually increases your exposure to WETH by borrowing stablecoins that are swapped for more WETH. When you deposit WETH into the vault, the following happens behind the scenes: - The supplied WETH is deposited into Aave - Stablecoins are then borrowed against the WETH collateral. Because there is a Loan-to-Value (LTV) ratio that must be maintained, there is limit to how much can be borrowed. The Beefy contracts address this by an iterative process where a certain percentage (the `borrowRate`) is borrowed, which is then deposited to increase the collateral, which then enables more borrowing, and this is repeated as many times as defined in the strategy (the 'borrowDepth). Instead of this iteration, Airlift first simulates the iteration to calculate the final amount to be borrowed and swapped for WETH, and then uses a Uniswap Flash Swap to do it all in one go. The flash swap enables the strategy contract to receive the WETH _before_ actually borrowing anything from Aave. The WETH received in the flash swap is deposited into Aave, which adds enough collateral to borrow the full about of USD stablecoin needed to send to Uniswap to complete the flash swap. With a `borrowRate` of 50% and `borrowDepth` of 15, this equates to a doubling of the WETH collateral and an Aave `healthFactor` of about 1.65. - When someone withdraws from the vault the process is reversed, with the flash swap going in the other direction, such that the strategy can repay some of the stablecoin debt in order to maintain the risk profile after the shares have been withdrawn - Borrow interest rates for DAI, USDC, and USDT can flucuate widely and frequently. At times, some stablecoin rates are much better than others. The strategy includes a function that can be called by the strategy manager to swap the debt to the most favorable interest rate. Again, Uniswap V3 Flash Swaps are used to swap the debt without needing to withdraw any WETH collateral from Aave. In this case the flash swap provides the stablecoin needed to repay the Aave debt _before_ the strategy then borrows an equivalent amount of another stablecoin with a lower interest rate, which is then sent to Uniswap to complete the flash swap. - There are functions that can be called by the stategy manage to adjust the risk profile, if market conditions warrant. - An off-chain bot would likely be run via a cron scheduler to check the Aave healthFactor and automatically rebalance if gets close to the liquidation threshold. - Note that I first implemented Uniswap V2 Flash Swaps and subsequently added V3 Flash Swaps. _Both_ were good learning experiences. While the contract in the [main] branch uses V3 swaps, you may note that the `StrategyAaveLeveraged.sol` contract includes functions for both V2 and V3. # Frontend Dapp The Airlift frontend dapp UI is hosted on Skynet decentralized storage. HTML and CSS is based on the frontend of UniLend Finance. The current version of https://airlift.finance is configured to interact with a fork of Ethereum Mainnet running on http://localhost:8545 (in my testing this fork was created using Hardhat based on an Alchemy RPC endpoint). A previous version was running on a testnet but due to the unpredicatble liquidity pools and widely different values coming from Aave and Uniswap price oracles, the leveraging and deleveraging swaps couldn't be reliably tested or demontsrated on the testnet. Forking mainnet -- which I had never done before! -- solved this and helped with debugging as it also enabled me to use Hardhat's `console.log` feature and actually have errors referencing line numbers in the contracts ... as opposed to just revert errors.