CCIP-Lending-Agent

Introduction

In the DeFi space, liquidity is often fragmented across multiple chains, leading to inefficiencies. This project is a Proof of Concept (PoC) for a cross-chain operation of asset supply and borrowing on lending protocol like Aave, utilizing Chainlink's Cross-Chain Interoperability Protocol (CCIP). The primary goal is to bridge the liquidity gaps between chains, aiming for a future where users can engage in chain-agnostic supply and borrowing activities. The project envisions aggregating collateral and borrowing positions across various chains, allowing users to secure optimal rates through an underlying aggregator that facilitates transactions across multiple chains.

Assumption and Limitation

CCIP only supports special token (CCIP BnM) on the Testnet, which isn't supported on Aave's Testnet contracts. Thus, a MockPool was developed to mimic Aave's Pool, where CCIP BnM tokens can be supplied. The project currently focuses only on the standard supply, borrow, and repay workflows, omitting interest rate calculations and liquidation processes.

This PoC currently lacks comprehensive local unit testing. Instead, the functionalities were directly validated on the testnet. Further research and development are required to establish best practices for unit testing in a CCIP environment.

Contracts

Two key contracts were developed:

  • MockPool: This contract simulates the Aave v3 Pool, providing basic functionalities like supply, borrow, repay, and withdraw. While the function interfaces match Aave v3 Pool, the implementation is simplified to basic token transfers, excluding components like interest rates and liquidation.

  • CrossChainAaveAgent: This contract acts as an intermediary for interacting with the Pool and CCIP. It functions as a smart contract wallet that holds user positions, enabling supply and borrowing of assets. The agent can send and receive cross-chain messages to other chains. Key functions include:

    • supply, borrow, repay, withdraw: Simply replay the operation to MockPool on same chain
    • borrowToChain: Initiates cross-chain borrowing, leveraging CCIP for asset transfer to a different chain.
    • repayToChain: Facilitates cross-chain repayment of loans using assets from a different chain.
    • setAllowedBorrower: Administrative function to manage cross-chain borrowing permissions.
    • Internal functions like _borrowFromThisChain, _repayToThisChain, and _ccipReceive handle cross-chain requests and message processing.

Future Exploration

  • Liquidation and Interest Earning: Apply liquidation management and interest-earning functionalities for supplied assets, improving risk mitigation and user incentives.

  • Multi-Chain Borrowing Capability: Enabling borrowing from various blockchains in one transaction, optimizing users' financial strategies by leveraging the best rates across networks.

  • Comprehensive Unit Testing: Developing unit tests, especially for CCIP functionalities, to ensure system reliability and security.

  • Cross-Chain Collateral Management: Allowing users to utilize their assets on different blockchains as collateral, increasing borrowing power and capital efficiency.

  • Governance and Decentralization Mechanisms: Introducing community-driven governance features for protocol decisions and upgrades, embracing the DeFi ethos of decentralization.

Built With

Share this project:

Updates