// 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
// Secure, transparent, and developer-friendly infrastructure
Retain full control of your assets; only you can transfer or withdraw funds.
Define which assets, protocols, and actions your AI agent can manage—no hidden moves.
Smart contracts strictly enforce your boundaries, ensuring the AI agent never oversteps.
Rely on open-source, immutable code instead of opaque server-side wallets.
Integrate new DeFi protocols ("legos") without migrating your wallet—stay future-proof.
Transparent, reviewable code that anyone can inspect or verify for security.
// High-level architecture overview
A personal smart contract that you—and your chosen AI agent—control.
Decide exactly which assets, protocols, or operations your agent can handle.
The agent can lend, swap, or rebalance your DeFi holdings—but only within your specified parameters.
// Deploy your AI Wallet in minutes
// Your wallet address
owner = "0xYourOwnerAddress"
user_ai_wallet = agent_factory.createUserWallet(
owner, // You are the ultimate owner
agent, // Your AI agent's address
)
// 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)
// 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.
// Real-world applications
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.
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.
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.
// 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:
// Frequently asked questions
// Join the community
Underscore bridges AI and DeFi without compromising security or sovereignty. Ready to scale trustless finance?
Deploy your AI Wallet today and experience the power of trustless finance.
GET STARTED