@indexfy/agentkit
v0.1.1
Published
Coinbase AgentKit action provider for Indexfy crypto indexes on Base
Maintainers
Readme
@indexfy/agentkit
A Coinbase AgentKit action provider for Indexfy crypto indexes on Base. Agents can research index tokens, then buy them with USDC and sell them back for USDC.
Each Indexfy index is an ERC-20 fully backed by a basket of tokens. For example, I5 is BTC 30%, ETH 30%, XRP 18%, SOL 14% and BNB 8%. A buy is one transaction that buys every basket token and mints index shares at basket value. A sell redeems the shares and sells the basket for USDC. Both revert below a quoted minimum.
Install
npm install @indexfy/agentkit @coinbase/agentkitUse
import { AgentKit } from "@coinbase/agentkit";
import { indexfyActionProvider } from "@indexfy/agentkit";
const agentkit = await AgentKit.from({
walletProvider, // any EvmWalletProvider on base-mainnet
actionProviders: [indexfyActionProvider() /* , ...others */],
});Then ask the agent something like "What's in the I5 index?", "Buy $25 of I5" or "Sell all my I5".
Actions
| Action | What it does |
|---|---|
| list_indexes | Indexes with price, TVL, 24h/7d performance and fees |
| get_index | One index's mandate and holdings, by address or ticker (e.g. I5) |
| get_portfolio | A wallet's index positions, value, P&L and points (defaults to the agent's wallet) |
| buy_index | Buy an index with up to usdcAmount USDC; unspent USDC is refunded |
| sell_index | Sell shares (or "all") for USDC |
Network: Base mainnet only. The wallet needs USDC on Base and a little ETH for gas.
How transactions are made
- The provider asks the public Indexfy API (
https://api.indexfy.xyz/mcp, no API key) to build the trade for the agent's wallet. The API returns unsigned calls (an approval if needed, then the trade) and a simulation of them at the latest block. - Before signing, the provider checks that:
- the calls are for Base and for this wallet;
- every call targets an allowed contract: Base USDC, the IndexfyZapper
(
0x44154FC4297823e39553649fea8cC6ce2517d7D4) or the index token itself; - the simulation didn't revert.
- The agent's own wallet signs and sends each call, waiting for each to confirm before the next.
The API never holds keys or sends transactions. Swap routes inside a buy or sell go stale within a few minutes, so the provider builds right before sending. If a trade reverts, call it again to rebuild.
Options
indexfyActionProvider({
apiUrl: "https://api.indexfy.xyz/mcp", // default
allowedTargets: [/* overrides the USDC + zapper allow-list */],
});Develop
npm install
npm test # jest, mocked API and wallet
npm run build # → dist/test/agentkitShim.js exists only for Jest. AgentKit's package root loads every built-in
provider, and some of their dependencies are ESM-only, which Jest can't load. The shim loads just
the base class, the decorator and the wallet providers from the same install.
License
MIT
