Skip to main content
Glama

write.asset_manager.yield_claimer_cowswap

Read-onlyIdempotent

Claims LP fees and swaps them to a target token via CowSwap batch auctions, providing MEV protection for yield optimization on Base chain.

Instructions

Encode args for yield claimer coupled with CowSwap. Claims LP fees, then swaps the claimed tokens to a target token via CowSwap batch auctions (MEV-protected). For staked LPs, sell_tokens is the staking reward token list (e.g. [AERO_address]). For non-staked LPs, sell_tokens is all LP fee tokens except the buy_token — e.g. for a WETH/USDC LP claiming fees as USDC, use sell_tokens: [WETH_address], buy_token: USDC_address. Sets metadata on BOTH the CowSwapper and the Yield Claimer. Returns { asset_managers, statuses, datas } with 2 entries (cowswapper + yield_claimer). Base only. Combinable with other intent tools.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dex_protocolYesDEX protocol of the LP position — used to resolve the correct asset manager address.
sell_tokensYesToken addresses to sell. Staked LP: [AERO]. Non-staked: [token0, token1] minus buy_token.
buy_tokenYesToken address to receive after swap
fee_recipientYesAddress to receive claimed fees
enabledNoTrue to enable, false to disable
chain_idNoChain ID: 8453 (Base) or 130 (Unichain)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
datasYes
statusesYes
descriptionNo
strategy_nameNo
asset_managersYes

Implementation Reference

  • Registration and implementation of the 'write.asset_manager.yield_claimer_cowswap' tool. It orchestrates the configuration of a cowSwapper and a yieldClaimer to automate fee claiming and swapping.
      server.registerTool(
        "write.asset_manager.yield_claimer_cowswap",
        {
          annotations: {
            title: "Encode Yield Claimer + CowSwap Automation",
            readOnlyHint: true,
            destructiveHint: false,
            idempotentHint: true,
            openWorldHint: false,
          },
          description:
            "Encode args for yield claimer coupled with CowSwap. Claims LP fees, then swaps the claimed tokens to a target token via CowSwap batch auctions (MEV-protected). For staked LPs, sell_tokens is the staking reward token list (e.g. [AERO_address]). For non-staked LPs, sell_tokens is all LP fee tokens except the buy_token — e.g. for a WETH/USDC LP claiming fees as USDC, use sell_tokens: [WETH_address], buy_token: USDC_address. Sets metadata on BOTH the CowSwapper and the Yield Claimer. Returns { asset_managers, statuses, datas } with 2 entries (cowswapper + yield_claimer). Base only. Combinable with other intent tools.",
          outputSchema: IntentOutput,
          inputSchema: {
            dex_protocol: DEX_PROTOCOL_SCHEMA,
            sell_tokens: z
              .array(z.string())
              .describe(
                "Token addresses to sell. Staked LP: [AERO]. Non-staked: [token0, token1] minus buy_token.",
              ),
            buy_token: z.string().describe("Token address to receive after swap"),
            fee_recipient: z.string().describe("Address to receive claimed fees"),
            enabled: z.boolean().default(true).describe("True to enable, false to disable"),
            chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
          },
        },
        async (params) => {
          try {
            const validChainId = validateChainId(params.chain_id);
            const amKey = dexProtocolToAmKey(params.dex_protocol);
            let cowSwapperAddress: string;
            try {
              cowSwapperAddress = getStandaloneAmAddress(validChainId, "cowSwapper");
            } catch {
              throw new Error(
                `yield_claimer_cowswap is not available on chain ${validChainId} because it requires cow_swapper, which is Base-only (8453).`,
              );
            }
            const yieldClaimerAddress = getAmProtocolAddress(validChainId, "yieldClaimers", amKey);
    
            if (!params.enabled) {
              return formatResult(
                disabledIntent(
                  [cowSwapperAddress, yieldClaimerAddress],
                  `Disable yield_claimer_cowswap (${params.dex_protocol})`,
                ),
              );
            }
    
            const validSellTokens = params.sell_tokens.map((t, i) =>
              validateAddress(t, `sell_tokens[${i}]`),
            );
            const validBuyToken = validateAddress(params.buy_token, "buy_token");
            const validFeeRecipient = validateAddress(params.fee_recipient, "fee_recipient");
    
            const cowSwapperData = encodeCowSwapTokenMetadata(
              "cow_swap_yield_claim",
              validSellTokens,
              validBuyToken,
            );
    
            const yieldClaimerData = encodeYieldClaimerCoupledCallbackData(
              COWSWAPPER_INITIATOR,
              validFeeRecipient,
              "cow_swap_yield_claim",
            );
    
            const result = {
              description: `Enable yield_claimer_cowswap (${params.dex_protocol}, cowswap)`,
              asset_managers: [cowSwapperAddress, yieldClaimerAddress],
              statuses: [true, true],
              datas: [cowSwapperData, yieldClaimerData],
            };
            return formatResult(result);
          } catch (err) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Error: ${err instanceof Error ? err.message : String(err)}`,
                },
              ],
              isError: true,
            };
          }
        },
      );
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/arcadia-finance/arcadia-finance-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server