Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions agent-wallet-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const sidebar = {
'guides/swap-and-bridge',
'guides/trade-perpetuals',
'guides/trade-prediction-markets',
'guides/earn-yield-vaults',
'guides/lend-and-borrow-aave',
'guides/check-balances-and-prices',
'guides/sign-messages-and-transactions',
Expand Down
7 changes: 7 additions & 0 deletions agent-wallet/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ After setup, prompt your agent in plain language:
| "Swap 0.1 ETH to USDC on Base" | Your agent fetches a quote, confirms with you, then executes. |
| "Open a 5x long on BTC with $100 on Hyperliquid" | Your agent deposits if needed, quotes, and opens the position. |
| "Bet 10 USDT on YES for BTC 5-min price up" | Your agent searches markets, confirms odds, and places the order. |
| "Supply 100 USDC to a yield vault on Base" | Your agent finds vaults, compares APYs, and supplies your tokens. |

<!-- vale on -->

Expand Down Expand Up @@ -79,6 +80,7 @@ Your agent routes natural-language requests to these commands through installed
| [Swap / bridge](guides/swap-and-bridge.md) | Quote, execute, and track swaps and cross-chain bridges |
| [Perpetuals](guides/trade-perpetuals.md) | Trade on Hyperliquid (deposit, open, modify, close) |
| [Prediction markets](guides/trade-prediction-markets.md) | Search, quote, trade, and redeem on Polymarket |
| [Earn (yield vaults)](guides/earn-yield-vaults.md) | Supply and withdraw from yield vaults across chains |
| [Aave V3](guides/lend-and-borrow-aave.md) | Supply, borrow, repay, and manage lending positions |
| [Market data](guides/check-balances-and-prices.md) | Spot prices, token discovery, supported chains |

Expand Down Expand Up @@ -113,6 +115,11 @@ See [Supported chains](reference/supported-chains.md) for typical networks.
title: 'Trade perpetuals',
description: 'Deposit, open, modify, and close Hyperliquid positions.',
},
{
href: '/agent-wallet/guides/earn-yield-vaults',
title: 'Earn with yield vaults',
description: 'Supply and withdraw from yield vaults across chains and protocols.',
},
{
href: '/agent-wallet/guides/lend-and-borrow-aave',
title: 'Lend and borrow with Aave V3',
Expand Down
104 changes: 104 additions & 0 deletions agent-wallet/guides/earn-yield-vaults.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
description: Supply and withdraw from yield vaults using `mm earn` commands.
keywords: [MetaMask, Agent Wallet, earn, yield, DeFi, vaults, mm]
---

# Earn with yield vaults

Browse yield vaults, supply tokens, and withdraw positions using the `mm earn` commands.
Agent Wallet routes supply and withdraw operations through LiFi for cross-chain support.

## Ask your agent

```text
You (to your agent): "Show me the best yield vaults for USDC on Base"
```

```text
You (to your agent): "Supply 100 USDC to a vault on Base"
```

```text
You (to your agent): "Withdraw all my USDC from the Aave vault on Base"
```

Your agent lists available vaults, compares APYs and TVL, confirms your choice, then executes.

## Prerequisites

- [Quickstart](../quickstart.md) completed
- Sufficient token balance on the source chain

## Browse vaults

List available yield vaults with APY and TVL data:

```bash
mm earn markets [--chain <chain-id>] [--protocol <protocol>] [--min-tvl <amount>]
```

Filter by chain, protocol, or minimum TVL to find the best opportunities.

## Check your positions

View your current yield positions:

```bash
mm earn positions
```

## Supply to a vault

Supply tokens to a yield vault:

```bash
mm earn supply --token <TOKEN> --amount <AMOUNT> [--chain <chain-id>] [--from-chain <chain-id>]
```

| Flag | Required | Description |
| -------------- | -------- | ------------------------------------- |
| `--token` | Yes | Token symbol or contract address |
| `--amount` | Yes | Human-readable amount to supply |
| `--chain` | No | Destination chain for the vault |
| `--from-chain` | No | Source chain if supplying cross-chain |

The CLI automatically handles ERC-20 approval when the vault's allowance is insufficient.

## Withdraw from a vault

Withdraw tokens from a yield vault:

```bash
mm earn withdraw --token <TOKEN> --amount <AMOUNT> [--chain <chain-id>]
```

Use `--amount all` to withdraw your full position.
For Aave rebasing aTokens, `--amount all` applies a small dust buffer to avoid revert from interest
accrual between the query and the transaction.

## Cross-chain supply

Supply from a different chain than the vault's chain by passing `--from-chain`:

```bash
mm earn supply --token USDC --amount 100 --chain 8453 --from-chain 1
```

This bridges and supplies in a single operation.

## Common pitfalls

:::caution Approval required
When supplying for the first time, the CLI sends an ERC-20 approval transaction before the supply
transaction. In server-wallet mode, this may require 2FA approval depending on your trading mode.
:::

:::note Withdraw reverts
If a full withdrawal reverts, retry with a slightly smaller amount. Rebasing tokens (like Aave
aTokens) accrue interest between the balance query and transaction execution.
:::

## Related commands

- [`mm earn`](../reference/commands.md#mm-earn) in the commands reference
- [Check balances and prices](check-balances-and-prices.md)
11 changes: 11 additions & 0 deletions agent-wallet/guides/send-tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ Your agent confirms the recipient, amount, token, and chain before executing.

4. Confirm the transaction hash in the command output.

## Gasless ERC-20 transfers

When your wallet's native balance cannot cover gas, the CLI automatically routes ERC-20 transfers
through a gasless relay. You can optionally pay relay fees in an ERC-20 token:

```bash
mm transfer --to <ADDRESS> --amount 10 --token USDC --chain-id 8453 --gas-token USDC --wait
```

Gasless transfers are not available for native token sends.

## Common pitfalls

:::note Per-chain balances
Expand Down
21 changes: 21 additions & 0 deletions agent-wallet/guides/swap-and-bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,27 @@ Do not use `--refuel` when the destination token is the destination chain's nati
example, bridging ETH to Arbitrum ETH).
The backend returns `NO_QUOTES` in that case.

## Compare quotes

Use `--all-quotes` to see all available routes ranked by your preferred strategy:

```bash
mm swap quote --from ETH --to USDC --amount 0.5 --from-chain 1 --all-quotes --strategy cost,speed
```

A ★ marks the recommended quote. Execute a specific quote by its ID:

```bash
mm swap execute --quote-id <QUOTE_ID>
```

Available strategies: `cost`, `speed`, `impact`, `output`. The default is `cost,speed`.

## Gasless swaps

When your wallet's native balance cannot cover gas, the CLI automatically uses gasless execution
via the EIP-7702 relay for eligible quotes. No additional flags are required.

## Common pitfalls

:::caution Verify the quote step succeeded
Expand Down
17 changes: 12 additions & 5 deletions agent-wallet/quickstart.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: Install CLI v3, add agent skills, verify readiness with mm doctor, and complete browser sign-in and wallet setup.
description: Install the latest CLI, add agent skills, verify readiness with mm doctor, and complete browser sign-in and wallet setup.
keywords: [MetaMask, Agent Wallet, quickstart, mm, mm doctor, skills, server-wallet]
---

Expand All @@ -19,11 +19,15 @@ After setup, use natural language for day-to-day wallet operations.
## 1. Install the CLI

```bash npm2yarn
npm install -g @metamask/agentic-cli@3
npm install -g @metamask/agentic-cli@latest
```

Run `mm doctor` after install to confirm the CLI version and skill compatibility.

:::note Node.js requirement
The CLI requires **Node.js 22.18** or later.
:::

## 2. Add skills to your agent

Skills teach your agent how to route natural-language requests to `mm` commands and follow safety
Expand All @@ -35,8 +39,8 @@ npx skills add MetaMask/agent-skills

When prompted, install `metamask-agent-wallet`.

Reinstall skills if you previously installed an older version (for example, v2.x).
The current skills target CLI v3.0.0.
Reinstall skills if you previously installed an older version.
The current skills target CLI v5.0.0.

## 3. Complete setup

Expand Down Expand Up @@ -72,12 +76,15 @@ skills), then run `mm doctor` again.

During `mm login`, choose **Dashboard (browser)** or **QR code (MetaMask Mobile)**.

- **Browser** (`mm login browser`): sign in through the MetaMask dashboard with Google or email.
- **Browser** (`mm login browser`): opens the MetaMask dashboard in your browser. After signing in
with Google or email, a CLI token is displayed that you paste back into the terminal.
Use this method in production.
- **QR code** (`mm login qr`): scan the QR code with MetaMask Mobile.
QR sign-in is not available in production; the CLI returns `COMING_SOON` and you should use browser
sign-in instead.

To use the legacy OTP pairing flow instead, pass `--otp-pair` to `mm login browser`.

Your sign-in method also determines how you receive 2-factor authentication approvals when a
transaction needs your confirmation.

Expand Down
12 changes: 12 additions & 0 deletions agent-wallet/reference/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ MetaMask's subscription that pairs Transaction Protection with priority support.
See [Transaction Shield](https://support.metamask.io/manage-crypto/transactions/transaction-shield/)
for subscription details, eligibility, coverage limits, and terms.

## Gasless execution

For ERC-20 transfers and swaps where the wallet's native balance cannot cover gas, the CLI
automatically routes through a gasless relay using EIP-7702. The relay submits the transaction on
your behalf and deducts fees from the transferred ERC-20 token or a `--gas-token` you specify.

## ERC-7821 batch execution

On eligible chains and accounts, the CLI combines ERC-20 approval and trade into a single atomic
`execute()` call using ERC-7821. This reduces the number of transactions and avoids approval
front-running. The CLI falls back to sequential submission when batching is not available.

## Smart Transactions

[Smart Transactions](https://support.metamask.io/manage-crypto/transactions/smart-transactions/)
Expand Down
Loading
Loading