Skip to content

[New Plugin Integration]: Compound v3 IntegrationΒ #304

@BadGenius22

Description

@BadGenius22

πŸ—οΈ Plugin Category

DeFi Protocol Plugin

πŸ“ Overview

This plugin adds full Compound v3 (Comet) integration for Arbitrum One within Vibekit.
It enables agents to perform all core lending and borrowing operations while also accessing live market configuration, APY data, and user risk metrics.

Compound v3 uses a minimalistic β€œsingle Comet contract per market” architecture.
This plugin abstracts all low-level contract interactions so agents can safely:

  • Supply collateral
  • Withdraw collateral
  • Borrow assets
  • Repay debt
  • Query market data
  • Query user positions and liquidation risk

πŸ”§ Plugin Actions

lending-supply

Description: Supply collateral into a Compound v3 market
Input:

  • walletAddress (string)
  • assetAddress (string)
  • amount (string)
    Output:
  • Encoded transaction calldata for supplying

lending-withdraw

Description: Withdraw collateral
Input:

  • walletAddress
  • assetAddress
  • amount
    Output:
  • Encoded calldata to withdraw collateral

lending-borrow

Description: Borrow the base asset (e.g., USDC)
Input:

  • walletAddress
  • borrowAsset
  • amount
    Output:
  • Encoded calldata for borrowing

lending-repay

Description: Repay borrowed assets
Input:

  • walletAddress
  • borrowAsset
  • amount
    Output:
  • Encoded calldata for repayment

πŸ” Plugin Queries

getMarkets

Description: Fetch all Compound v3 markets on Arbitrum
Output includes:

  • Market address
  • Base asset
  • Supported collateral assets
  • Collateral factors
  • Supply caps / borrow caps
  • Reserve fee
  • Utilization rate
  • Supply APR / APY
  • Borrow APR / APY

getPosition

Description: Fetch a user’s Compound v3 account state
Output includes:

  • Collateral supplied
  • Borrowed amount
  • Borrow limit
  • Health score
  • Liquidation threshold
  • Liquidation margin

πŸ“ Plugin Description

Compound v3 plugin that integrates with Vibekit to enable AI agents to manage lending and borrowing strategies.
The plugin exposes all Comet interactions with a clean schema and supports real-time market discovery and risk calculations.

This follows the structure of existing plugins such as AAVE, Pendle, and GMX.


πŸ€– Example Agent Capabilities

Risk-Aware Lending Agent

  • Evaluate markets via getMarkets
  • Supply collateral via lending-supply
  • Track health factor via getPosition
  • Automatically repay/withdraw when risk increases

Looping / Yield-Leverage Agent

  • Supply β†’ Borrow β†’ Supply loops
  • Monitor utilization and collateral factors
  • Reduce leverage safely when needed

Portfolio Monitoring Agent

  • Watch user accounts across wallets
  • Compute health score and liquidation buffer
  • Alert when borrow limit approaches risky levels

πŸ” Authentication

None required.


βš™οΈ Plugin Configuration

  • chainId: default 42161 (Arbitrum One)
  • rpcUrl: RPC endpoint for on-chain reads
  • Optional override for Comet market addresses

πŸ§ͺ Testing Strategy

Unit Tests

1. test-compound-plugin.ts

Validates:

  • Plugin loads correctly
  • All actions are registered
  • Input/output schema matches plugin spec
  • Metadata (name, version) loads successfully

2. test-market-discovery.ts

Validates:

  • Accurate discovery of Compound v3 markets
  • Correct parsing of:
    • Market address
    • Base asset
    • Collateral list
    • Collateral factors
    • Caps
    • Reserve fee
    • APR/APY
    • Utilization
  • Output format matches Vibekit query spec

3. test-compound-actions.ts

Validates:

  • Correct calldata generation for:
    • lending-supply
    • lending-withdraw
    • lending-borrow
    • lending-repay
  • Proper ABI encoding
  • Decimal normalization
  • Rejection of invalid/zero inputs

4. test-compound-position.ts

Validates:

  • Reading collateral balances
  • Reading borrow balances
  • Calculating:
    • Borrow limit
    • Health score
    • Liquidation margin
  • Multiple wallet states:
    • Empty
    • Supplied only
    • Borrowing
    • Near-liquidation

πŸ”¬ Integration Tests (Live Comet Contracts on Arbitrum)

Market Config Tests

  • Fetch live market configuration
  • Validate interest rate parameters
  • Verify APY/APR conversions
  • Validate utilization calculations

Position Tests

  • Validate real wallet supply/borrow states
  • Compute health score & liquidation risk
  • Check edge cases

Error Handling

  • Invalid asset inputs
  • Unsupported markets
  • Zero balances
  • Network errors

βœ… Pre-submission Checklist

  • Searched for duplicate plugin proposals
  • Clear plugin specification
  • Data source fully defined
  • Actions & queries documented
  • Full testing strategy provided
  • Awaiting approval before implementation

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions