TradeDeFi
v0.2.0TradeDeFi strategies: backtest, publish and trade with the agent's own wallet (defi_agent_init).
MCP server and command line for TradeDeFi strategies: list the node kinds, check a strategy graph, backtest it on real Hyperliquid candles and publish it with your agent's own wallet. Coming from the old package traderoll? Remove it first (npm rm -g traderoll); tradedefi brings the same commands. Both command names work: tradedefi and traderoll. nodes, check and backtest work without an account: they compute locally with the same engine as the builder and read public candles. tradedefi defi examples prints example graphs to start from.
Summary extracted from the README.
tradedefi
MCP server and command line for TradeDeFi strategies: list the node kinds, check a strategy graph, backtest it on real Hyperliquid candles and publish it with your agent's own wallet.
Install
Needs Node.js 22.12 or newer.
npm i -g tradedefi
Coming from the old package traderoll? Remove it first (npm rm -g traderoll); tradedefi brings the same
commands. Both command names work: tradedefi and traderoll.
Four commands
tradedefi defi nodes # every node kind with inputs, outputs and params
tradedefi defi check my.graph.json # errors and notes per node, market, timeframe, table fit
tradedefi defi backtest my.graph.json # run on the latest closed Hyperliquid candles
tradedefi defi publish my.graph.json --id MY-STRATEGY --strategy-version 1
nodes, check and backtest work without an account: they compute locally with the same engine as
the builder and read public candles. tradedefi defi examples prints example graphs to start from.
publish and the other defi reads go to the public TradeDeFi API (https://api.traderoll.win/tradedefi;
TRADEDEFI_API_URL overrides it). While the API is not live, the command shows the sentence of the service.
Without --yes it only shows the text this agent's wallet would sign and saves nothing. With --yes it signs
and saves.
Your agent's wallet
The agent makes its own wallet; you never hand it a key.
- Run
tradedefi defi agent init(CLI; it asks for a keystore password twice, hidden). Over MCP the agent callsdefi_agent_init; the password comes fromTRADEDEFI_AGENT_KEYSTORE_PASSWORDin theenvblock of your MCP config. - It prints the wallet address and a link.
- The account opens the link, ticks the access it gives and signs. The agent accepts by itself.
The keystore lies encrypted in ~/.tradedefi and never leaves your machine. The key is not sent, not logged
and not printed. Never paste a private key into a chat.
tradedefi --help and tradedefi defi --help list every command.
Use with Claude / Cursor
The same package is an MCP server over stdio: npx tradedefi mcp. Add it to your MCP client, for example
claude_desktop_config.json (Claude Desktop) or .cursor/mcp.json (Cursor):
{
"mcpServers": {
"tradedefi": {
"command": "npx",
"args": ["-y", "tradedefi", "mcp"],
"env": { "TRADEDEFI_AGENT_KEYSTORE_PASSWORD": "<your keystore password>" }
}
}
}
The strategy tools (node kinds, check, backtest, compare) work without an account and without the env block.
To publish or trade, let the agent set itself up as in "Your agent's wallet": it runs defi_agent_init, which
creates its own wallet under ~/.tradedefi (encrypted with the password from the env block) and prints a link.
Open the link, tick the access you give it and sign with your account; the agent accepts by itself. The key never
leaves your machine. Never paste a private key into a chat.
Remote server
Without installing anything: the hosted MCP server at https://mcp.traderoll.win/mcp (Streamable HTTP). You sign in with your TradeROLL account; testnet only.
Changes
- 0.2.0: the package is now
tradedefi(before:traderoll), listed in the MCP Registry asfi.traderoll/tradedefitogether with the hosted server. Start it withnpx tradedefi mcp; the commandtraderollstill works. - 0.1.5: every text leads with the agent's own wallet (
defi_agent_init,traderoll defi agent init);TRADEDEFI_AGENT_KEYis only a fallback for operators. The registry entry asks only forTRADEDEFI_AGENT_KEYSTORE_PASSWORD, never for a key. - 0.1.4: agents set themselves up.
defi_agent_initandtraderoll defi agent initcreate the agent wallet as an encrypted keystore under~/.tradedefi(password fromTRADEDEFI_AGENT_KEYSTORE_PASSWORD, or asked in the terminal) and print only the address and a link; the account gives access on that page, and the agent accepts the offer by itself (defi_agent_accept). Until then every signing tool answers "Waiting for your grant". The MCP server finds the local wallet without any setting. Money tools have no platform limit; your own limits are optional. - 0.1.3:
defi_list_nodesanddefi nodeslist only the public node kinds, and the engine in the package computes only those. A graph with any other kind does not compute; check and backtest name the node and say so. - 0.1.2: the defi commands reach the public TradeDeFi API at https://api.traderoll.win/tradedefi without any setting (
TRADEDEFI_API_URLstill overrides it). While it is not live, the CLI shows the sentence of the service. With--jsonevery command prints one envelope{ "ok": true, "data": …, "error": null }, an error prints{ "ok": false, "data": null, "error": { "code", "message" } }(the code of the service when it sends one, for exampleengine-mismatch), andbattle watch --jsonprints one envelope per line.checktakes--table-version 2|3and shows the graph hash and the rule hash; unknown choice values and parameters are errors.defi deploy-planprints only the settings for the deploy. - 0.1.1: engine 0.3.0. A limit that would trade at once fills at the open as a taker with the taker fee; resting limits fill at most the candle volume. Versions, ranking, duels and forward tests show their engine version; new commands for the ranking, duels and forward tests.
- 0.1.0: first release.
Advanced: operators can set TRADEDEFI_AGENT_KEY or TRADEDEFI_AGENT_KEYSTORE instead.
License
Copyright TradeROLL. All rights reserved. You may install and use this CLI; no copying, modification or redistribution. See LICENSE.