Inspiration

There are various DeFi products, but we wondered if these DeFi products were designed with users, specifically 'degens,' in mind. We believe that we should create DeFi products that degen users want. Additionally, with the recent mini bull market, we observed an increasing trend in airdrops across various blockchain protocols. Recognizing this, we anticipate proactive interest and participation from degens in leveraging for higher profits. LeverEZ aims to provide participants with the opportunity to leverage small capital for higher returns and optimize gas fees through innovative solutions.

What it does

LeverEZ is a platform that streamlines DeFi interactions with key features such as automated and gas-optimized flashloan looping. It offers real-time insights into collateral statuses across various DeFi lending protocols and utilizes Chainlink Data for on-chain valuations of assets. The platform includes black swan event management, allowing users to swiftly close all positions across multiple chains during unforeseen events, effectively managing risks.

Functionally, LeverEZ serves as a practical guide for users to interact with popular lending protocols like Compound V2, Aave V2, and Aave V3. Users can seamlessly perform actions such as leveraging, deleveraging, supplying, withdrawing, and managing assets strategically.

At the heart of LeverEZ is the Chainlink Cross-Chain Interoperability Protocol (CCIP), enabling seamless communication across diverse blockchains. The platform's Leverager provides users with unparalleled capabilities, including swift supply and borrow operations, opening leveraged yielding positions for optimized yields, seamless token management, dynamic closure of leveraged yielding positions, and the execution of a single transaction to close positions across multichain lending protocols in the same address.

In essence, LEVER-EZ enhances DeFi interactions by offering a comprehensive suite of features and functionalities, coupled with Chainlink CCIP integration, to empower users in navigating lending protocols efficiently and dynamically managing their positions in response to market events.

How we built it

We incorporated the Viem library from Wagmi and utilized Rainbow Kits for the wallet extension plugin, with Vercel serving as our chosen platform for hosting websites.

The process involves calculating the flashloan amount directly within the browser and encoding the data upon user button clicks.

For the flashloan receiver, we initially explored implementing the Balancer protocol due to its zero fees. However, we encountered challenges as it presented different addresses for assets not compatible with the Aave V3 lending protocols. Consequently, we decided to roll back our efforts in this direction.

   graph TD;
   Sepolia
   Leverager-->Propagator;
   Propagator-->Chainlink_Router;
   Chainlink_Router-->event_msg_to_fuji
   graph TD;
   Fuji
   Chainlink_Router --> Leverager

Challenges we ran into

  1. Difficulty in Restricting Frontend Input:

    • It seems like implementing restrictions on user input at the frontend was challenging. This could be related to user interface issues or input validation complexities.
  2. Decimals Error between Float and Bigint:

    • Converting between float and bigint data types can lead to precision errors, especially when dealing with decimals. This issue may have caused unexpected behavior in your calculations.
  3. Contract Discrepancies between AaveV3 Data Providers:

    • The contract differences between AaveV3 data providers on different networks (Sepolia, Mumbai for Fuji) resulted in a lengthy debugging process. Ensuring consistency across environments is crucial for smooth development.
  4. Long Experiment Times on Chainlink Testnet:

    • The extended time (around 20 minutes) required for a single experiment on the Chainlink testnet made the debugging process time-consuming. Efficient debugging is essential for the development workflow.
  5. Impersonation in Hardhat Test Environment:

    • To expedite testing in the hardhat test environment, you resorted to impersonating the address of the router, providing it with an ETH balance, and directly calling ccipReceive for testing purposes.
  6. Testnet Environment Challenges:

    • The testnet environment presented challenges, such as different addresses for the same asset symbol and difficulty in finding faucets. These issues can complicate testing procedures and hinder the identification of problems.
  7. Address Collection and Faucet Issues:

    • Collecting the addresses of available assets was time-consuming. Additionally, finding a faucet for Avalanche proved to be difficult, further delaying troubleshooting efforts.
  8. Contract size limit:

    • As it has lots of input numbers to execute the functions, we should've mitigated the contract size limit issues which should be less than 24KiB.
  9. Time attack

Accomplishments that we're proud of

Most dominant protocols, including Aave, Radiant, and others, do not facilitate leveraging or deleveraging assets using flashloans. We successfully implemented this during the hackathon period.

We've made the repo for testing the various features with debugging using hardhat tracer and contract code size for future buildings and contributing to open sources.

Mainnets would be easier to integrate, so it is a very vivid product to serve the yield farmers who need to leverage and contribute to the new lending protocols.

What we learned

  • Chainlink's Various Features: CCIP includes EVM messaging, automation, and data feed fetching methods. In summary, closing a position using CCIP was not a suitable choice as it takes approximately 10-20 minutes. However, if a lending protocol supports CCIP-based assets, we could integrate our functions to facilitate supply by transferring collaterals from other chains, thereby alleviating the high Loan-to-Value (LTV). This marked the first instance of precisely calculating amounts and prices, revealing differences in decimal precision between the new price information and the standard eight decimals for underlying assets.

  • Lending Protocol Architectures and Interest Calculation Models: Our investigation involved AAVE V2 and V3, as well as Compound V2 models for integration. Various methods exist for implementing interest calculations. For instance, in AAVE, the aTokens balanceOf is a calculated value in the amount of underlying assets. Conversely, in Compound, accruedInterest should be updated, and the index should be multiplied by the fixed amount of cTokens. Aave allows borrowing on behalf of someone with approval, a feature not present in Compound. Notably, Aave reverses transactions if collateral approval occurs before supply. Understanding these specific features is crucial for implementing each lending protocol.

  • Calculating Adequate Flashloan Amount: We've calculated adequate flash loan amounts to leverage or deleverage the positions.

  • Blazingly fast speed of Avalanche C chain

  • User activity data for each lending protocol using The Graph:

The majority of lending platform data obtained from smart contracts tends to be biased towards the current lending platform's parameters rather than user metrics. This bias arises because these platforms typically offer information based on the current state of the blockchain. However, by leveraging the capabilities of graph-based queries, such as the following for AaveV2, AaveV3, and CompoundV2:

{
  usageMetricsDailySnapshots {
    id
    dailyActiveUsers
    dailyTransactionCount
    dailyActiveBorrowers
    dailyActiveDepositors
    cumulativeUniqueUsers
  }
}

The following subgraphs are integrated.

You can access a more comprehensive set of user activity metrics from platforms like AaveV2, AaveV3, CompoundV2

Avalanche Integration

Supply

Leverage Supply

Withdraw

Borrow

Close(Repay)

Close(Deleverage)

Built With

Share this project:

Updates

Submission history