v0.1.0-alpha

Underscore Protocol:
Trustless AI Agents for DeFi

// Underscore is an open-source, onchain infrastructure that allows AI agents to operate on your behalf in DeFi—securely, transparently, and within boundaries you define.

// clone repository
$ git clone https://github.com/underscore-finance/underscore/underscore.git
$ cd underscore

// install dependencies
$ pip install -r requirements.txt

// run tests
$ python -m pytest
GET STARTED

Why Underscore?

// Secure, transparent, and developer-friendly infrastructure

Non-Custodial

Retain full control of your assets; only you can transfer or withdraw funds.

Granular Control

Define which assets, protocols, and actions your AI agent can manage—no hidden moves.

Rule-Based Autonomy

Smart contracts strictly enforce your boundaries, ensuring the AI agent never oversteps.

Minimal Trust

Rely on open-source, immutable code instead of opaque server-side wallets.

Extensible

Integrate new DeFi protocols ("legos") without migrating your wallet—stay future-proof.

Auditability

Transparent, reviewable code that anyone can inspect or verify for security.

How It Works

// High-level architecture overview

01

Deploy your AI Wallet

A personal smart contract that you—and your chosen AI agent—control.

02

Set Permissions & Rules

Decide exactly which assets, protocols, or operations your agent can handle.

03

AI Autonomy Within Limits

The agent can lend, swap, or rebalance your DeFi holdings—but only within your specified parameters.

Build with Underscore

// Deploy your AI Wallet in minutes

Create a User AI Wallet

// Your wallet address
owner = "0xYourOwnerAddress"

user_ai_wallet = agent_factory.createUserWallet(
owner, // You are the ultimate owner
agent, // Your AI agent's address
)

Configure Agent Permissions

// Allowed assets (e.g., WETH, USDC)
allowed_assets = [weth, usdc]
for asset in allowed_assets:
user_wallet_config.addAssetForAgent(agent, asset, sender=owner)

// Allowed protocols (e.g., Aave, Uniswap)
allowed_protocols = [1, 2]
for protocol_id in allowed_protocols:
user_wallet_config.addLegoIdForAgent(agent, protocol_id, sender=owner)

AI-Driven DeFi Actions

// Example: Swap WETH → USDC on Uniswap (legoId = 2)
swap = {"legoId": 2, "amountIn": weth_amount, "tokenPath": [weth, usdc]}
user_ai_wallet.swapTokens([swap], sender=agent)

// Example: Deposit into Aave (legoId = 1)
user_ai_wallet.depositTokens(1, usdc, usdc_amount, sender=agent)

Next Steps: Try more advanced configurations or run our sample tests in our developer docs.

Use Cases

// Real-world applications

Autonomous Yield Farming

your AI agent could monitor lending rates on Aave and Compound, shifting funds to whichever yields the best APY -- all within your specified risk tolerance.

Portfolio Rebalancing

your AI agent could dynamically rebalance your holdings (e.g., 50% stablecoins, 50% ETH). If the price of ETH spikes, the agent swaps just enough to maintain your target ratios.

Proactive Risk Monitoring

your agent could watch onchain data for liquidity drops or major volatility. If a threshold is hit, it automatically unwinds high-risk positions -- limited only to the protocols you've authorized.

Why It Matters

// Security and trust considerations

AI agents in DeFi are powerful but can be risky—server-side AI wallets can be compromised, leaving your funds vulnerable. Underscore takes a trust-minimized approach:

  • Smart Contracts Govern the Rules: No black-box infrastructure or opaque custodians.
  • No Blind Trust: Full transparency in code and onchain operations.
  • Security by Design: Even if the AI logic goes astray, it can't exceed your smart contract's strict parameters.

FAQ

// Frequently asked questions

Get Involved

// Join the community

v0.1.0-alpha

Ready to unlock secure AI-driven DeFi?

Deploy your AI Wallet today and experience the power of trustless finance.

GET STARTED