UStackUStack
agent-credit icon

agent-credit

agent-credit lets AI agents borrow and repay credit via Aave with per-asset approvals and safety checks before delegated borrowing.

agent-credit

What is agent-credit?

agent-credit is a credit delegation toolkit for AI agents that lets an agent borrow funds from an Aave position and later repay on the delegator’s behalf. The core idea is to separate the agent’s borrowing permission from its debt repayment, so you can define which assets the agent may borrow and how much, while the borrowing capacity comes from your collateral.

The repository provides bash scripts (invoked by an agent) to set up delegation status, perform delegated borrows, repay delegated debt, and check allowances/health before executing. It’s designed to work with Aave V2 and Aave V3 on EVM chains where Aave is deployed, with repository examples preconfigured for Base, Ethereum, Polygon, and Arbitrum.

Key Features

  • Delegated borrowing via Aave: The agent borrows from Aave when it needs funds, and the resulting debt accrues on the delegator’s Aave position.
  • Per-asset delegation approvals: You approve delegation independently for each debt token contract (e.g., USDC vs WETH), so the agent can’t borrow assets you didn’t explicitly allow.
  • Holistic borrowing capacity from collateral: Borrowing power derives from your full collateral position and configured LTV, but available borrowing for each asset is constrained by the specific delegation approvals you set.
  • Scripted workflow for agent execution: Provided scripts handle setup checks, delegated borrow calls, delegated repayments, and status reporting, with aborts on failed safety checks.
  • Safety checks before borrowing: Each borrow performs checks including a per-transaction cap, delegation allowance sufficiency, health factor after the borrow, and whether the agent wallet has enough ETH for gas.
  • Key handling designed to avoid private-key exposure: The agent never receives the delegator’s private key; it holds its own key to sign borrow/repay transactions and uses the delegator’s public address to target the correct Aave position.
  • Configurable safety parameters: The borrow scripts reference configuration values such as safety.maxBorrowPerTx and safety.minHealthFactor (default mentioned as 1.5).

How to Use agent-credit

  1. Set up delegation from your wallet: Using the Aave UI or a block explorer, configure your collateral and then set delegation approvals for the specific debt tokens the agent is allowed to borrow (e.g., USDC debt token → agent amount).
  2. Prepare configuration: Use config.example.json as a starting point to define values used by the scripts, including safety parameters and borrowing targets.
  3. Run the provided scripts from the agent: The repository’s scripts are intended for the agent’s execution, not for the delegator. Typical script flow includes:
    • aave-setup.sh to verify config/dependencies and delegation status
    • aave-borrow.sh <SYMBOL> <AMOUNT> to borrow via delegation (after safety checks)
    • aave-repay.sh <SYMBOL> <AMOUNT|max> to repay debt on behalf of the delegator
    • aave-status.sh [SYMBOL] [--health-only] [--json] to check allowances and health factor
  4. Revoke when needed: You can revoke delegation by setting delegation to 0 for the relevant debt token(s) at any time.

Use Cases

  • On-demand agent operations without manual funding: An agent borrows stablecoins or tokens via delegation only when it needs to cover operational costs, rather than requiring you to pre-fund its wallet repeatedly.
  • Agent-managed periodic swaps via a DeFi toolkit: Combined with Bankr skills (as described in the repository), the agent can borrow USDC via delegation and then swap/bridge/deploy it using Bankr flows.
  • Autonomous DCA using delegated USDC: The agent can periodically borrow USDC and use it to acquire ETH (via swap) as part of a DCA-like workflow.
  • Gas self-sufficiency for execution: The setup describes borrowing a small amount of WETH to cover the agent’s own gas when its ETH balance runs low.
  • Health-guarded liquidity access: Before each borrow, the scripts check the delegator’s health factor and abort the transaction if the post-borrow health would violate the configured threshold.

FAQ

Is the agent granted access to the delegator’s private key? No. The safety section states the agent never has access to the delegator’s private key; it holds its own key to sign borrow/repay transactions and only uses the delegator’s public address to select the correct position.

How does the agent decide how much it can borrow? Borrowing capacity comes from the delegator’s total collateral position (holistic), but the agent’s borrowable amounts for each asset are limited by per-debt-token delegation approvals configured via approveDelegation().

What prevents unsafe borrows? For each borrow, the scripts run checks including a per-transaction cap (safety.maxBorrowPerTx), delegation allowance sufficiency, a health factor constraint (safety.minHealthFactor, default 1.5 mentioned), and ensuring the agent has enough ETH for gas. If any check fails, the borrow aborts with an error.

Which networks and Aave versions are supported? The repository states it works on Aave V2 and Aave V3, and that it’s preconfigured for Base, Ethereum, Polygon, and Arbitrum, while also being intended for any EVM chain where Aave is deployed.

Can the agent run these flows inside different agent frameworks? The content notes the scripts are plain bash plus Foundry’s cast, so they can be used in any environment with a shell. The repo also mentions compatibility with OpenClaw (installing as a skill) and running scripts directly from a Claude Code session.

Alternatives

  • Manual Aave interaction via wallet/UI: Instead of delegating borrowing to an agent, you (or a backend service) can manually supply collateral, borrow, and repay on Aave; this keeps control but requires more frequent human or custom integration.
  • Third-party agent-to-DeFi connectors: Alternatives in this category provide an agent-friendly interface to DeFi protocols, but may not use Aave credit delegation and per-debt-token approval constraints in the same way.
  • Direct on-chain contract-based “agent wallet” borrowing: Some systems route agent actions through dedicated smart contracts; this differs because the permission model is enforced by contract logic rather than Aave delegation approvals per debt token.
  • Build a custom delegation + safety layer: You could reimplement delegation management and borrowing safety checks yourself using Aave contracts and transaction guards; this differs from using the ready-made bash scripts and config conventions in this repository.