write.asset_manager.compounder
Claim accumulated LP trading fees and reinvest them to compound interest. Automates compounding between rebalances when paired with a rebalancer.
Instructions
Encode args for the standalone compounder automation. Claims accumulated LP trading fees and reinvests them back into the position (compound interest). LP fees only — does NOT claim staking rewards like AERO; use write.asset_manager.compounder_staked for staked positions earning emission tokens. When paired with a rebalancer, the rebalancer compounds at rebalance time — adding a compounder also compounds between rebalances for higher effective APY. Returns { asset_managers, statuses, datas } — pass to write.account.set_asset_managers. Combinable with other intent tools.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dex_protocol | Yes | DEX protocol of the LP position — used to resolve the correct asset manager address. | |
| enabled | No | True to enable, false to disable | |
| chain_id | No | Chain ID: 8453 (Base), 130 (Unichain), or 10 (Optimism) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | ||
| asset_managers | Yes | ||
| statuses | Yes | ||
| datas | Yes | ||
| strategy_name | No |
Implementation Reference
- Handler function for write.asset_manager.compounder — validates inputs, resolves the compounder address for the given DEX protocol & chain, and encodes the callback data (or disabled intent). Registered via MCP server.registerTool with name 'write.asset_manager.compounder'.
server.registerTool( "write.asset_manager.compounder", { annotations: { title: "Encode Compounder Automation", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, description: "Encode args for the standalone compounder automation. Claims accumulated LP trading fees and reinvests them back into the position (compound interest). LP fees only — does NOT claim staking rewards like AERO; use write.asset_manager.compounder_staked for staked positions earning emission tokens. When paired with a rebalancer, the rebalancer compounds at rebalance time — adding a compounder also compounds between rebalances for higher effective APY. Returns { asset_managers, statuses, datas } — pass to write.account.set_asset_managers. Combinable with other intent tools.", outputSchema: IntentOutput, inputSchema: { dex_protocol: DEX_PROTOCOL_SCHEMA, enabled: z.boolean().default(true).describe("True to enable, false to disable"), chain_id: z.number().default(8453).describe(CHAIN_ID_DESCRIPTION), }, }, async (params) => { try { const validChainId = validateChainId(params.chain_id); const amKey = dexProtocolToAmKey(params.dex_protocol); const amAddress = getAmProtocolAddress(validChainId, "compounders", amKey); if (!params.enabled) return formatResult( disabledIntent([amAddress], `Disable compounder (${params.dex_protocol})`), ); const callbackData = encodeCompounderCallbackData(COMPOUNDER_INITIATOR); const result = { description: `Enable compounder (${params.dex_protocol})`, asset_managers: [amAddress], statuses: [true], datas: [callbackData], }; return formatResult(result); } catch (err) { return { content: [ { type: "text" as const, text: `Error: ${err instanceof Error ? err.message : String(err)}`, }, ], isError: true, }; } }, ); - Input schema for the compounder tool: dex_protocol (enum of DEX protocols), enabled (boolean, default true), chain_id (number, default 8453).
inputSchema: { dex_protocol: DEX_PROTOCOL_SCHEMA, enabled: z.boolean().default(true).describe("True to enable, false to disable"), chain_id: z.number().default(8453).describe(CHAIN_ID_DESCRIPTION), }, - src/tools/index.ts:71-71 (registration)Registration entry point — registerCompounderTools is called from src/tools/index.ts to add the compounder tools to the MCP server.
registerCompounderTools(server, chains); - Helper function that encodes the ABI-encoded callback data for the compounder, including the initiator address, fee/tolerance parameters, and empty metadata.
export function encodeCompounderCallbackData(initiator: `0x${string}`): `0x${string}` { return encodeAbiParameters( [ { name: "initiator", type: "address" }, { name: "maxClaimFee", type: "uint256" }, { name: "maxSwapFee", type: "uint256" }, { name: "maxTolerance", type: "uint256" }, { name: "minLiquidityRatio", type: "uint256" }, { name: "metaData_", type: "bytes" }, ], [ initiator, DEFAULT_MAX_CLAIM_FEE, DEFAULT_MAX_SWAP_FEE, DEFAULT_MAX_TOLERANCE, DEFAULT_MIN_LIQUIDITY_RATIO, "0x", ], ); } - src/tools/output-schemas.ts:32-38 (schema)Output schema (IntentOutput) used by the compounder tool — returns asset_managers, statuses, datas arrays intended for passing to write.account.set_asset_managers.
export const IntentOutput = z.object({ description: z.string().optional(), asset_managers: z.array(z.string()), statuses: z.array(z.boolean()), datas: z.array(z.string()), strategy_name: z.string().optional(), });